babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1058. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1059. */
  1060. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1061. /**
  1062. * Constant used to retrieve the position texture index in the textures array in the prepass
  1063. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1064. */
  1065. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1066. /**
  1067. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1069. */
  1070. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1073. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1074. */
  1075. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1078. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1079. */
  1080. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve albedo index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1091. }
  1092. }
  1093. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1094. import { Nullable } from "babylonjs/types";
  1095. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1096. /**
  1097. * This represents the required contract to create a new type of texture loader.
  1098. */
  1099. export interface IInternalTextureLoader {
  1100. /**
  1101. * Defines wether the loader supports cascade loading the different faces.
  1102. */
  1103. supportCascades: boolean;
  1104. /**
  1105. * This returns if the loader support the current file information.
  1106. * @param extension defines the file extension of the file being loaded
  1107. * @param mimeType defines the optional mime type of the file being loaded
  1108. * @returns true if the loader can load the specified file
  1109. */
  1110. canLoad(extension: string, mimeType?: string): boolean;
  1111. /**
  1112. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1113. * @param data contains the texture data
  1114. * @param texture defines the BabylonJS internal texture
  1115. * @param createPolynomials will be true if polynomials have been requested
  1116. * @param onLoad defines the callback to trigger once the texture is ready
  1117. * @param onError defines the callback to trigger in case of error
  1118. */
  1119. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1120. /**
  1121. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1122. * @param data contains the texture data
  1123. * @param texture defines the BabylonJS internal texture
  1124. * @param callback defines the method to call once ready to upload
  1125. */
  1126. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1127. }
  1128. }
  1129. declare module "babylonjs/Engines/IPipelineContext" {
  1130. /**
  1131. * Class used to store and describe the pipeline context associated with an effect
  1132. */
  1133. export interface IPipelineContext {
  1134. /**
  1135. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1136. */
  1137. isAsync: boolean;
  1138. /**
  1139. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1140. */
  1141. isReady: boolean;
  1142. /** @hidden */
  1143. _getVertexShaderCode(): string | null;
  1144. /** @hidden */
  1145. _getFragmentShaderCode(): string | null;
  1146. /** @hidden */
  1147. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1148. }
  1149. }
  1150. declare module "babylonjs/Meshes/dataBuffer" {
  1151. /**
  1152. * Class used to store gfx data (like WebGLBuffer)
  1153. */
  1154. export class DataBuffer {
  1155. /**
  1156. * Gets or sets the number of objects referencing this buffer
  1157. */
  1158. references: number;
  1159. /** Gets or sets the size of the underlying buffer */
  1160. capacity: number;
  1161. /**
  1162. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1163. */
  1164. is32Bits: boolean;
  1165. /**
  1166. * Gets the underlying buffer
  1167. */
  1168. get underlyingResource(): any;
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1172. /** @hidden */
  1173. export interface IShaderProcessor {
  1174. attributeProcessor?: (attribute: string) => string;
  1175. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1176. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1177. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1178. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1179. lineProcessor?: (line: string, isFragment: boolean) => string;
  1180. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1181. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1185. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1186. /** @hidden */
  1187. export interface ProcessingOptions {
  1188. defines: string[];
  1189. indexParameters: any;
  1190. isFragment: boolean;
  1191. shouldUseHighPrecisionShader: boolean;
  1192. supportsUniformBuffers: boolean;
  1193. shadersRepository: string;
  1194. includesShadersStore: {
  1195. [key: string]: string;
  1196. };
  1197. processor?: IShaderProcessor;
  1198. version: string;
  1199. platformName: string;
  1200. lookForClosingBracketForUniformBuffer?: boolean;
  1201. }
  1202. }
  1203. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1204. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1205. /** @hidden */
  1206. export class ShaderCodeNode {
  1207. line: string;
  1208. children: ShaderCodeNode[];
  1209. additionalDefineKey?: string;
  1210. additionalDefineValue?: string;
  1211. isValid(preprocessors: {
  1212. [key: string]: string;
  1213. }): boolean;
  1214. process(preprocessors: {
  1215. [key: string]: string;
  1216. }, options: ProcessingOptions): string;
  1217. }
  1218. }
  1219. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1220. /** @hidden */
  1221. export class ShaderCodeCursor {
  1222. private _lines;
  1223. lineIndex: number;
  1224. get currentLine(): string;
  1225. get canRead(): boolean;
  1226. set lines(value: string[]);
  1227. }
  1228. }
  1229. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1230. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1231. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1232. /** @hidden */
  1233. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1234. process(preprocessors: {
  1235. [key: string]: string;
  1236. }, options: ProcessingOptions): string;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1240. /** @hidden */
  1241. export class ShaderDefineExpression {
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. private static _OperatorPriority;
  1246. private static _Stack;
  1247. static postfixToInfix(postfix: string[]): string;
  1248. static infixToPostfix(infix: string): string[];
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1252. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. not: boolean;
  1268. constructor(define: string, not?: boolean);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1275. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1276. /** @hidden */
  1277. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1278. leftOperand: ShaderDefineExpression;
  1279. rightOperand: ShaderDefineExpression;
  1280. isTrue(preprocessors: {
  1281. [key: string]: string;
  1282. }): boolean;
  1283. }
  1284. }
  1285. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1286. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1287. /** @hidden */
  1288. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1289. leftOperand: ShaderDefineExpression;
  1290. rightOperand: ShaderDefineExpression;
  1291. isTrue(preprocessors: {
  1292. [key: string]: string;
  1293. }): boolean;
  1294. }
  1295. }
  1296. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1297. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1298. /** @hidden */
  1299. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1300. define: string;
  1301. operand: string;
  1302. testValue: string;
  1303. constructor(define: string, operand: string, testValue: string);
  1304. isTrue(preprocessors: {
  1305. [key: string]: string;
  1306. }): boolean;
  1307. }
  1308. }
  1309. declare module "babylonjs/Offline/IOfflineProvider" {
  1310. /**
  1311. * Class used to enable access to offline support
  1312. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1313. */
  1314. export interface IOfflineProvider {
  1315. /**
  1316. * Gets a boolean indicating if scene must be saved in the database
  1317. */
  1318. enableSceneOffline: boolean;
  1319. /**
  1320. * Gets a boolean indicating if textures must be saved in the database
  1321. */
  1322. enableTexturesOffline: boolean;
  1323. /**
  1324. * Open the offline support and make it available
  1325. * @param successCallback defines the callback to call on success
  1326. * @param errorCallback defines the callback to call on error
  1327. */
  1328. open(successCallback: () => void, errorCallback: () => void): void;
  1329. /**
  1330. * Loads an image from the offline support
  1331. * @param url defines the url to load from
  1332. * @param image defines the target DOM image
  1333. */
  1334. loadImage(url: string, image: HTMLImageElement): void;
  1335. /**
  1336. * Loads a file from offline support
  1337. * @param url defines the URL to load from
  1338. * @param sceneLoaded defines a callback to call on success
  1339. * @param progressCallBack defines a callback to call when progress changed
  1340. * @param errorCallback defines a callback to call on error
  1341. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1342. */
  1343. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1344. }
  1345. }
  1346. declare module "babylonjs/Misc/filesInputStore" {
  1347. /**
  1348. * Class used to help managing file picking and drag'n'drop
  1349. * File Storage
  1350. */
  1351. export class FilesInputStore {
  1352. /**
  1353. * List of files ready to be loaded
  1354. */
  1355. static FilesToLoad: {
  1356. [key: string]: File;
  1357. };
  1358. }
  1359. }
  1360. declare module "babylonjs/Misc/retryStrategy" {
  1361. import { WebRequest } from "babylonjs/Misc/webRequest";
  1362. /**
  1363. * Class used to define a retry strategy when error happens while loading assets
  1364. */
  1365. export class RetryStrategy {
  1366. /**
  1367. * Function used to defines an exponential back off strategy
  1368. * @param maxRetries defines the maximum number of retries (3 by default)
  1369. * @param baseInterval defines the interval between retries
  1370. * @returns the strategy function to use
  1371. */
  1372. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1373. }
  1374. }
  1375. declare module "babylonjs/Misc/baseError" {
  1376. /**
  1377. * @ignore
  1378. * Application error to support additional information when loading a file
  1379. */
  1380. export abstract class BaseError extends Error {
  1381. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1382. }
  1383. }
  1384. declare module "babylonjs/Misc/fileTools" {
  1385. import { WebRequest } from "babylonjs/Misc/webRequest";
  1386. import { Nullable } from "babylonjs/types";
  1387. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1388. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1389. import { BaseError } from "babylonjs/Misc/baseError";
  1390. /** @ignore */
  1391. export class LoadFileError extends BaseError {
  1392. request?: WebRequest;
  1393. file?: File;
  1394. /**
  1395. * Creates a new LoadFileError
  1396. * @param message defines the message of the error
  1397. * @param request defines the optional web request
  1398. * @param file defines the optional file
  1399. */
  1400. constructor(message: string, object?: WebRequest | File);
  1401. }
  1402. /** @ignore */
  1403. export class RequestFileError extends BaseError {
  1404. request: WebRequest;
  1405. /**
  1406. * Creates a new LoadFileError
  1407. * @param message defines the message of the error
  1408. * @param request defines the optional web request
  1409. */
  1410. constructor(message: string, request: WebRequest);
  1411. }
  1412. /** @ignore */
  1413. export class ReadFileError extends BaseError {
  1414. file: File;
  1415. /**
  1416. * Creates a new ReadFileError
  1417. * @param message defines the message of the error
  1418. * @param file defines the optional file
  1419. */
  1420. constructor(message: string, file: File);
  1421. }
  1422. /**
  1423. * @hidden
  1424. */
  1425. export class FileTools {
  1426. /**
  1427. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1428. */
  1429. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1430. /**
  1431. * Gets or sets the base URL to use to load assets
  1432. */
  1433. static BaseUrl: string;
  1434. /**
  1435. * Default behaviour for cors in the application.
  1436. * It can be a string if the expected behavior is identical in the entire app.
  1437. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1438. */
  1439. static CorsBehavior: string | ((url: string | string[]) => string);
  1440. /**
  1441. * Gets or sets a function used to pre-process url before using them to load assets
  1442. */
  1443. static PreprocessUrl: (url: string) => string;
  1444. /**
  1445. * Removes unwanted characters from an url
  1446. * @param url defines the url to clean
  1447. * @returns the cleaned url
  1448. */
  1449. private static _CleanUrl;
  1450. /**
  1451. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1452. * @param url define the url we are trying
  1453. * @param element define the dom element where to configure the cors policy
  1454. */
  1455. static SetCorsBehavior(url: string | string[], element: {
  1456. crossOrigin: string | null;
  1457. }): void;
  1458. /**
  1459. * Loads an image as an HTMLImageElement.
  1460. * @param input url string, ArrayBuffer, or Blob to load
  1461. * @param onLoad callback called when the image successfully loads
  1462. * @param onError callback called when the image fails to load
  1463. * @param offlineProvider offline provider for caching
  1464. * @param mimeType optional mime type
  1465. * @returns the HTMLImageElement of the loaded image
  1466. */
  1467. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1468. /**
  1469. * Reads a file from a File object
  1470. * @param file defines the file to load
  1471. * @param onSuccess defines the callback to call when data is loaded
  1472. * @param onProgress defines the callback to call during loading process
  1473. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1474. * @param onError defines the callback to call when an error occurs
  1475. * @returns a file request object
  1476. */
  1477. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1478. /**
  1479. * Loads a file from a url
  1480. * @param url url to load
  1481. * @param onSuccess callback called when the file successfully loads
  1482. * @param onProgress callback called while file is loading (if the server supports this mode)
  1483. * @param offlineProvider defines the offline provider for caching
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @returns a file request object
  1487. */
  1488. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1489. /**
  1490. * Loads a file
  1491. * @param url url to load
  1492. * @param onSuccess callback called when the file successfully loads
  1493. * @param onProgress callback called while file is loading (if the server supports this mode)
  1494. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1495. * @param onError callback called when the file fails to load
  1496. * @param onOpened callback called when the web request is opened
  1497. * @returns a file request object
  1498. */
  1499. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1500. /**
  1501. * Checks if the loaded document was accessed via `file:`-Protocol.
  1502. * @returns boolean
  1503. */
  1504. static IsFileURL(): boolean;
  1505. }
  1506. }
  1507. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1508. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1509. import { WebRequest } from "babylonjs/Misc/webRequest";
  1510. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1511. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1512. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1513. /** @hidden */
  1514. export class ShaderProcessor {
  1515. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1516. private static _ProcessPrecision;
  1517. private static _ExtractOperation;
  1518. private static _BuildSubExpression;
  1519. private static _BuildExpression;
  1520. private static _MoveCursorWithinIf;
  1521. private static _MoveCursor;
  1522. private static _EvaluatePreProcessors;
  1523. private static _PreparePreProcessors;
  1524. private static _ProcessShaderConversion;
  1525. private static _ProcessIncludes;
  1526. /**
  1527. * Loads a file from a url
  1528. * @param url url to load
  1529. * @param onSuccess callback called when the file successfully loads
  1530. * @param onProgress callback called while file is loading (if the server supports this mode)
  1531. * @param offlineProvider defines the offline provider for caching
  1532. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1533. * @param onError callback called when the file fails to load
  1534. * @returns a file request object
  1535. * @hidden
  1536. */
  1537. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1538. }
  1539. }
  1540. declare module "babylonjs/Maths/math.like" {
  1541. import { float, int, DeepImmutable } from "babylonjs/types";
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IColor4Like {
  1546. r: float;
  1547. g: float;
  1548. b: float;
  1549. a: float;
  1550. }
  1551. /**
  1552. * @hidden
  1553. */
  1554. export interface IColor3Like {
  1555. r: float;
  1556. g: float;
  1557. b: float;
  1558. }
  1559. /**
  1560. * @hidden
  1561. */
  1562. export interface IVector4Like {
  1563. x: float;
  1564. y: float;
  1565. z: float;
  1566. w: float;
  1567. }
  1568. /**
  1569. * @hidden
  1570. */
  1571. export interface IVector3Like {
  1572. x: float;
  1573. y: float;
  1574. z: float;
  1575. }
  1576. /**
  1577. * @hidden
  1578. */
  1579. export interface IVector2Like {
  1580. x: float;
  1581. y: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IMatrixLike {
  1587. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1588. updateFlag: int;
  1589. }
  1590. /**
  1591. * @hidden
  1592. */
  1593. export interface IViewportLike {
  1594. x: float;
  1595. y: float;
  1596. width: float;
  1597. height: float;
  1598. }
  1599. /**
  1600. * @hidden
  1601. */
  1602. export interface IPlaneLike {
  1603. normal: IVector3Like;
  1604. d: float;
  1605. normalize(): void;
  1606. }
  1607. }
  1608. declare module "babylonjs/Materials/iEffectFallbacks" {
  1609. import { Effect } from "babylonjs/Materials/effect";
  1610. /**
  1611. * Interface used to define common properties for effect fallbacks
  1612. */
  1613. export interface IEffectFallbacks {
  1614. /**
  1615. * Removes the defines that should be removed when falling back.
  1616. * @param currentDefines defines the current define statements for the shader.
  1617. * @param effect defines the current effect we try to compile
  1618. * @returns The resulting defines with defines of the current rank removed.
  1619. */
  1620. reduce(currentDefines: string, effect: Effect): string;
  1621. /**
  1622. * Removes the fallback from the bound mesh.
  1623. */
  1624. unBindMesh(): void;
  1625. /**
  1626. * Checks to see if more fallbacks are still availible.
  1627. */
  1628. hasMoreFallbacks: boolean;
  1629. }
  1630. }
  1631. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1632. /**
  1633. * Class used to evalaute queries containing `and` and `or` operators
  1634. */
  1635. export class AndOrNotEvaluator {
  1636. /**
  1637. * Evaluate a query
  1638. * @param query defines the query to evaluate
  1639. * @param evaluateCallback defines the callback used to filter result
  1640. * @returns true if the query matches
  1641. */
  1642. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1643. private static _HandleParenthesisContent;
  1644. private static _SimplifyNegation;
  1645. }
  1646. }
  1647. declare module "babylonjs/Misc/tags" {
  1648. /**
  1649. * Class used to store custom tags
  1650. */
  1651. export class Tags {
  1652. /**
  1653. * Adds support for tags on the given object
  1654. * @param obj defines the object to use
  1655. */
  1656. static EnableFor(obj: any): void;
  1657. /**
  1658. * Removes tags support
  1659. * @param obj defines the object to use
  1660. */
  1661. static DisableFor(obj: any): void;
  1662. /**
  1663. * Gets a boolean indicating if the given object has tags
  1664. * @param obj defines the object to use
  1665. * @returns a boolean
  1666. */
  1667. static HasTags(obj: any): boolean;
  1668. /**
  1669. * Gets the tags available on a given object
  1670. * @param obj defines the object to use
  1671. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1672. * @returns the tags
  1673. */
  1674. static GetTags(obj: any, asString?: boolean): any;
  1675. /**
  1676. * Adds tags to an object
  1677. * @param obj defines the object to use
  1678. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1679. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1680. */
  1681. static AddTagsTo(obj: any, tagsString: string): void;
  1682. /**
  1683. * @hidden
  1684. */
  1685. static _AddTagTo(obj: any, tag: string): void;
  1686. /**
  1687. * Removes specific tags from a specific object
  1688. * @param obj defines the object to use
  1689. * @param tagsString defines the tags to remove
  1690. */
  1691. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1692. /**
  1693. * @hidden
  1694. */
  1695. static _RemoveTagFrom(obj: any, tag: string): void;
  1696. /**
  1697. * Defines if tags hosted on an object match a given query
  1698. * @param obj defines the object to use
  1699. * @param tagsQuery defines the tag query
  1700. * @returns a boolean
  1701. */
  1702. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1703. }
  1704. }
  1705. declare module "babylonjs/Maths/math.scalar" {
  1706. /**
  1707. * Scalar computation library
  1708. */
  1709. export class Scalar {
  1710. /**
  1711. * Two pi constants convenient for computation.
  1712. */
  1713. static TwoPi: number;
  1714. /**
  1715. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1716. * @param a number
  1717. * @param b number
  1718. * @param epsilon (default = 1.401298E-45)
  1719. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1720. */
  1721. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1722. /**
  1723. * Returns a string : the upper case translation of the number i to hexadecimal.
  1724. * @param i number
  1725. * @returns the upper case translation of the number i to hexadecimal.
  1726. */
  1727. static ToHex(i: number): string;
  1728. /**
  1729. * Returns -1 if value is negative and +1 is value is positive.
  1730. * @param value the value
  1731. * @returns the value itself if it's equal to zero.
  1732. */
  1733. static Sign(value: number): number;
  1734. /**
  1735. * Returns the value itself if it's between min and max.
  1736. * Returns min if the value is lower than min.
  1737. * Returns max if the value is greater than max.
  1738. * @param value the value to clmap
  1739. * @param min the min value to clamp to (default: 0)
  1740. * @param max the max value to clamp to (default: 1)
  1741. * @returns the clamped value
  1742. */
  1743. static Clamp(value: number, min?: number, max?: number): number;
  1744. /**
  1745. * the log2 of value.
  1746. * @param value the value to compute log2 of
  1747. * @returns the log2 of value.
  1748. */
  1749. static Log2(value: number): number;
  1750. /**
  1751. * Loops the value, so that it is never larger than length and never smaller than 0.
  1752. *
  1753. * This is similar to the modulo operator but it works with floating point numbers.
  1754. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1755. * With t = 5 and length = 2.5, the result would be 0.0.
  1756. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1757. * @param value the value
  1758. * @param length the length
  1759. * @returns the looped value
  1760. */
  1761. static Repeat(value: number, length: number): number;
  1762. /**
  1763. * Normalize the value between 0.0 and 1.0 using min and max values
  1764. * @param value value to normalize
  1765. * @param min max to normalize between
  1766. * @param max min to normalize between
  1767. * @returns the normalized value
  1768. */
  1769. static Normalize(value: number, min: number, max: number): number;
  1770. /**
  1771. * Denormalize the value from 0.0 and 1.0 using min and max values
  1772. * @param normalized value to denormalize
  1773. * @param min max to denormalize between
  1774. * @param max min to denormalize between
  1775. * @returns the denormalized value
  1776. */
  1777. static Denormalize(normalized: number, min: number, max: number): number;
  1778. /**
  1779. * Calculates the shortest difference between two given angles given in degrees.
  1780. * @param current current angle in degrees
  1781. * @param target target angle in degrees
  1782. * @returns the delta
  1783. */
  1784. static DeltaAngle(current: number, target: number): number;
  1785. /**
  1786. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1787. * @param tx value
  1788. * @param length length
  1789. * @returns The returned value will move back and forth between 0 and length
  1790. */
  1791. static PingPong(tx: number, length: number): number;
  1792. /**
  1793. * Interpolates between min and max with smoothing at the limits.
  1794. *
  1795. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1796. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1797. * @param from from
  1798. * @param to to
  1799. * @param tx value
  1800. * @returns the smooth stepped value
  1801. */
  1802. static SmoothStep(from: number, to: number, tx: number): number;
  1803. /**
  1804. * Moves a value current towards target.
  1805. *
  1806. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1807. * Negative values of maxDelta pushes the value away from target.
  1808. * @param current current value
  1809. * @param target target value
  1810. * @param maxDelta max distance to move
  1811. * @returns resulting value
  1812. */
  1813. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1814. /**
  1815. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. *
  1817. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1818. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1819. * @param current current value
  1820. * @param target target value
  1821. * @param maxDelta max distance to move
  1822. * @returns resulting angle
  1823. */
  1824. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1825. /**
  1826. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1827. * @param start start value
  1828. * @param end target value
  1829. * @param amount amount to lerp between
  1830. * @returns the lerped value
  1831. */
  1832. static Lerp(start: number, end: number, amount: number): number;
  1833. /**
  1834. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1835. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1836. * @param start start value
  1837. * @param end target value
  1838. * @param amount amount to lerp between
  1839. * @returns the lerped value
  1840. */
  1841. static LerpAngle(start: number, end: number, amount: number): number;
  1842. /**
  1843. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1844. * @param a start value
  1845. * @param b target value
  1846. * @param value value between a and b
  1847. * @returns the inverseLerp value
  1848. */
  1849. static InverseLerp(a: number, b: number, value: number): number;
  1850. /**
  1851. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1852. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1853. * @param value1 spline value
  1854. * @param tangent1 spline value
  1855. * @param value2 spline value
  1856. * @param tangent2 spline value
  1857. * @param amount input value
  1858. * @returns hermite result
  1859. */
  1860. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1861. /**
  1862. * Returns a random float number between and min and max values
  1863. * @param min min value of random
  1864. * @param max max value of random
  1865. * @returns random value
  1866. */
  1867. static RandomRange(min: number, max: number): number;
  1868. /**
  1869. * This function returns percentage of a number in a given range.
  1870. *
  1871. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1872. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1873. * @param number to convert to percentage
  1874. * @param min min range
  1875. * @param max max range
  1876. * @returns the percentage
  1877. */
  1878. static RangeToPercent(number: number, min: number, max: number): number;
  1879. /**
  1880. * This function returns number that corresponds to the percentage in a given range.
  1881. *
  1882. * PercentToRange(0.34,0,100) will return 34.
  1883. * @param percent to convert to number
  1884. * @param min min range
  1885. * @param max max range
  1886. * @returns the number
  1887. */
  1888. static PercentToRange(percent: number, min: number, max: number): number;
  1889. /**
  1890. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1891. * @param angle The angle to normalize in radian.
  1892. * @return The converted angle.
  1893. */
  1894. static NormalizeRadians(angle: number): number;
  1895. }
  1896. }
  1897. declare module "babylonjs/Maths/math.constants" {
  1898. /**
  1899. * Constant used to convert a value to gamma space
  1900. * @ignorenaming
  1901. */
  1902. export const ToGammaSpace: number;
  1903. /**
  1904. * Constant used to convert a value to linear space
  1905. * @ignorenaming
  1906. */
  1907. export const ToLinearSpace = 2.2;
  1908. /**
  1909. * Constant used to define the minimal number value in Babylon.js
  1910. * @ignorenaming
  1911. */
  1912. let Epsilon: number;
  1913. export { Epsilon };
  1914. }
  1915. declare module "babylonjs/Maths/math.viewport" {
  1916. /**
  1917. * Class used to represent a viewport on screen
  1918. */
  1919. export class Viewport {
  1920. /** viewport left coordinate */
  1921. x: number;
  1922. /** viewport top coordinate */
  1923. y: number;
  1924. /**viewport width */
  1925. width: number;
  1926. /** viewport height */
  1927. height: number;
  1928. /**
  1929. * Creates a Viewport object located at (x, y) and sized (width, height)
  1930. * @param x defines viewport left coordinate
  1931. * @param y defines viewport top coordinate
  1932. * @param width defines the viewport width
  1933. * @param height defines the viewport height
  1934. */
  1935. constructor(
  1936. /** viewport left coordinate */
  1937. x: number,
  1938. /** viewport top coordinate */
  1939. y: number,
  1940. /**viewport width */
  1941. width: number,
  1942. /** viewport height */
  1943. height: number);
  1944. /**
  1945. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1946. * @param renderWidth defines the rendering width
  1947. * @param renderHeight defines the rendering height
  1948. * @returns a new Viewport
  1949. */
  1950. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1951. /**
  1952. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1953. * @param renderWidth defines the rendering width
  1954. * @param renderHeight defines the rendering height
  1955. * @param ref defines the target viewport
  1956. * @returns the current viewport
  1957. */
  1958. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1959. /**
  1960. * Returns a new Viewport copied from the current one
  1961. * @returns a new Viewport
  1962. */
  1963. clone(): Viewport;
  1964. }
  1965. }
  1966. declare module "babylonjs/Misc/arrayTools" {
  1967. /**
  1968. * Class containing a set of static utilities functions for arrays.
  1969. */
  1970. export class ArrayTools {
  1971. /**
  1972. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1973. * @param size the number of element to construct and put in the array
  1974. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1975. * @returns a new array filled with new objects
  1976. */
  1977. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1978. }
  1979. }
  1980. declare module "babylonjs/Maths/math.plane" {
  1981. import { DeepImmutable } from "babylonjs/types";
  1982. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1983. /**
  1984. * Represents a plane by the equation ax + by + cz + d = 0
  1985. */
  1986. export class Plane {
  1987. private static _TmpMatrix;
  1988. /**
  1989. * Normal of the plane (a,b,c)
  1990. */
  1991. normal: Vector3;
  1992. /**
  1993. * d component of the plane
  1994. */
  1995. d: number;
  1996. /**
  1997. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1998. * @param a a component of the plane
  1999. * @param b b component of the plane
  2000. * @param c c component of the plane
  2001. * @param d d component of the plane
  2002. */
  2003. constructor(a: number, b: number, c: number, d: number);
  2004. /**
  2005. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2006. */
  2007. asArray(): number[];
  2008. /**
  2009. * @returns a new plane copied from the current Plane.
  2010. */
  2011. clone(): Plane;
  2012. /**
  2013. * @returns the string "Plane".
  2014. */
  2015. getClassName(): string;
  2016. /**
  2017. * @returns the Plane hash code.
  2018. */
  2019. getHashCode(): number;
  2020. /**
  2021. * Normalize the current Plane in place.
  2022. * @returns the updated Plane.
  2023. */
  2024. normalize(): Plane;
  2025. /**
  2026. * Applies a transformation the plane and returns the result
  2027. * @param transformation the transformation matrix to be applied to the plane
  2028. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2029. */
  2030. transform(transformation: DeepImmutable<Matrix>): Plane;
  2031. /**
  2032. * Compute the dot product between the point and the plane normal
  2033. * @param point point to calculate the dot product with
  2034. * @returns the dot product (float) of the point coordinates and the plane normal.
  2035. */
  2036. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2037. /**
  2038. * Updates the current Plane from the plane defined by the three given points.
  2039. * @param point1 one of the points used to contruct the plane
  2040. * @param point2 one of the points used to contruct the plane
  2041. * @param point3 one of the points used to contruct the plane
  2042. * @returns the updated Plane.
  2043. */
  2044. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2045. /**
  2046. * Checks if the plane is facing a given direction
  2047. * @param direction the direction to check if the plane is facing
  2048. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2049. * @returns True is the vector "direction" is the same side than the plane normal.
  2050. */
  2051. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2052. /**
  2053. * Calculates the distance to a point
  2054. * @param point point to calculate distance to
  2055. * @returns the signed distance (float) from the given point to the Plane.
  2056. */
  2057. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2058. /**
  2059. * Creates a plane from an array
  2060. * @param array the array to create a plane from
  2061. * @returns a new Plane from the given array.
  2062. */
  2063. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2064. /**
  2065. * Creates a plane from three points
  2066. * @param point1 point used to create the plane
  2067. * @param point2 point used to create the plane
  2068. * @param point3 point used to create the plane
  2069. * @returns a new Plane defined by the three given points.
  2070. */
  2071. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2072. /**
  2073. * Creates a plane from an origin point and a normal
  2074. * @param origin origin of the plane to be constructed
  2075. * @param normal normal of the plane to be constructed
  2076. * @returns a new Plane the normal vector to this plane at the given origin point.
  2077. * Note : the vector "normal" is updated because normalized.
  2078. */
  2079. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2080. /**
  2081. * Calculates the distance from a plane and a point
  2082. * @param origin origin of the plane to be constructed
  2083. * @param normal normal of the plane to be constructed
  2084. * @param point point to calculate distance to
  2085. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2086. */
  2087. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2088. }
  2089. }
  2090. declare module "babylonjs/Engines/performanceConfigurator" {
  2091. /** @hidden */
  2092. export class PerformanceConfigurator {
  2093. /** @hidden */
  2094. static MatrixUse64Bits: boolean;
  2095. /** @hidden */
  2096. static MatrixTrackPrecisionChange: boolean;
  2097. /** @hidden */
  2098. static MatrixCurrentType: any;
  2099. /** @hidden */
  2100. static MatrixTrackedMatrices: Array<any> | null;
  2101. /** @hidden */
  2102. static SetMatrixPrecision(use64bits: boolean): void;
  2103. }
  2104. }
  2105. declare module "babylonjs/Maths/math.vector" {
  2106. import { Viewport } from "babylonjs/Maths/math.viewport";
  2107. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2108. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2109. import { Plane } from "babylonjs/Maths/math.plane";
  2110. /**
  2111. * Class representing a vector containing 2 coordinates
  2112. */
  2113. export class Vector2 {
  2114. /** defines the first coordinate */
  2115. x: number;
  2116. /** defines the second coordinate */
  2117. y: number;
  2118. /**
  2119. * Creates a new Vector2 from the given x and y coordinates
  2120. * @param x defines the first coordinate
  2121. * @param y defines the second coordinate
  2122. */
  2123. constructor(
  2124. /** defines the first coordinate */
  2125. x?: number,
  2126. /** defines the second coordinate */
  2127. y?: number);
  2128. /**
  2129. * Gets a string with the Vector2 coordinates
  2130. * @returns a string with the Vector2 coordinates
  2131. */
  2132. toString(): string;
  2133. /**
  2134. * Gets class name
  2135. * @returns the string "Vector2"
  2136. */
  2137. getClassName(): string;
  2138. /**
  2139. * Gets current vector hash code
  2140. * @returns the Vector2 hash code as a number
  2141. */
  2142. getHashCode(): number;
  2143. /**
  2144. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2145. * @param array defines the source array
  2146. * @param index defines the offset in source array
  2147. * @returns the current Vector2
  2148. */
  2149. toArray(array: FloatArray, index?: number): Vector2;
  2150. /**
  2151. * Update the current vector from an array
  2152. * @param array defines the destination array
  2153. * @param index defines the offset in the destination array
  2154. * @returns the current Vector3
  2155. */
  2156. fromArray(array: FloatArray, index?: number): Vector2;
  2157. /**
  2158. * Copy the current vector to an array
  2159. * @returns a new array with 2 elements: the Vector2 coordinates.
  2160. */
  2161. asArray(): number[];
  2162. /**
  2163. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2164. * @param source defines the source Vector2
  2165. * @returns the current updated Vector2
  2166. */
  2167. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2168. /**
  2169. * Sets the Vector2 coordinates with the given floats
  2170. * @param x defines the first coordinate
  2171. * @param y defines the second coordinate
  2172. * @returns the current updated Vector2
  2173. */
  2174. copyFromFloats(x: number, y: number): Vector2;
  2175. /**
  2176. * Sets the Vector2 coordinates with the given floats
  2177. * @param x defines the first coordinate
  2178. * @param y defines the second coordinate
  2179. * @returns the current updated Vector2
  2180. */
  2181. set(x: number, y: number): Vector2;
  2182. /**
  2183. * Add another vector with the current one
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2186. */
  2187. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2190. * @param otherVector defines the other vector
  2191. * @param result defines the target vector
  2192. * @returns the unmodified current Vector2
  2193. */
  2194. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2195. /**
  2196. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2197. * @param otherVector defines the other vector
  2198. * @returns the current updated Vector2
  2199. */
  2200. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2201. /**
  2202. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns a new Vector2
  2205. */
  2206. addVector3(otherVector: Vector3): Vector2;
  2207. /**
  2208. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2209. * @param otherVector defines the other vector
  2210. * @returns a new Vector2
  2211. */
  2212. subtract(otherVector: Vector2): Vector2;
  2213. /**
  2214. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2215. * @param otherVector defines the other vector
  2216. * @param result defines the target vector
  2217. * @returns the unmodified current Vector2
  2218. */
  2219. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2220. /**
  2221. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2222. * @param otherVector defines the other vector
  2223. * @returns the current updated Vector2
  2224. */
  2225. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Multiplies in place the current Vector2 coordinates by the given ones
  2228. * @param otherVector defines the other vector
  2229. * @returns the current updated Vector2
  2230. */
  2231. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2232. /**
  2233. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @returns a new Vector2
  2236. */
  2237. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2238. /**
  2239. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2240. * @param otherVector defines the other vector
  2241. * @param result defines the target vector
  2242. * @returns the unmodified current Vector2
  2243. */
  2244. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2245. /**
  2246. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2247. * @param x defines the first coordinate
  2248. * @param y defines the second coordinate
  2249. * @returns a new Vector2
  2250. */
  2251. multiplyByFloats(x: number, y: number): Vector2;
  2252. /**
  2253. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2254. * @param otherVector defines the other vector
  2255. * @returns a new Vector2
  2256. */
  2257. divide(otherVector: Vector2): Vector2;
  2258. /**
  2259. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2260. * @param otherVector defines the other vector
  2261. * @param result defines the target vector
  2262. * @returns the unmodified current Vector2
  2263. */
  2264. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2265. /**
  2266. * Divides the current Vector2 coordinates by the given ones
  2267. * @param otherVector defines the other vector
  2268. * @returns the current updated Vector2
  2269. */
  2270. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2271. /**
  2272. * Gets a new Vector2 with current Vector2 negated coordinates
  2273. * @returns a new Vector2
  2274. */
  2275. negate(): Vector2;
  2276. /**
  2277. * Negate this vector in place
  2278. * @returns this
  2279. */
  2280. negateInPlace(): Vector2;
  2281. /**
  2282. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2283. * @param result defines the Vector3 object where to store the result
  2284. * @returns the current Vector2
  2285. */
  2286. negateToRef(result: Vector2): Vector2;
  2287. /**
  2288. * Multiply the Vector2 coordinates by scale
  2289. * @param scale defines the scaling factor
  2290. * @returns the current updated Vector2
  2291. */
  2292. scaleInPlace(scale: number): Vector2;
  2293. /**
  2294. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2295. * @param scale defines the scaling factor
  2296. * @returns a new Vector2
  2297. */
  2298. scale(scale: number): Vector2;
  2299. /**
  2300. * Scale the current Vector2 values by a factor to a given Vector2
  2301. * @param scale defines the scale factor
  2302. * @param result defines the Vector2 object where to store the result
  2303. * @returns the unmodified current Vector2
  2304. */
  2305. scaleToRef(scale: number, result: Vector2): Vector2;
  2306. /**
  2307. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2308. * @param scale defines the scale factor
  2309. * @param result defines the Vector2 object where to store the result
  2310. * @returns the unmodified current Vector2
  2311. */
  2312. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2313. /**
  2314. * Gets a boolean if two vectors are equals
  2315. * @param otherVector defines the other vector
  2316. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2317. */
  2318. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2319. /**
  2320. * Gets a boolean if two vectors are equals (using an epsilon value)
  2321. * @param otherVector defines the other vector
  2322. * @param epsilon defines the minimal distance to consider equality
  2323. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2324. */
  2325. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2326. /**
  2327. * Gets a new Vector2 from current Vector2 floored values
  2328. * @returns a new Vector2
  2329. */
  2330. floor(): Vector2;
  2331. /**
  2332. * Gets a new Vector2 from current Vector2 floored values
  2333. * @returns a new Vector2
  2334. */
  2335. fract(): Vector2;
  2336. /**
  2337. * Gets the length of the vector
  2338. * @returns the vector length (float)
  2339. */
  2340. length(): number;
  2341. /**
  2342. * Gets the vector squared length
  2343. * @returns the vector squared length (float)
  2344. */
  2345. lengthSquared(): number;
  2346. /**
  2347. * Normalize the vector
  2348. * @returns the current updated Vector2
  2349. */
  2350. normalize(): Vector2;
  2351. /**
  2352. * Gets a new Vector2 copied from the Vector2
  2353. * @returns a new Vector2
  2354. */
  2355. clone(): Vector2;
  2356. /**
  2357. * Gets a new Vector2(0, 0)
  2358. * @returns a new Vector2
  2359. */
  2360. static Zero(): Vector2;
  2361. /**
  2362. * Gets a new Vector2(1, 1)
  2363. * @returns a new Vector2
  2364. */
  2365. static One(): Vector2;
  2366. /**
  2367. * Gets a new Vector2 set from the given index element of the given array
  2368. * @param array defines the data source
  2369. * @param offset defines the offset in the data source
  2370. * @returns a new Vector2
  2371. */
  2372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2373. /**
  2374. * Sets "result" from the given index element of the given array
  2375. * @param array defines the data source
  2376. * @param offset defines the offset in the data source
  2377. * @param result defines the target vector
  2378. */
  2379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2380. /**
  2381. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2382. * @param value1 defines 1st point of control
  2383. * @param value2 defines 2nd point of control
  2384. * @param value3 defines 3rd point of control
  2385. * @param value4 defines 4th point of control
  2386. * @param amount defines the interpolation factor
  2387. * @returns a new Vector2
  2388. */
  2389. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2390. /**
  2391. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2392. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2393. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2394. * @param value defines the value to clamp
  2395. * @param min defines the lower limit
  2396. * @param max defines the upper limit
  2397. * @returns a new Vector2
  2398. */
  2399. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2400. /**
  2401. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2402. * @param value1 defines the 1st control point
  2403. * @param tangent1 defines the outgoing tangent
  2404. * @param value2 defines the 2nd control point
  2405. * @param tangent2 defines the incoming tangent
  2406. * @param amount defines the interpolation factor
  2407. * @returns a new Vector2
  2408. */
  2409. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2410. /**
  2411. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2412. * @param start defines the start vector
  2413. * @param end defines the end vector
  2414. * @param amount defines the interpolation factor
  2415. * @returns a new Vector2
  2416. */
  2417. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2418. /**
  2419. * Gets the dot product of the vector "left" and the vector "right"
  2420. * @param left defines first vector
  2421. * @param right defines second vector
  2422. * @returns the dot product (float)
  2423. */
  2424. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2425. /**
  2426. * Returns a new Vector2 equal to the normalized given vector
  2427. * @param vector defines the vector to normalize
  2428. * @returns a new Vector2
  2429. */
  2430. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2431. /**
  2432. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2433. * @param left defines 1st vector
  2434. * @param right defines 2nd vector
  2435. * @returns a new Vector2
  2436. */
  2437. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2438. /**
  2439. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2440. * @param left defines 1st vector
  2441. * @param right defines 2nd vector
  2442. * @returns a new Vector2
  2443. */
  2444. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2445. /**
  2446. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2447. * @param vector defines the vector to transform
  2448. * @param transformation defines the matrix to apply
  2449. * @returns a new Vector2
  2450. */
  2451. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2452. /**
  2453. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2454. * @param vector defines the vector to transform
  2455. * @param transformation defines the matrix to apply
  2456. * @param result defines the target vector
  2457. */
  2458. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2459. /**
  2460. * Determines if a given vector is included in a triangle
  2461. * @param p defines the vector to test
  2462. * @param p0 defines 1st triangle point
  2463. * @param p1 defines 2nd triangle point
  2464. * @param p2 defines 3rd triangle point
  2465. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2466. */
  2467. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2468. /**
  2469. * Gets the distance between the vectors "value1" and "value2"
  2470. * @param value1 defines first vector
  2471. * @param value2 defines second vector
  2472. * @returns the distance between vectors
  2473. */
  2474. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2475. /**
  2476. * Returns the squared distance between the vectors "value1" and "value2"
  2477. * @param value1 defines first vector
  2478. * @param value2 defines second vector
  2479. * @returns the squared distance between vectors
  2480. */
  2481. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2482. /**
  2483. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2484. * @param value1 defines first vector
  2485. * @param value2 defines second vector
  2486. * @returns a new Vector2
  2487. */
  2488. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2489. /**
  2490. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2491. * @param p defines the middle point
  2492. * @param segA defines one point of the segment
  2493. * @param segB defines the other point of the segment
  2494. * @returns the shortest distance
  2495. */
  2496. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2497. }
  2498. /**
  2499. * Class used to store (x,y,z) vector representation
  2500. * A Vector3 is the main object used in 3D geometry
  2501. * It can represent etiher the coordinates of a point the space, either a direction
  2502. * Reminder: js uses a left handed forward facing system
  2503. */
  2504. export class Vector3 {
  2505. private static _UpReadOnly;
  2506. private static _ZeroReadOnly;
  2507. /** @hidden */
  2508. _x: number;
  2509. /** @hidden */
  2510. _y: number;
  2511. /** @hidden */
  2512. _z: number;
  2513. /** @hidden */
  2514. _isDirty: boolean;
  2515. /** Gets or sets the x coordinate */
  2516. get x(): number;
  2517. set x(value: number);
  2518. /** Gets or sets the y coordinate */
  2519. get y(): number;
  2520. set y(value: number);
  2521. /** Gets or sets the z coordinate */
  2522. get z(): number;
  2523. set z(value: number);
  2524. /**
  2525. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2526. * @param x defines the first coordinates (on X axis)
  2527. * @param y defines the second coordinates (on Y axis)
  2528. * @param z defines the third coordinates (on Z axis)
  2529. */
  2530. constructor(x?: number, y?: number, z?: number);
  2531. /**
  2532. * Creates a string representation of the Vector3
  2533. * @returns a string with the Vector3 coordinates.
  2534. */
  2535. toString(): string;
  2536. /**
  2537. * Gets the class name
  2538. * @returns the string "Vector3"
  2539. */
  2540. getClassName(): string;
  2541. /**
  2542. * Creates the Vector3 hash code
  2543. * @returns a number which tends to be unique between Vector3 instances
  2544. */
  2545. getHashCode(): number;
  2546. /**
  2547. * Creates an array containing three elements : the coordinates of the Vector3
  2548. * @returns a new array of numbers
  2549. */
  2550. asArray(): number[];
  2551. /**
  2552. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2553. * @param array defines the destination array
  2554. * @param index defines the offset in the destination array
  2555. * @returns the current Vector3
  2556. */
  2557. toArray(array: FloatArray, index?: number): Vector3;
  2558. /**
  2559. * Update the current vector from an array
  2560. * @param array defines the destination array
  2561. * @param index defines the offset in the destination array
  2562. * @returns the current Vector3
  2563. */
  2564. fromArray(array: FloatArray, index?: number): Vector3;
  2565. /**
  2566. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2567. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2568. */
  2569. toQuaternion(): Quaternion;
  2570. /**
  2571. * Adds the given vector to the current Vector3
  2572. * @param otherVector defines the second operand
  2573. * @returns the current updated Vector3
  2574. */
  2575. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2576. /**
  2577. * Adds the given coordinates to the current Vector3
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2584. /**
  2585. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Subtract the given vector from the current Vector3
  2599. * @param otherVector defines the second operand
  2600. * @returns the current updated Vector3
  2601. */
  2602. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2603. /**
  2604. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2605. * @param otherVector defines the second operand
  2606. * @returns the resulting Vector3
  2607. */
  2608. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2609. /**
  2610. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2611. * @param otherVector defines the second operand
  2612. * @param result defines the Vector3 object where to store the result
  2613. * @returns the current Vector3
  2614. */
  2615. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2618. * @param x defines the x coordinate of the operand
  2619. * @param y defines the y coordinate of the operand
  2620. * @param z defines the z coordinate of the operand
  2621. * @returns the resulting Vector3
  2622. */
  2623. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2624. /**
  2625. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2626. * @param x defines the x coordinate of the operand
  2627. * @param y defines the y coordinate of the operand
  2628. * @param z defines the z coordinate of the operand
  2629. * @param result defines the Vector3 object where to store the result
  2630. * @returns the current Vector3
  2631. */
  2632. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2633. /**
  2634. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2635. * @returns a new Vector3
  2636. */
  2637. negate(): Vector3;
  2638. /**
  2639. * Negate this vector in place
  2640. * @returns this
  2641. */
  2642. negateInPlace(): Vector3;
  2643. /**
  2644. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. negateToRef(result: Vector3): Vector3;
  2649. /**
  2650. * Multiplies the Vector3 coordinates by the float "scale"
  2651. * @param scale defines the multiplier factor
  2652. * @returns the current updated Vector3
  2653. */
  2654. scaleInPlace(scale: number): Vector3;
  2655. /**
  2656. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2657. * @param scale defines the multiplier factor
  2658. * @returns a new Vector3
  2659. */
  2660. scale(scale: number): Vector3;
  2661. /**
  2662. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2663. * @param scale defines the multiplier factor
  2664. * @param result defines the Vector3 object where to store the result
  2665. * @returns the current Vector3
  2666. */
  2667. scaleToRef(scale: number, result: Vector3): Vector3;
  2668. /**
  2669. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2670. * @param scale defines the scale factor
  2671. * @param result defines the Vector3 object where to store the result
  2672. * @returns the unmodified current Vector3
  2673. */
  2674. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2675. /**
  2676. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2677. * @param origin defines the origin of the projection ray
  2678. * @param plane defines the plane to project to
  2679. * @returns the projected vector3
  2680. */
  2681. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2682. /**
  2683. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2684. * @param origin defines the origin of the projection ray
  2685. * @param plane defines the plane to project to
  2686. * @param result defines the Vector3 where to store the result
  2687. */
  2688. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2689. /**
  2690. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2691. * @param otherVector defines the second operand
  2692. * @returns true if both vectors are equals
  2693. */
  2694. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2695. /**
  2696. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2697. * @param otherVector defines the second operand
  2698. * @param epsilon defines the minimal distance to define values as equals
  2699. * @returns true if both vectors are distant less than epsilon
  2700. */
  2701. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2702. /**
  2703. * Returns true if the current Vector3 coordinates equals the given floats
  2704. * @param x defines the x coordinate of the operand
  2705. * @param y defines the y coordinate of the operand
  2706. * @param z defines the z coordinate of the operand
  2707. * @returns true if both vectors are equals
  2708. */
  2709. equalsToFloats(x: number, y: number, z: number): boolean;
  2710. /**
  2711. * Multiplies the current Vector3 coordinates by the given ones
  2712. * @param otherVector defines the second operand
  2713. * @returns the current updated Vector3
  2714. */
  2715. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2716. /**
  2717. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2718. * @param otherVector defines the second operand
  2719. * @returns the new Vector3
  2720. */
  2721. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2722. /**
  2723. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2724. * @param otherVector defines the second operand
  2725. * @param result defines the Vector3 object where to store the result
  2726. * @returns the current Vector3
  2727. */
  2728. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2729. /**
  2730. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2731. * @param x defines the x coordinate of the operand
  2732. * @param y defines the y coordinate of the operand
  2733. * @param z defines the z coordinate of the operand
  2734. * @returns the new Vector3
  2735. */
  2736. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2739. * @param otherVector defines the second operand
  2740. * @returns the new Vector3
  2741. */
  2742. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2745. * @param otherVector defines the second operand
  2746. * @param result defines the Vector3 object where to store the result
  2747. * @returns the current Vector3
  2748. */
  2749. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2750. /**
  2751. * Divides the current Vector3 coordinates by the given ones.
  2752. * @param otherVector defines the second operand
  2753. * @returns the current updated Vector3
  2754. */
  2755. divideInPlace(otherVector: Vector3): Vector3;
  2756. /**
  2757. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2758. * @param other defines the second operand
  2759. * @returns the current updated Vector3
  2760. */
  2761. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2762. /**
  2763. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2764. * @param other defines the second operand
  2765. * @returns the current updated Vector3
  2766. */
  2767. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2768. /**
  2769. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2770. * @param x defines the x coordinate of the operand
  2771. * @param y defines the y coordinate of the operand
  2772. * @param z defines the z coordinate of the operand
  2773. * @returns the current updated Vector3
  2774. */
  2775. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2776. /**
  2777. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2778. * @param x defines the x coordinate of the operand
  2779. * @param y defines the y coordinate of the operand
  2780. * @param z defines the z coordinate of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2784. /**
  2785. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2786. * Check if is non uniform within a certain amount of decimal places to account for this
  2787. * @param epsilon the amount the values can differ
  2788. * @returns if the the vector is non uniform to a certain number of decimal places
  2789. */
  2790. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2791. /**
  2792. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2793. */
  2794. get isNonUniform(): boolean;
  2795. /**
  2796. * Gets a new Vector3 from current Vector3 floored values
  2797. * @returns a new Vector3
  2798. */
  2799. floor(): Vector3;
  2800. /**
  2801. * Gets a new Vector3 from current Vector3 floored values
  2802. * @returns a new Vector3
  2803. */
  2804. fract(): Vector3;
  2805. /**
  2806. * Gets the length of the Vector3
  2807. * @returns the length of the Vector3
  2808. */
  2809. length(): number;
  2810. /**
  2811. * Gets the squared length of the Vector3
  2812. * @returns squared length of the Vector3
  2813. */
  2814. lengthSquared(): number;
  2815. /**
  2816. * Normalize the current Vector3.
  2817. * Please note that this is an in place operation.
  2818. * @returns the current updated Vector3
  2819. */
  2820. normalize(): Vector3;
  2821. /**
  2822. * Reorders the x y z properties of the vector in place
  2823. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2824. * @returns the current updated vector
  2825. */
  2826. reorderInPlace(order: string): this;
  2827. /**
  2828. * Rotates the vector around 0,0,0 by a quaternion
  2829. * @param quaternion the rotation quaternion
  2830. * @param result vector to store the result
  2831. * @returns the resulting vector
  2832. */
  2833. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2834. /**
  2835. * Rotates a vector around a given point
  2836. * @param quaternion the rotation quaternion
  2837. * @param point the point to rotate around
  2838. * @param result vector to store the result
  2839. * @returns the resulting vector
  2840. */
  2841. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2842. /**
  2843. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2844. * The cross product is then orthogonal to both current and "other"
  2845. * @param other defines the right operand
  2846. * @returns the cross product
  2847. */
  2848. cross(other: Vector3): Vector3;
  2849. /**
  2850. * Normalize the current Vector3 with the given input length.
  2851. * Please note that this is an in place operation.
  2852. * @param len the length of the vector
  2853. * @returns the current updated Vector3
  2854. */
  2855. normalizeFromLength(len: number): Vector3;
  2856. /**
  2857. * Normalize the current Vector3 to a new vector
  2858. * @returns the new Vector3
  2859. */
  2860. normalizeToNew(): Vector3;
  2861. /**
  2862. * Normalize the current Vector3 to the reference
  2863. * @param reference define the Vector3 to update
  2864. * @returns the updated Vector3
  2865. */
  2866. normalizeToRef(reference: Vector3): Vector3;
  2867. /**
  2868. * Creates a new Vector3 copied from the current Vector3
  2869. * @returns the new Vector3
  2870. */
  2871. clone(): Vector3;
  2872. /**
  2873. * Copies the given vector coordinates to the current Vector3 ones
  2874. * @param source defines the source Vector3
  2875. * @returns the current updated Vector3
  2876. */
  2877. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2878. /**
  2879. * Copies the given floats to the current Vector3 coordinates
  2880. * @param x defines the x coordinate of the operand
  2881. * @param y defines the y coordinate of the operand
  2882. * @param z defines the z coordinate of the operand
  2883. * @returns the current updated Vector3
  2884. */
  2885. copyFromFloats(x: number, y: number, z: number): Vector3;
  2886. /**
  2887. * Copies the given floats to the current Vector3 coordinates
  2888. * @param x defines the x coordinate of the operand
  2889. * @param y defines the y coordinate of the operand
  2890. * @param z defines the z coordinate of the operand
  2891. * @returns the current updated Vector3
  2892. */
  2893. set(x: number, y: number, z: number): Vector3;
  2894. /**
  2895. * Copies the given float to the current Vector3 coordinates
  2896. * @param v defines the x, y and z coordinates of the operand
  2897. * @returns the current updated Vector3
  2898. */
  2899. setAll(v: number): Vector3;
  2900. /**
  2901. * Get the clip factor between two vectors
  2902. * @param vector0 defines the first operand
  2903. * @param vector1 defines the second operand
  2904. * @param axis defines the axis to use
  2905. * @param size defines the size along the axis
  2906. * @returns the clip factor
  2907. */
  2908. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2909. /**
  2910. * Get angle between two vectors
  2911. * @param vector0 angle between vector0 and vector1
  2912. * @param vector1 angle between vector0 and vector1
  2913. * @param normal direction of the normal
  2914. * @return the angle between vector0 and vector1
  2915. */
  2916. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2917. /**
  2918. * Returns a new Vector3 set from the index "offset" of the given array
  2919. * @param array defines the source array
  2920. * @param offset defines the offset in the source array
  2921. * @returns the new Vector3
  2922. */
  2923. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2924. /**
  2925. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2926. * @param array defines the source array
  2927. * @param offset defines the offset in the source array
  2928. * @returns the new Vector3
  2929. * @deprecated Please use FromArray instead.
  2930. */
  2931. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2932. /**
  2933. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2934. * @param array defines the source array
  2935. * @param offset defines the offset in the source array
  2936. * @param result defines the Vector3 where to store the result
  2937. */
  2938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2939. /**
  2940. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2941. * @param array defines the source array
  2942. * @param offset defines the offset in the source array
  2943. * @param result defines the Vector3 where to store the result
  2944. * @deprecated Please use FromArrayToRef instead.
  2945. */
  2946. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2947. /**
  2948. * Sets the given vector "result" with the given floats.
  2949. * @param x defines the x coordinate of the source
  2950. * @param y defines the y coordinate of the source
  2951. * @param z defines the z coordinate of the source
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2955. /**
  2956. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2957. * @returns a new empty Vector3
  2958. */
  2959. static Zero(): Vector3;
  2960. /**
  2961. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2962. * @returns a new unit Vector3
  2963. */
  2964. static One(): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2967. * @returns a new up Vector3
  2968. */
  2969. static Up(): Vector3;
  2970. /**
  2971. * Gets a up Vector3 that must not be updated
  2972. */
  2973. static get UpReadOnly(): DeepImmutable<Vector3>;
  2974. /**
  2975. * Gets a zero Vector3 that must not be updated
  2976. */
  2977. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2978. /**
  2979. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2980. * @returns a new down Vector3
  2981. */
  2982. static Down(): Vector3;
  2983. /**
  2984. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2985. * @param rightHandedSystem is the scene right-handed (negative z)
  2986. * @returns a new forward Vector3
  2987. */
  2988. static Forward(rightHandedSystem?: boolean): Vector3;
  2989. /**
  2990. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2991. * @param rightHandedSystem is the scene right-handed (negative-z)
  2992. * @returns a new forward Vector3
  2993. */
  2994. static Backward(rightHandedSystem?: boolean): Vector3;
  2995. /**
  2996. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2997. * @returns a new right Vector3
  2998. */
  2999. static Right(): Vector3;
  3000. /**
  3001. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3002. * @returns a new left Vector3
  3003. */
  3004. static Left(): Vector3;
  3005. /**
  3006. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3007. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3008. * @param vector defines the Vector3 to transform
  3009. * @param transformation defines the transformation matrix
  3010. * @returns the transformed Vector3
  3011. */
  3012. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3013. /**
  3014. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3015. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3016. * @param vector defines the Vector3 to transform
  3017. * @param transformation defines the transformation matrix
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3021. /**
  3022. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3023. * This method computes tranformed coordinates only, not transformed direction vectors
  3024. * @param x define the x coordinate of the source vector
  3025. * @param y define the y coordinate of the source vector
  3026. * @param z define the z coordinate of the source vector
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3033. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3034. * @param vector defines the Vector3 to transform
  3035. * @param transformation defines the transformation matrix
  3036. * @returns the new Vector3
  3037. */
  3038. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3039. /**
  3040. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3041. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3042. * @param vector defines the Vector3 to transform
  3043. * @param transformation defines the transformation matrix
  3044. * @param result defines the Vector3 where to store the result
  3045. */
  3046. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3047. /**
  3048. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3049. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3050. * @param x define the x coordinate of the source vector
  3051. * @param y define the y coordinate of the source vector
  3052. * @param z define the z coordinate of the source vector
  3053. * @param transformation defines the transformation matrix
  3054. * @param result defines the Vector3 where to store the result
  3055. */
  3056. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3057. /**
  3058. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3059. * @param value1 defines the first control point
  3060. * @param value2 defines the second control point
  3061. * @param value3 defines the third control point
  3062. * @param value4 defines the fourth control point
  3063. * @param amount defines the amount on the spline to use
  3064. * @returns the new Vector3
  3065. */
  3066. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3067. /**
  3068. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3069. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3070. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3071. * @param value defines the current value
  3072. * @param min defines the lower range value
  3073. * @param max defines the upper range value
  3074. * @returns the new Vector3
  3075. */
  3076. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3077. /**
  3078. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3079. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3080. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3081. * @param value defines the current value
  3082. * @param min defines the lower range value
  3083. * @param max defines the upper range value
  3084. * @param result defines the Vector3 where to store the result
  3085. */
  3086. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3087. /**
  3088. * Checks if a given vector is inside a specific range
  3089. * @param v defines the vector to test
  3090. * @param min defines the minimum range
  3091. * @param max defines the maximum range
  3092. */
  3093. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3094. /**
  3095. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3096. * @param value1 defines the first control point
  3097. * @param tangent1 defines the first tangent vector
  3098. * @param value2 defines the second control point
  3099. * @param tangent2 defines the second tangent vector
  3100. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3101. * @returns the new Vector3
  3102. */
  3103. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3104. /**
  3105. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3106. * @param start defines the start value
  3107. * @param end defines the end value
  3108. * @param amount max defines amount between both (between 0 and 1)
  3109. * @returns the new Vector3
  3110. */
  3111. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3112. /**
  3113. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3114. * @param start defines the start value
  3115. * @param end defines the end value
  3116. * @param amount max defines amount between both (between 0 and 1)
  3117. * @param result defines the Vector3 where to store the result
  3118. */
  3119. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3120. /**
  3121. * Returns the dot product (float) between the vectors "left" and "right"
  3122. * @param left defines the left operand
  3123. * @param right defines the right operand
  3124. * @returns the dot product
  3125. */
  3126. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3127. /**
  3128. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3129. * The cross product is then orthogonal to both "left" and "right"
  3130. * @param left defines the left operand
  3131. * @param right defines the right operand
  3132. * @returns the cross product
  3133. */
  3134. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3135. /**
  3136. * Sets the given vector "result" with the cross product of "left" and "right"
  3137. * The cross product is then orthogonal to both "left" and "right"
  3138. * @param left defines the left operand
  3139. * @param right defines the right operand
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3143. /**
  3144. * Returns a new Vector3 as the normalization of the given vector
  3145. * @param vector defines the Vector3 to normalize
  3146. * @returns the new Vector3
  3147. */
  3148. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3149. /**
  3150. * Sets the given vector "result" with the normalization of the given first vector
  3151. * @param vector defines the Vector3 to normalize
  3152. * @param result defines the Vector3 where to store the result
  3153. */
  3154. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3155. /**
  3156. * Project a Vector3 onto screen space
  3157. * @param vector defines the Vector3 to project
  3158. * @param world defines the world matrix to use
  3159. * @param transform defines the transform (view x projection) matrix to use
  3160. * @param viewport defines the screen viewport to use
  3161. * @returns the new Vector3
  3162. */
  3163. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3164. /** @hidden */
  3165. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3166. /**
  3167. * Unproject from screen space to object space
  3168. * @param source defines the screen space Vector3 to use
  3169. * @param viewportWidth defines the current width of the viewport
  3170. * @param viewportHeight defines the current height of the viewport
  3171. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3172. * @param transform defines the transform (view x projection) matrix to use
  3173. * @returns the new Vector3
  3174. */
  3175. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3176. /**
  3177. * Unproject from screen space to object space
  3178. * @param source defines the screen space Vector3 to use
  3179. * @param viewportWidth defines the current width of the viewport
  3180. * @param viewportHeight defines the current height of the viewport
  3181. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3182. * @param view defines the view matrix to use
  3183. * @param projection defines the projection matrix to use
  3184. * @returns the new Vector3
  3185. */
  3186. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3187. /**
  3188. * Unproject from screen space to object space
  3189. * @param source defines the screen space Vector3 to use
  3190. * @param viewportWidth defines the current width of the viewport
  3191. * @param viewportHeight defines the current height of the viewport
  3192. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3193. * @param view defines the view matrix to use
  3194. * @param projection defines the projection matrix to use
  3195. * @param result defines the Vector3 where to store the result
  3196. */
  3197. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3198. /**
  3199. * Unproject from screen space to object space
  3200. * @param sourceX defines the screen space x coordinate to use
  3201. * @param sourceY defines the screen space y coordinate to use
  3202. * @param sourceZ defines the screen space z coordinate to use
  3203. * @param viewportWidth defines the current width of the viewport
  3204. * @param viewportHeight defines the current height of the viewport
  3205. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3206. * @param view defines the view matrix to use
  3207. * @param projection defines the projection matrix to use
  3208. * @param result defines the Vector3 where to store the result
  3209. */
  3210. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3211. /**
  3212. * Gets the minimal coordinate values between two Vector3
  3213. * @param left defines the first operand
  3214. * @param right defines the second operand
  3215. * @returns the new Vector3
  3216. */
  3217. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3218. /**
  3219. * Gets the maximal coordinate values between two Vector3
  3220. * @param left defines the first operand
  3221. * @param right defines the second operand
  3222. * @returns the new Vector3
  3223. */
  3224. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3225. /**
  3226. * Returns the distance between the vectors "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the distance
  3230. */
  3231. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3232. /**
  3233. * Returns the squared distance between the vectors "value1" and "value2"
  3234. * @param value1 defines the first operand
  3235. * @param value2 defines the second operand
  3236. * @returns the squared distance
  3237. */
  3238. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3239. /**
  3240. * Returns a new Vector3 located at the center between "value1" and "value2"
  3241. * @param value1 defines the first operand
  3242. * @param value2 defines the second operand
  3243. * @returns the new Vector3
  3244. */
  3245. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3246. /**
  3247. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3248. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3249. * to something in order to rotate it from its local system to the given target system
  3250. * Note: axis1, axis2 and axis3 are normalized during this operation
  3251. * @param axis1 defines the first axis
  3252. * @param axis2 defines the second axis
  3253. * @param axis3 defines the third axis
  3254. * @returns a new Vector3
  3255. */
  3256. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3257. /**
  3258. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3259. * @param axis1 defines the first axis
  3260. * @param axis2 defines the second axis
  3261. * @param axis3 defines the third axis
  3262. * @param ref defines the Vector3 where to store the result
  3263. */
  3264. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3265. }
  3266. /**
  3267. * Vector4 class created for EulerAngle class conversion to Quaternion
  3268. */
  3269. export class Vector4 {
  3270. /** x value of the vector */
  3271. x: number;
  3272. /** y value of the vector */
  3273. y: number;
  3274. /** z value of the vector */
  3275. z: number;
  3276. /** w value of the vector */
  3277. w: number;
  3278. /**
  3279. * Creates a Vector4 object from the given floats.
  3280. * @param x x value of the vector
  3281. * @param y y value of the vector
  3282. * @param z z value of the vector
  3283. * @param w w value of the vector
  3284. */
  3285. constructor(
  3286. /** x value of the vector */
  3287. x: number,
  3288. /** y value of the vector */
  3289. y: number,
  3290. /** z value of the vector */
  3291. z: number,
  3292. /** w value of the vector */
  3293. w: number);
  3294. /**
  3295. * Returns the string with the Vector4 coordinates.
  3296. * @returns a string containing all the vector values
  3297. */
  3298. toString(): string;
  3299. /**
  3300. * Returns the string "Vector4".
  3301. * @returns "Vector4"
  3302. */
  3303. getClassName(): string;
  3304. /**
  3305. * Returns the Vector4 hash code.
  3306. * @returns a unique hash code
  3307. */
  3308. getHashCode(): number;
  3309. /**
  3310. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3311. * @returns the resulting array
  3312. */
  3313. asArray(): number[];
  3314. /**
  3315. * Populates the given array from the given index with the Vector4 coordinates.
  3316. * @param array array to populate
  3317. * @param index index of the array to start at (default: 0)
  3318. * @returns the Vector4.
  3319. */
  3320. toArray(array: FloatArray, index?: number): Vector4;
  3321. /**
  3322. * Update the current vector from an array
  3323. * @param array defines the destination array
  3324. * @param index defines the offset in the destination array
  3325. * @returns the current Vector3
  3326. */
  3327. fromArray(array: FloatArray, index?: number): Vector4;
  3328. /**
  3329. * Adds the given vector to the current Vector4.
  3330. * @param otherVector the vector to add
  3331. * @returns the updated Vector4.
  3332. */
  3333. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3336. * @param otherVector the vector to add
  3337. * @returns the resulting vector
  3338. */
  3339. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3342. * @param otherVector the vector to add
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Subtract in place the given vector from the current Vector4.
  3349. * @param otherVector the vector to subtract
  3350. * @returns the updated Vector4.
  3351. */
  3352. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3353. /**
  3354. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3355. * @param otherVector the vector to add
  3356. * @returns the new vector with the result
  3357. */
  3358. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3361. * @param otherVector the vector to subtract
  3362. * @param result the vector to store the result
  3363. * @returns the current Vector4.
  3364. */
  3365. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3366. /**
  3367. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3368. */
  3369. /**
  3370. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3371. * @param x value to subtract
  3372. * @param y value to subtract
  3373. * @param z value to subtract
  3374. * @param w value to subtract
  3375. * @returns new vector containing the result
  3376. */
  3377. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3378. /**
  3379. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3380. * @param x value to subtract
  3381. * @param y value to subtract
  3382. * @param z value to subtract
  3383. * @param w value to subtract
  3384. * @param result the vector to store the result in
  3385. * @returns the current Vector4.
  3386. */
  3387. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3388. /**
  3389. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3390. * @returns a new vector with the negated values
  3391. */
  3392. negate(): Vector4;
  3393. /**
  3394. * Negate this vector in place
  3395. * @returns this
  3396. */
  3397. negateInPlace(): Vector4;
  3398. /**
  3399. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3400. * @param result defines the Vector3 object where to store the result
  3401. * @returns the current Vector4
  3402. */
  3403. negateToRef(result: Vector4): Vector4;
  3404. /**
  3405. * Multiplies the current Vector4 coordinates by scale (float).
  3406. * @param scale the number to scale with
  3407. * @returns the updated Vector4.
  3408. */
  3409. scaleInPlace(scale: number): Vector4;
  3410. /**
  3411. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3412. * @param scale the number to scale with
  3413. * @returns a new vector with the result
  3414. */
  3415. scale(scale: number): Vector4;
  3416. /**
  3417. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3418. * @param scale the number to scale with
  3419. * @param result a vector to store the result in
  3420. * @returns the current Vector4.
  3421. */
  3422. scaleToRef(scale: number, result: Vector4): Vector4;
  3423. /**
  3424. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3425. * @param scale defines the scale factor
  3426. * @param result defines the Vector4 object where to store the result
  3427. * @returns the unmodified current Vector4
  3428. */
  3429. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3430. /**
  3431. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3432. * @param otherVector the vector to compare against
  3433. * @returns true if they are equal
  3434. */
  3435. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3436. /**
  3437. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3438. * @param otherVector vector to compare against
  3439. * @param epsilon (Default: very small number)
  3440. * @returns true if they are equal
  3441. */
  3442. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3443. /**
  3444. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3445. * @param x x value to compare against
  3446. * @param y y value to compare against
  3447. * @param z z value to compare against
  3448. * @param w w value to compare against
  3449. * @returns true if equal
  3450. */
  3451. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3452. /**
  3453. * Multiplies in place the current Vector4 by the given one.
  3454. * @param otherVector vector to multiple with
  3455. * @returns the updated Vector4.
  3456. */
  3457. multiplyInPlace(otherVector: Vector4): Vector4;
  3458. /**
  3459. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3460. * @param otherVector vector to multiple with
  3461. * @returns resulting new vector
  3462. */
  3463. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3464. /**
  3465. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3466. * @param otherVector vector to multiple with
  3467. * @param result vector to store the result
  3468. * @returns the current Vector4.
  3469. */
  3470. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3471. /**
  3472. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3473. * @param x x value multiply with
  3474. * @param y y value multiply with
  3475. * @param z z value multiply with
  3476. * @param w w value multiply with
  3477. * @returns resulting new vector
  3478. */
  3479. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3480. /**
  3481. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3482. * @param otherVector vector to devide with
  3483. * @returns resulting new vector
  3484. */
  3485. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3488. * @param otherVector vector to devide with
  3489. * @param result vector to store the result
  3490. * @returns the current Vector4.
  3491. */
  3492. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3493. /**
  3494. * Divides the current Vector3 coordinates by the given ones.
  3495. * @param otherVector vector to devide with
  3496. * @returns the updated Vector3.
  3497. */
  3498. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3499. /**
  3500. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3501. * @param other defines the second operand
  3502. * @returns the current updated Vector4
  3503. */
  3504. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3505. /**
  3506. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3507. * @param other defines the second operand
  3508. * @returns the current updated Vector4
  3509. */
  3510. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3511. /**
  3512. * Gets a new Vector4 from current Vector4 floored values
  3513. * @returns a new Vector4
  3514. */
  3515. floor(): Vector4;
  3516. /**
  3517. * Gets a new Vector4 from current Vector3 floored values
  3518. * @returns a new Vector4
  3519. */
  3520. fract(): Vector4;
  3521. /**
  3522. * Returns the Vector4 length (float).
  3523. * @returns the length
  3524. */
  3525. length(): number;
  3526. /**
  3527. * Returns the Vector4 squared length (float).
  3528. * @returns the length squared
  3529. */
  3530. lengthSquared(): number;
  3531. /**
  3532. * Normalizes in place the Vector4.
  3533. * @returns the updated Vector4.
  3534. */
  3535. normalize(): Vector4;
  3536. /**
  3537. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3538. * @returns this converted to a new vector3
  3539. */
  3540. toVector3(): Vector3;
  3541. /**
  3542. * Returns a new Vector4 copied from the current one.
  3543. * @returns the new cloned vector
  3544. */
  3545. clone(): Vector4;
  3546. /**
  3547. * Updates the current Vector4 with the given one coordinates.
  3548. * @param source the source vector to copy from
  3549. * @returns the updated Vector4.
  3550. */
  3551. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3552. /**
  3553. * Updates the current Vector4 coordinates with the given floats.
  3554. * @param x float to copy from
  3555. * @param y float to copy from
  3556. * @param z float to copy from
  3557. * @param w float to copy from
  3558. * @returns the updated Vector4.
  3559. */
  3560. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3561. /**
  3562. * Updates the current Vector4 coordinates with the given floats.
  3563. * @param x float to set from
  3564. * @param y float to set from
  3565. * @param z float to set from
  3566. * @param w float to set from
  3567. * @returns the updated Vector4.
  3568. */
  3569. set(x: number, y: number, z: number, w: number): Vector4;
  3570. /**
  3571. * Copies the given float to the current Vector3 coordinates
  3572. * @param v defines the x, y, z and w coordinates of the operand
  3573. * @returns the current updated Vector3
  3574. */
  3575. setAll(v: number): Vector4;
  3576. /**
  3577. * Returns a new Vector4 set from the starting index of the given array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @returns the new vector
  3581. */
  3582. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3583. /**
  3584. * Updates the given vector "result" from the starting index of the given array.
  3585. * @param array the array to pull values from
  3586. * @param offset the offset into the array to start at
  3587. * @param result the vector to store the result in
  3588. */
  3589. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3590. /**
  3591. * Updates the given vector "result" from the starting index of the given Float32Array.
  3592. * @param array the array to pull values from
  3593. * @param offset the offset into the array to start at
  3594. * @param result the vector to store the result in
  3595. */
  3596. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3597. /**
  3598. * Updates the given vector "result" coordinates from the given floats.
  3599. * @param x float to set from
  3600. * @param y float to set from
  3601. * @param z float to set from
  3602. * @param w float to set from
  3603. * @param result the vector to the floats in
  3604. */
  3605. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3606. /**
  3607. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3608. * @returns the new vector
  3609. */
  3610. static Zero(): Vector4;
  3611. /**
  3612. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3613. * @returns the new vector
  3614. */
  3615. static One(): Vector4;
  3616. /**
  3617. * Returns a new normalized Vector4 from the given one.
  3618. * @param vector the vector to normalize
  3619. * @returns the vector
  3620. */
  3621. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3622. /**
  3623. * Updates the given vector "result" from the normalization of the given one.
  3624. * @param vector the vector to normalize
  3625. * @param result the vector to store the result in
  3626. */
  3627. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3628. /**
  3629. * Returns a vector with the minimum values from the left and right vectors
  3630. * @param left left vector to minimize
  3631. * @param right right vector to minimize
  3632. * @returns a new vector with the minimum of the left and right vector values
  3633. */
  3634. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3635. /**
  3636. * Returns a vector with the maximum values from the left and right vectors
  3637. * @param left left vector to maximize
  3638. * @param right right vector to maximize
  3639. * @returns a new vector with the maximum of the left and right vector values
  3640. */
  3641. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3642. /**
  3643. * Returns the distance (float) between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the distance between
  3645. * @param value2 value to calulate the distance between
  3646. * @return the distance between the two vectors
  3647. */
  3648. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3649. /**
  3650. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3651. * @param value1 value to calulate the distance between
  3652. * @param value2 value to calulate the distance between
  3653. * @return the distance between the two vectors squared
  3654. */
  3655. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3656. /**
  3657. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3658. * @param value1 value to calulate the center between
  3659. * @param value2 value to calulate the center between
  3660. * @return the center between the two vectors
  3661. */
  3662. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3663. /**
  3664. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3665. * This methods computes transformed normalized direction vectors only.
  3666. * @param vector the vector to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @returns the new vector
  3669. */
  3670. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3671. /**
  3672. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3673. * This methods computes transformed normalized direction vectors only.
  3674. * @param vector the vector to transform
  3675. * @param transformation the transformation matrix to apply
  3676. * @param result the vector to store the result in
  3677. */
  3678. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3679. /**
  3680. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3681. * This methods computes transformed normalized direction vectors only.
  3682. * @param x value to transform
  3683. * @param y value to transform
  3684. * @param z value to transform
  3685. * @param w value to transform
  3686. * @param transformation the transformation matrix to apply
  3687. * @param result the vector to store the results in
  3688. */
  3689. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3690. /**
  3691. * Creates a new Vector4 from a Vector3
  3692. * @param source defines the source data
  3693. * @param w defines the 4th component (default is 0)
  3694. * @returns a new Vector4
  3695. */
  3696. static FromVector3(source: Vector3, w?: number): Vector4;
  3697. }
  3698. /**
  3699. * Class used to store quaternion data
  3700. * @see https://en.wikipedia.org/wiki/Quaternion
  3701. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3702. */
  3703. export class Quaternion {
  3704. /** @hidden */
  3705. _x: number;
  3706. /** @hidden */
  3707. _y: number;
  3708. /** @hidden */
  3709. _z: number;
  3710. /** @hidden */
  3711. _w: number;
  3712. /** @hidden */
  3713. _isDirty: boolean;
  3714. /** Gets or sets the x coordinate */
  3715. get x(): number;
  3716. set x(value: number);
  3717. /** Gets or sets the y coordinate */
  3718. get y(): number;
  3719. set y(value: number);
  3720. /** Gets or sets the z coordinate */
  3721. get z(): number;
  3722. set z(value: number);
  3723. /** Gets or sets the w coordinate */
  3724. get w(): number;
  3725. set w(value: number);
  3726. /**
  3727. * Creates a new Quaternion from the given floats
  3728. * @param x defines the first component (0 by default)
  3729. * @param y defines the second component (0 by default)
  3730. * @param z defines the third component (0 by default)
  3731. * @param w defines the fourth component (1.0 by default)
  3732. */
  3733. constructor(x?: number, y?: number, z?: number, w?: number);
  3734. /**
  3735. * Gets a string representation for the current quaternion
  3736. * @returns a string with the Quaternion coordinates
  3737. */
  3738. toString(): string;
  3739. /**
  3740. * Gets the class name of the quaternion
  3741. * @returns the string "Quaternion"
  3742. */
  3743. getClassName(): string;
  3744. /**
  3745. * Gets a hash code for this quaternion
  3746. * @returns the quaternion hash code
  3747. */
  3748. getHashCode(): number;
  3749. /**
  3750. * Copy the quaternion to an array
  3751. * @returns a new array populated with 4 elements from the quaternion coordinates
  3752. */
  3753. asArray(): number[];
  3754. /**
  3755. * Check if two quaternions are equals
  3756. * @param otherQuaternion defines the second operand
  3757. * @return true if the current quaternion and the given one coordinates are strictly equals
  3758. */
  3759. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3760. /**
  3761. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3762. * @param otherQuaternion defines the other quaternion
  3763. * @param epsilon defines the minimal distance to consider equality
  3764. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3765. */
  3766. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3767. /**
  3768. * Clone the current quaternion
  3769. * @returns a new quaternion copied from the current one
  3770. */
  3771. clone(): Quaternion;
  3772. /**
  3773. * Copy a quaternion to the current one
  3774. * @param other defines the other quaternion
  3775. * @returns the updated current quaternion
  3776. */
  3777. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3778. /**
  3779. * Updates the current quaternion with the given float coordinates
  3780. * @param x defines the x coordinate
  3781. * @param y defines the y coordinate
  3782. * @param z defines the z coordinate
  3783. * @param w defines the w coordinate
  3784. * @returns the updated current quaternion
  3785. */
  3786. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3787. /**
  3788. * Updates the current quaternion from the given float coordinates
  3789. * @param x defines the x coordinate
  3790. * @param y defines the y coordinate
  3791. * @param z defines the z coordinate
  3792. * @param w defines the w coordinate
  3793. * @returns the updated current quaternion
  3794. */
  3795. set(x: number, y: number, z: number, w: number): Quaternion;
  3796. /**
  3797. * Adds two quaternions
  3798. * @param other defines the second operand
  3799. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3800. */
  3801. add(other: DeepImmutable<Quaternion>): Quaternion;
  3802. /**
  3803. * Add a quaternion to the current one
  3804. * @param other defines the quaternion to add
  3805. * @returns the current quaternion
  3806. */
  3807. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3808. /**
  3809. * Subtract two quaternions
  3810. * @param other defines the second operand
  3811. * @returns a new quaternion as the subtraction result of the given one from the current one
  3812. */
  3813. subtract(other: Quaternion): Quaternion;
  3814. /**
  3815. * Multiplies the current quaternion by a scale factor
  3816. * @param value defines the scale factor
  3817. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3818. */
  3819. scale(value: number): Quaternion;
  3820. /**
  3821. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3822. * @param scale defines the scale factor
  3823. * @param result defines the Quaternion object where to store the result
  3824. * @returns the unmodified current quaternion
  3825. */
  3826. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3827. /**
  3828. * Multiplies in place the current quaternion by a scale factor
  3829. * @param value defines the scale factor
  3830. * @returns the current modified quaternion
  3831. */
  3832. scaleInPlace(value: number): Quaternion;
  3833. /**
  3834. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3835. * @param scale defines the scale factor
  3836. * @param result defines the Quaternion object where to store the result
  3837. * @returns the unmodified current quaternion
  3838. */
  3839. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3840. /**
  3841. * Multiplies two quaternions
  3842. * @param q1 defines the second operand
  3843. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3844. */
  3845. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3846. /**
  3847. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3848. * @param q1 defines the second operand
  3849. * @param result defines the target quaternion
  3850. * @returns the current quaternion
  3851. */
  3852. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3853. /**
  3854. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3855. * @param q1 defines the second operand
  3856. * @returns the currentupdated quaternion
  3857. */
  3858. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3859. /**
  3860. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3861. * @param ref defines the target quaternion
  3862. * @returns the current quaternion
  3863. */
  3864. conjugateToRef(ref: Quaternion): Quaternion;
  3865. /**
  3866. * Conjugates in place (1-q) the current quaternion
  3867. * @returns the current updated quaternion
  3868. */
  3869. conjugateInPlace(): Quaternion;
  3870. /**
  3871. * Conjugates in place (1-q) the current quaternion
  3872. * @returns a new quaternion
  3873. */
  3874. conjugate(): Quaternion;
  3875. /**
  3876. * Gets length of current quaternion
  3877. * @returns the quaternion length (float)
  3878. */
  3879. length(): number;
  3880. /**
  3881. * Normalize in place the current quaternion
  3882. * @returns the current updated quaternion
  3883. */
  3884. normalize(): Quaternion;
  3885. /**
  3886. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3887. * @param order is a reserved parameter and is ignore for now
  3888. * @returns a new Vector3 containing the Euler angles
  3889. */
  3890. toEulerAngles(order?: string): Vector3;
  3891. /**
  3892. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3893. * @param result defines the vector which will be filled with the Euler angles
  3894. * @param order is a reserved parameter and is ignore for now
  3895. * @returns the current unchanged quaternion
  3896. */
  3897. toEulerAnglesToRef(result: Vector3): Quaternion;
  3898. /**
  3899. * Updates the given rotation matrix with the current quaternion values
  3900. * @param result defines the target matrix
  3901. * @returns the current unchanged quaternion
  3902. */
  3903. toRotationMatrix(result: Matrix): Quaternion;
  3904. /**
  3905. * Updates the current quaternion from the given rotation matrix values
  3906. * @param matrix defines the source matrix
  3907. * @returns the current updated quaternion
  3908. */
  3909. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3910. /**
  3911. * Creates a new quaternion from a rotation matrix
  3912. * @param matrix defines the source matrix
  3913. * @returns a new quaternion created from the given rotation matrix values
  3914. */
  3915. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3916. /**
  3917. * Updates the given quaternion with the given rotation matrix values
  3918. * @param matrix defines the source matrix
  3919. * @param result defines the target quaternion
  3920. */
  3921. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3922. /**
  3923. * Returns the dot product (float) between the quaternions "left" and "right"
  3924. * @param left defines the left operand
  3925. * @param right defines the right operand
  3926. * @returns the dot product
  3927. */
  3928. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3929. /**
  3930. * Checks if the two quaternions are close to each other
  3931. * @param quat0 defines the first quaternion to check
  3932. * @param quat1 defines the second quaternion to check
  3933. * @returns true if the two quaternions are close to each other
  3934. */
  3935. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3936. /**
  3937. * Creates an empty quaternion
  3938. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3939. */
  3940. static Zero(): Quaternion;
  3941. /**
  3942. * Inverse a given quaternion
  3943. * @param q defines the source quaternion
  3944. * @returns a new quaternion as the inverted current quaternion
  3945. */
  3946. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3947. /**
  3948. * Inverse a given quaternion
  3949. * @param q defines the source quaternion
  3950. * @param result the quaternion the result will be stored in
  3951. * @returns the result quaternion
  3952. */
  3953. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3954. /**
  3955. * Creates an identity quaternion
  3956. * @returns the identity quaternion
  3957. */
  3958. static Identity(): Quaternion;
  3959. /**
  3960. * Gets a boolean indicating if the given quaternion is identity
  3961. * @param quaternion defines the quaternion to check
  3962. * @returns true if the quaternion is identity
  3963. */
  3964. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3965. /**
  3966. * Creates a quaternion from a rotation around an axis
  3967. * @param axis defines the axis to use
  3968. * @param angle defines the angle to use
  3969. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3970. */
  3971. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3972. /**
  3973. * Creates a rotation around an axis and stores it into the given quaternion
  3974. * @param axis defines the axis to use
  3975. * @param angle defines the angle to use
  3976. * @param result defines the target quaternion
  3977. * @returns the target quaternion
  3978. */
  3979. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3980. /**
  3981. * Creates a new quaternion from data stored into an array
  3982. * @param array defines the data source
  3983. * @param offset defines the offset in the source array where the data starts
  3984. * @returns a new quaternion
  3985. */
  3986. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3987. /**
  3988. * Updates the given quaternion "result" from the starting index of the given array.
  3989. * @param array the array to pull values from
  3990. * @param offset the offset into the array to start at
  3991. * @param result the quaternion to store the result in
  3992. */
  3993. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3994. /**
  3995. * Create a quaternion from Euler rotation angles
  3996. * @param x Pitch
  3997. * @param y Yaw
  3998. * @param z Roll
  3999. * @returns the new Quaternion
  4000. */
  4001. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4002. /**
  4003. * Updates a quaternion from Euler rotation angles
  4004. * @param x Pitch
  4005. * @param y Yaw
  4006. * @param z Roll
  4007. * @param result the quaternion to store the result
  4008. * @returns the updated quaternion
  4009. */
  4010. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4011. /**
  4012. * Create a quaternion from Euler rotation vector
  4013. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4014. * @returns the new Quaternion
  4015. */
  4016. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4017. /**
  4018. * Updates a quaternion from Euler rotation vector
  4019. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4020. * @param result the quaternion to store the result
  4021. * @returns the updated quaternion
  4022. */
  4023. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4024. /**
  4025. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4026. * @param yaw defines the rotation around Y axis
  4027. * @param pitch defines the rotation around X axis
  4028. * @param roll defines the rotation around Z axis
  4029. * @returns the new quaternion
  4030. */
  4031. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4032. /**
  4033. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4034. * @param yaw defines the rotation around Y axis
  4035. * @param pitch defines the rotation around X axis
  4036. * @param roll defines the rotation around Z axis
  4037. * @param result defines the target quaternion
  4038. */
  4039. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4040. /**
  4041. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4042. * @param alpha defines the rotation around first axis
  4043. * @param beta defines the rotation around second axis
  4044. * @param gamma defines the rotation around third axis
  4045. * @returns the new quaternion
  4046. */
  4047. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4048. /**
  4049. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4050. * @param alpha defines the rotation around first axis
  4051. * @param beta defines the rotation around second axis
  4052. * @param gamma defines the rotation around third axis
  4053. * @param result defines the target quaternion
  4054. */
  4055. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4056. /**
  4057. * 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)
  4058. * @param axis1 defines the first axis
  4059. * @param axis2 defines the second axis
  4060. * @param axis3 defines the third axis
  4061. * @returns the new quaternion
  4062. */
  4063. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4064. /**
  4065. * 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
  4066. * @param axis1 defines the first axis
  4067. * @param axis2 defines the second axis
  4068. * @param axis3 defines the third axis
  4069. * @param ref defines the target quaternion
  4070. */
  4071. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4072. /**
  4073. * Interpolates between two quaternions
  4074. * @param left defines first quaternion
  4075. * @param right defines second quaternion
  4076. * @param amount defines the gradient to use
  4077. * @returns the new interpolated quaternion
  4078. */
  4079. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4080. /**
  4081. * Interpolates between two quaternions and stores it into a target quaternion
  4082. * @param left defines first quaternion
  4083. * @param right defines second quaternion
  4084. * @param amount defines the gradient to use
  4085. * @param result defines the target quaternion
  4086. */
  4087. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4088. /**
  4089. * Interpolate between two quaternions using Hermite interpolation
  4090. * @param value1 defines first quaternion
  4091. * @param tangent1 defines the incoming tangent
  4092. * @param value2 defines second quaternion
  4093. * @param tangent2 defines the outgoing tangent
  4094. * @param amount defines the target quaternion
  4095. * @returns the new interpolated quaternion
  4096. */
  4097. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4098. }
  4099. /**
  4100. * Class used to store matrix data (4x4)
  4101. */
  4102. export class Matrix {
  4103. /**
  4104. * Gets the precision of matrix computations
  4105. */
  4106. static get Use64Bits(): boolean;
  4107. private static _updateFlagSeed;
  4108. private static _identityReadOnly;
  4109. private _isIdentity;
  4110. private _isIdentityDirty;
  4111. private _isIdentity3x2;
  4112. private _isIdentity3x2Dirty;
  4113. /**
  4114. * Gets the update flag of the matrix which is an unique number for the matrix.
  4115. * It will be incremented every time the matrix data change.
  4116. * You can use it to speed the comparison between two versions of the same matrix.
  4117. */
  4118. updateFlag: number;
  4119. private readonly _m;
  4120. /**
  4121. * Gets the internal data of the matrix
  4122. */
  4123. get m(): DeepImmutable<Float32Array | Array<number>>;
  4124. /** @hidden */
  4125. _markAsUpdated(): void;
  4126. /** @hidden */
  4127. private _updateIdentityStatus;
  4128. /**
  4129. * Creates an empty matrix (filled with zeros)
  4130. */
  4131. constructor();
  4132. /**
  4133. * Check if the current matrix is identity
  4134. * @returns true is the matrix is the identity matrix
  4135. */
  4136. isIdentity(): boolean;
  4137. /**
  4138. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4139. * @returns true is the matrix is the identity matrix
  4140. */
  4141. isIdentityAs3x2(): boolean;
  4142. /**
  4143. * Gets the determinant of the matrix
  4144. * @returns the matrix determinant
  4145. */
  4146. determinant(): number;
  4147. /**
  4148. * Returns the matrix as a Float32Array or Array<number>
  4149. * @returns the matrix underlying array
  4150. */
  4151. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4152. /**
  4153. * Returns the matrix as a Float32Array or Array<number>
  4154. * @returns the matrix underlying array.
  4155. */
  4156. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4157. /**
  4158. * Inverts the current matrix in place
  4159. * @returns the current inverted matrix
  4160. */
  4161. invert(): Matrix;
  4162. /**
  4163. * Sets all the matrix elements to zero
  4164. * @returns the current matrix
  4165. */
  4166. reset(): Matrix;
  4167. /**
  4168. * Adds the current matrix with a second one
  4169. * @param other defines the matrix to add
  4170. * @returns a new matrix as the addition of the current matrix and the given one
  4171. */
  4172. add(other: DeepImmutable<Matrix>): Matrix;
  4173. /**
  4174. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4175. * @param other defines the matrix to add
  4176. * @param result defines the target matrix
  4177. * @returns the current matrix
  4178. */
  4179. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4180. /**
  4181. * Adds in place the given matrix to the current matrix
  4182. * @param other defines the second operand
  4183. * @returns the current updated matrix
  4184. */
  4185. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4186. /**
  4187. * Sets the given matrix to the current inverted Matrix
  4188. * @param other defines the target matrix
  4189. * @returns the unmodified current matrix
  4190. */
  4191. invertToRef(other: Matrix): Matrix;
  4192. /**
  4193. * add a value at the specified position in the current Matrix
  4194. * @param index the index of the value within the matrix. between 0 and 15.
  4195. * @param value the value to be added
  4196. * @returns the current updated matrix
  4197. */
  4198. addAtIndex(index: number, value: number): Matrix;
  4199. /**
  4200. * mutiply the specified position in the current Matrix by a value
  4201. * @param index the index of the value within the matrix. between 0 and 15.
  4202. * @param value the value to be added
  4203. * @returns the current updated matrix
  4204. */
  4205. multiplyAtIndex(index: number, value: number): Matrix;
  4206. /**
  4207. * Inserts the translation vector (using 3 floats) in the current matrix
  4208. * @param x defines the 1st component of the translation
  4209. * @param y defines the 2nd component of the translation
  4210. * @param z defines the 3rd component of the translation
  4211. * @returns the current updated matrix
  4212. */
  4213. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4214. /**
  4215. * Adds the translation vector (using 3 floats) in the current matrix
  4216. * @param x defines the 1st component of the translation
  4217. * @param y defines the 2nd component of the translation
  4218. * @param z defines the 3rd component of the translation
  4219. * @returns the current updated matrix
  4220. */
  4221. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4222. /**
  4223. * Inserts the translation vector in the current matrix
  4224. * @param vector3 defines the translation to insert
  4225. * @returns the current updated matrix
  4226. */
  4227. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4228. /**
  4229. * Gets the translation value of the current matrix
  4230. * @returns a new Vector3 as the extracted translation from the matrix
  4231. */
  4232. getTranslation(): Vector3;
  4233. /**
  4234. * Fill a Vector3 with the extracted translation from the matrix
  4235. * @param result defines the Vector3 where to store the translation
  4236. * @returns the current matrix
  4237. */
  4238. getTranslationToRef(result: Vector3): Matrix;
  4239. /**
  4240. * Remove rotation and scaling part from the matrix
  4241. * @returns the updated matrix
  4242. */
  4243. removeRotationAndScaling(): Matrix;
  4244. /**
  4245. * Multiply two matrices
  4246. * @param other defines the second operand
  4247. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4248. */
  4249. multiply(other: DeepImmutable<Matrix>): Matrix;
  4250. /**
  4251. * Copy the current matrix from the given one
  4252. * @param other defines the source matrix
  4253. * @returns the current updated matrix
  4254. */
  4255. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4256. /**
  4257. * Populates the given array from the starting index with the current matrix values
  4258. * @param array defines the target array
  4259. * @param offset defines the offset in the target array where to start storing values
  4260. * @returns the current matrix
  4261. */
  4262. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4263. /**
  4264. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4265. * @param other defines the second operand
  4266. * @param result defines the matrix where to store the multiplication
  4267. * @returns the current matrix
  4268. */
  4269. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4270. /**
  4271. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4272. * @param other defines the second operand
  4273. * @param result defines the array where to store the multiplication
  4274. * @param offset defines the offset in the target array where to start storing values
  4275. * @returns the current matrix
  4276. */
  4277. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4278. /**
  4279. * Check equality between this matrix and a second one
  4280. * @param value defines the second matrix to compare
  4281. * @returns true is the current matrix and the given one values are strictly equal
  4282. */
  4283. equals(value: DeepImmutable<Matrix>): boolean;
  4284. /**
  4285. * Clone the current matrix
  4286. * @returns a new matrix from the current matrix
  4287. */
  4288. clone(): Matrix;
  4289. /**
  4290. * Returns the name of the current matrix class
  4291. * @returns the string "Matrix"
  4292. */
  4293. getClassName(): string;
  4294. /**
  4295. * Gets the hash code of the current matrix
  4296. * @returns the hash code
  4297. */
  4298. getHashCode(): number;
  4299. /**
  4300. * Decomposes the current Matrix into a translation, rotation and scaling components
  4301. * @param scale defines the scale vector3 given as a reference to update
  4302. * @param rotation defines the rotation quaternion given as a reference to update
  4303. * @param translation defines the translation vector3 given as a reference to update
  4304. * @returns true if operation was successful
  4305. */
  4306. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4307. /**
  4308. * Gets specific row of the matrix
  4309. * @param index defines the number of the row to get
  4310. * @returns the index-th row of the current matrix as a new Vector4
  4311. */
  4312. getRow(index: number): Nullable<Vector4>;
  4313. /**
  4314. * Sets the index-th row of the current matrix to the vector4 values
  4315. * @param index defines the number of the row to set
  4316. * @param row defines the target vector4
  4317. * @returns the updated current matrix
  4318. */
  4319. setRow(index: number, row: Vector4): Matrix;
  4320. /**
  4321. * Compute the transpose of the matrix
  4322. * @returns the new transposed matrix
  4323. */
  4324. transpose(): Matrix;
  4325. /**
  4326. * Compute the transpose of the matrix and store it in a given matrix
  4327. * @param result defines the target matrix
  4328. * @returns the current matrix
  4329. */
  4330. transposeToRef(result: Matrix): Matrix;
  4331. /**
  4332. * Sets the index-th row of the current matrix with the given 4 x float values
  4333. * @param index defines the row index
  4334. * @param x defines the x component to set
  4335. * @param y defines the y component to set
  4336. * @param z defines the z component to set
  4337. * @param w defines the w component to set
  4338. * @returns the updated current matrix
  4339. */
  4340. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4341. /**
  4342. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4343. * @param scale defines the scale factor
  4344. * @returns a new matrix
  4345. */
  4346. scale(scale: number): Matrix;
  4347. /**
  4348. * Scale the current matrix values by a factor to a given result matrix
  4349. * @param scale defines the scale factor
  4350. * @param result defines the matrix to store the result
  4351. * @returns the current matrix
  4352. */
  4353. scaleToRef(scale: number, result: Matrix): Matrix;
  4354. /**
  4355. * Scale the current matrix values by a factor and add the result to a given matrix
  4356. * @param scale defines the scale factor
  4357. * @param result defines the Matrix to store the result
  4358. * @returns the current matrix
  4359. */
  4360. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4361. /**
  4362. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4363. * @param ref matrix to store the result
  4364. */
  4365. toNormalMatrix(ref: Matrix): void;
  4366. /**
  4367. * Gets only rotation part of the current matrix
  4368. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4369. */
  4370. getRotationMatrix(): Matrix;
  4371. /**
  4372. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4373. * @param result defines the target matrix to store data to
  4374. * @returns the current matrix
  4375. */
  4376. getRotationMatrixToRef(result: Matrix): Matrix;
  4377. /**
  4378. * Toggles model matrix from being right handed to left handed in place and vice versa
  4379. */
  4380. toggleModelMatrixHandInPlace(): void;
  4381. /**
  4382. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4383. */
  4384. toggleProjectionMatrixHandInPlace(): void;
  4385. /**
  4386. * Creates a matrix from an array
  4387. * @param array defines the source array
  4388. * @param offset defines an offset in the source array
  4389. * @returns a new Matrix set from the starting index of the given array
  4390. */
  4391. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4392. /**
  4393. * Copy the content of an array into a given matrix
  4394. * @param array defines the source array
  4395. * @param offset defines an offset in the source array
  4396. * @param result defines the target matrix
  4397. */
  4398. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4399. /**
  4400. * Stores an array into a matrix after having multiplied each component by a given factor
  4401. * @param array defines the source array
  4402. * @param offset defines the offset in the source array
  4403. * @param scale defines the scaling factor
  4404. * @param result defines the target matrix
  4405. */
  4406. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4407. /**
  4408. * Gets an identity matrix that must not be updated
  4409. */
  4410. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4411. /**
  4412. * Stores a list of values (16) inside a given matrix
  4413. * @param initialM11 defines 1st value of 1st row
  4414. * @param initialM12 defines 2nd value of 1st row
  4415. * @param initialM13 defines 3rd value of 1st row
  4416. * @param initialM14 defines 4th value of 1st row
  4417. * @param initialM21 defines 1st value of 2nd row
  4418. * @param initialM22 defines 2nd value of 2nd row
  4419. * @param initialM23 defines 3rd value of 2nd row
  4420. * @param initialM24 defines 4th value of 2nd row
  4421. * @param initialM31 defines 1st value of 3rd row
  4422. * @param initialM32 defines 2nd value of 3rd row
  4423. * @param initialM33 defines 3rd value of 3rd row
  4424. * @param initialM34 defines 4th value of 3rd row
  4425. * @param initialM41 defines 1st value of 4th row
  4426. * @param initialM42 defines 2nd value of 4th row
  4427. * @param initialM43 defines 3rd value of 4th row
  4428. * @param initialM44 defines 4th value of 4th row
  4429. * @param result defines the target matrix
  4430. */
  4431. 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;
  4432. /**
  4433. * Creates new matrix from a list of values (16)
  4434. * @param initialM11 defines 1st value of 1st row
  4435. * @param initialM12 defines 2nd value of 1st row
  4436. * @param initialM13 defines 3rd value of 1st row
  4437. * @param initialM14 defines 4th value of 1st row
  4438. * @param initialM21 defines 1st value of 2nd row
  4439. * @param initialM22 defines 2nd value of 2nd row
  4440. * @param initialM23 defines 3rd value of 2nd row
  4441. * @param initialM24 defines 4th value of 2nd row
  4442. * @param initialM31 defines 1st value of 3rd row
  4443. * @param initialM32 defines 2nd value of 3rd row
  4444. * @param initialM33 defines 3rd value of 3rd row
  4445. * @param initialM34 defines 4th value of 3rd row
  4446. * @param initialM41 defines 1st value of 4th row
  4447. * @param initialM42 defines 2nd value of 4th row
  4448. * @param initialM43 defines 3rd value of 4th row
  4449. * @param initialM44 defines 4th value of 4th row
  4450. * @returns the new matrix
  4451. */
  4452. 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;
  4453. /**
  4454. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4455. * @param scale defines the scale vector3
  4456. * @param rotation defines the rotation quaternion
  4457. * @param translation defines the translation vector3
  4458. * @returns a new matrix
  4459. */
  4460. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4461. /**
  4462. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4463. * @param scale defines the scale vector3
  4464. * @param rotation defines the rotation quaternion
  4465. * @param translation defines the translation vector3
  4466. * @param result defines the target matrix
  4467. */
  4468. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4469. /**
  4470. * Creates a new identity matrix
  4471. * @returns a new identity matrix
  4472. */
  4473. static Identity(): Matrix;
  4474. /**
  4475. * Creates a new identity matrix and stores the result in a given matrix
  4476. * @param result defines the target matrix
  4477. */
  4478. static IdentityToRef(result: Matrix): void;
  4479. /**
  4480. * Creates a new zero matrix
  4481. * @returns a new zero matrix
  4482. */
  4483. static Zero(): Matrix;
  4484. /**
  4485. * Creates a new rotation matrix for "angle" radians around the X axis
  4486. * @param angle defines the angle (in radians) to use
  4487. * @return the new matrix
  4488. */
  4489. static RotationX(angle: number): Matrix;
  4490. /**
  4491. * Creates a new matrix as the invert of a given matrix
  4492. * @param source defines the source matrix
  4493. * @returns the new matrix
  4494. */
  4495. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4496. /**
  4497. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4498. * @param angle defines the angle (in radians) to use
  4499. * @param result defines the target matrix
  4500. */
  4501. static RotationXToRef(angle: number, result: Matrix): void;
  4502. /**
  4503. * Creates a new rotation matrix for "angle" radians around the Y axis
  4504. * @param angle defines the angle (in radians) to use
  4505. * @return the new matrix
  4506. */
  4507. static RotationY(angle: number): Matrix;
  4508. /**
  4509. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4510. * @param angle defines the angle (in radians) to use
  4511. * @param result defines the target matrix
  4512. */
  4513. static RotationYToRef(angle: number, result: Matrix): void;
  4514. /**
  4515. * Creates a new rotation matrix for "angle" radians around the Z axis
  4516. * @param angle defines the angle (in radians) to use
  4517. * @return the new matrix
  4518. */
  4519. static RotationZ(angle: number): Matrix;
  4520. /**
  4521. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4522. * @param angle defines the angle (in radians) to use
  4523. * @param result defines the target matrix
  4524. */
  4525. static RotationZToRef(angle: number, result: Matrix): void;
  4526. /**
  4527. * Creates a new rotation matrix for "angle" radians around the given axis
  4528. * @param axis defines the axis to use
  4529. * @param angle defines the angle (in radians) to use
  4530. * @return the new matrix
  4531. */
  4532. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4533. /**
  4534. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4535. * @param axis defines the axis to use
  4536. * @param angle defines the angle (in radians) to use
  4537. * @param result defines the target matrix
  4538. */
  4539. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4540. /**
  4541. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4542. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4543. * @param from defines the vector to align
  4544. * @param to defines the vector to align to
  4545. * @param result defines the target matrix
  4546. */
  4547. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4548. /**
  4549. * Creates a rotation matrix
  4550. * @param yaw defines the yaw angle in radians (Y axis)
  4551. * @param pitch defines the pitch angle in radians (X axis)
  4552. * @param roll defines the roll angle in radians (Z axis)
  4553. * @returns the new rotation matrix
  4554. */
  4555. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4556. /**
  4557. * Creates a rotation matrix and stores it in a given matrix
  4558. * @param yaw defines the yaw angle in radians (Y axis)
  4559. * @param pitch defines the pitch angle in radians (X axis)
  4560. * @param roll defines the roll angle in radians (Z axis)
  4561. * @param result defines the target matrix
  4562. */
  4563. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4564. /**
  4565. * Creates a scaling matrix
  4566. * @param x defines the scale factor on X axis
  4567. * @param y defines the scale factor on Y axis
  4568. * @param z defines the scale factor on Z axis
  4569. * @returns the new matrix
  4570. */
  4571. static Scaling(x: number, y: number, z: number): Matrix;
  4572. /**
  4573. * Creates a scaling matrix and stores it in a given matrix
  4574. * @param x defines the scale factor on X axis
  4575. * @param y defines the scale factor on Y axis
  4576. * @param z defines the scale factor on Z axis
  4577. * @param result defines the target matrix
  4578. */
  4579. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4580. /**
  4581. * Creates a translation matrix
  4582. * @param x defines the translation on X axis
  4583. * @param y defines the translation on Y axis
  4584. * @param z defines the translationon Z axis
  4585. * @returns the new matrix
  4586. */
  4587. static Translation(x: number, y: number, z: number): Matrix;
  4588. /**
  4589. * Creates a translation matrix and stores it in a given matrix
  4590. * @param x defines the translation on X axis
  4591. * @param y defines the translation on Y axis
  4592. * @param z defines the translationon Z axis
  4593. * @param result defines the target matrix
  4594. */
  4595. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4596. /**
  4597. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4598. * @param startValue defines the start value
  4599. * @param endValue defines the end value
  4600. * @param gradient defines the gradient factor
  4601. * @returns the new matrix
  4602. */
  4603. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4604. /**
  4605. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4606. * @param startValue defines the start value
  4607. * @param endValue defines the end value
  4608. * @param gradient defines the gradient factor
  4609. * @param result defines the Matrix object where to store data
  4610. */
  4611. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4612. /**
  4613. * Builds a new matrix whose values are computed by:
  4614. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4615. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4616. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4617. * @param startValue defines the first matrix
  4618. * @param endValue defines the second matrix
  4619. * @param gradient defines the gradient between the two matrices
  4620. * @returns the new matrix
  4621. */
  4622. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4623. /**
  4624. * Update a matrix to values which are computed by:
  4625. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4626. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4627. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4628. * @param startValue defines the first matrix
  4629. * @param endValue defines the second matrix
  4630. * @param gradient defines the gradient between the two matrices
  4631. * @param result defines the target matrix
  4632. */
  4633. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4634. /**
  4635. * 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"
  4636. * This function works in left handed mode
  4637. * @param eye defines the final position of the entity
  4638. * @param target defines where the entity should look at
  4639. * @param up defines the up vector for the entity
  4640. * @returns the new matrix
  4641. */
  4642. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4643. /**
  4644. * 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".
  4645. * This function works in left handed mode
  4646. * @param eye defines the final position of the entity
  4647. * @param target defines where the entity should look at
  4648. * @param up defines the up vector for the entity
  4649. * @param result defines the target matrix
  4650. */
  4651. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4652. /**
  4653. * 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"
  4654. * This function works in right handed mode
  4655. * @param eye defines the final position of the entity
  4656. * @param target defines where the entity should look at
  4657. * @param up defines the up vector for the entity
  4658. * @returns the new matrix
  4659. */
  4660. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4661. /**
  4662. * 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".
  4663. * This function works in right handed mode
  4664. * @param eye defines the final position of the entity
  4665. * @param target defines where the entity should look at
  4666. * @param up defines the up vector for the entity
  4667. * @param result defines the target matrix
  4668. */
  4669. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4670. /**
  4671. * Create a left-handed orthographic projection matrix
  4672. * @param width defines the viewport width
  4673. * @param height defines the viewport height
  4674. * @param znear defines the near clip plane
  4675. * @param zfar defines the far clip plane
  4676. * @returns a new matrix as a left-handed orthographic projection matrix
  4677. */
  4678. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4679. /**
  4680. * Store a left-handed orthographic projection to a given matrix
  4681. * @param width defines the viewport width
  4682. * @param height defines the viewport height
  4683. * @param znear defines the near clip plane
  4684. * @param zfar defines the far clip plane
  4685. * @param result defines the target matrix
  4686. */
  4687. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4688. /**
  4689. * Create a left-handed orthographic projection matrix
  4690. * @param left defines the viewport left coordinate
  4691. * @param right defines the viewport right coordinate
  4692. * @param bottom defines the viewport bottom coordinate
  4693. * @param top defines the viewport top coordinate
  4694. * @param znear defines the near clip plane
  4695. * @param zfar defines the far clip plane
  4696. * @returns a new matrix as a left-handed orthographic projection matrix
  4697. */
  4698. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4699. /**
  4700. * Stores a left-handed orthographic projection into a given matrix
  4701. * @param left defines the viewport left coordinate
  4702. * @param right defines the viewport right coordinate
  4703. * @param bottom defines the viewport bottom coordinate
  4704. * @param top defines the viewport top coordinate
  4705. * @param znear defines the near clip plane
  4706. * @param zfar defines the far clip plane
  4707. * @param result defines the target matrix
  4708. */
  4709. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4710. /**
  4711. * Creates a right-handed orthographic projection matrix
  4712. * @param left defines the viewport left coordinate
  4713. * @param right defines the viewport right coordinate
  4714. * @param bottom defines the viewport bottom coordinate
  4715. * @param top defines the viewport top coordinate
  4716. * @param znear defines the near clip plane
  4717. * @param zfar defines the far clip plane
  4718. * @returns a new matrix as a right-handed orthographic projection matrix
  4719. */
  4720. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4721. /**
  4722. * Stores a right-handed orthographic projection into a given matrix
  4723. * @param left defines the viewport left coordinate
  4724. * @param right defines the viewport right coordinate
  4725. * @param bottom defines the viewport bottom coordinate
  4726. * @param top defines the viewport top coordinate
  4727. * @param znear defines the near clip plane
  4728. * @param zfar defines the far clip plane
  4729. * @param result defines the target matrix
  4730. */
  4731. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4732. /**
  4733. * Creates a left-handed perspective projection matrix
  4734. * @param width defines the viewport width
  4735. * @param height defines the viewport height
  4736. * @param znear defines the near clip plane
  4737. * @param zfar defines the far clip plane
  4738. * @returns a new matrix as a left-handed perspective projection matrix
  4739. */
  4740. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4741. /**
  4742. * Creates a left-handed perspective projection matrix
  4743. * @param fov defines the horizontal field of view
  4744. * @param aspect defines the aspect ratio
  4745. * @param znear defines the near clip plane
  4746. * @param zfar defines the far clip plane
  4747. * @returns a new matrix as a left-handed perspective projection matrix
  4748. */
  4749. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4750. /**
  4751. * Stores a left-handed perspective projection into a given matrix
  4752. * @param fov defines the horizontal field of view
  4753. * @param aspect defines the aspect ratio
  4754. * @param znear defines the near clip plane
  4755. * @param zfar defines the far clip plane
  4756. * @param result defines the target matrix
  4757. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4758. */
  4759. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4760. /**
  4761. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar not used as infinity is used as far clip
  4766. * @param result defines the target matrix
  4767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4768. */
  4769. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4770. /**
  4771. * Creates a right-handed perspective projection matrix
  4772. * @param fov defines the horizontal field of view
  4773. * @param aspect defines the aspect ratio
  4774. * @param znear defines the near clip plane
  4775. * @param zfar defines the far clip plane
  4776. * @returns a new matrix as a right-handed perspective projection matrix
  4777. */
  4778. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4779. /**
  4780. * Stores a right-handed perspective projection into a given matrix
  4781. * @param fov defines the horizontal field of view
  4782. * @param aspect defines the aspect ratio
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @param result defines the target matrix
  4786. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4787. */
  4788. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4789. /**
  4790. * Stores a right-handed perspective projection into a given matrix
  4791. * @param fov defines the horizontal field of view
  4792. * @param aspect defines the aspect ratio
  4793. * @param znear defines the near clip plane
  4794. * @param zfar not used as infinity is used as far clip
  4795. * @param result defines the target matrix
  4796. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4797. */
  4798. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4799. /**
  4800. * Stores a perspective projection for WebVR info a given matrix
  4801. * @param fov defines the field of view
  4802. * @param znear defines the near clip plane
  4803. * @param zfar defines the far clip plane
  4804. * @param result defines the target matrix
  4805. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4806. */
  4807. static PerspectiveFovWebVRToRef(fov: {
  4808. upDegrees: number;
  4809. downDegrees: number;
  4810. leftDegrees: number;
  4811. rightDegrees: number;
  4812. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4813. /**
  4814. * Computes a complete transformation matrix
  4815. * @param viewport defines the viewport to use
  4816. * @param world defines the world matrix
  4817. * @param view defines the view matrix
  4818. * @param projection defines the projection matrix
  4819. * @param zmin defines the near clip plane
  4820. * @param zmax defines the far clip plane
  4821. * @returns the transformation matrix
  4822. */
  4823. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4824. /**
  4825. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4826. * @param matrix defines the matrix to use
  4827. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4828. */
  4829. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4830. /**
  4831. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4832. * @param matrix defines the matrix to use
  4833. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4834. */
  4835. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4836. /**
  4837. * Compute the transpose of a given matrix
  4838. * @param matrix defines the matrix to transpose
  4839. * @returns the new matrix
  4840. */
  4841. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4842. /**
  4843. * Compute the transpose of a matrix and store it in a target matrix
  4844. * @param matrix defines the matrix to transpose
  4845. * @param result defines the target matrix
  4846. */
  4847. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4848. /**
  4849. * Computes a reflection matrix from a plane
  4850. * @param plane defines the reflection plane
  4851. * @returns a new matrix
  4852. */
  4853. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4854. /**
  4855. * Computes a reflection matrix from a plane
  4856. * @param plane defines the reflection plane
  4857. * @param result defines the target matrix
  4858. */
  4859. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4860. /**
  4861. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4862. * @param xaxis defines the value of the 1st axis
  4863. * @param yaxis defines the value of the 2nd axis
  4864. * @param zaxis defines the value of the 3rd axis
  4865. * @param result defines the target matrix
  4866. */
  4867. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4868. /**
  4869. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4870. * @param quat defines the quaternion to use
  4871. * @param result defines the target matrix
  4872. */
  4873. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4874. }
  4875. /**
  4876. * @hidden
  4877. */
  4878. export class TmpVectors {
  4879. static Vector2: Vector2[];
  4880. static Vector3: Vector3[];
  4881. static Vector4: Vector4[];
  4882. static Quaternion: Quaternion[];
  4883. static Matrix: Matrix[];
  4884. }
  4885. }
  4886. declare module "babylonjs/Maths/math.path" {
  4887. import { DeepImmutable, Nullable } from "babylonjs/types";
  4888. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4889. /**
  4890. * Defines potential orientation for back face culling
  4891. */
  4892. export enum Orientation {
  4893. /**
  4894. * Clockwise
  4895. */
  4896. CW = 0,
  4897. /** Counter clockwise */
  4898. CCW = 1
  4899. }
  4900. /** Class used to represent a Bezier curve */
  4901. export class BezierCurve {
  4902. /**
  4903. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4904. * @param t defines the time
  4905. * @param x1 defines the left coordinate on X axis
  4906. * @param y1 defines the left coordinate on Y axis
  4907. * @param x2 defines the right coordinate on X axis
  4908. * @param y2 defines the right coordinate on Y axis
  4909. * @returns the interpolated value
  4910. */
  4911. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4912. }
  4913. /**
  4914. * Defines angle representation
  4915. */
  4916. export class Angle {
  4917. private _radians;
  4918. /**
  4919. * Creates an Angle object of "radians" radians (float).
  4920. * @param radians the angle in radians
  4921. */
  4922. constructor(radians: number);
  4923. /**
  4924. * Get value in degrees
  4925. * @returns the Angle value in degrees (float)
  4926. */
  4927. degrees(): number;
  4928. /**
  4929. * Get value in radians
  4930. * @returns the Angle value in radians (float)
  4931. */
  4932. radians(): number;
  4933. /**
  4934. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4935. * @param a defines first point as the origin
  4936. * @param b defines point
  4937. * @returns a new Angle
  4938. */
  4939. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4940. /**
  4941. * Gets a new Angle object from the given float in radians
  4942. * @param radians defines the angle value in radians
  4943. * @returns a new Angle
  4944. */
  4945. static FromRadians(radians: number): Angle;
  4946. /**
  4947. * Gets a new Angle object from the given float in degrees
  4948. * @param degrees defines the angle value in degrees
  4949. * @returns a new Angle
  4950. */
  4951. static FromDegrees(degrees: number): Angle;
  4952. }
  4953. /**
  4954. * This represents an arc in a 2d space.
  4955. */
  4956. export class Arc2 {
  4957. /** Defines the start point of the arc */
  4958. startPoint: Vector2;
  4959. /** Defines the mid point of the arc */
  4960. midPoint: Vector2;
  4961. /** Defines the end point of the arc */
  4962. endPoint: Vector2;
  4963. /**
  4964. * Defines the center point of the arc.
  4965. */
  4966. centerPoint: Vector2;
  4967. /**
  4968. * Defines the radius of the arc.
  4969. */
  4970. radius: number;
  4971. /**
  4972. * Defines the angle of the arc (from mid point to end point).
  4973. */
  4974. angle: Angle;
  4975. /**
  4976. * Defines the start angle of the arc (from start point to middle point).
  4977. */
  4978. startAngle: Angle;
  4979. /**
  4980. * Defines the orientation of the arc (clock wise/counter clock wise).
  4981. */
  4982. orientation: Orientation;
  4983. /**
  4984. * Creates an Arc object from the three given points : start, middle and end.
  4985. * @param startPoint Defines the start point of the arc
  4986. * @param midPoint Defines the midlle point of the arc
  4987. * @param endPoint Defines the end point of the arc
  4988. */
  4989. constructor(
  4990. /** Defines the start point of the arc */
  4991. startPoint: Vector2,
  4992. /** Defines the mid point of the arc */
  4993. midPoint: Vector2,
  4994. /** Defines the end point of the arc */
  4995. endPoint: Vector2);
  4996. }
  4997. /**
  4998. * Represents a 2D path made up of multiple 2D points
  4999. */
  5000. export class Path2 {
  5001. private _points;
  5002. private _length;
  5003. /**
  5004. * If the path start and end point are the same
  5005. */
  5006. closed: boolean;
  5007. /**
  5008. * Creates a Path2 object from the starting 2D coordinates x and y.
  5009. * @param x the starting points x value
  5010. * @param y the starting points y value
  5011. */
  5012. constructor(x: number, y: number);
  5013. /**
  5014. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5015. * @param x the added points x value
  5016. * @param y the added points y value
  5017. * @returns the updated Path2.
  5018. */
  5019. addLineTo(x: number, y: number): Path2;
  5020. /**
  5021. * 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.
  5022. * @param midX middle point x value
  5023. * @param midY middle point y value
  5024. * @param endX end point x value
  5025. * @param endY end point y value
  5026. * @param numberOfSegments (default: 36)
  5027. * @returns the updated Path2.
  5028. */
  5029. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5030. /**
  5031. * Closes the Path2.
  5032. * @returns the Path2.
  5033. */
  5034. close(): Path2;
  5035. /**
  5036. * Gets the sum of the distance between each sequential point in the path
  5037. * @returns the Path2 total length (float).
  5038. */
  5039. length(): number;
  5040. /**
  5041. * Gets the points which construct the path
  5042. * @returns the Path2 internal array of points.
  5043. */
  5044. getPoints(): Vector2[];
  5045. /**
  5046. * Retreives the point at the distance aways from the starting point
  5047. * @param normalizedLengthPosition the length along the path to retreive the point from
  5048. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5049. */
  5050. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5051. /**
  5052. * Creates a new path starting from an x and y position
  5053. * @param x starting x value
  5054. * @param y starting y value
  5055. * @returns a new Path2 starting at the coordinates (x, y).
  5056. */
  5057. static StartingAt(x: number, y: number): Path2;
  5058. }
  5059. /**
  5060. * Represents a 3D path made up of multiple 3D points
  5061. */
  5062. export class Path3D {
  5063. /**
  5064. * an array of Vector3, the curve axis of the Path3D
  5065. */
  5066. path: Vector3[];
  5067. private _curve;
  5068. private _distances;
  5069. private _tangents;
  5070. private _normals;
  5071. private _binormals;
  5072. private _raw;
  5073. private _alignTangentsWithPath;
  5074. private readonly _pointAtData;
  5075. /**
  5076. * new Path3D(path, normal, raw)
  5077. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5078. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5079. * @param path an array of Vector3, the curve axis of the Path3D
  5080. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5081. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5082. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5083. */
  5084. constructor(
  5085. /**
  5086. * an array of Vector3, the curve axis of the Path3D
  5087. */
  5088. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5089. /**
  5090. * Returns the Path3D array of successive Vector3 designing its curve.
  5091. * @returns the Path3D array of successive Vector3 designing its curve.
  5092. */
  5093. getCurve(): Vector3[];
  5094. /**
  5095. * Returns the Path3D array of successive Vector3 designing its curve.
  5096. * @returns the Path3D array of successive Vector3 designing its curve.
  5097. */
  5098. getPoints(): Vector3[];
  5099. /**
  5100. * @returns the computed length (float) of the path.
  5101. */
  5102. length(): number;
  5103. /**
  5104. * Returns an array populated with tangent vectors on each Path3D curve point.
  5105. * @returns an array populated with tangent vectors on each Path3D curve point.
  5106. */
  5107. getTangents(): Vector3[];
  5108. /**
  5109. * Returns an array populated with normal vectors on each Path3D curve point.
  5110. * @returns an array populated with normal vectors on each Path3D curve point.
  5111. */
  5112. getNormals(): Vector3[];
  5113. /**
  5114. * Returns an array populated with binormal vectors on each Path3D curve point.
  5115. * @returns an array populated with binormal vectors on each Path3D curve point.
  5116. */
  5117. getBinormals(): Vector3[];
  5118. /**
  5119. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5120. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5121. */
  5122. getDistances(): number[];
  5123. /**
  5124. * Returns an interpolated point along this path
  5125. * @param position the position of the point along this path, from 0.0 to 1.0
  5126. * @returns a new Vector3 as the point
  5127. */
  5128. getPointAt(position: number): Vector3;
  5129. /**
  5130. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5131. * @param position the position of the point along this path, from 0.0 to 1.0
  5132. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5133. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5134. */
  5135. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5136. /**
  5137. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5138. * @param position the position of the point along this path, from 0.0 to 1.0
  5139. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5140. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5141. */
  5142. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5143. /**
  5144. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5145. * @param position the position of the point along this path, from 0.0 to 1.0
  5146. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5147. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5148. */
  5149. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5150. /**
  5151. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5152. * @param position the position of the point along this path, from 0.0 to 1.0
  5153. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5154. */
  5155. getDistanceAt(position: number): number;
  5156. /**
  5157. * Returns the array index of the previous point of an interpolated point along this path
  5158. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5159. * @returns the array index
  5160. */
  5161. getPreviousPointIndexAt(position: number): number;
  5162. /**
  5163. * 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)
  5164. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5165. * @returns the sub position
  5166. */
  5167. getSubPositionAt(position: number): number;
  5168. /**
  5169. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5170. * @param target the vector of which to get the closest position to
  5171. * @returns the position of the closest virtual point on this path to the target vector
  5172. */
  5173. getClosestPositionTo(target: Vector3): number;
  5174. /**
  5175. * Returns a sub path (slice) of this path
  5176. * @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
  5177. * @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
  5178. * @returns a sub path (slice) of this path
  5179. */
  5180. slice(start?: number, end?: number): Path3D;
  5181. /**
  5182. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5183. * @param path path which all values are copied into the curves points
  5184. * @param firstNormal which should be projected onto the curve
  5185. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5186. * @returns the same object updated.
  5187. */
  5188. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5189. private _compute;
  5190. private _getFirstNonNullVector;
  5191. private _getLastNonNullVector;
  5192. private _normalVector;
  5193. /**
  5194. * Updates the point at data for an interpolated point along this curve
  5195. * @param position the position of the point along this curve, from 0.0 to 1.0
  5196. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5197. * @returns the (updated) point at data
  5198. */
  5199. private _updatePointAtData;
  5200. /**
  5201. * Updates the point at data from the specified parameters
  5202. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5203. * @param point the interpolated point
  5204. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5205. */
  5206. private _setPointAtData;
  5207. /**
  5208. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5209. */
  5210. private _updateInterpolationMatrix;
  5211. }
  5212. /**
  5213. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5214. * A Curve3 is designed from a series of successive Vector3.
  5215. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5216. */
  5217. export class Curve3 {
  5218. private _points;
  5219. private _length;
  5220. /**
  5221. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5222. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5223. * @param v1 (Vector3) the control point
  5224. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5225. * @param nbPoints (integer) the wanted number of points in the curve
  5226. * @returns the created Curve3
  5227. */
  5228. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5229. /**
  5230. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5231. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5232. * @param v1 (Vector3) the first control point
  5233. * @param v2 (Vector3) the second control point
  5234. * @param v3 (Vector3) the end point of the Cubic Bezier
  5235. * @param nbPoints (integer) the wanted number of points in the curve
  5236. * @returns the created Curve3
  5237. */
  5238. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5239. /**
  5240. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5241. * @param p1 (Vector3) the origin point of the Hermite Spline
  5242. * @param t1 (Vector3) the tangent vector at the origin point
  5243. * @param p2 (Vector3) the end point of the Hermite Spline
  5244. * @param t2 (Vector3) the tangent vector at the end point
  5245. * @param nbPoints (integer) the wanted number of points in the curve
  5246. * @returns the created Curve3
  5247. */
  5248. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5249. /**
  5250. * Returns a Curve3 object along a CatmullRom Spline curve :
  5251. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5252. * @param nbPoints (integer) the wanted number of points between each curve control points
  5253. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5254. * @returns the created Curve3
  5255. */
  5256. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5257. /**
  5258. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5259. * A Curve3 is designed from a series of successive Vector3.
  5260. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5261. * @param points points which make up the curve
  5262. */
  5263. constructor(points: Vector3[]);
  5264. /**
  5265. * @returns the Curve3 stored array of successive Vector3
  5266. */
  5267. getPoints(): Vector3[];
  5268. /**
  5269. * @returns the computed length (float) of the curve.
  5270. */
  5271. length(): number;
  5272. /**
  5273. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5274. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5275. * curveA and curveB keep unchanged.
  5276. * @param curve the curve to continue from this curve
  5277. * @returns the newly constructed curve
  5278. */
  5279. continue(curve: DeepImmutable<Curve3>): Curve3;
  5280. private _computeLength;
  5281. }
  5282. }
  5283. declare module "babylonjs/Animations/easing" {
  5284. /**
  5285. * This represents the main contract an easing function should follow.
  5286. * Easing functions are used throughout the animation system.
  5287. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5288. */
  5289. export interface IEasingFunction {
  5290. /**
  5291. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5292. * of the easing function.
  5293. * The link below provides some of the most common examples of easing functions.
  5294. * @see https://easings.net/
  5295. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5296. * @returns the corresponding value on the curve defined by the easing function
  5297. */
  5298. ease(gradient: number): number;
  5299. }
  5300. /**
  5301. * Base class used for every default easing function.
  5302. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5303. */
  5304. export class EasingFunction implements IEasingFunction {
  5305. /**
  5306. * Interpolation follows the mathematical formula associated with the easing function.
  5307. */
  5308. static readonly EASINGMODE_EASEIN: number;
  5309. /**
  5310. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5311. */
  5312. static readonly EASINGMODE_EASEOUT: number;
  5313. /**
  5314. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5315. */
  5316. static readonly EASINGMODE_EASEINOUT: number;
  5317. private _easingMode;
  5318. /**
  5319. * Sets the easing mode of the current function.
  5320. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5321. */
  5322. setEasingMode(easingMode: number): void;
  5323. /**
  5324. * Gets the current easing mode.
  5325. * @returns the easing mode
  5326. */
  5327. getEasingMode(): number;
  5328. /**
  5329. * @hidden
  5330. */
  5331. easeInCore(gradient: number): number;
  5332. /**
  5333. * Given an input gradient between 0 and 1, this returns the corresponding value
  5334. * of the easing function.
  5335. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5336. * @returns the corresponding value on the curve defined by the easing function
  5337. */
  5338. ease(gradient: number): number;
  5339. }
  5340. /**
  5341. * Easing function with a circle shape (see link below).
  5342. * @see https://easings.net/#easeInCirc
  5343. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5344. */
  5345. export class CircleEase extends EasingFunction implements IEasingFunction {
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a ease back shape (see link below).
  5351. * @see https://easings.net/#easeInBack
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BackEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the amplitude of the function */
  5356. amplitude: number;
  5357. /**
  5358. * Instantiates a back ease easing
  5359. * @see https://easings.net/#easeInBack
  5360. * @param amplitude Defines the amplitude of the function
  5361. */
  5362. constructor(
  5363. /** Defines the amplitude of the function */
  5364. amplitude?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with a bouncing shape (see link below).
  5370. * @see https://easings.net/#easeInBounce
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class BounceEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the number of bounces */
  5375. bounces: number;
  5376. /** Defines the amplitude of the bounce */
  5377. bounciness: number;
  5378. /**
  5379. * Instantiates a bounce easing
  5380. * @see https://easings.net/#easeInBounce
  5381. * @param bounces Defines the number of bounces
  5382. * @param bounciness Defines the amplitude of the bounce
  5383. */
  5384. constructor(
  5385. /** Defines the number of bounces */
  5386. bounces?: number,
  5387. /** Defines the amplitude of the bounce */
  5388. bounciness?: number);
  5389. /** @hidden */
  5390. easeInCore(gradient: number): number;
  5391. }
  5392. /**
  5393. * Easing function with a power of 3 shape (see link below).
  5394. * @see https://easings.net/#easeInCubic
  5395. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5396. */
  5397. export class CubicEase extends EasingFunction implements IEasingFunction {
  5398. /** @hidden */
  5399. easeInCore(gradient: number): number;
  5400. }
  5401. /**
  5402. * Easing function with an elastic shape (see link below).
  5403. * @see https://easings.net/#easeInElastic
  5404. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5405. */
  5406. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5407. /** Defines the number of oscillations*/
  5408. oscillations: number;
  5409. /** Defines the amplitude of the oscillations*/
  5410. springiness: number;
  5411. /**
  5412. * Instantiates an elastic easing function
  5413. * @see https://easings.net/#easeInElastic
  5414. * @param oscillations Defines the number of oscillations
  5415. * @param springiness Defines the amplitude of the oscillations
  5416. */
  5417. constructor(
  5418. /** Defines the number of oscillations*/
  5419. oscillations?: number,
  5420. /** Defines the amplitude of the oscillations*/
  5421. springiness?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with an exponential shape (see link below).
  5427. * @see https://easings.net/#easeInExpo
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the exponent of the function */
  5432. exponent: number;
  5433. /**
  5434. * Instantiates an exponential easing function
  5435. * @see https://easings.net/#easeInExpo
  5436. * @param exponent Defines the exponent of the function
  5437. */
  5438. constructor(
  5439. /** Defines the exponent of the function */
  5440. exponent?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class PowerEase extends EasingFunction implements IEasingFunction {
  5450. /** Defines the power of the function */
  5451. power: number;
  5452. /**
  5453. * Instantiates an power base easing function
  5454. * @see https://easings.net/#easeInQuad
  5455. * @param power Defines the power of the function
  5456. */
  5457. constructor(
  5458. /** Defines the power of the function */
  5459. power?: number);
  5460. /** @hidden */
  5461. easeInCore(gradient: number): number;
  5462. }
  5463. /**
  5464. * Easing function with a power of 2 shape (see link below).
  5465. * @see https://easings.net/#easeInQuad
  5466. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5467. */
  5468. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5469. /** @hidden */
  5470. easeInCore(gradient: number): number;
  5471. }
  5472. /**
  5473. * Easing function with a power of 4 shape (see link below).
  5474. * @see https://easings.net/#easeInQuart
  5475. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5476. */
  5477. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5478. /** @hidden */
  5479. easeInCore(gradient: number): number;
  5480. }
  5481. /**
  5482. * Easing function with a power of 5 shape (see link below).
  5483. * @see https://easings.net/#easeInQuint
  5484. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5485. */
  5486. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5487. /** @hidden */
  5488. easeInCore(gradient: number): number;
  5489. }
  5490. /**
  5491. * Easing function with a sin shape (see link below).
  5492. * @see https://easings.net/#easeInSine
  5493. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5494. */
  5495. export class SineEase extends EasingFunction implements IEasingFunction {
  5496. /** @hidden */
  5497. easeInCore(gradient: number): number;
  5498. }
  5499. /**
  5500. * Easing function with a bezier shape (see link below).
  5501. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5502. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5503. */
  5504. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5505. /** Defines the x component of the start tangent in the bezier curve */
  5506. x1: number;
  5507. /** Defines the y component of the start tangent in the bezier curve */
  5508. y1: number;
  5509. /** Defines the x component of the end tangent in the bezier curve */
  5510. x2: number;
  5511. /** Defines the y component of the end tangent in the bezier curve */
  5512. y2: number;
  5513. /**
  5514. * Instantiates a bezier function
  5515. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5516. * @param x1 Defines the x component of the start tangent in the bezier curve
  5517. * @param y1 Defines the y component of the start tangent in the bezier curve
  5518. * @param x2 Defines the x component of the end tangent in the bezier curve
  5519. * @param y2 Defines the y component of the end tangent in the bezier curve
  5520. */
  5521. constructor(
  5522. /** Defines the x component of the start tangent in the bezier curve */
  5523. x1?: number,
  5524. /** Defines the y component of the start tangent in the bezier curve */
  5525. y1?: number,
  5526. /** Defines the x component of the end tangent in the bezier curve */
  5527. x2?: number,
  5528. /** Defines the y component of the end tangent in the bezier curve */
  5529. y2?: number);
  5530. /** @hidden */
  5531. easeInCore(gradient: number): number;
  5532. }
  5533. }
  5534. declare module "babylonjs/Maths/math.color" {
  5535. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5536. /**
  5537. * Class used to hold a RBG color
  5538. */
  5539. export class Color3 {
  5540. /**
  5541. * Defines the red component (between 0 and 1, default is 0)
  5542. */
  5543. r: number;
  5544. /**
  5545. * Defines the green component (between 0 and 1, default is 0)
  5546. */
  5547. g: number;
  5548. /**
  5549. * Defines the blue component (between 0 and 1, default is 0)
  5550. */
  5551. b: number;
  5552. /**
  5553. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5554. * @param r defines the red component (between 0 and 1, default is 0)
  5555. * @param g defines the green component (between 0 and 1, default is 0)
  5556. * @param b defines the blue component (between 0 and 1, default is 0)
  5557. */
  5558. constructor(
  5559. /**
  5560. * Defines the red component (between 0 and 1, default is 0)
  5561. */
  5562. r?: number,
  5563. /**
  5564. * Defines the green component (between 0 and 1, default is 0)
  5565. */
  5566. g?: number,
  5567. /**
  5568. * Defines the blue component (between 0 and 1, default is 0)
  5569. */
  5570. b?: number);
  5571. /**
  5572. * Creates a string with the Color3 current values
  5573. * @returns the string representation of the Color3 object
  5574. */
  5575. toString(): string;
  5576. /**
  5577. * Returns the string "Color3"
  5578. * @returns "Color3"
  5579. */
  5580. getClassName(): string;
  5581. /**
  5582. * Compute the Color3 hash code
  5583. * @returns an unique number that can be used to hash Color3 objects
  5584. */
  5585. getHashCode(): number;
  5586. /**
  5587. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5588. * @param array defines the array where to store the r,g,b components
  5589. * @param index defines an optional index in the target array to define where to start storing values
  5590. * @returns the current Color3 object
  5591. */
  5592. toArray(array: FloatArray, index?: number): Color3;
  5593. /**
  5594. * Update the current color with values stored in an array from the starting index of the given array
  5595. * @param array defines the source array
  5596. * @param offset defines an offset in the source array
  5597. * @returns the current Color3 object
  5598. */
  5599. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5600. /**
  5601. * Returns a new Color4 object from the current Color3 and the given alpha
  5602. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5603. * @returns a new Color4 object
  5604. */
  5605. toColor4(alpha?: number): Color4;
  5606. /**
  5607. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5608. * @returns the new array
  5609. */
  5610. asArray(): number[];
  5611. /**
  5612. * Returns the luminance value
  5613. * @returns a float value
  5614. */
  5615. toLuminance(): number;
  5616. /**
  5617. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5618. * @param otherColor defines the second operand
  5619. * @returns the new Color3 object
  5620. */
  5621. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5622. /**
  5623. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5624. * @param otherColor defines the second operand
  5625. * @param result defines the Color3 object where to store the result
  5626. * @returns the current Color3
  5627. */
  5628. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5629. /**
  5630. * Determines equality between Color3 objects
  5631. * @param otherColor defines the second operand
  5632. * @returns true if the rgb values are equal to the given ones
  5633. */
  5634. equals(otherColor: DeepImmutable<Color3>): boolean;
  5635. /**
  5636. * Determines equality between the current Color3 object and a set of r,b,g values
  5637. * @param r defines the red component to check
  5638. * @param g defines the green component to check
  5639. * @param b defines the blue component to check
  5640. * @returns true if the rgb values are equal to the given ones
  5641. */
  5642. equalsFloats(r: number, g: number, b: number): boolean;
  5643. /**
  5644. * Multiplies in place each rgb value by scale
  5645. * @param scale defines the scaling factor
  5646. * @returns the updated Color3
  5647. */
  5648. scale(scale: number): Color3;
  5649. /**
  5650. * Multiplies the rgb values by scale and stores the result into "result"
  5651. * @param scale defines the scaling factor
  5652. * @param result defines the Color3 object where to store the result
  5653. * @returns the unmodified current Color3
  5654. */
  5655. scaleToRef(scale: number, result: Color3): Color3;
  5656. /**
  5657. * Scale the current Color3 values by a factor and add the result to a given Color3
  5658. * @param scale defines the scale factor
  5659. * @param result defines color to store the result into
  5660. * @returns the unmodified current Color3
  5661. */
  5662. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5663. /**
  5664. * Clamps the rgb values by the min and max values and stores the result into "result"
  5665. * @param min defines minimum clamping value (default is 0)
  5666. * @param max defines maximum clamping value (default is 1)
  5667. * @param result defines color to store the result into
  5668. * @returns the original Color3
  5669. */
  5670. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5671. /**
  5672. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5673. * @param otherColor defines the second operand
  5674. * @returns the new Color3
  5675. */
  5676. add(otherColor: DeepImmutable<Color3>): Color3;
  5677. /**
  5678. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5679. * @param otherColor defines the second operand
  5680. * @param result defines Color3 object to store the result into
  5681. * @returns the unmodified current Color3
  5682. */
  5683. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5684. /**
  5685. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5686. * @param otherColor defines the second operand
  5687. * @returns the new Color3
  5688. */
  5689. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5690. /**
  5691. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5692. * @param otherColor defines the second operand
  5693. * @param result defines Color3 object to store the result into
  5694. * @returns the unmodified current Color3
  5695. */
  5696. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5697. /**
  5698. * Copy the current object
  5699. * @returns a new Color3 copied the current one
  5700. */
  5701. clone(): Color3;
  5702. /**
  5703. * Copies the rgb values from the source in the current Color3
  5704. * @param source defines the source Color3 object
  5705. * @returns the updated Color3 object
  5706. */
  5707. copyFrom(source: DeepImmutable<Color3>): Color3;
  5708. /**
  5709. * Updates the Color3 rgb values from the given floats
  5710. * @param r defines the red component to read from
  5711. * @param g defines the green component to read from
  5712. * @param b defines the blue component to read from
  5713. * @returns the current Color3 object
  5714. */
  5715. copyFromFloats(r: number, g: number, b: number): Color3;
  5716. /**
  5717. * Updates the Color3 rgb values from the given floats
  5718. * @param r defines the red component to read from
  5719. * @param g defines the green component to read from
  5720. * @param b defines the blue component to read from
  5721. * @returns the current Color3 object
  5722. */
  5723. set(r: number, g: number, b: number): Color3;
  5724. /**
  5725. * Compute the Color3 hexadecimal code as a string
  5726. * @returns a string containing the hexadecimal representation of the Color3 object
  5727. */
  5728. toHexString(): string;
  5729. /**
  5730. * Computes a new Color3 converted from the current one to linear space
  5731. * @returns a new Color3 object
  5732. */
  5733. toLinearSpace(): Color3;
  5734. /**
  5735. * Converts current color in rgb space to HSV values
  5736. * @returns a new color3 representing the HSV values
  5737. */
  5738. toHSV(): Color3;
  5739. /**
  5740. * Converts current color in rgb space to HSV values
  5741. * @param result defines the Color3 where to store the HSV values
  5742. */
  5743. toHSVToRef(result: Color3): void;
  5744. /**
  5745. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5746. * @param convertedColor defines the Color3 object where to store the linear space version
  5747. * @returns the unmodified Color3
  5748. */
  5749. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5750. /**
  5751. * Computes a new Color3 converted from the current one to gamma space
  5752. * @returns a new Color3 object
  5753. */
  5754. toGammaSpace(): Color3;
  5755. /**
  5756. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5757. * @param convertedColor defines the Color3 object where to store the gamma space version
  5758. * @returns the unmodified Color3
  5759. */
  5760. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5761. private static _BlackReadOnly;
  5762. /**
  5763. * Convert Hue, saturation and value to a Color3 (RGB)
  5764. * @param hue defines the hue
  5765. * @param saturation defines the saturation
  5766. * @param value defines the value
  5767. * @param result defines the Color3 where to store the RGB values
  5768. */
  5769. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5770. /**
  5771. * Creates a new Color3 from the string containing valid hexadecimal values
  5772. * @param hex defines a string containing valid hexadecimal values
  5773. * @returns a new Color3 object
  5774. */
  5775. static FromHexString(hex: string): Color3;
  5776. /**
  5777. * Creates a new Color3 from the starting index of the given array
  5778. * @param array defines the source array
  5779. * @param offset defines an offset in the source array
  5780. * @returns a new Color3 object
  5781. */
  5782. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5783. /**
  5784. * Creates a new Color3 from the starting index element of the given array
  5785. * @param array defines the source array to read from
  5786. * @param offset defines the offset in the source array
  5787. * @param result defines the target Color3 object
  5788. */
  5789. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5790. /**
  5791. * Creates a new Color3 from integer values (< 256)
  5792. * @param r defines the red component to read from (value between 0 and 255)
  5793. * @param g defines the green component to read from (value between 0 and 255)
  5794. * @param b defines the blue component to read from (value between 0 and 255)
  5795. * @returns a new Color3 object
  5796. */
  5797. static FromInts(r: number, g: number, b: number): Color3;
  5798. /**
  5799. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5800. * @param start defines the start Color3 value
  5801. * @param end defines the end Color3 value
  5802. * @param amount defines the gradient value between start and end
  5803. * @returns a new Color3 object
  5804. */
  5805. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5806. /**
  5807. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5808. * @param left defines the start value
  5809. * @param right defines the end value
  5810. * @param amount defines the gradient factor
  5811. * @param result defines the Color3 object where to store the result
  5812. */
  5813. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5814. /**
  5815. * Returns a Color3 value containing a red color
  5816. * @returns a new Color3 object
  5817. */
  5818. static Red(): Color3;
  5819. /**
  5820. * Returns a Color3 value containing a green color
  5821. * @returns a new Color3 object
  5822. */
  5823. static Green(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a blue color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Blue(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a black color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Black(): Color3;
  5834. /**
  5835. * Gets a Color3 value containing a black color that must not be updated
  5836. */
  5837. static get BlackReadOnly(): DeepImmutable<Color3>;
  5838. /**
  5839. * Returns a Color3 value containing a white color
  5840. * @returns a new Color3 object
  5841. */
  5842. static White(): Color3;
  5843. /**
  5844. * Returns a Color3 value containing a purple color
  5845. * @returns a new Color3 object
  5846. */
  5847. static Purple(): Color3;
  5848. /**
  5849. * Returns a Color3 value containing a magenta color
  5850. * @returns a new Color3 object
  5851. */
  5852. static Magenta(): Color3;
  5853. /**
  5854. * Returns a Color3 value containing a yellow color
  5855. * @returns a new Color3 object
  5856. */
  5857. static Yellow(): Color3;
  5858. /**
  5859. * Returns a Color3 value containing a gray color
  5860. * @returns a new Color3 object
  5861. */
  5862. static Gray(): Color3;
  5863. /**
  5864. * Returns a Color3 value containing a teal color
  5865. * @returns a new Color3 object
  5866. */
  5867. static Teal(): Color3;
  5868. /**
  5869. * Returns a Color3 value containing a random color
  5870. * @returns a new Color3 object
  5871. */
  5872. static Random(): Color3;
  5873. }
  5874. /**
  5875. * Class used to hold a RBGA color
  5876. */
  5877. export class Color4 {
  5878. /**
  5879. * Defines the red component (between 0 and 1, default is 0)
  5880. */
  5881. r: number;
  5882. /**
  5883. * Defines the green component (between 0 and 1, default is 0)
  5884. */
  5885. g: number;
  5886. /**
  5887. * Defines the blue component (between 0 and 1, default is 0)
  5888. */
  5889. b: number;
  5890. /**
  5891. * Defines the alpha component (between 0 and 1, default is 1)
  5892. */
  5893. a: number;
  5894. /**
  5895. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5896. * @param r defines the red component (between 0 and 1, default is 0)
  5897. * @param g defines the green component (between 0 and 1, default is 0)
  5898. * @param b defines the blue component (between 0 and 1, default is 0)
  5899. * @param a defines the alpha component (between 0 and 1, default is 1)
  5900. */
  5901. constructor(
  5902. /**
  5903. * Defines the red component (between 0 and 1, default is 0)
  5904. */
  5905. r?: number,
  5906. /**
  5907. * Defines the green component (between 0 and 1, default is 0)
  5908. */
  5909. g?: number,
  5910. /**
  5911. * Defines the blue component (between 0 and 1, default is 0)
  5912. */
  5913. b?: number,
  5914. /**
  5915. * Defines the alpha component (between 0 and 1, default is 1)
  5916. */
  5917. a?: number);
  5918. /**
  5919. * Adds in place the given Color4 values to the current Color4 object
  5920. * @param right defines the second operand
  5921. * @returns the current updated Color4 object
  5922. */
  5923. addInPlace(right: DeepImmutable<Color4>): Color4;
  5924. /**
  5925. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5926. * @returns the new array
  5927. */
  5928. asArray(): number[];
  5929. /**
  5930. * Stores from the starting index in the given array the Color4 successive values
  5931. * @param array defines the array where to store the r,g,b components
  5932. * @param index defines an optional index in the target array to define where to start storing values
  5933. * @returns the current Color4 object
  5934. */
  5935. toArray(array: number[], index?: number): Color4;
  5936. /**
  5937. * Update the current color with values stored in an array from the starting index of the given array
  5938. * @param array defines the source array
  5939. * @param offset defines an offset in the source array
  5940. * @returns the current Color4 object
  5941. */
  5942. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5943. /**
  5944. * Determines equality between Color4 objects
  5945. * @param otherColor defines the second operand
  5946. * @returns true if the rgba values are equal to the given ones
  5947. */
  5948. equals(otherColor: DeepImmutable<Color4>): boolean;
  5949. /**
  5950. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5951. * @param right defines the second operand
  5952. * @returns a new Color4 object
  5953. */
  5954. add(right: DeepImmutable<Color4>): Color4;
  5955. /**
  5956. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5957. * @param right defines the second operand
  5958. * @returns a new Color4 object
  5959. */
  5960. subtract(right: DeepImmutable<Color4>): Color4;
  5961. /**
  5962. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5963. * @param right defines the second operand
  5964. * @param result defines the Color4 object where to store the result
  5965. * @returns the current Color4 object
  5966. */
  5967. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5968. /**
  5969. * Creates a new Color4 with the current Color4 values multiplied by scale
  5970. * @param scale defines the scaling factor to apply
  5971. * @returns a new Color4 object
  5972. */
  5973. scale(scale: number): Color4;
  5974. /**
  5975. * Multiplies the current Color4 values by scale and stores the result in "result"
  5976. * @param scale defines the scaling factor to apply
  5977. * @param result defines the Color4 object where to store the result
  5978. * @returns the current unmodified Color4
  5979. */
  5980. scaleToRef(scale: number, result: Color4): Color4;
  5981. /**
  5982. * Scale the current Color4 values by a factor and add the result to a given Color4
  5983. * @param scale defines the scale factor
  5984. * @param result defines the Color4 object where to store the result
  5985. * @returns the unmodified current Color4
  5986. */
  5987. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5988. /**
  5989. * Clamps the rgb values by the min and max values and stores the result into "result"
  5990. * @param min defines minimum clamping value (default is 0)
  5991. * @param max defines maximum clamping value (default is 1)
  5992. * @param result defines color to store the result into.
  5993. * @returns the cuurent Color4
  5994. */
  5995. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5996. /**
  5997. * Multipy an Color4 value by another and return a new Color4 object
  5998. * @param color defines the Color4 value to multiply by
  5999. * @returns a new Color4 object
  6000. */
  6001. multiply(color: Color4): Color4;
  6002. /**
  6003. * Multipy a Color4 value by another and push the result in a reference value
  6004. * @param color defines the Color4 value to multiply by
  6005. * @param result defines the Color4 to fill the result in
  6006. * @returns the result Color4
  6007. */
  6008. multiplyToRef(color: Color4, result: Color4): Color4;
  6009. /**
  6010. * Creates a string with the Color4 current values
  6011. * @returns the string representation of the Color4 object
  6012. */
  6013. toString(): string;
  6014. /**
  6015. * Returns the string "Color4"
  6016. * @returns "Color4"
  6017. */
  6018. getClassName(): string;
  6019. /**
  6020. * Compute the Color4 hash code
  6021. * @returns an unique number that can be used to hash Color4 objects
  6022. */
  6023. getHashCode(): number;
  6024. /**
  6025. * Creates a new Color4 copied from the current one
  6026. * @returns a new Color4 object
  6027. */
  6028. clone(): Color4;
  6029. /**
  6030. * Copies the given Color4 values into the current one
  6031. * @param source defines the source Color4 object
  6032. * @returns the current updated Color4 object
  6033. */
  6034. copyFrom(source: Color4): Color4;
  6035. /**
  6036. * Copies the given float values into the current one
  6037. * @param r defines the red component to read from
  6038. * @param g defines the green component to read from
  6039. * @param b defines the blue component to read from
  6040. * @param a defines the alpha component to read from
  6041. * @returns the current updated Color4 object
  6042. */
  6043. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6044. /**
  6045. * Copies the given float values into the current one
  6046. * @param r defines the red component to read from
  6047. * @param g defines the green component to read from
  6048. * @param b defines the blue component to read from
  6049. * @param a defines the alpha component to read from
  6050. * @returns the current updated Color4 object
  6051. */
  6052. set(r: number, g: number, b: number, a: number): Color4;
  6053. /**
  6054. * Compute the Color4 hexadecimal code as a string
  6055. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6056. * @returns a string containing the hexadecimal representation of the Color4 object
  6057. */
  6058. toHexString(returnAsColor3?: boolean): string;
  6059. /**
  6060. * Computes a new Color4 converted from the current one to linear space
  6061. * @returns a new Color4 object
  6062. */
  6063. toLinearSpace(): Color4;
  6064. /**
  6065. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6066. * @param convertedColor defines the Color4 object where to store the linear space version
  6067. * @returns the unmodified Color4
  6068. */
  6069. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6070. /**
  6071. * Computes a new Color4 converted from the current one to gamma space
  6072. * @returns a new Color4 object
  6073. */
  6074. toGammaSpace(): Color4;
  6075. /**
  6076. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6077. * @param convertedColor defines the Color4 object where to store the gamma space version
  6078. * @returns the unmodified Color4
  6079. */
  6080. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6081. /**
  6082. * Creates a new Color4 from the string containing valid hexadecimal values
  6083. * @param hex defines a string containing valid hexadecimal values
  6084. * @returns a new Color4 object
  6085. */
  6086. static FromHexString(hex: string): Color4;
  6087. /**
  6088. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6089. * @param left defines the start value
  6090. * @param right defines the end value
  6091. * @param amount defines the gradient factor
  6092. * @returns a new Color4 object
  6093. */
  6094. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6095. /**
  6096. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6097. * @param left defines the start value
  6098. * @param right defines the end value
  6099. * @param amount defines the gradient factor
  6100. * @param result defines the Color4 object where to store data
  6101. */
  6102. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6103. /**
  6104. * Creates a new Color4 from a Color3 and an alpha value
  6105. * @param color3 defines the source Color3 to read from
  6106. * @param alpha defines the alpha component (1.0 by default)
  6107. * @returns a new Color4 object
  6108. */
  6109. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6110. /**
  6111. * Creates a new Color4 from the starting index element of the given array
  6112. * @param array defines the source array to read from
  6113. * @param offset defines the offset in the source array
  6114. * @returns a new Color4 object
  6115. */
  6116. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6117. /**
  6118. * Creates a new Color4 from the starting index element of the given array
  6119. * @param array defines the source array to read from
  6120. * @param offset defines the offset in the source array
  6121. * @param result defines the target Color4 object
  6122. */
  6123. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6124. /**
  6125. * Creates a new Color3 from integer values (< 256)
  6126. * @param r defines the red component to read from (value between 0 and 255)
  6127. * @param g defines the green component to read from (value between 0 and 255)
  6128. * @param b defines the blue component to read from (value between 0 and 255)
  6129. * @param a defines the alpha component to read from (value between 0 and 255)
  6130. * @returns a new Color3 object
  6131. */
  6132. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6133. /**
  6134. * Check the content of a given array and convert it to an array containing RGBA data
  6135. * If the original array was already containing count * 4 values then it is returned directly
  6136. * @param colors defines the array to check
  6137. * @param count defines the number of RGBA data to expect
  6138. * @returns an array containing count * 4 values (RGBA)
  6139. */
  6140. static CheckColors4(colors: number[], count: number): number[];
  6141. }
  6142. /**
  6143. * @hidden
  6144. */
  6145. export class TmpColors {
  6146. static Color3: Color3[];
  6147. static Color4: Color4[];
  6148. }
  6149. }
  6150. declare module "babylonjs/Animations/animationKey" {
  6151. /**
  6152. * Defines an interface which represents an animation key frame
  6153. */
  6154. export interface IAnimationKey {
  6155. /**
  6156. * Frame of the key frame
  6157. */
  6158. frame: number;
  6159. /**
  6160. * Value at the specifies key frame
  6161. */
  6162. value: any;
  6163. /**
  6164. * The input tangent for the cubic hermite spline
  6165. */
  6166. inTangent?: any;
  6167. /**
  6168. * The output tangent for the cubic hermite spline
  6169. */
  6170. outTangent?: any;
  6171. /**
  6172. * The animation interpolation type
  6173. */
  6174. interpolation?: AnimationKeyInterpolation;
  6175. }
  6176. /**
  6177. * Enum for the animation key frame interpolation type
  6178. */
  6179. export enum AnimationKeyInterpolation {
  6180. /**
  6181. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6182. */
  6183. STEP = 1
  6184. }
  6185. }
  6186. declare module "babylonjs/Animations/animationRange" {
  6187. /**
  6188. * Represents the range of an animation
  6189. */
  6190. export class AnimationRange {
  6191. /**The name of the animation range**/
  6192. name: string;
  6193. /**The starting frame of the animation */
  6194. from: number;
  6195. /**The ending frame of the animation*/
  6196. to: number;
  6197. /**
  6198. * Initializes the range of an animation
  6199. * @param name The name of the animation range
  6200. * @param from The starting frame of the animation
  6201. * @param to The ending frame of the animation
  6202. */
  6203. constructor(
  6204. /**The name of the animation range**/
  6205. name: string,
  6206. /**The starting frame of the animation */
  6207. from: number,
  6208. /**The ending frame of the animation*/
  6209. to: number);
  6210. /**
  6211. * Makes a copy of the animation range
  6212. * @returns A copy of the animation range
  6213. */
  6214. clone(): AnimationRange;
  6215. }
  6216. }
  6217. declare module "babylonjs/Animations/animationEvent" {
  6218. /**
  6219. * Composed of a frame, and an action function
  6220. */
  6221. export class AnimationEvent {
  6222. /** The frame for which the event is triggered **/
  6223. frame: number;
  6224. /** The event to perform when triggered **/
  6225. action: (currentFrame: number) => void;
  6226. /** Specifies if the event should be triggered only once**/
  6227. onlyOnce?: boolean | undefined;
  6228. /**
  6229. * Specifies if the animation event is done
  6230. */
  6231. isDone: boolean;
  6232. /**
  6233. * Initializes the animation event
  6234. * @param frame The frame for which the event is triggered
  6235. * @param action The event to perform when triggered
  6236. * @param onlyOnce Specifies if the event should be triggered only once
  6237. */
  6238. constructor(
  6239. /** The frame for which the event is triggered **/
  6240. frame: number,
  6241. /** The event to perform when triggered **/
  6242. action: (currentFrame: number) => void,
  6243. /** Specifies if the event should be triggered only once**/
  6244. onlyOnce?: boolean | undefined);
  6245. /** @hidden */
  6246. _clone(): AnimationEvent;
  6247. }
  6248. }
  6249. declare module "babylonjs/Behaviors/behavior" {
  6250. import { Nullable } from "babylonjs/types";
  6251. /**
  6252. * Interface used to define a behavior
  6253. */
  6254. export interface Behavior<T> {
  6255. /** gets or sets behavior's name */
  6256. name: string;
  6257. /**
  6258. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6259. */
  6260. init(): void;
  6261. /**
  6262. * Called when the behavior is attached to a target
  6263. * @param target defines the target where the behavior is attached to
  6264. */
  6265. attach(target: T): void;
  6266. /**
  6267. * Called when the behavior is detached from its target
  6268. */
  6269. detach(): void;
  6270. }
  6271. /**
  6272. * Interface implemented by classes supporting behaviors
  6273. */
  6274. export interface IBehaviorAware<T> {
  6275. /**
  6276. * Attach a behavior
  6277. * @param behavior defines the behavior to attach
  6278. * @returns the current host
  6279. */
  6280. addBehavior(behavior: Behavior<T>): T;
  6281. /**
  6282. * Remove a behavior from the current object
  6283. * @param behavior defines the behavior to detach
  6284. * @returns the current host
  6285. */
  6286. removeBehavior(behavior: Behavior<T>): T;
  6287. /**
  6288. * Gets a behavior using its name to search
  6289. * @param name defines the name to search
  6290. * @returns the behavior or null if not found
  6291. */
  6292. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6293. }
  6294. }
  6295. declare module "babylonjs/Misc/smartArray" {
  6296. /**
  6297. * Defines an array and its length.
  6298. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6299. */
  6300. export interface ISmartArrayLike<T> {
  6301. /**
  6302. * The data of the array.
  6303. */
  6304. data: Array<T>;
  6305. /**
  6306. * The active length of the array.
  6307. */
  6308. length: number;
  6309. }
  6310. /**
  6311. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6312. */
  6313. export class SmartArray<T> implements ISmartArrayLike<T> {
  6314. /**
  6315. * The full set of data from the array.
  6316. */
  6317. data: Array<T>;
  6318. /**
  6319. * The active length of the array.
  6320. */
  6321. length: number;
  6322. protected _id: number;
  6323. /**
  6324. * Instantiates a Smart Array.
  6325. * @param capacity defines the default capacity of the array.
  6326. */
  6327. constructor(capacity: number);
  6328. /**
  6329. * Pushes a value at the end of the active data.
  6330. * @param value defines the object to push in the array.
  6331. */
  6332. push(value: T): void;
  6333. /**
  6334. * Iterates over the active data and apply the lambda to them.
  6335. * @param func defines the action to apply on each value.
  6336. */
  6337. forEach(func: (content: T) => void): void;
  6338. /**
  6339. * Sorts the full sets of data.
  6340. * @param compareFn defines the comparison function to apply.
  6341. */
  6342. sort(compareFn: (a: T, b: T) => number): void;
  6343. /**
  6344. * Resets the active data to an empty array.
  6345. */
  6346. reset(): void;
  6347. /**
  6348. * Releases all the data from the array as well as the array.
  6349. */
  6350. dispose(): void;
  6351. /**
  6352. * Concats the active data with a given array.
  6353. * @param array defines the data to concatenate with.
  6354. */
  6355. concat(array: any): void;
  6356. /**
  6357. * Returns the position of a value in the active data.
  6358. * @param value defines the value to find the index for
  6359. * @returns the index if found in the active data otherwise -1
  6360. */
  6361. indexOf(value: T): number;
  6362. /**
  6363. * Returns whether an element is part of the active data.
  6364. * @param value defines the value to look for
  6365. * @returns true if found in the active data otherwise false
  6366. */
  6367. contains(value: T): boolean;
  6368. private static _GlobalId;
  6369. }
  6370. /**
  6371. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6372. * The data in this array can only be present once
  6373. */
  6374. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6375. private _duplicateId;
  6376. /**
  6377. * Pushes a value at the end of the active data.
  6378. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6379. * @param value defines the object to push in the array.
  6380. */
  6381. push(value: T): void;
  6382. /**
  6383. * Pushes a value at the end of the active data.
  6384. * If the data is already present, it won t be added again
  6385. * @param value defines the object to push in the array.
  6386. * @returns true if added false if it was already present
  6387. */
  6388. pushNoDuplicate(value: T): boolean;
  6389. /**
  6390. * Resets the active data to an empty array.
  6391. */
  6392. reset(): void;
  6393. /**
  6394. * Concats the active data with a given array.
  6395. * This ensures no dupplicate will be present in the result.
  6396. * @param array defines the data to concatenate with.
  6397. */
  6398. concatWithNoDuplicate(array: any): void;
  6399. }
  6400. }
  6401. declare module "babylonjs/Cameras/cameraInputsManager" {
  6402. import { Nullable } from "babylonjs/types";
  6403. import { Camera } from "babylonjs/Cameras/camera";
  6404. /**
  6405. * @ignore
  6406. * This is a list of all the different input types that are available in the application.
  6407. * Fo instance: ArcRotateCameraGamepadInput...
  6408. */
  6409. export var CameraInputTypes: {};
  6410. /**
  6411. * This is the contract to implement in order to create a new input class.
  6412. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6413. */
  6414. export interface ICameraInput<TCamera extends Camera> {
  6415. /**
  6416. * Defines the camera the input is attached to.
  6417. */
  6418. camera: Nullable<TCamera>;
  6419. /**
  6420. * Gets the class name of the current intput.
  6421. * @returns the class name
  6422. */
  6423. getClassName(): string;
  6424. /**
  6425. * Get the friendly name associated with the input class.
  6426. * @returns the input friendly name
  6427. */
  6428. getSimpleName(): string;
  6429. /**
  6430. * Attach the input controls to a specific dom element to get the input from.
  6431. * @param element Defines the element the controls should be listened from
  6432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6433. */
  6434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6435. /**
  6436. * Detach the current controls from the specified dom element.
  6437. * @param element Defines the element to stop listening the inputs from
  6438. */
  6439. detachControl(element: Nullable<HTMLElement>): void;
  6440. /**
  6441. * Update the current camera state depending on the inputs that have been used this frame.
  6442. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6443. */
  6444. checkInputs?: () => void;
  6445. }
  6446. /**
  6447. * Represents a map of input types to input instance or input index to input instance.
  6448. */
  6449. export interface CameraInputsMap<TCamera extends Camera> {
  6450. /**
  6451. * Accessor to the input by input type.
  6452. */
  6453. [name: string]: ICameraInput<TCamera>;
  6454. /**
  6455. * Accessor to the input by input index.
  6456. */
  6457. [idx: number]: ICameraInput<TCamera>;
  6458. }
  6459. /**
  6460. * This represents the input manager used within a camera.
  6461. * It helps dealing with all the different kind of input attached to a camera.
  6462. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6463. */
  6464. export class CameraInputsManager<TCamera extends Camera> {
  6465. /**
  6466. * Defines the list of inputs attahed to the camera.
  6467. */
  6468. attached: CameraInputsMap<TCamera>;
  6469. /**
  6470. * Defines the dom element the camera is collecting inputs from.
  6471. * This is null if the controls have not been attached.
  6472. */
  6473. attachedElement: Nullable<HTMLElement>;
  6474. /**
  6475. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6476. */
  6477. noPreventDefault: boolean;
  6478. /**
  6479. * Defined the camera the input manager belongs to.
  6480. */
  6481. camera: TCamera;
  6482. /**
  6483. * Update the current camera state depending on the inputs that have been used this frame.
  6484. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6485. */
  6486. checkInputs: () => void;
  6487. /**
  6488. * Instantiate a new Camera Input Manager.
  6489. * @param camera Defines the camera the input manager blongs to
  6490. */
  6491. constructor(camera: TCamera);
  6492. /**
  6493. * Add an input method to a camera
  6494. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6495. * @param input camera input method
  6496. */
  6497. add(input: ICameraInput<TCamera>): void;
  6498. /**
  6499. * Remove a specific input method from a camera
  6500. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6501. * @param inputToRemove camera input method
  6502. */
  6503. remove(inputToRemove: ICameraInput<TCamera>): void;
  6504. /**
  6505. * Remove a specific input type from a camera
  6506. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6507. * @param inputType the type of the input to remove
  6508. */
  6509. removeByType(inputType: string): void;
  6510. private _addCheckInputs;
  6511. /**
  6512. * Attach the input controls to the currently attached dom element to listen the events from.
  6513. * @param input Defines the input to attach
  6514. */
  6515. attachInput(input: ICameraInput<TCamera>): void;
  6516. /**
  6517. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6518. * @param element Defines the dom element to collect the events from
  6519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6520. */
  6521. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6522. /**
  6523. * Detach the current manager inputs controls from a specific dom element.
  6524. * @param element Defines the dom element to collect the events from
  6525. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6526. */
  6527. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6528. /**
  6529. * Rebuild the dynamic inputCheck function from the current list of
  6530. * defined inputs in the manager.
  6531. */
  6532. rebuildInputCheck(): void;
  6533. /**
  6534. * Remove all attached input methods from a camera
  6535. */
  6536. clear(): void;
  6537. /**
  6538. * Serialize the current input manager attached to a camera.
  6539. * This ensures than once parsed,
  6540. * the input associated to the camera will be identical to the current ones
  6541. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6542. */
  6543. serialize(serializedCamera: any): void;
  6544. /**
  6545. * Parses an input manager serialized JSON to restore the previous list of inputs
  6546. * and states associated to a camera.
  6547. * @param parsedCamera Defines the JSON to parse
  6548. */
  6549. parse(parsedCamera: any): void;
  6550. }
  6551. }
  6552. declare module "babylonjs/Meshes/buffer" {
  6553. import { Nullable, DataArray } from "babylonjs/types";
  6554. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6555. /**
  6556. * Class used to store data that will be store in GPU memory
  6557. */
  6558. export class Buffer {
  6559. private _engine;
  6560. private _buffer;
  6561. /** @hidden */
  6562. _data: Nullable<DataArray>;
  6563. private _updatable;
  6564. private _instanced;
  6565. private _divisor;
  6566. /**
  6567. * Gets the byte stride.
  6568. */
  6569. readonly byteStride: number;
  6570. /**
  6571. * Constructor
  6572. * @param engine the engine
  6573. * @param data the data to use for this buffer
  6574. * @param updatable whether the data is updatable
  6575. * @param stride the stride (optional)
  6576. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6577. * @param instanced whether the buffer is instanced (optional)
  6578. * @param useBytes set to true if the stride in in bytes (optional)
  6579. * @param divisor sets an optional divisor for instances (1 by default)
  6580. */
  6581. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6582. /**
  6583. * Create a new VertexBuffer based on the current buffer
  6584. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6585. * @param offset defines offset in the buffer (0 by default)
  6586. * @param size defines the size in floats of attributes (position is 3 for instance)
  6587. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6588. * @param instanced defines if the vertex buffer contains indexed data
  6589. * @param useBytes defines if the offset and stride are in bytes *
  6590. * @param divisor sets an optional divisor for instances (1 by default)
  6591. * @returns the new vertex buffer
  6592. */
  6593. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6594. /**
  6595. * Gets a boolean indicating if the Buffer is updatable?
  6596. * @returns true if the buffer is updatable
  6597. */
  6598. isUpdatable(): boolean;
  6599. /**
  6600. * Gets current buffer's data
  6601. * @returns a DataArray or null
  6602. */
  6603. getData(): Nullable<DataArray>;
  6604. /**
  6605. * Gets underlying native buffer
  6606. * @returns underlying native buffer
  6607. */
  6608. getBuffer(): Nullable<DataBuffer>;
  6609. /**
  6610. * Gets the stride in float32 units (i.e. byte stride / 4).
  6611. * May not be an integer if the byte stride is not divisible by 4.
  6612. * @returns the stride in float32 units
  6613. * @deprecated Please use byteStride instead.
  6614. */
  6615. getStrideSize(): number;
  6616. /**
  6617. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6618. * @param data defines the data to store
  6619. */
  6620. create(data?: Nullable<DataArray>): void;
  6621. /** @hidden */
  6622. _rebuild(): void;
  6623. /**
  6624. * Update current buffer data
  6625. * @param data defines the data to store
  6626. */
  6627. update(data: DataArray): void;
  6628. /**
  6629. * Updates the data directly.
  6630. * @param data the new data
  6631. * @param offset the new offset
  6632. * @param vertexCount the vertex count (optional)
  6633. * @param useBytes set to true if the offset is in bytes
  6634. */
  6635. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6636. /**
  6637. * Release all resources
  6638. */
  6639. dispose(): void;
  6640. }
  6641. /**
  6642. * Specialized buffer used to store vertex data
  6643. */
  6644. export class VertexBuffer {
  6645. /** @hidden */
  6646. _buffer: Buffer;
  6647. private _kind;
  6648. private _size;
  6649. private _ownsBuffer;
  6650. private _instanced;
  6651. private _instanceDivisor;
  6652. /**
  6653. * The byte type.
  6654. */
  6655. static readonly BYTE: number;
  6656. /**
  6657. * The unsigned byte type.
  6658. */
  6659. static readonly UNSIGNED_BYTE: number;
  6660. /**
  6661. * The short type.
  6662. */
  6663. static readonly SHORT: number;
  6664. /**
  6665. * The unsigned short type.
  6666. */
  6667. static readonly UNSIGNED_SHORT: number;
  6668. /**
  6669. * The integer type.
  6670. */
  6671. static readonly INT: number;
  6672. /**
  6673. * The unsigned integer type.
  6674. */
  6675. static readonly UNSIGNED_INT: number;
  6676. /**
  6677. * The float type.
  6678. */
  6679. static readonly FLOAT: number;
  6680. /**
  6681. * Gets or sets the instance divisor when in instanced mode
  6682. */
  6683. get instanceDivisor(): number;
  6684. set instanceDivisor(value: number);
  6685. /**
  6686. * Gets the byte stride.
  6687. */
  6688. readonly byteStride: number;
  6689. /**
  6690. * Gets the byte offset.
  6691. */
  6692. readonly byteOffset: number;
  6693. /**
  6694. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6695. */
  6696. readonly normalized: boolean;
  6697. /**
  6698. * Gets the data type of each component in the array.
  6699. */
  6700. readonly type: number;
  6701. /**
  6702. * Constructor
  6703. * @param engine the engine
  6704. * @param data the data to use for this vertex buffer
  6705. * @param kind the vertex buffer kind
  6706. * @param updatable whether the data is updatable
  6707. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6708. * @param stride the stride (optional)
  6709. * @param instanced whether the buffer is instanced (optional)
  6710. * @param offset the offset of the data (optional)
  6711. * @param size the number of components (optional)
  6712. * @param type the type of the component (optional)
  6713. * @param normalized whether the data contains normalized data (optional)
  6714. * @param useBytes set to true if stride and offset are in bytes (optional)
  6715. * @param divisor defines the instance divisor to use (1 by default)
  6716. */
  6717. 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);
  6718. /** @hidden */
  6719. _rebuild(): void;
  6720. /**
  6721. * Returns the kind of the VertexBuffer (string)
  6722. * @returns a string
  6723. */
  6724. getKind(): string;
  6725. /**
  6726. * Gets a boolean indicating if the VertexBuffer is updatable?
  6727. * @returns true if the buffer is updatable
  6728. */
  6729. isUpdatable(): boolean;
  6730. /**
  6731. * Gets current buffer's data
  6732. * @returns a DataArray or null
  6733. */
  6734. getData(): Nullable<DataArray>;
  6735. /**
  6736. * Gets underlying native buffer
  6737. * @returns underlying native buffer
  6738. */
  6739. getBuffer(): Nullable<DataBuffer>;
  6740. /**
  6741. * Gets the stride in float32 units (i.e. byte stride / 4).
  6742. * May not be an integer if the byte stride is not divisible by 4.
  6743. * @returns the stride in float32 units
  6744. * @deprecated Please use byteStride instead.
  6745. */
  6746. getStrideSize(): number;
  6747. /**
  6748. * Returns the offset as a multiple of the type byte length.
  6749. * @returns the offset in bytes
  6750. * @deprecated Please use byteOffset instead.
  6751. */
  6752. getOffset(): number;
  6753. /**
  6754. * Returns the number of components per vertex attribute (integer)
  6755. * @returns the size in float
  6756. */
  6757. getSize(): number;
  6758. /**
  6759. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6760. * @returns true if this buffer is instanced
  6761. */
  6762. getIsInstanced(): boolean;
  6763. /**
  6764. * Returns the instancing divisor, zero for non-instanced (integer).
  6765. * @returns a number
  6766. */
  6767. getInstanceDivisor(): number;
  6768. /**
  6769. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6770. * @param data defines the data to store
  6771. */
  6772. create(data?: DataArray): void;
  6773. /**
  6774. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6775. * This function will create a new buffer if the current one is not updatable
  6776. * @param data defines the data to store
  6777. */
  6778. update(data: DataArray): void;
  6779. /**
  6780. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6781. * Returns the directly updated WebGLBuffer.
  6782. * @param data the new data
  6783. * @param offset the new offset
  6784. * @param useBytes set to true if the offset is in bytes
  6785. */
  6786. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6787. /**
  6788. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6789. */
  6790. dispose(): void;
  6791. /**
  6792. * Enumerates each value of this vertex buffer as numbers.
  6793. * @param count the number of values to enumerate
  6794. * @param callback the callback function called for each value
  6795. */
  6796. forEach(count: number, callback: (value: number, index: number) => void): void;
  6797. /**
  6798. * Positions
  6799. */
  6800. static readonly PositionKind: string;
  6801. /**
  6802. * Normals
  6803. */
  6804. static readonly NormalKind: string;
  6805. /**
  6806. * Tangents
  6807. */
  6808. static readonly TangentKind: string;
  6809. /**
  6810. * Texture coordinates
  6811. */
  6812. static readonly UVKind: string;
  6813. /**
  6814. * Texture coordinates 2
  6815. */
  6816. static readonly UV2Kind: string;
  6817. /**
  6818. * Texture coordinates 3
  6819. */
  6820. static readonly UV3Kind: string;
  6821. /**
  6822. * Texture coordinates 4
  6823. */
  6824. static readonly UV4Kind: string;
  6825. /**
  6826. * Texture coordinates 5
  6827. */
  6828. static readonly UV5Kind: string;
  6829. /**
  6830. * Texture coordinates 6
  6831. */
  6832. static readonly UV6Kind: string;
  6833. /**
  6834. * Colors
  6835. */
  6836. static readonly ColorKind: string;
  6837. /**
  6838. * Matrix indices (for bones)
  6839. */
  6840. static readonly MatricesIndicesKind: string;
  6841. /**
  6842. * Matrix weights (for bones)
  6843. */
  6844. static readonly MatricesWeightsKind: string;
  6845. /**
  6846. * Additional matrix indices (for bones)
  6847. */
  6848. static readonly MatricesIndicesExtraKind: string;
  6849. /**
  6850. * Additional matrix weights (for bones)
  6851. */
  6852. static readonly MatricesWeightsExtraKind: string;
  6853. /**
  6854. * Deduces the stride given a kind.
  6855. * @param kind The kind string to deduce
  6856. * @returns The deduced stride
  6857. */
  6858. static DeduceStride(kind: string): number;
  6859. /**
  6860. * Gets the byte length of the given type.
  6861. * @param type the type
  6862. * @returns the number of bytes
  6863. */
  6864. static GetTypeByteLength(type: number): number;
  6865. /**
  6866. * Enumerates each value of the given parameters as numbers.
  6867. * @param data the data to enumerate
  6868. * @param byteOffset the byte offset of the data
  6869. * @param byteStride the byte stride of the data
  6870. * @param componentCount the number of components per element
  6871. * @param componentType the type of the component
  6872. * @param count the number of values to enumerate
  6873. * @param normalized whether the data is normalized
  6874. * @param callback the callback function called for each value
  6875. */
  6876. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6877. private static _GetFloatValue;
  6878. }
  6879. }
  6880. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6881. import { Vector3 } from "babylonjs/Maths/math.vector";
  6882. import { Mesh } from "babylonjs/Meshes/mesh";
  6883. /**
  6884. * The options Interface for creating a Capsule Mesh
  6885. */
  6886. export interface ICreateCapsuleOptions {
  6887. /** The Orientation of the capsule. Default : Vector3.Up() */
  6888. orientation?: Vector3;
  6889. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6890. subdivisions: number;
  6891. /** Number of cylindrical segments on the capsule. */
  6892. tessellation: number;
  6893. /** Height or Length of the capsule. */
  6894. height: number;
  6895. /** Radius of the capsule. */
  6896. radius: number;
  6897. /** Height or Length of the capsule. */
  6898. capSubdivisions: number;
  6899. /** Overwrite for the top radius. */
  6900. radiusTop?: number;
  6901. /** Overwrite for the bottom radius. */
  6902. radiusBottom?: number;
  6903. /** Overwrite for the top capSubdivisions. */
  6904. topCapSubdivisions?: number;
  6905. /** Overwrite for the bottom capSubdivisions. */
  6906. bottomCapSubdivisions?: number;
  6907. }
  6908. /**
  6909. * Class containing static functions to help procedurally build meshes
  6910. */
  6911. export class CapsuleBuilder {
  6912. /**
  6913. * Creates a capsule or a pill mesh
  6914. * @param name defines the name of the mesh
  6915. * @param options The constructors options.
  6916. * @param scene The scene the mesh is scoped to.
  6917. * @returns Capsule Mesh
  6918. */
  6919. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6920. }
  6921. }
  6922. declare module "babylonjs/Collisions/intersectionInfo" {
  6923. import { Nullable } from "babylonjs/types";
  6924. /**
  6925. * @hidden
  6926. */
  6927. export class IntersectionInfo {
  6928. bu: Nullable<number>;
  6929. bv: Nullable<number>;
  6930. distance: number;
  6931. faceId: number;
  6932. subMeshId: number;
  6933. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6934. }
  6935. }
  6936. declare module "babylonjs/Culling/boundingSphere" {
  6937. import { DeepImmutable } from "babylonjs/types";
  6938. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6939. import { Plane } from "babylonjs/Maths/math.plane";
  6940. /**
  6941. * Class used to store bounding sphere information
  6942. */
  6943. export class BoundingSphere {
  6944. /**
  6945. * Gets the center of the bounding sphere in local space
  6946. */
  6947. readonly center: Vector3;
  6948. /**
  6949. * Radius of the bounding sphere in local space
  6950. */
  6951. radius: number;
  6952. /**
  6953. * Gets the center of the bounding sphere in world space
  6954. */
  6955. readonly centerWorld: Vector3;
  6956. /**
  6957. * Radius of the bounding sphere in world space
  6958. */
  6959. radiusWorld: number;
  6960. /**
  6961. * Gets the minimum vector in local space
  6962. */
  6963. readonly minimum: Vector3;
  6964. /**
  6965. * Gets the maximum vector in local space
  6966. */
  6967. readonly maximum: Vector3;
  6968. private _worldMatrix;
  6969. private static readonly TmpVector3;
  6970. /**
  6971. * Creates a new bounding sphere
  6972. * @param min defines the minimum vector (in local space)
  6973. * @param max defines the maximum vector (in local space)
  6974. * @param worldMatrix defines the new world matrix
  6975. */
  6976. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6977. /**
  6978. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6979. * @param min defines the new minimum vector (in local space)
  6980. * @param max defines the new maximum vector (in local space)
  6981. * @param worldMatrix defines the new world matrix
  6982. */
  6983. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6984. /**
  6985. * Scale the current bounding sphere by applying a scale factor
  6986. * @param factor defines the scale factor to apply
  6987. * @returns the current bounding box
  6988. */
  6989. scale(factor: number): BoundingSphere;
  6990. /**
  6991. * Gets the world matrix of the bounding box
  6992. * @returns a matrix
  6993. */
  6994. getWorldMatrix(): DeepImmutable<Matrix>;
  6995. /** @hidden */
  6996. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6997. /**
  6998. * Tests if the bounding sphere is intersecting the frustum planes
  6999. * @param frustumPlanes defines the frustum planes to test
  7000. * @returns true if there is an intersection
  7001. */
  7002. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7003. /**
  7004. * Tests if the bounding sphere center is in between the frustum planes.
  7005. * Used for optimistic fast inclusion.
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @returns true if the sphere center is in between the frustum planes
  7008. */
  7009. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. /**
  7011. * Tests if a point is inside the bounding sphere
  7012. * @param point defines the point to test
  7013. * @returns true if the point is inside the bounding sphere
  7014. */
  7015. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7016. /**
  7017. * Checks if two sphere intersct
  7018. * @param sphere0 sphere 0
  7019. * @param sphere1 sphere 1
  7020. * @returns true if the speres intersect
  7021. */
  7022. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7023. }
  7024. }
  7025. declare module "babylonjs/Culling/boundingBox" {
  7026. import { DeepImmutable } from "babylonjs/types";
  7027. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7028. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7029. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7030. import { Plane } from "babylonjs/Maths/math.plane";
  7031. /**
  7032. * Class used to store bounding box information
  7033. */
  7034. export class BoundingBox implements ICullable {
  7035. /**
  7036. * Gets the 8 vectors representing the bounding box in local space
  7037. */
  7038. readonly vectors: Vector3[];
  7039. /**
  7040. * Gets the center of the bounding box in local space
  7041. */
  7042. readonly center: Vector3;
  7043. /**
  7044. * Gets the center of the bounding box in world space
  7045. */
  7046. readonly centerWorld: Vector3;
  7047. /**
  7048. * Gets the extend size in local space
  7049. */
  7050. readonly extendSize: Vector3;
  7051. /**
  7052. * Gets the extend size in world space
  7053. */
  7054. readonly extendSizeWorld: Vector3;
  7055. /**
  7056. * Gets the OBB (object bounding box) directions
  7057. */
  7058. readonly directions: Vector3[];
  7059. /**
  7060. * Gets the 8 vectors representing the bounding box in world space
  7061. */
  7062. readonly vectorsWorld: Vector3[];
  7063. /**
  7064. * Gets the minimum vector in world space
  7065. */
  7066. readonly minimumWorld: Vector3;
  7067. /**
  7068. * Gets the maximum vector in world space
  7069. */
  7070. readonly maximumWorld: Vector3;
  7071. /**
  7072. * Gets the minimum vector in local space
  7073. */
  7074. readonly minimum: Vector3;
  7075. /**
  7076. * Gets the maximum vector in local space
  7077. */
  7078. readonly maximum: Vector3;
  7079. private _worldMatrix;
  7080. private static readonly TmpVector3;
  7081. /**
  7082. * @hidden
  7083. */
  7084. _tag: number;
  7085. /**
  7086. * Creates a new bounding box
  7087. * @param min defines the minimum vector (in local space)
  7088. * @param max defines the maximum vector (in local space)
  7089. * @param worldMatrix defines the new world matrix
  7090. */
  7091. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7092. /**
  7093. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7094. * @param min defines the new minimum vector (in local space)
  7095. * @param max defines the new maximum vector (in local space)
  7096. * @param worldMatrix defines the new world matrix
  7097. */
  7098. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7099. /**
  7100. * Scale the current bounding box by applying a scale factor
  7101. * @param factor defines the scale factor to apply
  7102. * @returns the current bounding box
  7103. */
  7104. scale(factor: number): BoundingBox;
  7105. /**
  7106. * Gets the world matrix of the bounding box
  7107. * @returns a matrix
  7108. */
  7109. getWorldMatrix(): DeepImmutable<Matrix>;
  7110. /** @hidden */
  7111. _update(world: DeepImmutable<Matrix>): void;
  7112. /**
  7113. * Tests if the bounding box is intersecting the frustum planes
  7114. * @param frustumPlanes defines the frustum planes to test
  7115. * @returns true if there is an intersection
  7116. */
  7117. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7118. /**
  7119. * Tests if the bounding box is entirely inside the frustum planes
  7120. * @param frustumPlanes defines the frustum planes to test
  7121. * @returns true if there is an inclusion
  7122. */
  7123. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7124. /**
  7125. * Tests if a point is inside the bounding box
  7126. * @param point defines the point to test
  7127. * @returns true if the point is inside the bounding box
  7128. */
  7129. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7130. /**
  7131. * Tests if the bounding box intersects with a bounding sphere
  7132. * @param sphere defines the sphere to test
  7133. * @returns true if there is an intersection
  7134. */
  7135. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7136. /**
  7137. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7138. * @param min defines the min vector to use
  7139. * @param max defines the max vector to use
  7140. * @returns true if there is an intersection
  7141. */
  7142. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7143. /**
  7144. * Tests if two bounding boxes are intersections
  7145. * @param box0 defines the first box to test
  7146. * @param box1 defines the second box to test
  7147. * @returns true if there is an intersection
  7148. */
  7149. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7150. /**
  7151. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7152. * @param minPoint defines the minimum vector of the bounding box
  7153. * @param maxPoint defines the maximum vector of the bounding box
  7154. * @param sphereCenter defines the sphere center
  7155. * @param sphereRadius defines the sphere radius
  7156. * @returns true if there is an intersection
  7157. */
  7158. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7159. /**
  7160. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7161. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7162. * @param frustumPlanes defines the frustum planes to test
  7163. * @return true if there is an inclusion
  7164. */
  7165. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7166. /**
  7167. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7168. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7169. * @param frustumPlanes defines the frustum planes to test
  7170. * @return true if there is an intersection
  7171. */
  7172. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7173. }
  7174. }
  7175. declare module "babylonjs/Collisions/collider" {
  7176. import { Nullable, IndicesArray } from "babylonjs/types";
  7177. import { Vector3 } from "babylonjs/Maths/math.vector";
  7178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7179. import { Plane } from "babylonjs/Maths/math.plane";
  7180. /** @hidden */
  7181. export class Collider {
  7182. /** Define if a collision was found */
  7183. collisionFound: boolean;
  7184. /**
  7185. * Define last intersection point in local space
  7186. */
  7187. intersectionPoint: Vector3;
  7188. /**
  7189. * Define last collided mesh
  7190. */
  7191. collidedMesh: Nullable<AbstractMesh>;
  7192. private _collisionPoint;
  7193. private _planeIntersectionPoint;
  7194. private _tempVector;
  7195. private _tempVector2;
  7196. private _tempVector3;
  7197. private _tempVector4;
  7198. private _edge;
  7199. private _baseToVertex;
  7200. private _destinationPoint;
  7201. private _slidePlaneNormal;
  7202. private _displacementVector;
  7203. /** @hidden */
  7204. _radius: Vector3;
  7205. /** @hidden */
  7206. _retry: number;
  7207. private _velocity;
  7208. private _basePoint;
  7209. private _epsilon;
  7210. /** @hidden */
  7211. _velocityWorldLength: number;
  7212. /** @hidden */
  7213. _basePointWorld: Vector3;
  7214. private _velocityWorld;
  7215. private _normalizedVelocity;
  7216. /** @hidden */
  7217. _initialVelocity: Vector3;
  7218. /** @hidden */
  7219. _initialPosition: Vector3;
  7220. private _nearestDistance;
  7221. private _collisionMask;
  7222. get collisionMask(): number;
  7223. set collisionMask(mask: number);
  7224. /**
  7225. * Gets the plane normal used to compute the sliding response (in local space)
  7226. */
  7227. get slidePlaneNormal(): Vector3;
  7228. /** @hidden */
  7229. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7230. /** @hidden */
  7231. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7232. /** @hidden */
  7233. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7234. /** @hidden */
  7235. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7236. /** @hidden */
  7237. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7238. /** @hidden */
  7239. _getResponse(pos: Vector3, vel: Vector3): void;
  7240. }
  7241. }
  7242. declare module "babylonjs/Culling/boundingInfo" {
  7243. import { DeepImmutable } from "babylonjs/types";
  7244. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7245. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7246. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7247. import { Plane } from "babylonjs/Maths/math.plane";
  7248. import { Collider } from "babylonjs/Collisions/collider";
  7249. /**
  7250. * Interface for cullable objects
  7251. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7252. */
  7253. export interface ICullable {
  7254. /**
  7255. * Checks if the object or part of the object is in the frustum
  7256. * @param frustumPlanes Camera near/planes
  7257. * @returns true if the object is in frustum otherwise false
  7258. */
  7259. isInFrustum(frustumPlanes: Plane[]): boolean;
  7260. /**
  7261. * Checks if a cullable object (mesh...) is in the camera frustum
  7262. * Unlike isInFrustum this cheks the full bounding box
  7263. * @param frustumPlanes Camera near/planes
  7264. * @returns true if the object is in frustum otherwise false
  7265. */
  7266. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7267. }
  7268. /**
  7269. * Info for a bounding data of a mesh
  7270. */
  7271. export class BoundingInfo implements ICullable {
  7272. /**
  7273. * Bounding box for the mesh
  7274. */
  7275. readonly boundingBox: BoundingBox;
  7276. /**
  7277. * Bounding sphere for the mesh
  7278. */
  7279. readonly boundingSphere: BoundingSphere;
  7280. private _isLocked;
  7281. private static readonly TmpVector3;
  7282. /**
  7283. * Constructs bounding info
  7284. * @param minimum min vector of the bounding box/sphere
  7285. * @param maximum max vector of the bounding box/sphere
  7286. * @param worldMatrix defines the new world matrix
  7287. */
  7288. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7289. /**
  7290. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7291. * @param min defines the new minimum vector (in local space)
  7292. * @param max defines the new maximum vector (in local space)
  7293. * @param worldMatrix defines the new world matrix
  7294. */
  7295. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7296. /**
  7297. * min vector of the bounding box/sphere
  7298. */
  7299. get minimum(): Vector3;
  7300. /**
  7301. * max vector of the bounding box/sphere
  7302. */
  7303. get maximum(): Vector3;
  7304. /**
  7305. * If the info is locked and won't be updated to avoid perf overhead
  7306. */
  7307. get isLocked(): boolean;
  7308. set isLocked(value: boolean);
  7309. /**
  7310. * Updates the bounding sphere and box
  7311. * @param world world matrix to be used to update
  7312. */
  7313. update(world: DeepImmutable<Matrix>): void;
  7314. /**
  7315. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7316. * @param center New center of the bounding info
  7317. * @param extend New extend of the bounding info
  7318. * @returns the current bounding info
  7319. */
  7320. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7321. /**
  7322. * Scale the current bounding info by applying a scale factor
  7323. * @param factor defines the scale factor to apply
  7324. * @returns the current bounding info
  7325. */
  7326. scale(factor: number): BoundingInfo;
  7327. /**
  7328. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7329. * @param frustumPlanes defines the frustum to test
  7330. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7331. * @returns true if the bounding info is in the frustum planes
  7332. */
  7333. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7334. /**
  7335. * Gets the world distance between the min and max points of the bounding box
  7336. */
  7337. get diagonalLength(): number;
  7338. /**
  7339. * Checks if a cullable object (mesh...) is in the camera frustum
  7340. * Unlike isInFrustum this cheks the full bounding box
  7341. * @param frustumPlanes Camera near/planes
  7342. * @returns true if the object is in frustum otherwise false
  7343. */
  7344. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7345. /** @hidden */
  7346. _checkCollision(collider: Collider): boolean;
  7347. /**
  7348. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7349. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7350. * @param point the point to check intersection with
  7351. * @returns if the point intersects
  7352. */
  7353. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7354. /**
  7355. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7356. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7357. * @param boundingInfo the bounding info to check intersection with
  7358. * @param precise if the intersection should be done using OBB
  7359. * @returns if the bounding info intersects
  7360. */
  7361. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7362. }
  7363. }
  7364. declare module "babylonjs/Maths/math.functions" {
  7365. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7366. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7367. /**
  7368. * Extracts minimum and maximum values from a list of indexed positions
  7369. * @param positions defines the positions to use
  7370. * @param indices defines the indices to the positions
  7371. * @param indexStart defines the start index
  7372. * @param indexCount defines the end index
  7373. * @param bias defines bias value to add to the result
  7374. * @return minimum and maximum values
  7375. */
  7376. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7377. minimum: Vector3;
  7378. maximum: Vector3;
  7379. };
  7380. /**
  7381. * Extracts minimum and maximum values from a list of positions
  7382. * @param positions defines the positions to use
  7383. * @param start defines the start index in the positions array
  7384. * @param count defines the number of positions to handle
  7385. * @param bias defines bias value to add to the result
  7386. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7387. * @return minimum and maximum values
  7388. */
  7389. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7390. minimum: Vector3;
  7391. maximum: Vector3;
  7392. };
  7393. }
  7394. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7395. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7396. /** @hidden */
  7397. export class WebGLDataBuffer extends DataBuffer {
  7398. private _buffer;
  7399. constructor(resource: WebGLBuffer);
  7400. get underlyingResource(): any;
  7401. }
  7402. }
  7403. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7404. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7405. import { Nullable } from "babylonjs/types";
  7406. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7407. /** @hidden */
  7408. export class WebGLPipelineContext implements IPipelineContext {
  7409. engine: ThinEngine;
  7410. program: Nullable<WebGLProgram>;
  7411. context?: WebGLRenderingContext;
  7412. vertexShader?: WebGLShader;
  7413. fragmentShader?: WebGLShader;
  7414. isParallelCompiled: boolean;
  7415. onCompiled?: () => void;
  7416. transformFeedback?: WebGLTransformFeedback | null;
  7417. vertexCompilationError: Nullable<string>;
  7418. fragmentCompilationError: Nullable<string>;
  7419. programLinkError: Nullable<string>;
  7420. programValidationError: Nullable<string>;
  7421. get isAsync(): boolean;
  7422. get isReady(): boolean;
  7423. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7424. _getVertexShaderCode(): string | null;
  7425. _getFragmentShaderCode(): string | null;
  7426. }
  7427. }
  7428. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7429. import { FloatArray, Nullable } from "babylonjs/types";
  7430. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7431. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7432. module "babylonjs/Engines/thinEngine" {
  7433. interface ThinEngine {
  7434. /**
  7435. * Create an uniform buffer
  7436. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7437. * @param elements defines the content of the uniform buffer
  7438. * @returns the webGL uniform buffer
  7439. */
  7440. createUniformBuffer(elements: FloatArray): DataBuffer;
  7441. /**
  7442. * Create a dynamic uniform buffer
  7443. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7444. * @param elements defines the content of the uniform buffer
  7445. * @returns the webGL uniform buffer
  7446. */
  7447. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7448. /**
  7449. * Update an existing uniform buffer
  7450. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7451. * @param uniformBuffer defines the target uniform buffer
  7452. * @param elements defines the content to update
  7453. * @param offset defines the offset in the uniform buffer where update should start
  7454. * @param count defines the size of the data to update
  7455. */
  7456. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7457. /**
  7458. * Bind an uniform buffer to the current webGL context
  7459. * @param buffer defines the buffer to bind
  7460. */
  7461. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7462. /**
  7463. * Bind a buffer to the current webGL context at a given location
  7464. * @param buffer defines the buffer to bind
  7465. * @param location defines the index where to bind the buffer
  7466. */
  7467. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7468. /**
  7469. * Bind a specific block at a given index in a specific shader program
  7470. * @param pipelineContext defines the pipeline context to use
  7471. * @param blockName defines the block name
  7472. * @param index defines the index where to bind the block
  7473. */
  7474. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7475. }
  7476. }
  7477. }
  7478. declare module "babylonjs/Materials/uniformBuffer" {
  7479. import { Nullable, FloatArray } from "babylonjs/types";
  7480. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7481. import { Engine } from "babylonjs/Engines/engine";
  7482. import { Effect } from "babylonjs/Materials/effect";
  7483. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7484. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7485. import { Color3 } from "babylonjs/Maths/math.color";
  7486. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7487. /**
  7488. * Uniform buffer objects.
  7489. *
  7490. * Handles blocks of uniform on the GPU.
  7491. *
  7492. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7493. *
  7494. * For more information, please refer to :
  7495. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7496. */
  7497. export class UniformBuffer {
  7498. private _engine;
  7499. private _buffer;
  7500. private _data;
  7501. private _bufferData;
  7502. private _dynamic?;
  7503. private _uniformLocations;
  7504. private _uniformSizes;
  7505. private _uniformLocationPointer;
  7506. private _needSync;
  7507. private _noUBO;
  7508. private _currentEffect;
  7509. /** @hidden */
  7510. _alreadyBound: boolean;
  7511. private static _MAX_UNIFORM_SIZE;
  7512. private static _tempBuffer;
  7513. /**
  7514. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7515. * This is dynamic to allow compat with webgl 1 and 2.
  7516. * You will need to pass the name of the uniform as well as the value.
  7517. */
  7518. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7519. /**
  7520. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7521. * This is dynamic to allow compat with webgl 1 and 2.
  7522. * You will need to pass the name of the uniform as well as the value.
  7523. */
  7524. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7525. /**
  7526. * Lambda to Update a single float in a uniform buffer.
  7527. * This is dynamic to allow compat with webgl 1 and 2.
  7528. * You will need to pass the name of the uniform as well as the value.
  7529. */
  7530. updateFloat: (name: string, x: number) => void;
  7531. /**
  7532. * Lambda to Update a vec2 of float in a uniform buffer.
  7533. * This is dynamic to allow compat with webgl 1 and 2.
  7534. * You will need to pass the name of the uniform as well as the value.
  7535. */
  7536. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7537. /**
  7538. * Lambda to Update a vec3 of float in a uniform buffer.
  7539. * This is dynamic to allow compat with webgl 1 and 2.
  7540. * You will need to pass the name of the uniform as well as the value.
  7541. */
  7542. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7543. /**
  7544. * Lambda to Update a vec4 of float in a uniform buffer.
  7545. * This is dynamic to allow compat with webgl 1 and 2.
  7546. * You will need to pass the name of the uniform as well as the value.
  7547. */
  7548. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7549. /**
  7550. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7551. * This is dynamic to allow compat with webgl 1 and 2.
  7552. * You will need to pass the name of the uniform as well as the value.
  7553. */
  7554. updateMatrix: (name: string, mat: Matrix) => void;
  7555. /**
  7556. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7557. * This is dynamic to allow compat with webgl 1 and 2.
  7558. * You will need to pass the name of the uniform as well as the value.
  7559. */
  7560. updateVector3: (name: string, vector: Vector3) => void;
  7561. /**
  7562. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7563. * This is dynamic to allow compat with webgl 1 and 2.
  7564. * You will need to pass the name of the uniform as well as the value.
  7565. */
  7566. updateVector4: (name: string, vector: Vector4) => void;
  7567. /**
  7568. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7569. * This is dynamic to allow compat with webgl 1 and 2.
  7570. * You will need to pass the name of the uniform as well as the value.
  7571. */
  7572. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7573. /**
  7574. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7575. * This is dynamic to allow compat with webgl 1 and 2.
  7576. * You will need to pass the name of the uniform as well as the value.
  7577. */
  7578. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7579. /**
  7580. * Instantiates a new Uniform buffer objects.
  7581. *
  7582. * Handles blocks of uniform on the GPU.
  7583. *
  7584. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7585. *
  7586. * For more information, please refer to :
  7587. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7588. * @param engine Define the engine the buffer is associated with
  7589. * @param data Define the data contained in the buffer
  7590. * @param dynamic Define if the buffer is updatable
  7591. */
  7592. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7593. /**
  7594. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7595. * or just falling back on setUniformXXX calls.
  7596. */
  7597. get useUbo(): boolean;
  7598. /**
  7599. * Indicates if the WebGL underlying uniform buffer is in sync
  7600. * with the javascript cache data.
  7601. */
  7602. get isSync(): boolean;
  7603. /**
  7604. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7605. * Also, a dynamic UniformBuffer will disable cache verification and always
  7606. * update the underlying WebGL uniform buffer to the GPU.
  7607. * @returns if Dynamic, otherwise false
  7608. */
  7609. isDynamic(): boolean;
  7610. /**
  7611. * The data cache on JS side.
  7612. * @returns the underlying data as a float array
  7613. */
  7614. getData(): Float32Array;
  7615. /**
  7616. * The underlying WebGL Uniform buffer.
  7617. * @returns the webgl buffer
  7618. */
  7619. getBuffer(): Nullable<DataBuffer>;
  7620. /**
  7621. * std140 layout specifies how to align data within an UBO structure.
  7622. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7623. * for specs.
  7624. */
  7625. private _fillAlignment;
  7626. /**
  7627. * Adds an uniform in the buffer.
  7628. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7629. * for the layout to be correct !
  7630. * @param name Name of the uniform, as used in the uniform block in the shader.
  7631. * @param size Data size, or data directly.
  7632. */
  7633. addUniform(name: string, size: number | number[]): void;
  7634. /**
  7635. * Adds a Matrix 4x4 to the uniform buffer.
  7636. * @param name Name of the uniform, as used in the uniform block in the shader.
  7637. * @param mat A 4x4 matrix.
  7638. */
  7639. addMatrix(name: string, mat: Matrix): void;
  7640. /**
  7641. * Adds a vec2 to the uniform buffer.
  7642. * @param name Name of the uniform, as used in the uniform block in the shader.
  7643. * @param x Define the x component value of the vec2
  7644. * @param y Define the y component value of the vec2
  7645. */
  7646. addFloat2(name: string, x: number, y: number): void;
  7647. /**
  7648. * Adds a vec3 to the uniform buffer.
  7649. * @param name Name of the uniform, as used in the uniform block in the shader.
  7650. * @param x Define the x component value of the vec3
  7651. * @param y Define the y component value of the vec3
  7652. * @param z Define the z component value of the vec3
  7653. */
  7654. addFloat3(name: string, x: number, y: number, z: number): void;
  7655. /**
  7656. * Adds a vec3 to the uniform buffer.
  7657. * @param name Name of the uniform, as used in the uniform block in the shader.
  7658. * @param color Define the vec3 from a Color
  7659. */
  7660. addColor3(name: string, color: Color3): void;
  7661. /**
  7662. * Adds a vec4 to the uniform buffer.
  7663. * @param name Name of the uniform, as used in the uniform block in the shader.
  7664. * @param color Define the rgb components from a Color
  7665. * @param alpha Define the a component of the vec4
  7666. */
  7667. addColor4(name: string, color: Color3, alpha: number): void;
  7668. /**
  7669. * Adds a vec3 to the uniform buffer.
  7670. * @param name Name of the uniform, as used in the uniform block in the shader.
  7671. * @param vector Define the vec3 components from a Vector
  7672. */
  7673. addVector3(name: string, vector: Vector3): void;
  7674. /**
  7675. * Adds a Matrix 3x3 to the uniform buffer.
  7676. * @param name Name of the uniform, as used in the uniform block in the shader.
  7677. */
  7678. addMatrix3x3(name: string): void;
  7679. /**
  7680. * Adds a Matrix 2x2 to the uniform buffer.
  7681. * @param name Name of the uniform, as used in the uniform block in the shader.
  7682. */
  7683. addMatrix2x2(name: string): void;
  7684. /**
  7685. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7686. */
  7687. create(): void;
  7688. /** @hidden */
  7689. _rebuild(): void;
  7690. /**
  7691. * Updates the WebGL Uniform Buffer on the GPU.
  7692. * If the `dynamic` flag is set to true, no cache comparison is done.
  7693. * Otherwise, the buffer will be updated only if the cache differs.
  7694. */
  7695. update(): void;
  7696. /**
  7697. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7698. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7699. * @param data Define the flattened data
  7700. * @param size Define the size of the data.
  7701. */
  7702. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7703. private _valueCache;
  7704. private _cacheMatrix;
  7705. private _updateMatrix3x3ForUniform;
  7706. private _updateMatrix3x3ForEffect;
  7707. private _updateMatrix2x2ForEffect;
  7708. private _updateMatrix2x2ForUniform;
  7709. private _updateFloatForEffect;
  7710. private _updateFloatForUniform;
  7711. private _updateFloat2ForEffect;
  7712. private _updateFloat2ForUniform;
  7713. private _updateFloat3ForEffect;
  7714. private _updateFloat3ForUniform;
  7715. private _updateFloat4ForEffect;
  7716. private _updateFloat4ForUniform;
  7717. private _updateMatrixForEffect;
  7718. private _updateMatrixForUniform;
  7719. private _updateVector3ForEffect;
  7720. private _updateVector3ForUniform;
  7721. private _updateVector4ForEffect;
  7722. private _updateVector4ForUniform;
  7723. private _updateColor3ForEffect;
  7724. private _updateColor3ForUniform;
  7725. private _updateColor4ForEffect;
  7726. private _updateColor4ForUniform;
  7727. /**
  7728. * Sets a sampler uniform on the effect.
  7729. * @param name Define the name of the sampler.
  7730. * @param texture Define the texture to set in the sampler
  7731. */
  7732. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7733. /**
  7734. * Directly updates the value of the uniform in the cache AND on the GPU.
  7735. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7736. * @param data Define the flattened data
  7737. */
  7738. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7739. /**
  7740. * Binds this uniform buffer to an effect.
  7741. * @param effect Define the effect to bind the buffer to
  7742. * @param name Name of the uniform block in the shader.
  7743. */
  7744. bindToEffect(effect: Effect, name: string): void;
  7745. /**
  7746. * Disposes the uniform buffer.
  7747. */
  7748. dispose(): void;
  7749. }
  7750. }
  7751. declare module "babylonjs/Misc/iInspectable" {
  7752. /**
  7753. * Enum that determines the text-wrapping mode to use.
  7754. */
  7755. export enum InspectableType {
  7756. /**
  7757. * Checkbox for booleans
  7758. */
  7759. Checkbox = 0,
  7760. /**
  7761. * Sliders for numbers
  7762. */
  7763. Slider = 1,
  7764. /**
  7765. * Vector3
  7766. */
  7767. Vector3 = 2,
  7768. /**
  7769. * Quaternions
  7770. */
  7771. Quaternion = 3,
  7772. /**
  7773. * Color3
  7774. */
  7775. Color3 = 4,
  7776. /**
  7777. * String
  7778. */
  7779. String = 5
  7780. }
  7781. /**
  7782. * Interface used to define custom inspectable properties.
  7783. * This interface is used by the inspector to display custom property grids
  7784. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7785. */
  7786. export interface IInspectable {
  7787. /**
  7788. * Gets the label to display
  7789. */
  7790. label: string;
  7791. /**
  7792. * Gets the name of the property to edit
  7793. */
  7794. propertyName: string;
  7795. /**
  7796. * Gets the type of the editor to use
  7797. */
  7798. type: InspectableType;
  7799. /**
  7800. * Gets the minimum value of the property when using in "slider" mode
  7801. */
  7802. min?: number;
  7803. /**
  7804. * Gets the maximum value of the property when using in "slider" mode
  7805. */
  7806. max?: number;
  7807. /**
  7808. * Gets the setp to use when using in "slider" mode
  7809. */
  7810. step?: number;
  7811. }
  7812. }
  7813. declare module "babylonjs/Misc/timingTools" {
  7814. /**
  7815. * Class used to provide helper for timing
  7816. */
  7817. export class TimingTools {
  7818. /**
  7819. * Polyfill for setImmediate
  7820. * @param action defines the action to execute after the current execution block
  7821. */
  7822. static SetImmediate(action: () => void): void;
  7823. }
  7824. }
  7825. declare module "babylonjs/Misc/instantiationTools" {
  7826. /**
  7827. * Class used to enable instatition of objects by class name
  7828. */
  7829. export class InstantiationTools {
  7830. /**
  7831. * Use this object to register external classes like custom textures or material
  7832. * to allow the laoders to instantiate them
  7833. */
  7834. static RegisteredExternalClasses: {
  7835. [key: string]: Object;
  7836. };
  7837. /**
  7838. * Tries to instantiate a new object from a given class name
  7839. * @param className defines the class name to instantiate
  7840. * @returns the new object or null if the system was not able to do the instantiation
  7841. */
  7842. static Instantiate(className: string): any;
  7843. }
  7844. }
  7845. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7846. /**
  7847. * Define options used to create a depth texture
  7848. */
  7849. export class DepthTextureCreationOptions {
  7850. /** Specifies whether or not a stencil should be allocated in the texture */
  7851. generateStencil?: boolean;
  7852. /** Specifies whether or not bilinear filtering is enable on the texture */
  7853. bilinearFiltering?: boolean;
  7854. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7855. comparisonFunction?: number;
  7856. /** Specifies if the created texture is a cube texture */
  7857. isCube?: boolean;
  7858. }
  7859. }
  7860. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7861. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7862. import { Nullable } from "babylonjs/types";
  7863. import { Scene } from "babylonjs/scene";
  7864. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7865. module "babylonjs/Engines/thinEngine" {
  7866. interface ThinEngine {
  7867. /**
  7868. * Creates a depth stencil cube texture.
  7869. * This is only available in WebGL 2.
  7870. * @param size The size of face edge in the cube texture.
  7871. * @param options The options defining the cube texture.
  7872. * @returns The cube texture
  7873. */
  7874. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7875. /**
  7876. * Creates a cube texture
  7877. * @param rootUrl defines the url where the files to load is located
  7878. * @param scene defines the current scene
  7879. * @param files defines the list of files to load (1 per face)
  7880. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7881. * @param onLoad defines an optional callback raised when the texture is loaded
  7882. * @param onError defines an optional callback raised if there is an issue to load the texture
  7883. * @param format defines the format of the data
  7884. * @param forcedExtension defines the extension to use to pick the right loader
  7885. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7886. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7887. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7888. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7889. * @returns the cube texture as an InternalTexture
  7890. */
  7891. 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;
  7892. /**
  7893. * Creates a cube texture
  7894. * @param rootUrl defines the url where the files to load is located
  7895. * @param scene defines the current scene
  7896. * @param files defines the list of files to load (1 per face)
  7897. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7898. * @param onLoad defines an optional callback raised when the texture is loaded
  7899. * @param onError defines an optional callback raised if there is an issue to load the texture
  7900. * @param format defines the format of the data
  7901. * @param forcedExtension defines the extension to use to pick the right loader
  7902. * @returns the cube texture as an InternalTexture
  7903. */
  7904. 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;
  7905. /**
  7906. * Creates a cube texture
  7907. * @param rootUrl defines the url where the files to load is located
  7908. * @param scene defines the current scene
  7909. * @param files defines the list of files to load (1 per face)
  7910. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7911. * @param onLoad defines an optional callback raised when the texture is loaded
  7912. * @param onError defines an optional callback raised if there is an issue to load the texture
  7913. * @param format defines the format of the data
  7914. * @param forcedExtension defines the extension to use to pick the right loader
  7915. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7916. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7917. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7918. * @returns the cube texture as an InternalTexture
  7919. */
  7920. 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;
  7921. /** @hidden */
  7922. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7923. /** @hidden */
  7924. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7925. /** @hidden */
  7926. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7927. /** @hidden */
  7928. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7929. /**
  7930. * @hidden
  7931. */
  7932. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7933. }
  7934. }
  7935. }
  7936. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7937. import { Nullable } from "babylonjs/types";
  7938. import { Scene } from "babylonjs/scene";
  7939. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7940. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7941. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7942. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7943. import { Observable } from "babylonjs/Misc/observable";
  7944. /**
  7945. * Class for creating a cube texture
  7946. */
  7947. export class CubeTexture extends BaseTexture {
  7948. private _delayedOnLoad;
  7949. /**
  7950. * Observable triggered once the texture has been loaded.
  7951. */
  7952. onLoadObservable: Observable<CubeTexture>;
  7953. /**
  7954. * The url of the texture
  7955. */
  7956. url: string;
  7957. /**
  7958. * Gets or sets the center of the bounding box associated with the cube texture.
  7959. * It must define where the camera used to render the texture was set
  7960. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7961. */
  7962. boundingBoxPosition: Vector3;
  7963. private _boundingBoxSize;
  7964. /**
  7965. * Gets or sets the size of the bounding box associated with the cube texture
  7966. * When defined, the cubemap will switch to local mode
  7967. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7968. * @example https://www.babylonjs-playground.com/#RNASML
  7969. */
  7970. set boundingBoxSize(value: Vector3);
  7971. /**
  7972. * Returns the bounding box size
  7973. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7974. */
  7975. get boundingBoxSize(): Vector3;
  7976. protected _rotationY: number;
  7977. /**
  7978. * Sets texture matrix rotation angle around Y axis in radians.
  7979. */
  7980. set rotationY(value: number);
  7981. /**
  7982. * Gets texture matrix rotation angle around Y axis radians.
  7983. */
  7984. get rotationY(): number;
  7985. /**
  7986. * Are mip maps generated for this texture or not.
  7987. */
  7988. get noMipmap(): boolean;
  7989. private _noMipmap;
  7990. private _files;
  7991. protected _forcedExtension: Nullable<string>;
  7992. private _extensions;
  7993. private _textureMatrix;
  7994. private _format;
  7995. private _createPolynomials;
  7996. /**
  7997. * Creates a cube texture from an array of image urls
  7998. * @param files defines an array of image urls
  7999. * @param scene defines the hosting scene
  8000. * @param noMipmap specifies if mip maps are not used
  8001. * @returns a cube texture
  8002. */
  8003. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8004. /**
  8005. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8006. * @param url defines the url of the prefiltered texture
  8007. * @param scene defines the scene the texture is attached to
  8008. * @param forcedExtension defines the extension of the file if different from the url
  8009. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8010. * @return the prefiltered texture
  8011. */
  8012. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8013. /**
  8014. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8015. * as prefiltered data.
  8016. * @param rootUrl defines the url of the texture or the root name of the six images
  8017. * @param null defines the scene or engine the texture is attached to
  8018. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8019. * @param noMipmap defines if mipmaps should be created or not
  8020. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8021. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8022. * @param onError defines a callback triggered in case of error during load
  8023. * @param format defines the internal format to use for the texture once loaded
  8024. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8025. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8026. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8027. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8028. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8029. * @return the cube texture
  8030. */
  8031. 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);
  8032. /**
  8033. * Get the current class name of the texture useful for serialization or dynamic coding.
  8034. * @returns "CubeTexture"
  8035. */
  8036. getClassName(): string;
  8037. /**
  8038. * Update the url (and optional buffer) of this texture if url was null during construction.
  8039. * @param url the url of the texture
  8040. * @param forcedExtension defines the extension to use
  8041. * @param onLoad callback called when the texture is loaded (defaults to null)
  8042. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8043. */
  8044. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8045. /**
  8046. * Delays loading of the cube texture
  8047. * @param forcedExtension defines the extension to use
  8048. */
  8049. delayLoad(forcedExtension?: string): void;
  8050. /**
  8051. * Returns the reflection texture matrix
  8052. * @returns the reflection texture matrix
  8053. */
  8054. getReflectionTextureMatrix(): Matrix;
  8055. /**
  8056. * Sets the reflection texture matrix
  8057. * @param value Reflection texture matrix
  8058. */
  8059. setReflectionTextureMatrix(value: Matrix): void;
  8060. /**
  8061. * Parses text to create a cube texture
  8062. * @param parsedTexture define the serialized text to read from
  8063. * @param scene defines the hosting scene
  8064. * @param rootUrl defines the root url of the cube texture
  8065. * @returns a cube texture
  8066. */
  8067. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8068. /**
  8069. * Makes a clone, or deep copy, of the cube texture
  8070. * @returns a new cube texture
  8071. */
  8072. clone(): CubeTexture;
  8073. }
  8074. }
  8075. declare module "babylonjs/Materials/materialDefines" {
  8076. /**
  8077. * Manages the defines for the Material
  8078. */
  8079. export class MaterialDefines {
  8080. /** @hidden */
  8081. protected _keys: string[];
  8082. private _isDirty;
  8083. /** @hidden */
  8084. _renderId: number;
  8085. /** @hidden */
  8086. _areLightsDirty: boolean;
  8087. /** @hidden */
  8088. _areLightsDisposed: boolean;
  8089. /** @hidden */
  8090. _areAttributesDirty: boolean;
  8091. /** @hidden */
  8092. _areTexturesDirty: boolean;
  8093. /** @hidden */
  8094. _areFresnelDirty: boolean;
  8095. /** @hidden */
  8096. _areMiscDirty: boolean;
  8097. /** @hidden */
  8098. _areImageProcessingDirty: boolean;
  8099. /** @hidden */
  8100. _normals: boolean;
  8101. /** @hidden */
  8102. _uvs: boolean;
  8103. /** @hidden */
  8104. _needNormals: boolean;
  8105. /** @hidden */
  8106. _needUVs: boolean;
  8107. [id: string]: any;
  8108. /**
  8109. * Specifies if the material needs to be re-calculated
  8110. */
  8111. get isDirty(): boolean;
  8112. /**
  8113. * Marks the material to indicate that it has been re-calculated
  8114. */
  8115. markAsProcessed(): void;
  8116. /**
  8117. * Marks the material to indicate that it needs to be re-calculated
  8118. */
  8119. markAsUnprocessed(): void;
  8120. /**
  8121. * Marks the material to indicate all of its defines need to be re-calculated
  8122. */
  8123. markAllAsDirty(): void;
  8124. /**
  8125. * Marks the material to indicate that image processing needs to be re-calculated
  8126. */
  8127. markAsImageProcessingDirty(): void;
  8128. /**
  8129. * Marks the material to indicate the lights need to be re-calculated
  8130. * @param disposed Defines whether the light is dirty due to dispose or not
  8131. */
  8132. markAsLightDirty(disposed?: boolean): void;
  8133. /**
  8134. * Marks the attribute state as changed
  8135. */
  8136. markAsAttributesDirty(): void;
  8137. /**
  8138. * Marks the texture state as changed
  8139. */
  8140. markAsTexturesDirty(): void;
  8141. /**
  8142. * Marks the fresnel state as changed
  8143. */
  8144. markAsFresnelDirty(): void;
  8145. /**
  8146. * Marks the misc state as changed
  8147. */
  8148. markAsMiscDirty(): void;
  8149. /**
  8150. * Rebuilds the material defines
  8151. */
  8152. rebuild(): void;
  8153. /**
  8154. * Specifies if two material defines are equal
  8155. * @param other - A material define instance to compare to
  8156. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8157. */
  8158. isEqual(other: MaterialDefines): boolean;
  8159. /**
  8160. * Clones this instance's defines to another instance
  8161. * @param other - material defines to clone values to
  8162. */
  8163. cloneTo(other: MaterialDefines): void;
  8164. /**
  8165. * Resets the material define values
  8166. */
  8167. reset(): void;
  8168. /**
  8169. * Converts the material define values to a string
  8170. * @returns - String of material define information
  8171. */
  8172. toString(): string;
  8173. }
  8174. }
  8175. declare module "babylonjs/Materials/colorCurves" {
  8176. import { Effect } from "babylonjs/Materials/effect";
  8177. /**
  8178. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8179. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8180. * 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;
  8181. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8182. */
  8183. export class ColorCurves {
  8184. private _dirty;
  8185. private _tempColor;
  8186. private _globalCurve;
  8187. private _highlightsCurve;
  8188. private _midtonesCurve;
  8189. private _shadowsCurve;
  8190. private _positiveCurve;
  8191. private _negativeCurve;
  8192. private _globalHue;
  8193. private _globalDensity;
  8194. private _globalSaturation;
  8195. private _globalExposure;
  8196. /**
  8197. * Gets the global Hue value.
  8198. * 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).
  8199. */
  8200. get globalHue(): number;
  8201. /**
  8202. * Sets the global Hue value.
  8203. * 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).
  8204. */
  8205. set globalHue(value: number);
  8206. /**
  8207. * Gets the global Density value.
  8208. * 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.
  8209. * Values less than zero provide a filter of opposite hue.
  8210. */
  8211. get globalDensity(): number;
  8212. /**
  8213. * Sets the global Density value.
  8214. * 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.
  8215. * Values less than zero provide a filter of opposite hue.
  8216. */
  8217. set globalDensity(value: number);
  8218. /**
  8219. * Gets the global Saturation value.
  8220. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8221. */
  8222. get globalSaturation(): number;
  8223. /**
  8224. * Sets the global Saturation value.
  8225. * 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.
  8226. */
  8227. set globalSaturation(value: number);
  8228. /**
  8229. * Gets the global Exposure value.
  8230. * 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.
  8231. */
  8232. get globalExposure(): number;
  8233. /**
  8234. * Sets the global Exposure value.
  8235. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8236. */
  8237. set globalExposure(value: number);
  8238. private _highlightsHue;
  8239. private _highlightsDensity;
  8240. private _highlightsSaturation;
  8241. private _highlightsExposure;
  8242. /**
  8243. * Gets the highlights Hue value.
  8244. * 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).
  8245. */
  8246. get highlightsHue(): number;
  8247. /**
  8248. * Sets the highlights Hue value.
  8249. * 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).
  8250. */
  8251. set highlightsHue(value: number);
  8252. /**
  8253. * Gets the highlights Density value.
  8254. * 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.
  8255. * Values less than zero provide a filter of opposite hue.
  8256. */
  8257. get highlightsDensity(): number;
  8258. /**
  8259. * Sets the highlights Density value.
  8260. * 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.
  8261. * Values less than zero provide a filter of opposite hue.
  8262. */
  8263. set highlightsDensity(value: number);
  8264. /**
  8265. * Gets the highlights Saturation value.
  8266. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8267. */
  8268. get highlightsSaturation(): number;
  8269. /**
  8270. * Sets the highlights Saturation value.
  8271. * 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.
  8272. */
  8273. set highlightsSaturation(value: number);
  8274. /**
  8275. * Gets the highlights Exposure value.
  8276. * 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.
  8277. */
  8278. get highlightsExposure(): number;
  8279. /**
  8280. * Sets the highlights Exposure value.
  8281. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8282. */
  8283. set highlightsExposure(value: number);
  8284. private _midtonesHue;
  8285. private _midtonesDensity;
  8286. private _midtonesSaturation;
  8287. private _midtonesExposure;
  8288. /**
  8289. * Gets the midtones Hue value.
  8290. * 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).
  8291. */
  8292. get midtonesHue(): number;
  8293. /**
  8294. * Sets the midtones Hue value.
  8295. * 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).
  8296. */
  8297. set midtonesHue(value: number);
  8298. /**
  8299. * Gets the midtones Density value.
  8300. * 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.
  8301. * Values less than zero provide a filter of opposite hue.
  8302. */
  8303. get midtonesDensity(): number;
  8304. /**
  8305. * Sets the midtones Density value.
  8306. * 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.
  8307. * Values less than zero provide a filter of opposite hue.
  8308. */
  8309. set midtonesDensity(value: number);
  8310. /**
  8311. * Gets the midtones Saturation value.
  8312. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8313. */
  8314. get midtonesSaturation(): number;
  8315. /**
  8316. * Sets the midtones Saturation value.
  8317. * 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.
  8318. */
  8319. set midtonesSaturation(value: number);
  8320. /**
  8321. * Gets the midtones Exposure value.
  8322. * 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.
  8323. */
  8324. get midtonesExposure(): number;
  8325. /**
  8326. * Sets the midtones Exposure value.
  8327. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8328. */
  8329. set midtonesExposure(value: number);
  8330. private _shadowsHue;
  8331. private _shadowsDensity;
  8332. private _shadowsSaturation;
  8333. private _shadowsExposure;
  8334. /**
  8335. * Gets the shadows Hue value.
  8336. * 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).
  8337. */
  8338. get shadowsHue(): number;
  8339. /**
  8340. * Sets the shadows Hue value.
  8341. * 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).
  8342. */
  8343. set shadowsHue(value: number);
  8344. /**
  8345. * Gets the shadows Density value.
  8346. * 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.
  8347. * Values less than zero provide a filter of opposite hue.
  8348. */
  8349. get shadowsDensity(): number;
  8350. /**
  8351. * Sets the shadows Density value.
  8352. * 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.
  8353. * Values less than zero provide a filter of opposite hue.
  8354. */
  8355. set shadowsDensity(value: number);
  8356. /**
  8357. * Gets the shadows Saturation value.
  8358. * 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.
  8359. */
  8360. get shadowsSaturation(): number;
  8361. /**
  8362. * Sets the shadows Saturation value.
  8363. * 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.
  8364. */
  8365. set shadowsSaturation(value: number);
  8366. /**
  8367. * Gets the shadows Exposure value.
  8368. * 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.
  8369. */
  8370. get shadowsExposure(): number;
  8371. /**
  8372. * Sets the shadows Exposure value.
  8373. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8374. */
  8375. set shadowsExposure(value: number);
  8376. /**
  8377. * Returns the class name
  8378. * @returns The class name
  8379. */
  8380. getClassName(): string;
  8381. /**
  8382. * Binds the color curves to the shader.
  8383. * @param colorCurves The color curve to bind
  8384. * @param effect The effect to bind to
  8385. * @param positiveUniform The positive uniform shader parameter
  8386. * @param neutralUniform The neutral uniform shader parameter
  8387. * @param negativeUniform The negative uniform shader parameter
  8388. */
  8389. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8390. /**
  8391. * Prepare the list of uniforms associated with the ColorCurves effects.
  8392. * @param uniformsList The list of uniforms used in the effect
  8393. */
  8394. static PrepareUniforms(uniformsList: string[]): void;
  8395. /**
  8396. * Returns color grading data based on a hue, density, saturation and exposure value.
  8397. * @param filterHue The hue of the color filter.
  8398. * @param filterDensity The density of the color filter.
  8399. * @param saturation The saturation.
  8400. * @param exposure The exposure.
  8401. * @param result The result data container.
  8402. */
  8403. private getColorGradingDataToRef;
  8404. /**
  8405. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8406. * @param value The input slider value in range [-100,100].
  8407. * @returns Adjusted value.
  8408. */
  8409. private static applyColorGradingSliderNonlinear;
  8410. /**
  8411. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8412. * @param hue The hue (H) input.
  8413. * @param saturation The saturation (S) input.
  8414. * @param brightness The brightness (B) input.
  8415. * @result An RGBA color represented as Vector4.
  8416. */
  8417. private static fromHSBToRef;
  8418. /**
  8419. * Returns a value clamped between min and max
  8420. * @param value The value to clamp
  8421. * @param min The minimum of value
  8422. * @param max The maximum of value
  8423. * @returns The clamped value.
  8424. */
  8425. private static clamp;
  8426. /**
  8427. * Clones the current color curve instance.
  8428. * @return The cloned curves
  8429. */
  8430. clone(): ColorCurves;
  8431. /**
  8432. * Serializes the current color curve instance to a json representation.
  8433. * @return a JSON representation
  8434. */
  8435. serialize(): any;
  8436. /**
  8437. * Parses the color curve from a json representation.
  8438. * @param source the JSON source to parse
  8439. * @return The parsed curves
  8440. */
  8441. static Parse(source: any): ColorCurves;
  8442. }
  8443. }
  8444. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8445. import { Observable } from "babylonjs/Misc/observable";
  8446. import { Nullable } from "babylonjs/types";
  8447. import { Color4 } from "babylonjs/Maths/math.color";
  8448. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8449. import { Effect } from "babylonjs/Materials/effect";
  8450. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8451. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8452. /**
  8453. * Interface to follow in your material defines to integrate easily the
  8454. * Image proccessing functions.
  8455. * @hidden
  8456. */
  8457. export interface IImageProcessingConfigurationDefines {
  8458. IMAGEPROCESSING: boolean;
  8459. VIGNETTE: boolean;
  8460. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8461. VIGNETTEBLENDMODEOPAQUE: boolean;
  8462. TONEMAPPING: boolean;
  8463. TONEMAPPING_ACES: boolean;
  8464. CONTRAST: boolean;
  8465. EXPOSURE: boolean;
  8466. COLORCURVES: boolean;
  8467. COLORGRADING: boolean;
  8468. COLORGRADING3D: boolean;
  8469. SAMPLER3DGREENDEPTH: boolean;
  8470. SAMPLER3DBGRMAP: boolean;
  8471. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8472. }
  8473. /**
  8474. * @hidden
  8475. */
  8476. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8477. IMAGEPROCESSING: boolean;
  8478. VIGNETTE: boolean;
  8479. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8480. VIGNETTEBLENDMODEOPAQUE: boolean;
  8481. TONEMAPPING: boolean;
  8482. TONEMAPPING_ACES: boolean;
  8483. CONTRAST: boolean;
  8484. COLORCURVES: boolean;
  8485. COLORGRADING: boolean;
  8486. COLORGRADING3D: boolean;
  8487. SAMPLER3DGREENDEPTH: boolean;
  8488. SAMPLER3DBGRMAP: boolean;
  8489. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8490. EXPOSURE: boolean;
  8491. constructor();
  8492. }
  8493. /**
  8494. * This groups together the common properties used for image processing either in direct forward pass
  8495. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8496. * or not.
  8497. */
  8498. export class ImageProcessingConfiguration {
  8499. /**
  8500. * Default tone mapping applied in BabylonJS.
  8501. */
  8502. static readonly TONEMAPPING_STANDARD: number;
  8503. /**
  8504. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8505. * to other engines rendering to increase portability.
  8506. */
  8507. static readonly TONEMAPPING_ACES: number;
  8508. /**
  8509. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8510. */
  8511. colorCurves: Nullable<ColorCurves>;
  8512. private _colorCurvesEnabled;
  8513. /**
  8514. * Gets wether the color curves effect is enabled.
  8515. */
  8516. get colorCurvesEnabled(): boolean;
  8517. /**
  8518. * Sets wether the color curves effect is enabled.
  8519. */
  8520. set colorCurvesEnabled(value: boolean);
  8521. private _colorGradingTexture;
  8522. /**
  8523. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8524. */
  8525. get colorGradingTexture(): Nullable<BaseTexture>;
  8526. /**
  8527. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8528. */
  8529. set colorGradingTexture(value: Nullable<BaseTexture>);
  8530. private _colorGradingEnabled;
  8531. /**
  8532. * Gets wether the color grading effect is enabled.
  8533. */
  8534. get colorGradingEnabled(): boolean;
  8535. /**
  8536. * Sets wether the color grading effect is enabled.
  8537. */
  8538. set colorGradingEnabled(value: boolean);
  8539. private _colorGradingWithGreenDepth;
  8540. /**
  8541. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8542. */
  8543. get colorGradingWithGreenDepth(): boolean;
  8544. /**
  8545. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8546. */
  8547. set colorGradingWithGreenDepth(value: boolean);
  8548. private _colorGradingBGR;
  8549. /**
  8550. * Gets wether the color grading texture contains BGR values.
  8551. */
  8552. get colorGradingBGR(): boolean;
  8553. /**
  8554. * Sets wether the color grading texture contains BGR values.
  8555. */
  8556. set colorGradingBGR(value: boolean);
  8557. /** @hidden */
  8558. _exposure: number;
  8559. /**
  8560. * Gets the Exposure used in the effect.
  8561. */
  8562. get exposure(): number;
  8563. /**
  8564. * Sets the Exposure used in the effect.
  8565. */
  8566. set exposure(value: number);
  8567. private _toneMappingEnabled;
  8568. /**
  8569. * Gets wether the tone mapping effect is enabled.
  8570. */
  8571. get toneMappingEnabled(): boolean;
  8572. /**
  8573. * Sets wether the tone mapping effect is enabled.
  8574. */
  8575. set toneMappingEnabled(value: boolean);
  8576. private _toneMappingType;
  8577. /**
  8578. * Gets the type of tone mapping effect.
  8579. */
  8580. get toneMappingType(): number;
  8581. /**
  8582. * Sets the type of tone mapping effect used in BabylonJS.
  8583. */
  8584. set toneMappingType(value: number);
  8585. protected _contrast: number;
  8586. /**
  8587. * Gets the contrast used in the effect.
  8588. */
  8589. get contrast(): number;
  8590. /**
  8591. * Sets the contrast used in the effect.
  8592. */
  8593. set contrast(value: number);
  8594. /**
  8595. * Vignette stretch size.
  8596. */
  8597. vignetteStretch: number;
  8598. /**
  8599. * Vignette centre X Offset.
  8600. */
  8601. vignetteCentreX: number;
  8602. /**
  8603. * Vignette centre Y Offset.
  8604. */
  8605. vignetteCentreY: number;
  8606. /**
  8607. * Vignette weight or intensity of the vignette effect.
  8608. */
  8609. vignetteWeight: number;
  8610. /**
  8611. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8612. * if vignetteEnabled is set to true.
  8613. */
  8614. vignetteColor: Color4;
  8615. /**
  8616. * Camera field of view used by the Vignette effect.
  8617. */
  8618. vignetteCameraFov: number;
  8619. private _vignetteBlendMode;
  8620. /**
  8621. * Gets the vignette blend mode allowing different kind of effect.
  8622. */
  8623. get vignetteBlendMode(): number;
  8624. /**
  8625. * Sets the vignette blend mode allowing different kind of effect.
  8626. */
  8627. set vignetteBlendMode(value: number);
  8628. private _vignetteEnabled;
  8629. /**
  8630. * Gets wether the vignette effect is enabled.
  8631. */
  8632. get vignetteEnabled(): boolean;
  8633. /**
  8634. * Sets wether the vignette effect is enabled.
  8635. */
  8636. set vignetteEnabled(value: boolean);
  8637. private _applyByPostProcess;
  8638. /**
  8639. * Gets wether the image processing is applied through a post process or not.
  8640. */
  8641. get applyByPostProcess(): boolean;
  8642. /**
  8643. * Sets wether the image processing is applied through a post process or not.
  8644. */
  8645. set applyByPostProcess(value: boolean);
  8646. private _isEnabled;
  8647. /**
  8648. * Gets wether the image processing is enabled or not.
  8649. */
  8650. get isEnabled(): boolean;
  8651. /**
  8652. * Sets wether the image processing is enabled or not.
  8653. */
  8654. set isEnabled(value: boolean);
  8655. /**
  8656. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8657. */
  8658. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8659. /**
  8660. * Method called each time the image processing information changes requires to recompile the effect.
  8661. */
  8662. protected _updateParameters(): void;
  8663. /**
  8664. * Gets the current class name.
  8665. * @return "ImageProcessingConfiguration"
  8666. */
  8667. getClassName(): string;
  8668. /**
  8669. * Prepare the list of uniforms associated with the Image Processing effects.
  8670. * @param uniforms The list of uniforms used in the effect
  8671. * @param defines the list of defines currently in use
  8672. */
  8673. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8674. /**
  8675. * Prepare the list of samplers associated with the Image Processing effects.
  8676. * @param samplersList The list of uniforms used in the effect
  8677. * @param defines the list of defines currently in use
  8678. */
  8679. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8680. /**
  8681. * Prepare the list of defines associated to the shader.
  8682. * @param defines the list of defines to complete
  8683. * @param forPostProcess Define if we are currently in post process mode or not
  8684. */
  8685. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8686. /**
  8687. * Returns true if all the image processing information are ready.
  8688. * @returns True if ready, otherwise, false
  8689. */
  8690. isReady(): boolean;
  8691. /**
  8692. * Binds the image processing to the shader.
  8693. * @param effect The effect to bind to
  8694. * @param overrideAspectRatio Override the aspect ratio of the effect
  8695. */
  8696. bind(effect: Effect, overrideAspectRatio?: number): void;
  8697. /**
  8698. * Clones the current image processing instance.
  8699. * @return The cloned image processing
  8700. */
  8701. clone(): ImageProcessingConfiguration;
  8702. /**
  8703. * Serializes the current image processing instance to a json representation.
  8704. * @return a JSON representation
  8705. */
  8706. serialize(): any;
  8707. /**
  8708. * Parses the image processing from a json representation.
  8709. * @param source the JSON source to parse
  8710. * @return The parsed image processing
  8711. */
  8712. static Parse(source: any): ImageProcessingConfiguration;
  8713. private static _VIGNETTEMODE_MULTIPLY;
  8714. private static _VIGNETTEMODE_OPAQUE;
  8715. /**
  8716. * Used to apply the vignette as a mix with the pixel color.
  8717. */
  8718. static get VIGNETTEMODE_MULTIPLY(): number;
  8719. /**
  8720. * Used to apply the vignette as a replacement of the pixel color.
  8721. */
  8722. static get VIGNETTEMODE_OPAQUE(): number;
  8723. }
  8724. }
  8725. declare module "babylonjs/Shaders/postprocess.vertex" {
  8726. /** @hidden */
  8727. export var postprocessVertexShader: {
  8728. name: string;
  8729. shader: string;
  8730. };
  8731. }
  8732. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8733. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8734. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8735. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8736. /**
  8737. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8738. */
  8739. export type RenderTargetTextureSize = number | {
  8740. width: number;
  8741. height: number;
  8742. layers?: number;
  8743. };
  8744. module "babylonjs/Engines/thinEngine" {
  8745. interface ThinEngine {
  8746. /**
  8747. * Creates a new render target texture
  8748. * @param size defines the size of the texture
  8749. * @param options defines the options used to create the texture
  8750. * @returns a new render target texture stored in an InternalTexture
  8751. */
  8752. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8753. /**
  8754. * Creates a depth stencil texture.
  8755. * This is only available in WebGL 2 or with the depth texture extension available.
  8756. * @param size The size of face edge in the texture.
  8757. * @param options The options defining the texture.
  8758. * @returns The texture
  8759. */
  8760. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8761. /** @hidden */
  8762. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8763. }
  8764. }
  8765. }
  8766. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8767. /**
  8768. * Defines the kind of connection point for node based material
  8769. */
  8770. export enum NodeMaterialBlockConnectionPointTypes {
  8771. /** Float */
  8772. Float = 1,
  8773. /** Int */
  8774. Int = 2,
  8775. /** Vector2 */
  8776. Vector2 = 4,
  8777. /** Vector3 */
  8778. Vector3 = 8,
  8779. /** Vector4 */
  8780. Vector4 = 16,
  8781. /** Color3 */
  8782. Color3 = 32,
  8783. /** Color4 */
  8784. Color4 = 64,
  8785. /** Matrix */
  8786. Matrix = 128,
  8787. /** Custom object */
  8788. Object = 256,
  8789. /** Detect type based on connection */
  8790. AutoDetect = 1024,
  8791. /** Output type that will be defined by input type */
  8792. BasedOnInput = 2048
  8793. }
  8794. }
  8795. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8796. /**
  8797. * Enum used to define the target of a block
  8798. */
  8799. export enum NodeMaterialBlockTargets {
  8800. /** Vertex shader */
  8801. Vertex = 1,
  8802. /** Fragment shader */
  8803. Fragment = 2,
  8804. /** Neutral */
  8805. Neutral = 4,
  8806. /** Vertex and Fragment */
  8807. VertexAndFragment = 3
  8808. }
  8809. }
  8810. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8811. /**
  8812. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8813. */
  8814. export enum NodeMaterialBlockConnectionPointMode {
  8815. /** Value is an uniform */
  8816. Uniform = 0,
  8817. /** Value is a mesh attribute */
  8818. Attribute = 1,
  8819. /** Value is a varying between vertex and fragment shaders */
  8820. Varying = 2,
  8821. /** Mode is undefined */
  8822. Undefined = 3
  8823. }
  8824. }
  8825. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8826. /**
  8827. * Enum used to define system values e.g. values automatically provided by the system
  8828. */
  8829. export enum NodeMaterialSystemValues {
  8830. /** World */
  8831. World = 1,
  8832. /** View */
  8833. View = 2,
  8834. /** Projection */
  8835. Projection = 3,
  8836. /** ViewProjection */
  8837. ViewProjection = 4,
  8838. /** WorldView */
  8839. WorldView = 5,
  8840. /** WorldViewProjection */
  8841. WorldViewProjection = 6,
  8842. /** CameraPosition */
  8843. CameraPosition = 7,
  8844. /** Fog Color */
  8845. FogColor = 8,
  8846. /** Delta time */
  8847. DeltaTime = 9
  8848. }
  8849. }
  8850. declare module "babylonjs/Maths/math.axis" {
  8851. import { Vector3 } from "babylonjs/Maths/math.vector";
  8852. /** Defines supported spaces */
  8853. export enum Space {
  8854. /** Local (object) space */
  8855. LOCAL = 0,
  8856. /** World space */
  8857. WORLD = 1,
  8858. /** Bone space */
  8859. BONE = 2
  8860. }
  8861. /** Defines the 3 main axes */
  8862. export class Axis {
  8863. /** X axis */
  8864. static X: Vector3;
  8865. /** Y axis */
  8866. static Y: Vector3;
  8867. /** Z axis */
  8868. static Z: Vector3;
  8869. }
  8870. }
  8871. declare module "babylonjs/Maths/math.frustum" {
  8872. import { Matrix } from "babylonjs/Maths/math.vector";
  8873. import { DeepImmutable } from "babylonjs/types";
  8874. import { Plane } from "babylonjs/Maths/math.plane";
  8875. /**
  8876. * Represents a camera frustum
  8877. */
  8878. export class Frustum {
  8879. /**
  8880. * Gets the planes representing the frustum
  8881. * @param transform matrix to be applied to the returned planes
  8882. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8883. */
  8884. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8885. /**
  8886. * Gets the near frustum plane transformed by the transform matrix
  8887. * @param transform transformation matrix to be applied to the resulting frustum plane
  8888. * @param frustumPlane the resuling frustum plane
  8889. */
  8890. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8891. /**
  8892. * Gets the far frustum plane transformed by the transform matrix
  8893. * @param transform transformation matrix to be applied to the resulting frustum plane
  8894. * @param frustumPlane the resuling frustum plane
  8895. */
  8896. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8897. /**
  8898. * Gets the left frustum plane transformed by the transform matrix
  8899. * @param transform transformation matrix to be applied to the resulting frustum plane
  8900. * @param frustumPlane the resuling frustum plane
  8901. */
  8902. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8903. /**
  8904. * Gets the right frustum plane transformed by the transform matrix
  8905. * @param transform transformation matrix to be applied to the resulting frustum plane
  8906. * @param frustumPlane the resuling frustum plane
  8907. */
  8908. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8909. /**
  8910. * Gets the top frustum plane transformed by the transform matrix
  8911. * @param transform transformation matrix to be applied to the resulting frustum plane
  8912. * @param frustumPlane the resuling frustum plane
  8913. */
  8914. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8915. /**
  8916. * Gets the bottom frustum plane transformed by the transform matrix
  8917. * @param transform transformation matrix to be applied to the resulting frustum plane
  8918. * @param frustumPlane the resuling frustum plane
  8919. */
  8920. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8921. /**
  8922. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8923. * @param transform transformation matrix to be applied to the resulting frustum planes
  8924. * @param frustumPlanes the resuling frustum planes
  8925. */
  8926. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8927. }
  8928. }
  8929. declare module "babylonjs/Maths/math.size" {
  8930. /**
  8931. * Interface for the size containing width and height
  8932. */
  8933. export interface ISize {
  8934. /**
  8935. * Width
  8936. */
  8937. width: number;
  8938. /**
  8939. * Heighht
  8940. */
  8941. height: number;
  8942. }
  8943. /**
  8944. * Size containing widht and height
  8945. */
  8946. export class Size implements ISize {
  8947. /**
  8948. * Width
  8949. */
  8950. width: number;
  8951. /**
  8952. * Height
  8953. */
  8954. height: number;
  8955. /**
  8956. * Creates a Size object from the given width and height (floats).
  8957. * @param width width of the new size
  8958. * @param height height of the new size
  8959. */
  8960. constructor(width: number, height: number);
  8961. /**
  8962. * Returns a string with the Size width and height
  8963. * @returns a string with the Size width and height
  8964. */
  8965. toString(): string;
  8966. /**
  8967. * "Size"
  8968. * @returns the string "Size"
  8969. */
  8970. getClassName(): string;
  8971. /**
  8972. * Returns the Size hash code.
  8973. * @returns a hash code for a unique width and height
  8974. */
  8975. getHashCode(): number;
  8976. /**
  8977. * Updates the current size from the given one.
  8978. * @param src the given size
  8979. */
  8980. copyFrom(src: Size): void;
  8981. /**
  8982. * Updates in place the current Size from the given floats.
  8983. * @param width width of the new size
  8984. * @param height height of the new size
  8985. * @returns the updated Size.
  8986. */
  8987. copyFromFloats(width: number, height: number): Size;
  8988. /**
  8989. * Updates in place the current Size from the given floats.
  8990. * @param width width to set
  8991. * @param height height to set
  8992. * @returns the updated Size.
  8993. */
  8994. set(width: number, height: number): Size;
  8995. /**
  8996. * Multiplies the width and height by numbers
  8997. * @param w factor to multiple the width by
  8998. * @param h factor to multiple the height by
  8999. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9000. */
  9001. multiplyByFloats(w: number, h: number): Size;
  9002. /**
  9003. * Clones the size
  9004. * @returns a new Size copied from the given one.
  9005. */
  9006. clone(): Size;
  9007. /**
  9008. * True if the current Size and the given one width and height are strictly equal.
  9009. * @param other the other size to compare against
  9010. * @returns True if the current Size and the given one width and height are strictly equal.
  9011. */
  9012. equals(other: Size): boolean;
  9013. /**
  9014. * The surface of the Size : width * height (float).
  9015. */
  9016. get surface(): number;
  9017. /**
  9018. * Create a new size of zero
  9019. * @returns a new Size set to (0.0, 0.0)
  9020. */
  9021. static Zero(): Size;
  9022. /**
  9023. * Sums the width and height of two sizes
  9024. * @param otherSize size to add to this size
  9025. * @returns a new Size set as the addition result of the current Size and the given one.
  9026. */
  9027. add(otherSize: Size): Size;
  9028. /**
  9029. * Subtracts the width and height of two
  9030. * @param otherSize size to subtract to this size
  9031. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9032. */
  9033. subtract(otherSize: Size): Size;
  9034. /**
  9035. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9036. * @param start starting size to lerp between
  9037. * @param end end size to lerp between
  9038. * @param amount amount to lerp between the start and end values
  9039. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9040. */
  9041. static Lerp(start: Size, end: Size, amount: number): Size;
  9042. }
  9043. }
  9044. declare module "babylonjs/Maths/math.vertexFormat" {
  9045. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9046. /**
  9047. * Contains position and normal vectors for a vertex
  9048. */
  9049. export class PositionNormalVertex {
  9050. /** the position of the vertex (defaut: 0,0,0) */
  9051. position: Vector3;
  9052. /** the normal of the vertex (defaut: 0,1,0) */
  9053. normal: Vector3;
  9054. /**
  9055. * Creates a PositionNormalVertex
  9056. * @param position the position of the vertex (defaut: 0,0,0)
  9057. * @param normal the normal of the vertex (defaut: 0,1,0)
  9058. */
  9059. constructor(
  9060. /** the position of the vertex (defaut: 0,0,0) */
  9061. position?: Vector3,
  9062. /** the normal of the vertex (defaut: 0,1,0) */
  9063. normal?: Vector3);
  9064. /**
  9065. * Clones the PositionNormalVertex
  9066. * @returns the cloned PositionNormalVertex
  9067. */
  9068. clone(): PositionNormalVertex;
  9069. }
  9070. /**
  9071. * Contains position, normal and uv vectors for a vertex
  9072. */
  9073. export class PositionNormalTextureVertex {
  9074. /** the position of the vertex (defaut: 0,0,0) */
  9075. position: Vector3;
  9076. /** the normal of the vertex (defaut: 0,1,0) */
  9077. normal: Vector3;
  9078. /** the uv of the vertex (default: 0,0) */
  9079. uv: Vector2;
  9080. /**
  9081. * Creates a PositionNormalTextureVertex
  9082. * @param position the position of the vertex (defaut: 0,0,0)
  9083. * @param normal the normal of the vertex (defaut: 0,1,0)
  9084. * @param uv the uv of the vertex (default: 0,0)
  9085. */
  9086. constructor(
  9087. /** the position of the vertex (defaut: 0,0,0) */
  9088. position?: Vector3,
  9089. /** the normal of the vertex (defaut: 0,1,0) */
  9090. normal?: Vector3,
  9091. /** the uv of the vertex (default: 0,0) */
  9092. uv?: Vector2);
  9093. /**
  9094. * Clones the PositionNormalTextureVertex
  9095. * @returns the cloned PositionNormalTextureVertex
  9096. */
  9097. clone(): PositionNormalTextureVertex;
  9098. }
  9099. }
  9100. declare module "babylonjs/Maths/math" {
  9101. export * from "babylonjs/Maths/math.axis";
  9102. export * from "babylonjs/Maths/math.color";
  9103. export * from "babylonjs/Maths/math.constants";
  9104. export * from "babylonjs/Maths/math.frustum";
  9105. export * from "babylonjs/Maths/math.path";
  9106. export * from "babylonjs/Maths/math.plane";
  9107. export * from "babylonjs/Maths/math.size";
  9108. export * from "babylonjs/Maths/math.vector";
  9109. export * from "babylonjs/Maths/math.vertexFormat";
  9110. export * from "babylonjs/Maths/math.viewport";
  9111. }
  9112. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9113. /**
  9114. * Enum defining the type of animations supported by InputBlock
  9115. */
  9116. export enum AnimatedInputBlockTypes {
  9117. /** No animation */
  9118. None = 0,
  9119. /** Time based animation. Will only work for floats */
  9120. Time = 1
  9121. }
  9122. }
  9123. declare module "babylonjs/Lights/shadowLight" {
  9124. import { Camera } from "babylonjs/Cameras/camera";
  9125. import { Scene } from "babylonjs/scene";
  9126. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9128. import { Light } from "babylonjs/Lights/light";
  9129. /**
  9130. * Interface describing all the common properties and methods a shadow light needs to implement.
  9131. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9132. * as well as binding the different shadow properties to the effects.
  9133. */
  9134. export interface IShadowLight extends Light {
  9135. /**
  9136. * The light id in the scene (used in scene.findLighById for instance)
  9137. */
  9138. id: string;
  9139. /**
  9140. * The position the shdow will be casted from.
  9141. */
  9142. position: Vector3;
  9143. /**
  9144. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9145. */
  9146. direction: Vector3;
  9147. /**
  9148. * The transformed position. Position of the light in world space taking parenting in account.
  9149. */
  9150. transformedPosition: Vector3;
  9151. /**
  9152. * The transformed direction. Direction of the light in world space taking parenting in account.
  9153. */
  9154. transformedDirection: Vector3;
  9155. /**
  9156. * The friendly name of the light in the scene.
  9157. */
  9158. name: string;
  9159. /**
  9160. * Defines the shadow projection clipping minimum z value.
  9161. */
  9162. shadowMinZ: number;
  9163. /**
  9164. * Defines the shadow projection clipping maximum z value.
  9165. */
  9166. shadowMaxZ: number;
  9167. /**
  9168. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9169. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9170. */
  9171. computeTransformedInformation(): boolean;
  9172. /**
  9173. * Gets the scene the light belongs to.
  9174. * @returns The scene
  9175. */
  9176. getScene(): Scene;
  9177. /**
  9178. * Callback defining a custom Projection Matrix Builder.
  9179. * This can be used to override the default projection matrix computation.
  9180. */
  9181. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9182. /**
  9183. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9184. * @param matrix The materix to updated with the projection information
  9185. * @param viewMatrix The transform matrix of the light
  9186. * @param renderList The list of mesh to render in the map
  9187. * @returns The current light
  9188. */
  9189. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9190. /**
  9191. * Gets the current depth scale used in ESM.
  9192. * @returns The scale
  9193. */
  9194. getDepthScale(): number;
  9195. /**
  9196. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9197. * @returns true if a cube texture needs to be use
  9198. */
  9199. needCube(): boolean;
  9200. /**
  9201. * Detects if the projection matrix requires to be recomputed this frame.
  9202. * @returns true if it requires to be recomputed otherwise, false.
  9203. */
  9204. needProjectionMatrixCompute(): boolean;
  9205. /**
  9206. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9207. */
  9208. forceProjectionMatrixCompute(): void;
  9209. /**
  9210. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9211. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9212. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9213. */
  9214. getShadowDirection(faceIndex?: number): Vector3;
  9215. /**
  9216. * Gets the minZ used for shadow according to both the scene and the light.
  9217. * @param activeCamera The camera we are returning the min for
  9218. * @returns the depth min z
  9219. */
  9220. getDepthMinZ(activeCamera: Camera): number;
  9221. /**
  9222. * Gets the maxZ used for shadow according to both the scene and the light.
  9223. * @param activeCamera The camera we are returning the max for
  9224. * @returns the depth max z
  9225. */
  9226. getDepthMaxZ(activeCamera: Camera): number;
  9227. }
  9228. /**
  9229. * Base implementation IShadowLight
  9230. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9231. */
  9232. export abstract class ShadowLight extends Light implements IShadowLight {
  9233. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9234. protected _position: Vector3;
  9235. protected _setPosition(value: Vector3): void;
  9236. /**
  9237. * Sets the position the shadow will be casted from. Also use as the light position for both
  9238. * point and spot lights.
  9239. */
  9240. get position(): Vector3;
  9241. /**
  9242. * Sets the position the shadow will be casted from. Also use as the light position for both
  9243. * point and spot lights.
  9244. */
  9245. set position(value: Vector3);
  9246. protected _direction: Vector3;
  9247. protected _setDirection(value: Vector3): void;
  9248. /**
  9249. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9250. * Also use as the light direction on spot and directional lights.
  9251. */
  9252. get direction(): Vector3;
  9253. /**
  9254. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9255. * Also use as the light direction on spot and directional lights.
  9256. */
  9257. set direction(value: Vector3);
  9258. protected _shadowMinZ: number;
  9259. /**
  9260. * Gets the shadow projection clipping minimum z value.
  9261. */
  9262. get shadowMinZ(): number;
  9263. /**
  9264. * Sets the shadow projection clipping minimum z value.
  9265. */
  9266. set shadowMinZ(value: number);
  9267. protected _shadowMaxZ: number;
  9268. /**
  9269. * Sets the shadow projection clipping maximum z value.
  9270. */
  9271. get shadowMaxZ(): number;
  9272. /**
  9273. * Gets the shadow projection clipping maximum z value.
  9274. */
  9275. set shadowMaxZ(value: number);
  9276. /**
  9277. * Callback defining a custom Projection Matrix Builder.
  9278. * This can be used to override the default projection matrix computation.
  9279. */
  9280. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9281. /**
  9282. * The transformed position. Position of the light in world space taking parenting in account.
  9283. */
  9284. transformedPosition: Vector3;
  9285. /**
  9286. * The transformed direction. Direction of the light in world space taking parenting in account.
  9287. */
  9288. transformedDirection: Vector3;
  9289. private _needProjectionMatrixCompute;
  9290. /**
  9291. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9292. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9293. */
  9294. computeTransformedInformation(): boolean;
  9295. /**
  9296. * Return the depth scale used for the shadow map.
  9297. * @returns the depth scale.
  9298. */
  9299. getDepthScale(): number;
  9300. /**
  9301. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9302. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9303. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9304. */
  9305. getShadowDirection(faceIndex?: number): Vector3;
  9306. /**
  9307. * Returns the ShadowLight absolute position in the World.
  9308. * @returns the position vector in world space
  9309. */
  9310. getAbsolutePosition(): Vector3;
  9311. /**
  9312. * Sets the ShadowLight direction toward the passed target.
  9313. * @param target The point to target in local space
  9314. * @returns the updated ShadowLight direction
  9315. */
  9316. setDirectionToTarget(target: Vector3): Vector3;
  9317. /**
  9318. * Returns the light rotation in euler definition.
  9319. * @returns the x y z rotation in local space.
  9320. */
  9321. getRotation(): Vector3;
  9322. /**
  9323. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9324. * @returns true if a cube texture needs to be use
  9325. */
  9326. needCube(): boolean;
  9327. /**
  9328. * Detects if the projection matrix requires to be recomputed this frame.
  9329. * @returns true if it requires to be recomputed otherwise, false.
  9330. */
  9331. needProjectionMatrixCompute(): boolean;
  9332. /**
  9333. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9334. */
  9335. forceProjectionMatrixCompute(): void;
  9336. /** @hidden */
  9337. _initCache(): void;
  9338. /** @hidden */
  9339. _isSynchronized(): boolean;
  9340. /**
  9341. * Computes the world matrix of the node
  9342. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9343. * @returns the world matrix
  9344. */
  9345. computeWorldMatrix(force?: boolean): Matrix;
  9346. /**
  9347. * Gets the minZ used for shadow according to both the scene and the light.
  9348. * @param activeCamera The camera we are returning the min for
  9349. * @returns the depth min z
  9350. */
  9351. getDepthMinZ(activeCamera: Camera): number;
  9352. /**
  9353. * Gets the maxZ used for shadow according to both the scene and the light.
  9354. * @param activeCamera The camera we are returning the max for
  9355. * @returns the depth max z
  9356. */
  9357. getDepthMaxZ(activeCamera: Camera): number;
  9358. /**
  9359. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9360. * @param matrix The materix to updated with the projection information
  9361. * @param viewMatrix The transform matrix of the light
  9362. * @param renderList The list of mesh to render in the map
  9363. * @returns The current light
  9364. */
  9365. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9366. }
  9367. }
  9368. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9369. /** @hidden */
  9370. export var packingFunctions: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9376. /** @hidden */
  9377. export var bayerDitherFunctions: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9383. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9384. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9385. /** @hidden */
  9386. export var shadowMapFragmentDeclaration: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9392. /** @hidden */
  9393. export var clipPlaneFragmentDeclaration: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9399. /** @hidden */
  9400. export var clipPlaneFragment: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9406. /** @hidden */
  9407. export var shadowMapFragment: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9413. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9414. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9415. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9416. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9417. /** @hidden */
  9418. export var shadowMapPixelShader: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9424. /** @hidden */
  9425. export var bonesDeclaration: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9431. /** @hidden */
  9432. export var morphTargetsVertexGlobalDeclaration: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9438. /** @hidden */
  9439. export var morphTargetsVertexDeclaration: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9445. /** @hidden */
  9446. export var instancesDeclaration: {
  9447. name: string;
  9448. shader: string;
  9449. };
  9450. }
  9451. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9452. /** @hidden */
  9453. export var helperFunctions: {
  9454. name: string;
  9455. shader: string;
  9456. };
  9457. }
  9458. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9459. /** @hidden */
  9460. export var shadowMapVertexDeclaration: {
  9461. name: string;
  9462. shader: string;
  9463. };
  9464. }
  9465. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9466. /** @hidden */
  9467. export var clipPlaneVertexDeclaration: {
  9468. name: string;
  9469. shader: string;
  9470. };
  9471. }
  9472. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9473. /** @hidden */
  9474. export var morphTargetsVertex: {
  9475. name: string;
  9476. shader: string;
  9477. };
  9478. }
  9479. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9480. /** @hidden */
  9481. export var instancesVertex: {
  9482. name: string;
  9483. shader: string;
  9484. };
  9485. }
  9486. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9487. /** @hidden */
  9488. export var bonesVertex: {
  9489. name: string;
  9490. shader: string;
  9491. };
  9492. }
  9493. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9494. /** @hidden */
  9495. export var shadowMapVertexNormalBias: {
  9496. name: string;
  9497. shader: string;
  9498. };
  9499. }
  9500. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9501. /** @hidden */
  9502. export var shadowMapVertexMetric: {
  9503. name: string;
  9504. shader: string;
  9505. };
  9506. }
  9507. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9508. /** @hidden */
  9509. export var clipPlaneVertex: {
  9510. name: string;
  9511. shader: string;
  9512. };
  9513. }
  9514. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9515. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9516. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9517. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9518. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9519. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9520. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9521. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9522. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9523. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9524. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9525. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9526. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9527. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9528. /** @hidden */
  9529. export var shadowMapVertexShader: {
  9530. name: string;
  9531. shader: string;
  9532. };
  9533. }
  9534. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9535. /** @hidden */
  9536. export var depthBoxBlurPixelShader: {
  9537. name: string;
  9538. shader: string;
  9539. };
  9540. }
  9541. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9542. /** @hidden */
  9543. export var shadowMapFragmentSoftTransparentShadow: {
  9544. name: string;
  9545. shader: string;
  9546. };
  9547. }
  9548. declare module "babylonjs/Materials/effectFallbacks" {
  9549. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9550. import { Effect } from "babylonjs/Materials/effect";
  9551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9552. /**
  9553. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9554. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9555. */
  9556. export class EffectFallbacks implements IEffectFallbacks {
  9557. private _defines;
  9558. private _currentRank;
  9559. private _maxRank;
  9560. private _mesh;
  9561. /**
  9562. * Removes the fallback from the bound mesh.
  9563. */
  9564. unBindMesh(): void;
  9565. /**
  9566. * Adds a fallback on the specified property.
  9567. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9568. * @param define The name of the define in the shader
  9569. */
  9570. addFallback(rank: number, define: string): void;
  9571. /**
  9572. * Sets the mesh to use CPU skinning when needing to fallback.
  9573. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9574. * @param mesh The mesh to use the fallbacks.
  9575. */
  9576. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9577. /**
  9578. * Checks to see if more fallbacks are still availible.
  9579. */
  9580. get hasMoreFallbacks(): boolean;
  9581. /**
  9582. * Removes the defines that should be removed when falling back.
  9583. * @param currentDefines defines the current define statements for the shader.
  9584. * @param effect defines the current effect we try to compile
  9585. * @returns The resulting defines with defines of the current rank removed.
  9586. */
  9587. reduce(currentDefines: string, effect: Effect): string;
  9588. }
  9589. }
  9590. declare module "babylonjs/Actions/action" {
  9591. import { Observable } from "babylonjs/Misc/observable";
  9592. import { Condition } from "babylonjs/Actions/condition";
  9593. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9594. import { Nullable } from "babylonjs/types";
  9595. import { Scene } from "babylonjs/scene";
  9596. import { ActionManager } from "babylonjs/Actions/actionManager";
  9597. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9598. import { Node } from "babylonjs/node";
  9599. /**
  9600. * Interface used to define Action
  9601. */
  9602. export interface IAction {
  9603. /**
  9604. * Trigger for the action
  9605. */
  9606. trigger: number;
  9607. /** Options of the trigger */
  9608. triggerOptions: any;
  9609. /**
  9610. * Gets the trigger parameters
  9611. * @returns the trigger parameters
  9612. */
  9613. getTriggerParameter(): any;
  9614. /**
  9615. * Internal only - executes current action event
  9616. * @hidden
  9617. */
  9618. _executeCurrent(evt?: ActionEvent): void;
  9619. /**
  9620. * Serialize placeholder for child classes
  9621. * @param parent of child
  9622. * @returns the serialized object
  9623. */
  9624. serialize(parent: any): any;
  9625. /**
  9626. * Internal only
  9627. * @hidden
  9628. */
  9629. _prepare(): void;
  9630. /**
  9631. * Internal only - manager for action
  9632. * @hidden
  9633. */
  9634. _actionManager: Nullable<AbstractActionManager>;
  9635. /**
  9636. * Adds action to chain of actions, may be a DoNothingAction
  9637. * @param action defines the next action to execute
  9638. * @returns The action passed in
  9639. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9640. */
  9641. then(action: IAction): IAction;
  9642. }
  9643. /**
  9644. * The action to be carried out following a trigger
  9645. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9646. */
  9647. export class Action implements IAction {
  9648. /** the trigger, with or without parameters, for the action */
  9649. triggerOptions: any;
  9650. /**
  9651. * Trigger for the action
  9652. */
  9653. trigger: number;
  9654. /**
  9655. * Internal only - manager for action
  9656. * @hidden
  9657. */
  9658. _actionManager: ActionManager;
  9659. private _nextActiveAction;
  9660. private _child;
  9661. private _condition?;
  9662. private _triggerParameter;
  9663. /**
  9664. * An event triggered prior to action being executed.
  9665. */
  9666. onBeforeExecuteObservable: Observable<Action>;
  9667. /**
  9668. * Creates a new Action
  9669. * @param triggerOptions the trigger, with or without parameters, for the action
  9670. * @param condition an optional determinant of action
  9671. */
  9672. constructor(
  9673. /** the trigger, with or without parameters, for the action */
  9674. triggerOptions: any, condition?: Condition);
  9675. /**
  9676. * Internal only
  9677. * @hidden
  9678. */
  9679. _prepare(): void;
  9680. /**
  9681. * Gets the trigger parameters
  9682. * @returns the trigger parameters
  9683. */
  9684. getTriggerParameter(): any;
  9685. /**
  9686. * Internal only - executes current action event
  9687. * @hidden
  9688. */
  9689. _executeCurrent(evt?: ActionEvent): void;
  9690. /**
  9691. * Execute placeholder for child classes
  9692. * @param evt optional action event
  9693. */
  9694. execute(evt?: ActionEvent): void;
  9695. /**
  9696. * Skips to next active action
  9697. */
  9698. skipToNextActiveAction(): void;
  9699. /**
  9700. * Adds action to chain of actions, may be a DoNothingAction
  9701. * @param action defines the next action to execute
  9702. * @returns The action passed in
  9703. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9704. */
  9705. then(action: Action): Action;
  9706. /**
  9707. * Internal only
  9708. * @hidden
  9709. */
  9710. _getProperty(propertyPath: string): string;
  9711. /**
  9712. * Internal only
  9713. * @hidden
  9714. */
  9715. _getEffectiveTarget(target: any, propertyPath: string): any;
  9716. /**
  9717. * Serialize placeholder for child classes
  9718. * @param parent of child
  9719. * @returns the serialized object
  9720. */
  9721. serialize(parent: any): any;
  9722. /**
  9723. * Internal only called by serialize
  9724. * @hidden
  9725. */
  9726. protected _serialize(serializedAction: any, parent?: any): any;
  9727. /**
  9728. * Internal only
  9729. * @hidden
  9730. */
  9731. static _SerializeValueAsString: (value: any) => string;
  9732. /**
  9733. * Internal only
  9734. * @hidden
  9735. */
  9736. static _GetTargetProperty: (target: Scene | Node) => {
  9737. name: string;
  9738. targetType: string;
  9739. value: string;
  9740. };
  9741. }
  9742. }
  9743. declare module "babylonjs/Actions/condition" {
  9744. import { ActionManager } from "babylonjs/Actions/actionManager";
  9745. /**
  9746. * A Condition applied to an Action
  9747. */
  9748. export class Condition {
  9749. /**
  9750. * Internal only - manager for action
  9751. * @hidden
  9752. */
  9753. _actionManager: ActionManager;
  9754. /**
  9755. * Internal only
  9756. * @hidden
  9757. */
  9758. _evaluationId: number;
  9759. /**
  9760. * Internal only
  9761. * @hidden
  9762. */
  9763. _currentResult: boolean;
  9764. /**
  9765. * Creates a new Condition
  9766. * @param actionManager the manager of the action the condition is applied to
  9767. */
  9768. constructor(actionManager: ActionManager);
  9769. /**
  9770. * Check if the current condition is valid
  9771. * @returns a boolean
  9772. */
  9773. isValid(): boolean;
  9774. /**
  9775. * Internal only
  9776. * @hidden
  9777. */
  9778. _getProperty(propertyPath: string): string;
  9779. /**
  9780. * Internal only
  9781. * @hidden
  9782. */
  9783. _getEffectiveTarget(target: any, propertyPath: string): any;
  9784. /**
  9785. * Serialize placeholder for child classes
  9786. * @returns the serialized object
  9787. */
  9788. serialize(): any;
  9789. /**
  9790. * Internal only
  9791. * @hidden
  9792. */
  9793. protected _serialize(serializedCondition: any): any;
  9794. }
  9795. /**
  9796. * Defines specific conditional operators as extensions of Condition
  9797. */
  9798. export class ValueCondition extends Condition {
  9799. /** path to specify the property of the target the conditional operator uses */
  9800. propertyPath: string;
  9801. /** the value compared by the conditional operator against the current value of the property */
  9802. value: any;
  9803. /** the conditional operator, default ValueCondition.IsEqual */
  9804. operator: number;
  9805. /**
  9806. * Internal only
  9807. * @hidden
  9808. */
  9809. private static _IsEqual;
  9810. /**
  9811. * Internal only
  9812. * @hidden
  9813. */
  9814. private static _IsDifferent;
  9815. /**
  9816. * Internal only
  9817. * @hidden
  9818. */
  9819. private static _IsGreater;
  9820. /**
  9821. * Internal only
  9822. * @hidden
  9823. */
  9824. private static _IsLesser;
  9825. /**
  9826. * returns the number for IsEqual
  9827. */
  9828. static get IsEqual(): number;
  9829. /**
  9830. * Returns the number for IsDifferent
  9831. */
  9832. static get IsDifferent(): number;
  9833. /**
  9834. * Returns the number for IsGreater
  9835. */
  9836. static get IsGreater(): number;
  9837. /**
  9838. * Returns the number for IsLesser
  9839. */
  9840. static get IsLesser(): number;
  9841. /**
  9842. * Internal only The action manager for the condition
  9843. * @hidden
  9844. */
  9845. _actionManager: ActionManager;
  9846. /**
  9847. * Internal only
  9848. * @hidden
  9849. */
  9850. private _target;
  9851. /**
  9852. * Internal only
  9853. * @hidden
  9854. */
  9855. private _effectiveTarget;
  9856. /**
  9857. * Internal only
  9858. * @hidden
  9859. */
  9860. private _property;
  9861. /**
  9862. * Creates a new ValueCondition
  9863. * @param actionManager manager for the action the condition applies to
  9864. * @param target for the action
  9865. * @param propertyPath path to specify the property of the target the conditional operator uses
  9866. * @param value the value compared by the conditional operator against the current value of the property
  9867. * @param operator the conditional operator, default ValueCondition.IsEqual
  9868. */
  9869. constructor(actionManager: ActionManager, target: any,
  9870. /** path to specify the property of the target the conditional operator uses */
  9871. propertyPath: string,
  9872. /** the value compared by the conditional operator against the current value of the property */
  9873. value: any,
  9874. /** the conditional operator, default ValueCondition.IsEqual */
  9875. operator?: number);
  9876. /**
  9877. * Compares the given value with the property value for the specified conditional operator
  9878. * @returns the result of the comparison
  9879. */
  9880. isValid(): boolean;
  9881. /**
  9882. * Serialize the ValueCondition into a JSON compatible object
  9883. * @returns serialization object
  9884. */
  9885. serialize(): any;
  9886. /**
  9887. * Gets the name of the conditional operator for the ValueCondition
  9888. * @param operator the conditional operator
  9889. * @returns the name
  9890. */
  9891. static GetOperatorName(operator: number): string;
  9892. }
  9893. /**
  9894. * Defines a predicate condition as an extension of Condition
  9895. */
  9896. export class PredicateCondition extends Condition {
  9897. /** defines the predicate function used to validate the condition */
  9898. predicate: () => boolean;
  9899. /**
  9900. * Internal only - manager for action
  9901. * @hidden
  9902. */
  9903. _actionManager: ActionManager;
  9904. /**
  9905. * Creates a new PredicateCondition
  9906. * @param actionManager manager for the action the condition applies to
  9907. * @param predicate defines the predicate function used to validate the condition
  9908. */
  9909. constructor(actionManager: ActionManager,
  9910. /** defines the predicate function used to validate the condition */
  9911. predicate: () => boolean);
  9912. /**
  9913. * @returns the validity of the predicate condition
  9914. */
  9915. isValid(): boolean;
  9916. }
  9917. /**
  9918. * Defines a state condition as an extension of Condition
  9919. */
  9920. export class StateCondition extends Condition {
  9921. /** Value to compare with target state */
  9922. value: string;
  9923. /**
  9924. * Internal only - manager for action
  9925. * @hidden
  9926. */
  9927. _actionManager: ActionManager;
  9928. /**
  9929. * Internal only
  9930. * @hidden
  9931. */
  9932. private _target;
  9933. /**
  9934. * Creates a new StateCondition
  9935. * @param actionManager manager for the action the condition applies to
  9936. * @param target of the condition
  9937. * @param value to compare with target state
  9938. */
  9939. constructor(actionManager: ActionManager, target: any,
  9940. /** Value to compare with target state */
  9941. value: string);
  9942. /**
  9943. * Gets a boolean indicating if the current condition is met
  9944. * @returns the validity of the state
  9945. */
  9946. isValid(): boolean;
  9947. /**
  9948. * Serialize the StateCondition into a JSON compatible object
  9949. * @returns serialization object
  9950. */
  9951. serialize(): any;
  9952. }
  9953. }
  9954. declare module "babylonjs/Actions/directActions" {
  9955. import { Action } from "babylonjs/Actions/action";
  9956. import { Condition } from "babylonjs/Actions/condition";
  9957. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9958. /**
  9959. * This defines an action responsible to toggle a boolean once triggered.
  9960. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9961. */
  9962. export class SwitchBooleanAction extends Action {
  9963. /**
  9964. * The path to the boolean property in the target object
  9965. */
  9966. propertyPath: string;
  9967. private _target;
  9968. private _effectiveTarget;
  9969. private _property;
  9970. /**
  9971. * Instantiate the action
  9972. * @param triggerOptions defines the trigger options
  9973. * @param target defines the object containing the boolean
  9974. * @param propertyPath defines the path to the boolean property in the target object
  9975. * @param condition defines the trigger related conditions
  9976. */
  9977. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9978. /** @hidden */
  9979. _prepare(): void;
  9980. /**
  9981. * Execute the action toggle the boolean value.
  9982. */
  9983. execute(): void;
  9984. /**
  9985. * Serializes the actions and its related information.
  9986. * @param parent defines the object to serialize in
  9987. * @returns the serialized object
  9988. */
  9989. serialize(parent: any): any;
  9990. }
  9991. /**
  9992. * This defines an action responsible to set a the state field of the target
  9993. * to a desired value once triggered.
  9994. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9995. */
  9996. export class SetStateAction extends Action {
  9997. /**
  9998. * The value to store in the state field.
  9999. */
  10000. value: string;
  10001. private _target;
  10002. /**
  10003. * Instantiate the action
  10004. * @param triggerOptions defines the trigger options
  10005. * @param target defines the object containing the state property
  10006. * @param value defines the value to store in the state field
  10007. * @param condition defines the trigger related conditions
  10008. */
  10009. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10010. /**
  10011. * Execute the action and store the value on the target state property.
  10012. */
  10013. execute(): void;
  10014. /**
  10015. * Serializes the actions and its related information.
  10016. * @param parent defines the object to serialize in
  10017. * @returns the serialized object
  10018. */
  10019. serialize(parent: any): any;
  10020. }
  10021. /**
  10022. * This defines an action responsible to set a property of the target
  10023. * to a desired value once triggered.
  10024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class SetValueAction extends Action {
  10027. /**
  10028. * The path of the property to set in the target.
  10029. */
  10030. propertyPath: string;
  10031. /**
  10032. * The value to set in the property
  10033. */
  10034. value: any;
  10035. private _target;
  10036. private _effectiveTarget;
  10037. private _property;
  10038. /**
  10039. * Instantiate the action
  10040. * @param triggerOptions defines the trigger options
  10041. * @param target defines the object containing the property
  10042. * @param propertyPath defines the path of the property to set in the target
  10043. * @param value defines the value to set in the property
  10044. * @param condition defines the trigger related conditions
  10045. */
  10046. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10047. /** @hidden */
  10048. _prepare(): void;
  10049. /**
  10050. * Execute the action and set the targetted property to the desired value.
  10051. */
  10052. execute(): void;
  10053. /**
  10054. * Serializes the actions and its related information.
  10055. * @param parent defines the object to serialize in
  10056. * @returns the serialized object
  10057. */
  10058. serialize(parent: any): any;
  10059. }
  10060. /**
  10061. * This defines an action responsible to increment the target value
  10062. * to a desired value once triggered.
  10063. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10064. */
  10065. export class IncrementValueAction extends Action {
  10066. /**
  10067. * The path of the property to increment in the target.
  10068. */
  10069. propertyPath: string;
  10070. /**
  10071. * The value we should increment the property by.
  10072. */
  10073. value: any;
  10074. private _target;
  10075. private _effectiveTarget;
  10076. private _property;
  10077. /**
  10078. * Instantiate the action
  10079. * @param triggerOptions defines the trigger options
  10080. * @param target defines the object containing the property
  10081. * @param propertyPath defines the path of the property to increment in the target
  10082. * @param value defines the value value we should increment the property by
  10083. * @param condition defines the trigger related conditions
  10084. */
  10085. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10086. /** @hidden */
  10087. _prepare(): void;
  10088. /**
  10089. * Execute the action and increment the target of the value amount.
  10090. */
  10091. execute(): void;
  10092. /**
  10093. * Serializes the actions and its related information.
  10094. * @param parent defines the object to serialize in
  10095. * @returns the serialized object
  10096. */
  10097. serialize(parent: any): any;
  10098. }
  10099. /**
  10100. * This defines an action responsible to start an animation once triggered.
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10102. */
  10103. export class PlayAnimationAction extends Action {
  10104. /**
  10105. * Where the animation should start (animation frame)
  10106. */
  10107. from: number;
  10108. /**
  10109. * Where the animation should stop (animation frame)
  10110. */
  10111. to: number;
  10112. /**
  10113. * Define if the animation should loop or stop after the first play.
  10114. */
  10115. loop?: boolean;
  10116. private _target;
  10117. /**
  10118. * Instantiate the action
  10119. * @param triggerOptions defines the trigger options
  10120. * @param target defines the target animation or animation name
  10121. * @param from defines from where the animation should start (animation frame)
  10122. * @param end defines where the animation should stop (animation frame)
  10123. * @param loop defines if the animation should loop or stop after the first play
  10124. * @param condition defines the trigger related conditions
  10125. */
  10126. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10127. /** @hidden */
  10128. _prepare(): void;
  10129. /**
  10130. * Execute the action and play the animation.
  10131. */
  10132. execute(): void;
  10133. /**
  10134. * Serializes the actions and its related information.
  10135. * @param parent defines the object to serialize in
  10136. * @returns the serialized object
  10137. */
  10138. serialize(parent: any): any;
  10139. }
  10140. /**
  10141. * This defines an action responsible to stop an animation once triggered.
  10142. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10143. */
  10144. export class StopAnimationAction extends Action {
  10145. private _target;
  10146. /**
  10147. * Instantiate the action
  10148. * @param triggerOptions defines the trigger options
  10149. * @param target defines the target animation or animation name
  10150. * @param condition defines the trigger related conditions
  10151. */
  10152. constructor(triggerOptions: any, target: any, condition?: Condition);
  10153. /** @hidden */
  10154. _prepare(): void;
  10155. /**
  10156. * Execute the action and stop the animation.
  10157. */
  10158. execute(): void;
  10159. /**
  10160. * Serializes the actions and its related information.
  10161. * @param parent defines the object to serialize in
  10162. * @returns the serialized object
  10163. */
  10164. serialize(parent: any): any;
  10165. }
  10166. /**
  10167. * This defines an action responsible that does nothing once triggered.
  10168. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10169. */
  10170. export class DoNothingAction extends Action {
  10171. /**
  10172. * Instantiate the action
  10173. * @param triggerOptions defines the trigger options
  10174. * @param condition defines the trigger related conditions
  10175. */
  10176. constructor(triggerOptions?: any, condition?: Condition);
  10177. /**
  10178. * Execute the action and do nothing.
  10179. */
  10180. execute(): void;
  10181. /**
  10182. * Serializes the actions and its related information.
  10183. * @param parent defines the object to serialize in
  10184. * @returns the serialized object
  10185. */
  10186. serialize(parent: any): any;
  10187. }
  10188. /**
  10189. * This defines an action responsible to trigger several actions once triggered.
  10190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10191. */
  10192. export class CombineAction extends Action {
  10193. /**
  10194. * The list of aggregated animations to run.
  10195. */
  10196. children: Action[];
  10197. /**
  10198. * Instantiate the action
  10199. * @param triggerOptions defines the trigger options
  10200. * @param children defines the list of aggregated animations to run
  10201. * @param condition defines the trigger related conditions
  10202. */
  10203. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10204. /** @hidden */
  10205. _prepare(): void;
  10206. /**
  10207. * Execute the action and executes all the aggregated actions.
  10208. */
  10209. execute(evt: ActionEvent): void;
  10210. /**
  10211. * Serializes the actions and its related information.
  10212. * @param parent defines the object to serialize in
  10213. * @returns the serialized object
  10214. */
  10215. serialize(parent: any): any;
  10216. }
  10217. /**
  10218. * This defines an action responsible to run code (external event) once triggered.
  10219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10220. */
  10221. export class ExecuteCodeAction extends Action {
  10222. /**
  10223. * The callback function to run.
  10224. */
  10225. func: (evt: ActionEvent) => void;
  10226. /**
  10227. * Instantiate the action
  10228. * @param triggerOptions defines the trigger options
  10229. * @param func defines the callback function to run
  10230. * @param condition defines the trigger related conditions
  10231. */
  10232. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10233. /**
  10234. * Execute the action and run the attached code.
  10235. */
  10236. execute(evt: ActionEvent): void;
  10237. }
  10238. /**
  10239. * This defines an action responsible to set the parent property of the target once triggered.
  10240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10241. */
  10242. export class SetParentAction extends Action {
  10243. private _parent;
  10244. private _target;
  10245. /**
  10246. * Instantiate the action
  10247. * @param triggerOptions defines the trigger options
  10248. * @param target defines the target containing the parent property
  10249. * @param parent defines from where the animation should start (animation frame)
  10250. * @param condition defines the trigger related conditions
  10251. */
  10252. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10253. /** @hidden */
  10254. _prepare(): void;
  10255. /**
  10256. * Execute the action and set the parent property.
  10257. */
  10258. execute(): void;
  10259. /**
  10260. * Serializes the actions and its related information.
  10261. * @param parent defines the object to serialize in
  10262. * @returns the serialized object
  10263. */
  10264. serialize(parent: any): any;
  10265. }
  10266. }
  10267. declare module "babylonjs/Actions/actionManager" {
  10268. import { Nullable } from "babylonjs/types";
  10269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10270. import { Scene } from "babylonjs/scene";
  10271. import { IAction } from "babylonjs/Actions/action";
  10272. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10273. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10274. /**
  10275. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10276. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10277. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10278. */
  10279. export class ActionManager extends AbstractActionManager {
  10280. /**
  10281. * Nothing
  10282. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10283. */
  10284. static readonly NothingTrigger: number;
  10285. /**
  10286. * On pick
  10287. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10288. */
  10289. static readonly OnPickTrigger: number;
  10290. /**
  10291. * On left pick
  10292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10293. */
  10294. static readonly OnLeftPickTrigger: number;
  10295. /**
  10296. * On right pick
  10297. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10298. */
  10299. static readonly OnRightPickTrigger: number;
  10300. /**
  10301. * On center pick
  10302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10303. */
  10304. static readonly OnCenterPickTrigger: number;
  10305. /**
  10306. * On pick down
  10307. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10308. */
  10309. static readonly OnPickDownTrigger: number;
  10310. /**
  10311. * On double pick
  10312. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10313. */
  10314. static readonly OnDoublePickTrigger: number;
  10315. /**
  10316. * On pick up
  10317. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10318. */
  10319. static readonly OnPickUpTrigger: number;
  10320. /**
  10321. * On pick out.
  10322. * This trigger will only be raised if you also declared a OnPickDown
  10323. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10324. */
  10325. static readonly OnPickOutTrigger: number;
  10326. /**
  10327. * On long press
  10328. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10329. */
  10330. static readonly OnLongPressTrigger: number;
  10331. /**
  10332. * On pointer over
  10333. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10334. */
  10335. static readonly OnPointerOverTrigger: number;
  10336. /**
  10337. * On pointer out
  10338. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10339. */
  10340. static readonly OnPointerOutTrigger: number;
  10341. /**
  10342. * On every frame
  10343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10344. */
  10345. static readonly OnEveryFrameTrigger: number;
  10346. /**
  10347. * On intersection enter
  10348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10349. */
  10350. static readonly OnIntersectionEnterTrigger: number;
  10351. /**
  10352. * On intersection exit
  10353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10354. */
  10355. static readonly OnIntersectionExitTrigger: number;
  10356. /**
  10357. * On key down
  10358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10359. */
  10360. static readonly OnKeyDownTrigger: number;
  10361. /**
  10362. * On key up
  10363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10364. */
  10365. static readonly OnKeyUpTrigger: number;
  10366. private _scene;
  10367. /**
  10368. * Creates a new action manager
  10369. * @param scene defines the hosting scene
  10370. */
  10371. constructor(scene: Scene);
  10372. /**
  10373. * Releases all associated resources
  10374. */
  10375. dispose(): void;
  10376. /**
  10377. * Gets hosting scene
  10378. * @returns the hosting scene
  10379. */
  10380. getScene(): Scene;
  10381. /**
  10382. * Does this action manager handles actions of any of the given triggers
  10383. * @param triggers defines the triggers to be tested
  10384. * @return a boolean indicating whether one (or more) of the triggers is handled
  10385. */
  10386. hasSpecificTriggers(triggers: number[]): boolean;
  10387. /**
  10388. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10389. * speed.
  10390. * @param triggerA defines the trigger to be tested
  10391. * @param triggerB defines the trigger to be tested
  10392. * @return a boolean indicating whether one (or more) of the triggers is handled
  10393. */
  10394. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10395. /**
  10396. * Does this action manager handles actions of a given trigger
  10397. * @param trigger defines the trigger to be tested
  10398. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10399. * @return whether the trigger is handled
  10400. */
  10401. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10402. /**
  10403. * Does this action manager has pointer triggers
  10404. */
  10405. get hasPointerTriggers(): boolean;
  10406. /**
  10407. * Does this action manager has pick triggers
  10408. */
  10409. get hasPickTriggers(): boolean;
  10410. /**
  10411. * Registers an action to this action manager
  10412. * @param action defines the action to be registered
  10413. * @return the action amended (prepared) after registration
  10414. */
  10415. registerAction(action: IAction): Nullable<IAction>;
  10416. /**
  10417. * Unregisters an action to this action manager
  10418. * @param action defines the action to be unregistered
  10419. * @return a boolean indicating whether the action has been unregistered
  10420. */
  10421. unregisterAction(action: IAction): Boolean;
  10422. /**
  10423. * Process a specific trigger
  10424. * @param trigger defines the trigger to process
  10425. * @param evt defines the event details to be processed
  10426. */
  10427. processTrigger(trigger: number, evt?: IActionEvent): void;
  10428. /** @hidden */
  10429. _getEffectiveTarget(target: any, propertyPath: string): any;
  10430. /** @hidden */
  10431. _getProperty(propertyPath: string): string;
  10432. /**
  10433. * Serialize this manager to a JSON object
  10434. * @param name defines the property name to store this manager
  10435. * @returns a JSON representation of this manager
  10436. */
  10437. serialize(name: string): any;
  10438. /**
  10439. * Creates a new ActionManager from a JSON data
  10440. * @param parsedActions defines the JSON data to read from
  10441. * @param object defines the hosting mesh
  10442. * @param scene defines the hosting scene
  10443. */
  10444. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10445. /**
  10446. * Get a trigger name by index
  10447. * @param trigger defines the trigger index
  10448. * @returns a trigger name
  10449. */
  10450. static GetTriggerName(trigger: number): string;
  10451. }
  10452. }
  10453. declare module "babylonjs/Sprites/sprite" {
  10454. import { Vector3 } from "babylonjs/Maths/math.vector";
  10455. import { Nullable } from "babylonjs/types";
  10456. import { ActionManager } from "babylonjs/Actions/actionManager";
  10457. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10458. import { Color4 } from "babylonjs/Maths/math.color";
  10459. import { Observable } from "babylonjs/Misc/observable";
  10460. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10461. import { Animation } from "babylonjs/Animations/animation";
  10462. /**
  10463. * Class used to represent a sprite
  10464. * @see https://doc.babylonjs.com/babylon101/sprites
  10465. */
  10466. export class Sprite implements IAnimatable {
  10467. /** defines the name */
  10468. name: string;
  10469. /** Gets or sets the current world position */
  10470. position: Vector3;
  10471. /** Gets or sets the main color */
  10472. color: Color4;
  10473. /** Gets or sets the width */
  10474. width: number;
  10475. /** Gets or sets the height */
  10476. height: number;
  10477. /** Gets or sets rotation angle */
  10478. angle: number;
  10479. /** Gets or sets the cell index in the sprite sheet */
  10480. cellIndex: number;
  10481. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10482. cellRef: string;
  10483. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10484. invertU: boolean;
  10485. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10486. invertV: boolean;
  10487. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10488. disposeWhenFinishedAnimating: boolean;
  10489. /** Gets the list of attached animations */
  10490. animations: Nullable<Array<Animation>>;
  10491. /** Gets or sets a boolean indicating if the sprite can be picked */
  10492. isPickable: boolean;
  10493. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10494. useAlphaForPicking: boolean;
  10495. /** @hidden */
  10496. _xOffset: number;
  10497. /** @hidden */
  10498. _yOffset: number;
  10499. /** @hidden */
  10500. _xSize: number;
  10501. /** @hidden */
  10502. _ySize: number;
  10503. /**
  10504. * Gets or sets the associated action manager
  10505. */
  10506. actionManager: Nullable<ActionManager>;
  10507. /**
  10508. * An event triggered when the control has been disposed
  10509. */
  10510. onDisposeObservable: Observable<Sprite>;
  10511. private _animationStarted;
  10512. private _loopAnimation;
  10513. private _fromIndex;
  10514. private _toIndex;
  10515. private _delay;
  10516. private _direction;
  10517. private _manager;
  10518. private _time;
  10519. private _onAnimationEnd;
  10520. /**
  10521. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10522. */
  10523. isVisible: boolean;
  10524. /**
  10525. * Gets or sets the sprite size
  10526. */
  10527. get size(): number;
  10528. set size(value: number);
  10529. /**
  10530. * Returns a boolean indicating if the animation is started
  10531. */
  10532. get animationStarted(): boolean;
  10533. /**
  10534. * Gets or sets the unique id of the sprite
  10535. */
  10536. uniqueId: number;
  10537. /**
  10538. * Gets the manager of this sprite
  10539. */
  10540. get manager(): ISpriteManager;
  10541. /**
  10542. * Creates a new Sprite
  10543. * @param name defines the name
  10544. * @param manager defines the manager
  10545. */
  10546. constructor(
  10547. /** defines the name */
  10548. name: string, manager: ISpriteManager);
  10549. /**
  10550. * Returns the string "Sprite"
  10551. * @returns "Sprite"
  10552. */
  10553. getClassName(): string;
  10554. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10555. get fromIndex(): number;
  10556. set fromIndex(value: number);
  10557. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10558. get toIndex(): number;
  10559. set toIndex(value: number);
  10560. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10561. get loopAnimation(): boolean;
  10562. set loopAnimation(value: boolean);
  10563. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10564. get delay(): number;
  10565. set delay(value: number);
  10566. /**
  10567. * Starts an animation
  10568. * @param from defines the initial key
  10569. * @param to defines the end key
  10570. * @param loop defines if the animation must loop
  10571. * @param delay defines the start delay (in ms)
  10572. * @param onAnimationEnd defines a callback to call when animation ends
  10573. */
  10574. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10575. /** Stops current animation (if any) */
  10576. stopAnimation(): void;
  10577. /** @hidden */
  10578. _animate(deltaTime: number): void;
  10579. /** Release associated resources */
  10580. dispose(): void;
  10581. /**
  10582. * Serializes the sprite to a JSON object
  10583. * @returns the JSON object
  10584. */
  10585. serialize(): any;
  10586. /**
  10587. * Parses a JSON object to create a new sprite
  10588. * @param parsedSprite The JSON object to parse
  10589. * @param manager defines the hosting manager
  10590. * @returns the new sprite
  10591. */
  10592. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10593. }
  10594. }
  10595. declare module "babylonjs/Collisions/pickingInfo" {
  10596. import { Nullable } from "babylonjs/types";
  10597. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10599. import { Sprite } from "babylonjs/Sprites/sprite";
  10600. import { Ray } from "babylonjs/Culling/ray";
  10601. /**
  10602. * Information about the result of picking within a scene
  10603. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10604. */
  10605. export class PickingInfo {
  10606. /** @hidden */
  10607. _pickingUnavailable: boolean;
  10608. /**
  10609. * If the pick collided with an object
  10610. */
  10611. hit: boolean;
  10612. /**
  10613. * Distance away where the pick collided
  10614. */
  10615. distance: number;
  10616. /**
  10617. * The location of pick collision
  10618. */
  10619. pickedPoint: Nullable<Vector3>;
  10620. /**
  10621. * The mesh corresponding the the pick collision
  10622. */
  10623. pickedMesh: Nullable<AbstractMesh>;
  10624. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10625. bu: number;
  10626. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10627. bv: number;
  10628. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10629. faceId: number;
  10630. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10631. subMeshFaceId: number;
  10632. /** Id of the the submesh that was picked */
  10633. subMeshId: number;
  10634. /** If a sprite was picked, this will be the sprite the pick collided with */
  10635. pickedSprite: Nullable<Sprite>;
  10636. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10637. thinInstanceIndex: number;
  10638. /**
  10639. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10640. */
  10641. originMesh: Nullable<AbstractMesh>;
  10642. /**
  10643. * The ray that was used to perform the picking.
  10644. */
  10645. ray: Nullable<Ray>;
  10646. /**
  10647. * Gets the normal correspodning to the face the pick collided with
  10648. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10649. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10650. * @returns The normal correspodning to the face the pick collided with
  10651. */
  10652. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10653. /**
  10654. * Gets the texture coordinates of where the pick occured
  10655. * @returns the vector containing the coordnates of the texture
  10656. */
  10657. getTextureCoordinates(): Nullable<Vector2>;
  10658. }
  10659. }
  10660. declare module "babylonjs/Culling/ray" {
  10661. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10662. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10664. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10665. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10666. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10667. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10668. import { Plane } from "babylonjs/Maths/math.plane";
  10669. /**
  10670. * Class representing a ray with position and direction
  10671. */
  10672. export class Ray {
  10673. /** origin point */
  10674. origin: Vector3;
  10675. /** direction */
  10676. direction: Vector3;
  10677. /** length of the ray */
  10678. length: number;
  10679. private static readonly _TmpVector3;
  10680. private _tmpRay;
  10681. /**
  10682. * Creates a new ray
  10683. * @param origin origin point
  10684. * @param direction direction
  10685. * @param length length of the ray
  10686. */
  10687. constructor(
  10688. /** origin point */
  10689. origin: Vector3,
  10690. /** direction */
  10691. direction: Vector3,
  10692. /** length of the ray */
  10693. length?: number);
  10694. /**
  10695. * Checks if the ray intersects a box
  10696. * This does not account for the ray lenght by design to improve perfs.
  10697. * @param minimum bound of the box
  10698. * @param maximum bound of the box
  10699. * @param intersectionTreshold extra extend to be added to the box in all direction
  10700. * @returns if the box was hit
  10701. */
  10702. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  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 box the bounding box to check
  10707. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10708. * @returns if the box was hit
  10709. */
  10710. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10711. /**
  10712. * If the ray hits a sphere
  10713. * @param sphere the bounding sphere to check
  10714. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10715. * @returns true if it hits the sphere
  10716. */
  10717. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10718. /**
  10719. * If the ray hits a triange
  10720. * @param vertex0 triangle vertex
  10721. * @param vertex1 triangle vertex
  10722. * @param vertex2 triangle vertex
  10723. * @returns intersection information if hit
  10724. */
  10725. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10726. /**
  10727. * Checks if ray intersects a plane
  10728. * @param plane the plane to check
  10729. * @returns the distance away it was hit
  10730. */
  10731. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10732. /**
  10733. * Calculate the intercept of a ray on a given axis
  10734. * @param axis to check 'x' | 'y' | 'z'
  10735. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10736. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10737. */
  10738. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10739. /**
  10740. * Checks if ray intersects a mesh
  10741. * @param mesh the mesh to check
  10742. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10743. * @returns picking info of the intersecton
  10744. */
  10745. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10746. /**
  10747. * Checks if ray intersects a mesh
  10748. * @param meshes the meshes to check
  10749. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10750. * @param results array to store result in
  10751. * @returns Array of picking infos
  10752. */
  10753. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10754. private _comparePickingInfo;
  10755. private static smallnum;
  10756. private static rayl;
  10757. /**
  10758. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10759. * @param sega the first point of the segment to test the intersection against
  10760. * @param segb the second point of the segment to test the intersection against
  10761. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10762. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10763. */
  10764. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10765. /**
  10766. * Update the ray from viewport position
  10767. * @param x position
  10768. * @param y y position
  10769. * @param viewportWidth viewport width
  10770. * @param viewportHeight viewport height
  10771. * @param world world matrix
  10772. * @param view view matrix
  10773. * @param projection projection matrix
  10774. * @returns this ray updated
  10775. */
  10776. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10777. /**
  10778. * Creates a ray with origin and direction of 0,0,0
  10779. * @returns the new ray
  10780. */
  10781. static Zero(): Ray;
  10782. /**
  10783. * Creates a new ray from screen space and viewport
  10784. * @param x position
  10785. * @param y y position
  10786. * @param viewportWidth viewport width
  10787. * @param viewportHeight viewport height
  10788. * @param world world matrix
  10789. * @param view view matrix
  10790. * @param projection projection matrix
  10791. * @returns new ray
  10792. */
  10793. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10794. /**
  10795. * 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
  10796. * transformed to the given world matrix.
  10797. * @param origin The origin point
  10798. * @param end The end point
  10799. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10800. * @returns the new ray
  10801. */
  10802. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10803. /**
  10804. * Transforms a ray by a matrix
  10805. * @param ray ray to transform
  10806. * @param matrix matrix to apply
  10807. * @returns the resulting new ray
  10808. */
  10809. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10810. /**
  10811. * Transforms a ray by a matrix
  10812. * @param ray ray to transform
  10813. * @param matrix matrix to apply
  10814. * @param result ray to store result in
  10815. */
  10816. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10817. /**
  10818. * Unproject a ray from screen space to object space
  10819. * @param sourceX defines the screen space x coordinate to use
  10820. * @param sourceY defines the screen space y coordinate to use
  10821. * @param viewportWidth defines the current width of the viewport
  10822. * @param viewportHeight defines the current height of the viewport
  10823. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10824. * @param view defines the view matrix to use
  10825. * @param projection defines the projection matrix to use
  10826. */
  10827. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10828. }
  10829. /**
  10830. * Type used to define predicate used to select faces when a mesh intersection is detected
  10831. */
  10832. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10833. module "babylonjs/scene" {
  10834. interface Scene {
  10835. /** @hidden */
  10836. _tempPickingRay: Nullable<Ray>;
  10837. /** @hidden */
  10838. _cachedRayForTransform: Ray;
  10839. /** @hidden */
  10840. _pickWithRayInverseMatrix: Matrix;
  10841. /** @hidden */
  10842. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10843. /** @hidden */
  10844. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10845. /** @hidden */
  10846. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10847. }
  10848. }
  10849. }
  10850. declare module "babylonjs/sceneComponent" {
  10851. import { Scene } from "babylonjs/scene";
  10852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10853. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10854. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10855. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10856. import { Nullable } from "babylonjs/types";
  10857. import { Camera } from "babylonjs/Cameras/camera";
  10858. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10859. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10860. import { AbstractScene } from "babylonjs/abstractScene";
  10861. import { Mesh } from "babylonjs/Meshes/mesh";
  10862. /**
  10863. * Groups all the scene component constants in one place to ease maintenance.
  10864. * @hidden
  10865. */
  10866. export class SceneComponentConstants {
  10867. static readonly NAME_EFFECTLAYER: string;
  10868. static readonly NAME_LAYER: string;
  10869. static readonly NAME_LENSFLARESYSTEM: string;
  10870. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10871. static readonly NAME_PARTICLESYSTEM: string;
  10872. static readonly NAME_GAMEPAD: string;
  10873. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10874. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10875. static readonly NAME_PREPASSRENDERER: string;
  10876. static readonly NAME_DEPTHRENDERER: string;
  10877. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10878. static readonly NAME_SPRITE: string;
  10879. static readonly NAME_SUBSURFACE: string;
  10880. static readonly NAME_OUTLINERENDERER: string;
  10881. static readonly NAME_PROCEDURALTEXTURE: string;
  10882. static readonly NAME_SHADOWGENERATOR: string;
  10883. static readonly NAME_OCTREE: string;
  10884. static readonly NAME_PHYSICSENGINE: string;
  10885. static readonly NAME_AUDIO: string;
  10886. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10887. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10888. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10889. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10890. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10891. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10892. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10893. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10894. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10895. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10896. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10897. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10898. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10899. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10900. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10901. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10902. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10903. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10904. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10905. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10906. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10907. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10908. static readonly STEP_AFTERRENDER_AUDIO: number;
  10909. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10910. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10911. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10912. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10913. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10914. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10915. static readonly STEP_POINTERMOVE_SPRITE: number;
  10916. static readonly STEP_POINTERDOWN_SPRITE: number;
  10917. static readonly STEP_POINTERUP_SPRITE: number;
  10918. }
  10919. /**
  10920. * This represents a scene component.
  10921. *
  10922. * This is used to decouple the dependency the scene is having on the different workloads like
  10923. * layers, post processes...
  10924. */
  10925. export interface ISceneComponent {
  10926. /**
  10927. * The name of the component. Each component must have a unique name.
  10928. */
  10929. name: string;
  10930. /**
  10931. * The scene the component belongs to.
  10932. */
  10933. scene: Scene;
  10934. /**
  10935. * Register the component to one instance of a scene.
  10936. */
  10937. register(): void;
  10938. /**
  10939. * Rebuilds the elements related to this component in case of
  10940. * context lost for instance.
  10941. */
  10942. rebuild(): void;
  10943. /**
  10944. * Disposes the component and the associated ressources.
  10945. */
  10946. dispose(): void;
  10947. }
  10948. /**
  10949. * This represents a SERIALIZABLE scene component.
  10950. *
  10951. * This extends Scene Component to add Serialization methods on top.
  10952. */
  10953. export interface ISceneSerializableComponent extends ISceneComponent {
  10954. /**
  10955. * Adds all the elements from the container to the scene
  10956. * @param container the container holding the elements
  10957. */
  10958. addFromContainer(container: AbstractScene): void;
  10959. /**
  10960. * Removes all the elements in the container from the scene
  10961. * @param container contains the elements to remove
  10962. * @param dispose if the removed element should be disposed (default: false)
  10963. */
  10964. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10965. /**
  10966. * Serializes the component data to the specified json object
  10967. * @param serializationObject The object to serialize to
  10968. */
  10969. serialize(serializationObject: any): void;
  10970. }
  10971. /**
  10972. * Strong typing of a Mesh related stage step action
  10973. */
  10974. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10975. /**
  10976. * Strong typing of a Evaluate Sub Mesh related stage step action
  10977. */
  10978. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10979. /**
  10980. * Strong typing of a Active Mesh related stage step action
  10981. */
  10982. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10983. /**
  10984. * Strong typing of a Camera related stage step action
  10985. */
  10986. export type CameraStageAction = (camera: Camera) => void;
  10987. /**
  10988. * Strong typing of a Camera Frame buffer related stage step action
  10989. */
  10990. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10991. /**
  10992. * Strong typing of a Render Target related stage step action
  10993. */
  10994. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10995. /**
  10996. * Strong typing of a RenderingGroup related stage step action
  10997. */
  10998. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10999. /**
  11000. * Strong typing of a Mesh Render related stage step action
  11001. */
  11002. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11003. /**
  11004. * Strong typing of a simple stage step action
  11005. */
  11006. export type SimpleStageAction = () => void;
  11007. /**
  11008. * Strong typing of a render target action.
  11009. */
  11010. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11011. /**
  11012. * Strong typing of a pointer move action.
  11013. */
  11014. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11015. /**
  11016. * Strong typing of a pointer up/down action.
  11017. */
  11018. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11019. /**
  11020. * Representation of a stage in the scene (Basically a list of ordered steps)
  11021. * @hidden
  11022. */
  11023. export class Stage<T extends Function> extends Array<{
  11024. index: number;
  11025. component: ISceneComponent;
  11026. action: T;
  11027. }> {
  11028. /**
  11029. * Hide ctor from the rest of the world.
  11030. * @param items The items to add.
  11031. */
  11032. private constructor();
  11033. /**
  11034. * Creates a new Stage.
  11035. * @returns A new instance of a Stage
  11036. */
  11037. static Create<T extends Function>(): Stage<T>;
  11038. /**
  11039. * Registers a step in an ordered way in the targeted stage.
  11040. * @param index Defines the position to register the step in
  11041. * @param component Defines the component attached to the step
  11042. * @param action Defines the action to launch during the step
  11043. */
  11044. registerStep(index: number, component: ISceneComponent, action: T): void;
  11045. /**
  11046. * Clears all the steps from the stage.
  11047. */
  11048. clear(): void;
  11049. }
  11050. }
  11051. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11052. import { Nullable } from "babylonjs/types";
  11053. import { Observable } from "babylonjs/Misc/observable";
  11054. import { Scene } from "babylonjs/scene";
  11055. import { Sprite } from "babylonjs/Sprites/sprite";
  11056. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11057. import { Ray } from "babylonjs/Culling/ray";
  11058. import { Camera } from "babylonjs/Cameras/camera";
  11059. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11060. import { ISceneComponent } from "babylonjs/sceneComponent";
  11061. module "babylonjs/scene" {
  11062. interface Scene {
  11063. /** @hidden */
  11064. _pointerOverSprite: Nullable<Sprite>;
  11065. /** @hidden */
  11066. _pickedDownSprite: Nullable<Sprite>;
  11067. /** @hidden */
  11068. _tempSpritePickingRay: Nullable<Ray>;
  11069. /**
  11070. * All of the sprite managers added to this scene
  11071. * @see https://doc.babylonjs.com/babylon101/sprites
  11072. */
  11073. spriteManagers: Array<ISpriteManager>;
  11074. /**
  11075. * An event triggered when sprites rendering is about to start
  11076. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11077. */
  11078. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11079. /**
  11080. * An event triggered when sprites rendering is done
  11081. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11082. */
  11083. onAfterSpritesRenderingObservable: Observable<Scene>;
  11084. /** @hidden */
  11085. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11086. /** Launch a ray to try to pick a sprite in the scene
  11087. * @param x position on screen
  11088. * @param y position on screen
  11089. * @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
  11090. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11091. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11092. * @returns a PickingInfo
  11093. */
  11094. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11095. /** Use the given ray to pick a sprite in the scene
  11096. * @param ray The ray (in world space) to use to pick meshes
  11097. * @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
  11098. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11099. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11100. * @returns a PickingInfo
  11101. */
  11102. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11103. /** @hidden */
  11104. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11105. /** Launch a ray to try to pick sprites in the scene
  11106. * @param x position on screen
  11107. * @param y position on screen
  11108. * @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
  11109. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11110. * @returns a PickingInfo array
  11111. */
  11112. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11113. /** Use the given ray to pick sprites in the scene
  11114. * @param ray The ray (in world space) to use to pick meshes
  11115. * @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
  11116. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11117. * @returns a PickingInfo array
  11118. */
  11119. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11120. /**
  11121. * Force the sprite under the pointer
  11122. * @param sprite defines the sprite to use
  11123. */
  11124. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11125. /**
  11126. * Gets the sprite under the pointer
  11127. * @returns a Sprite or null if no sprite is under the pointer
  11128. */
  11129. getPointerOverSprite(): Nullable<Sprite>;
  11130. }
  11131. }
  11132. /**
  11133. * Defines the sprite scene component responsible to manage sprites
  11134. * in a given scene.
  11135. */
  11136. export class SpriteSceneComponent implements ISceneComponent {
  11137. /**
  11138. * The component name helpfull to identify the component in the list of scene components.
  11139. */
  11140. readonly name: string;
  11141. /**
  11142. * The scene the component belongs to.
  11143. */
  11144. scene: Scene;
  11145. /** @hidden */
  11146. private _spritePredicate;
  11147. /**
  11148. * Creates a new instance of the component for the given scene
  11149. * @param scene Defines the scene to register the component in
  11150. */
  11151. constructor(scene: Scene);
  11152. /**
  11153. * Registers the component in a given scene
  11154. */
  11155. register(): void;
  11156. /**
  11157. * Rebuilds the elements related to this component in case of
  11158. * context lost for instance.
  11159. */
  11160. rebuild(): void;
  11161. /**
  11162. * Disposes the component and the associated ressources.
  11163. */
  11164. dispose(): void;
  11165. private _pickSpriteButKeepRay;
  11166. private _pointerMove;
  11167. private _pointerDown;
  11168. private _pointerUp;
  11169. }
  11170. }
  11171. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11172. /** @hidden */
  11173. export var fogFragmentDeclaration: {
  11174. name: string;
  11175. shader: string;
  11176. };
  11177. }
  11178. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11179. /** @hidden */
  11180. export var fogFragment: {
  11181. name: string;
  11182. shader: string;
  11183. };
  11184. }
  11185. declare module "babylonjs/Shaders/sprites.fragment" {
  11186. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11187. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11188. /** @hidden */
  11189. export var spritesPixelShader: {
  11190. name: string;
  11191. shader: string;
  11192. };
  11193. }
  11194. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11195. /** @hidden */
  11196. export var fogVertexDeclaration: {
  11197. name: string;
  11198. shader: string;
  11199. };
  11200. }
  11201. declare module "babylonjs/Shaders/sprites.vertex" {
  11202. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11203. /** @hidden */
  11204. export var spritesVertexShader: {
  11205. name: string;
  11206. shader: string;
  11207. };
  11208. }
  11209. declare module "babylonjs/Sprites/spriteManager" {
  11210. import { IDisposable, Scene } from "babylonjs/scene";
  11211. import { Nullable } from "babylonjs/types";
  11212. import { Observable } from "babylonjs/Misc/observable";
  11213. import { Sprite } from "babylonjs/Sprites/sprite";
  11214. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11215. import { Camera } from "babylonjs/Cameras/camera";
  11216. import { Texture } from "babylonjs/Materials/Textures/texture";
  11217. import "babylonjs/Shaders/sprites.fragment";
  11218. import "babylonjs/Shaders/sprites.vertex";
  11219. import { Ray } from "babylonjs/Culling/ray";
  11220. /**
  11221. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11222. */
  11223. export interface ISpriteManager extends IDisposable {
  11224. /**
  11225. * Gets manager's name
  11226. */
  11227. name: string;
  11228. /**
  11229. * Restricts the camera to viewing objects with the same layerMask.
  11230. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11231. */
  11232. layerMask: number;
  11233. /**
  11234. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11235. */
  11236. isPickable: boolean;
  11237. /**
  11238. * Gets the hosting scene
  11239. */
  11240. scene: Scene;
  11241. /**
  11242. * Specifies the rendering group id for this mesh (0 by default)
  11243. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11244. */
  11245. renderingGroupId: number;
  11246. /**
  11247. * Defines the list of sprites managed by the manager.
  11248. */
  11249. sprites: Array<Sprite>;
  11250. /**
  11251. * Gets or sets the spritesheet texture
  11252. */
  11253. texture: Texture;
  11254. /** Defines the default width of a cell in the spritesheet */
  11255. cellWidth: number;
  11256. /** Defines the default height of a cell in the spritesheet */
  11257. cellHeight: number;
  11258. /**
  11259. * Tests the intersection of a sprite with a specific ray.
  11260. * @param ray The ray we are sending to test the collision
  11261. * @param camera The camera space we are sending rays in
  11262. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11263. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11264. * @returns picking info or null.
  11265. */
  11266. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11267. /**
  11268. * Intersects the sprites with a ray
  11269. * @param ray defines the ray to intersect with
  11270. * @param camera defines the current active camera
  11271. * @param predicate defines a predicate used to select candidate sprites
  11272. * @returns null if no hit or a PickingInfo array
  11273. */
  11274. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11275. /**
  11276. * Renders the list of sprites on screen.
  11277. */
  11278. render(): void;
  11279. }
  11280. /**
  11281. * Class used to manage multiple sprites on the same spritesheet
  11282. * @see https://doc.babylonjs.com/babylon101/sprites
  11283. */
  11284. export class SpriteManager implements ISpriteManager {
  11285. /** defines the manager's name */
  11286. name: string;
  11287. /** Define the Url to load snippets */
  11288. static SnippetUrl: string;
  11289. /** Snippet ID if the manager was created from the snippet server */
  11290. snippetId: string;
  11291. /** Gets the list of sprites */
  11292. sprites: Sprite[];
  11293. /** Gets or sets the rendering group id (0 by default) */
  11294. renderingGroupId: number;
  11295. /** Gets or sets camera layer mask */
  11296. layerMask: number;
  11297. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11298. fogEnabled: boolean;
  11299. /** Gets or sets a boolean indicating if the sprites are pickable */
  11300. isPickable: boolean;
  11301. /** Defines the default width of a cell in the spritesheet */
  11302. cellWidth: number;
  11303. /** Defines the default height of a cell in the spritesheet */
  11304. cellHeight: number;
  11305. /** Associative array from JSON sprite data file */
  11306. private _cellData;
  11307. /** Array of sprite names from JSON sprite data file */
  11308. private _spriteMap;
  11309. /** True when packed cell data from JSON file is ready*/
  11310. private _packedAndReady;
  11311. private _textureContent;
  11312. private _useInstancing;
  11313. /**
  11314. * An event triggered when the manager is disposed.
  11315. */
  11316. onDisposeObservable: Observable<SpriteManager>;
  11317. private _onDisposeObserver;
  11318. /**
  11319. * Callback called when the manager is disposed
  11320. */
  11321. set onDispose(callback: () => void);
  11322. private _capacity;
  11323. private _fromPacked;
  11324. private _spriteTexture;
  11325. private _epsilon;
  11326. private _scene;
  11327. private _vertexData;
  11328. private _buffer;
  11329. private _vertexBuffers;
  11330. private _spriteBuffer;
  11331. private _indexBuffer;
  11332. private _effectBase;
  11333. private _effectFog;
  11334. private _vertexBufferSize;
  11335. /**
  11336. * Gets or sets the unique id of the sprite
  11337. */
  11338. uniqueId: number;
  11339. /**
  11340. * Gets the array of sprites
  11341. */
  11342. get children(): Sprite[];
  11343. /**
  11344. * Gets the hosting scene
  11345. */
  11346. get scene(): Scene;
  11347. /**
  11348. * Gets the capacity of the manager
  11349. */
  11350. get capacity(): number;
  11351. /**
  11352. * Gets or sets the spritesheet texture
  11353. */
  11354. get texture(): Texture;
  11355. set texture(value: Texture);
  11356. private _blendMode;
  11357. /**
  11358. * Blend mode use to render the particle, it can be any of
  11359. * the static Constants.ALPHA_x properties provided in this class.
  11360. * Default value is Constants.ALPHA_COMBINE
  11361. */
  11362. get blendMode(): number;
  11363. set blendMode(blendMode: number);
  11364. /** Disables writing to the depth buffer when rendering the sprites.
  11365. * It can be handy to disable depth writing when using textures without alpha channel
  11366. * and setting some specific blend modes.
  11367. */
  11368. disableDepthWrite: boolean;
  11369. /**
  11370. * Creates a new sprite manager
  11371. * @param name defines the manager's name
  11372. * @param imgUrl defines the sprite sheet url
  11373. * @param capacity defines the maximum allowed number of sprites
  11374. * @param cellSize defines the size of a sprite cell
  11375. * @param scene defines the hosting scene
  11376. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11377. * @param samplingMode defines the smapling mode to use with spritesheet
  11378. * @param fromPacked set to false; do not alter
  11379. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11380. */
  11381. constructor(
  11382. /** defines the manager's name */
  11383. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11384. /**
  11385. * Returns the string "SpriteManager"
  11386. * @returns "SpriteManager"
  11387. */
  11388. getClassName(): string;
  11389. private _makePacked;
  11390. private _appendSpriteVertex;
  11391. private _checkTextureAlpha;
  11392. /**
  11393. * Intersects the sprites with a ray
  11394. * @param ray defines the ray to intersect with
  11395. * @param camera defines the current active camera
  11396. * @param predicate defines a predicate used to select candidate sprites
  11397. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11398. * @returns null if no hit or a PickingInfo
  11399. */
  11400. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  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. * @returns null if no hit or a PickingInfo array
  11407. */
  11408. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11409. /**
  11410. * Render all child sprites
  11411. */
  11412. render(): void;
  11413. /**
  11414. * Release associated resources
  11415. */
  11416. dispose(): void;
  11417. /**
  11418. * Serializes the sprite manager to a JSON object
  11419. * @param serializeTexture defines if the texture must be serialized as well
  11420. * @returns the JSON object
  11421. */
  11422. serialize(serializeTexture?: boolean): any;
  11423. /**
  11424. * Parses a JSON object to create a new sprite manager.
  11425. * @param parsedManager The JSON object to parse
  11426. * @param scene The scene to create the sprite managerin
  11427. * @param rootUrl The root url to use to load external dependencies like texture
  11428. * @returns the new sprite manager
  11429. */
  11430. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11431. /**
  11432. * Creates a sprite manager from a snippet saved in a remote file
  11433. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11434. * @param url defines the url to load from
  11435. * @param scene defines the hosting scene
  11436. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11437. * @returns a promise that will resolve to the new sprite manager
  11438. */
  11439. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11440. /**
  11441. * Creates a sprite manager from a snippet saved by the sprite editor
  11442. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11443. * @param scene defines the hosting scene
  11444. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11445. * @returns a promise that will resolve to the new sprite manager
  11446. */
  11447. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11448. }
  11449. }
  11450. declare module "babylonjs/Misc/gradients" {
  11451. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11452. /** Interface used by value gradients (color, factor, ...) */
  11453. export interface IValueGradient {
  11454. /**
  11455. * Gets or sets the gradient value (between 0 and 1)
  11456. */
  11457. gradient: number;
  11458. }
  11459. /** Class used to store color4 gradient */
  11460. export class ColorGradient implements IValueGradient {
  11461. /**
  11462. * Gets or sets the gradient value (between 0 and 1)
  11463. */
  11464. gradient: number;
  11465. /**
  11466. * Gets or sets first associated color
  11467. */
  11468. color1: Color4;
  11469. /**
  11470. * Gets or sets second associated color
  11471. */
  11472. color2?: Color4 | undefined;
  11473. /**
  11474. * Creates a new color4 gradient
  11475. * @param gradient gets or sets the gradient value (between 0 and 1)
  11476. * @param color1 gets or sets first associated color
  11477. * @param color2 gets or sets first second color
  11478. */
  11479. constructor(
  11480. /**
  11481. * Gets or sets the gradient value (between 0 and 1)
  11482. */
  11483. gradient: number,
  11484. /**
  11485. * Gets or sets first associated color
  11486. */
  11487. color1: Color4,
  11488. /**
  11489. * Gets or sets second associated color
  11490. */
  11491. color2?: Color4 | undefined);
  11492. /**
  11493. * Will get a color picked randomly between color1 and color2.
  11494. * If color2 is undefined then color1 will be used
  11495. * @param result defines the target Color4 to store the result in
  11496. */
  11497. getColorToRef(result: Color4): void;
  11498. }
  11499. /** Class used to store color 3 gradient */
  11500. export class Color3Gradient implements IValueGradient {
  11501. /**
  11502. * Gets or sets the gradient value (between 0 and 1)
  11503. */
  11504. gradient: number;
  11505. /**
  11506. * Gets or sets the associated color
  11507. */
  11508. color: Color3;
  11509. /**
  11510. * Creates a new color3 gradient
  11511. * @param gradient gets or sets the gradient value (between 0 and 1)
  11512. * @param color gets or sets associated color
  11513. */
  11514. constructor(
  11515. /**
  11516. * Gets or sets the gradient value (between 0 and 1)
  11517. */
  11518. gradient: number,
  11519. /**
  11520. * Gets or sets the associated color
  11521. */
  11522. color: Color3);
  11523. }
  11524. /** Class used to store factor gradient */
  11525. export class FactorGradient implements IValueGradient {
  11526. /**
  11527. * Gets or sets the gradient value (between 0 and 1)
  11528. */
  11529. gradient: number;
  11530. /**
  11531. * Gets or sets first associated factor
  11532. */
  11533. factor1: number;
  11534. /**
  11535. * Gets or sets second associated factor
  11536. */
  11537. factor2?: number | undefined;
  11538. /**
  11539. * Creates a new factor gradient
  11540. * @param gradient gets or sets the gradient value (between 0 and 1)
  11541. * @param factor1 gets or sets first associated factor
  11542. * @param factor2 gets or sets second associated factor
  11543. */
  11544. constructor(
  11545. /**
  11546. * Gets or sets the gradient value (between 0 and 1)
  11547. */
  11548. gradient: number,
  11549. /**
  11550. * Gets or sets first associated factor
  11551. */
  11552. factor1: number,
  11553. /**
  11554. * Gets or sets second associated factor
  11555. */
  11556. factor2?: number | undefined);
  11557. /**
  11558. * Will get a number picked randomly between factor1 and factor2.
  11559. * If factor2 is undefined then factor1 will be used
  11560. * @returns the picked number
  11561. */
  11562. getFactor(): number;
  11563. }
  11564. /**
  11565. * Helper used to simplify some generic gradient tasks
  11566. */
  11567. export class GradientHelper {
  11568. /**
  11569. * Gets the current gradient from an array of IValueGradient
  11570. * @param ratio defines the current ratio to get
  11571. * @param gradients defines the array of IValueGradient
  11572. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11573. */
  11574. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11575. }
  11576. }
  11577. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11578. import { Nullable } from "babylonjs/types";
  11579. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11580. import { Scene } from "babylonjs/scene";
  11581. module "babylonjs/Engines/thinEngine" {
  11582. interface ThinEngine {
  11583. /**
  11584. * Creates a raw texture
  11585. * @param data defines the data to store in the texture
  11586. * @param width defines the width of the texture
  11587. * @param height defines the height of the texture
  11588. * @param format defines the format of the data
  11589. * @param generateMipMaps defines if the engine should generate the mip levels
  11590. * @param invertY defines if data must be stored with Y axis inverted
  11591. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11592. * @param compression defines the compression used (null by default)
  11593. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11594. * @returns the raw texture inside an InternalTexture
  11595. */
  11596. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11597. /**
  11598. * Update a raw texture
  11599. * @param texture defines the texture to update
  11600. * @param data defines the data to store in the texture
  11601. * @param format defines the format of the data
  11602. * @param invertY defines if data must be stored with Y axis inverted
  11603. */
  11604. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11605. /**
  11606. * Update a raw texture
  11607. * @param texture defines the texture to update
  11608. * @param data defines the data to store in the texture
  11609. * @param format defines the format of the data
  11610. * @param invertY defines if data must be stored with Y axis inverted
  11611. * @param compression defines the compression used (null by default)
  11612. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11613. */
  11614. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11615. /**
  11616. * Creates a new raw cube texture
  11617. * @param data defines the array of data to use to create each face
  11618. * @param size defines the size of the textures
  11619. * @param format defines the format of the data
  11620. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11621. * @param generateMipMaps defines if the engine should generate the mip levels
  11622. * @param invertY defines if data must be stored with Y axis inverted
  11623. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11624. * @param compression defines the compression used (null by default)
  11625. * @returns the cube texture as an InternalTexture
  11626. */
  11627. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11628. /**
  11629. * Update a raw cube texture
  11630. * @param texture defines the texture to udpdate
  11631. * @param data defines the data to store
  11632. * @param format defines the data format
  11633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11634. * @param invertY defines if data must be stored with Y axis inverted
  11635. */
  11636. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  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. * @param compression defines the compression used (null by default)
  11645. */
  11646. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11647. /**
  11648. * Update a raw cube texture
  11649. * @param texture defines the texture to udpdate
  11650. * @param data defines the data to store
  11651. * @param format defines the data format
  11652. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11653. * @param invertY defines if data must be stored with Y axis inverted
  11654. * @param compression defines the compression used (null by default)
  11655. * @param level defines which level of the texture to update
  11656. */
  11657. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11658. /**
  11659. * Creates a new raw cube texture from a specified url
  11660. * @param url defines the url where the data is located
  11661. * @param scene defines the current scene
  11662. * @param size defines the size of the textures
  11663. * @param format defines the format of the data
  11664. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11665. * @param noMipmap defines if the engine should avoid generating the mip levels
  11666. * @param callback defines a callback used to extract texture data from loaded data
  11667. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11668. * @param onLoad defines a callback called when texture is loaded
  11669. * @param onError defines a callback called if there is an error
  11670. * @returns the cube texture as an InternalTexture
  11671. */
  11672. 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;
  11673. /**
  11674. * Creates a new raw cube texture from a specified url
  11675. * @param url defines the url where the data is located
  11676. * @param scene defines the current scene
  11677. * @param size defines the size of the textures
  11678. * @param format defines the format of the data
  11679. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11680. * @param noMipmap defines if the engine should avoid generating the mip levels
  11681. * @param callback defines a callback used to extract texture data from loaded data
  11682. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11683. * @param onLoad defines a callback called when texture is loaded
  11684. * @param onError defines a callback called if there is an error
  11685. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11686. * @param invertY defines if data must be stored with Y axis inverted
  11687. * @returns the cube texture as an InternalTexture
  11688. */
  11689. 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;
  11690. /**
  11691. * Creates a new raw 3D texture
  11692. * @param data defines the data used to create the texture
  11693. * @param width defines the width of the texture
  11694. * @param height defines the height of the texture
  11695. * @param depth defines the depth of the texture
  11696. * @param format defines the format of the texture
  11697. * @param generateMipMaps defines if the engine must generate mip levels
  11698. * @param invertY defines if data must be stored with Y axis inverted
  11699. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11700. * @param compression defines the compressed used (can be null)
  11701. * @param textureType defines the compressed used (can be null)
  11702. * @returns a new raw 3D texture (stored in an InternalTexture)
  11703. */
  11704. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11705. /**
  11706. * Update a raw 3D texture
  11707. * @param texture defines the texture to update
  11708. * @param data defines the data to store
  11709. * @param format defines the data format
  11710. * @param invertY defines if data must be stored with Y axis inverted
  11711. */
  11712. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11713. /**
  11714. * Update a raw 3D texture
  11715. * @param texture defines the texture to update
  11716. * @param data defines the data to store
  11717. * @param format defines the data format
  11718. * @param invertY defines if data must be stored with Y axis inverted
  11719. * @param compression defines the used compression (can be null)
  11720. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11721. */
  11722. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11723. /**
  11724. * Creates a new raw 2D array texture
  11725. * @param data defines the data used to create the texture
  11726. * @param width defines the width of the texture
  11727. * @param height defines the height of the texture
  11728. * @param depth defines the number of layers of the texture
  11729. * @param format defines the format of the texture
  11730. * @param generateMipMaps defines if the engine must generate mip levels
  11731. * @param invertY defines if data must be stored with Y axis inverted
  11732. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11733. * @param compression defines the compressed used (can be null)
  11734. * @param textureType defines the compressed used (can be null)
  11735. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11736. */
  11737. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11738. /**
  11739. * Update a raw 2D array texture
  11740. * @param texture defines the texture to update
  11741. * @param data defines the data to store
  11742. * @param format defines the data format
  11743. * @param invertY defines if data must be stored with Y axis inverted
  11744. */
  11745. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11746. /**
  11747. * Update a raw 2D array texture
  11748. * @param texture defines the texture to update
  11749. * @param data defines the data to store
  11750. * @param format defines the data format
  11751. * @param invertY defines if data must be stored with Y axis inverted
  11752. * @param compression defines the used compression (can be null)
  11753. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11754. */
  11755. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11756. }
  11757. }
  11758. }
  11759. declare module "babylonjs/Materials/Textures/rawTexture" {
  11760. import { Texture } from "babylonjs/Materials/Textures/texture";
  11761. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11762. import { Nullable } from "babylonjs/types";
  11763. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11764. import { Scene } from "babylonjs/scene";
  11765. /**
  11766. * Raw texture can help creating a texture directly from an array of data.
  11767. * This can be super useful if you either get the data from an uncompressed source or
  11768. * if you wish to create your texture pixel by pixel.
  11769. */
  11770. export class RawTexture extends Texture {
  11771. /**
  11772. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11773. */
  11774. format: number;
  11775. /**
  11776. * Instantiates a new RawTexture.
  11777. * Raw texture can help creating a texture directly from an array of data.
  11778. * This can be super useful if you either get the data from an uncompressed source or
  11779. * if you wish to create your texture pixel by pixel.
  11780. * @param data define the array of data to use to create the texture
  11781. * @param width define the width of the texture
  11782. * @param height define the height of the texture
  11783. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11784. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11785. * @param generateMipMaps define whether mip maps should be generated or not
  11786. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11787. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11788. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11789. */
  11790. constructor(data: ArrayBufferView, width: number, height: number,
  11791. /**
  11792. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11793. */
  11794. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11795. /**
  11796. * Updates the texture underlying data.
  11797. * @param data Define the new data of the texture
  11798. */
  11799. update(data: ArrayBufferView): void;
  11800. /**
  11801. * Creates a luminance texture from some data.
  11802. * @param data Define the texture data
  11803. * @param width Define the width of the texture
  11804. * @param height Define the height of the texture
  11805. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11806. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11807. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11808. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11809. * @returns the luminance texture
  11810. */
  11811. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11812. /**
  11813. * Creates a luminance alpha texture from some data.
  11814. * @param data Define the texture data
  11815. * @param width Define the width of the texture
  11816. * @param height Define the height of the texture
  11817. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11818. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11819. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11820. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11821. * @returns the luminance alpha texture
  11822. */
  11823. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11824. /**
  11825. * Creates an alpha texture from some data.
  11826. * @param data Define the texture data
  11827. * @param width Define the width of the texture
  11828. * @param height Define the height of the texture
  11829. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11830. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11831. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11832. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11833. * @returns the alpha texture
  11834. */
  11835. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11836. /**
  11837. * Creates a RGB texture from some data.
  11838. * @param data Define the texture data
  11839. * @param width Define the width of the texture
  11840. * @param height Define the height of the texture
  11841. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11842. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11843. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11844. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11845. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11846. * @returns the RGB alpha texture
  11847. */
  11848. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11849. /**
  11850. * Creates a RGBA texture from some data.
  11851. * @param data Define the texture data
  11852. * @param width Define the width of the texture
  11853. * @param height Define the height of the texture
  11854. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11855. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11856. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11857. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11858. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11859. * @returns the RGBA texture
  11860. */
  11861. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11862. /**
  11863. * Creates a R texture from some data.
  11864. * @param data Define the texture data
  11865. * @param width Define the width of the texture
  11866. * @param height Define the height of the texture
  11867. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11868. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11869. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11870. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11871. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11872. * @returns the R texture
  11873. */
  11874. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11875. }
  11876. }
  11877. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11878. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11879. import { IndicesArray, DataArray } from "babylonjs/types";
  11880. module "babylonjs/Engines/thinEngine" {
  11881. interface ThinEngine {
  11882. /**
  11883. * Update a dynamic index buffer
  11884. * @param indexBuffer defines the target index buffer
  11885. * @param indices defines the data to update
  11886. * @param offset defines the offset in the target index buffer where update should start
  11887. */
  11888. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11889. /**
  11890. * Updates a dynamic vertex buffer.
  11891. * @param vertexBuffer the vertex buffer to update
  11892. * @param data the data used to update the vertex buffer
  11893. * @param byteOffset the byte offset of the data
  11894. * @param byteLength the byte length of the data
  11895. */
  11896. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11897. }
  11898. }
  11899. }
  11900. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11901. import { Scene } from "babylonjs/scene";
  11902. import { ISceneComponent } from "babylonjs/sceneComponent";
  11903. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11904. module "babylonjs/abstractScene" {
  11905. interface AbstractScene {
  11906. /**
  11907. * The list of procedural textures added to the scene
  11908. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11909. */
  11910. proceduralTextures: Array<ProceduralTexture>;
  11911. }
  11912. }
  11913. /**
  11914. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11915. * in a given scene.
  11916. */
  11917. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11918. /**
  11919. * The component name helpfull to identify the component in the list of scene components.
  11920. */
  11921. readonly name: string;
  11922. /**
  11923. * The scene the component belongs to.
  11924. */
  11925. scene: Scene;
  11926. /**
  11927. * Creates a new instance of the component for the given scene
  11928. * @param scene Defines the scene to register the component in
  11929. */
  11930. constructor(scene: Scene);
  11931. /**
  11932. * Registers the component in a given scene
  11933. */
  11934. register(): void;
  11935. /**
  11936. * Rebuilds the elements related to this component in case of
  11937. * context lost for instance.
  11938. */
  11939. rebuild(): void;
  11940. /**
  11941. * Disposes the component and the associated ressources.
  11942. */
  11943. dispose(): void;
  11944. private _beforeClear;
  11945. }
  11946. }
  11947. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11948. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11949. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11950. module "babylonjs/Engines/thinEngine" {
  11951. interface ThinEngine {
  11952. /**
  11953. * Creates a new render target cube texture
  11954. * @param size defines the size of the texture
  11955. * @param options defines the options used to create the texture
  11956. * @returns a new render target cube texture stored in an InternalTexture
  11957. */
  11958. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11959. }
  11960. }
  11961. }
  11962. declare module "babylonjs/Shaders/procedural.vertex" {
  11963. /** @hidden */
  11964. export var proceduralVertexShader: {
  11965. name: string;
  11966. shader: string;
  11967. };
  11968. }
  11969. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11970. import { Observable } from "babylonjs/Misc/observable";
  11971. import { Nullable } from "babylonjs/types";
  11972. import { Scene } from "babylonjs/scene";
  11973. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11974. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11975. import { Effect } from "babylonjs/Materials/effect";
  11976. import { Texture } from "babylonjs/Materials/Textures/texture";
  11977. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11978. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11979. import "babylonjs/Shaders/procedural.vertex";
  11980. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  11981. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  11982. /**
  11983. * 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.
  11984. * This is the base class of any Procedural texture and contains most of the shareable code.
  11985. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11986. */
  11987. export class ProceduralTexture extends Texture {
  11988. /**
  11989. * Define if the texture is enabled or not (disabled texture will not render)
  11990. */
  11991. isEnabled: boolean;
  11992. /**
  11993. * Define if the texture must be cleared before rendering (default is true)
  11994. */
  11995. autoClear: boolean;
  11996. /**
  11997. * Callback called when the texture is generated
  11998. */
  11999. onGenerated: () => void;
  12000. /**
  12001. * Event raised when the texture is generated
  12002. */
  12003. onGeneratedObservable: Observable<ProceduralTexture>;
  12004. /**
  12005. * Event raised before the texture is generated
  12006. */
  12007. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12008. /**
  12009. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12010. */
  12011. nodeMaterialSource: Nullable<NodeMaterial>;
  12012. /** @hidden */
  12013. _generateMipMaps: boolean;
  12014. /** @hidden **/
  12015. _effect: Effect;
  12016. /** @hidden */
  12017. _textures: {
  12018. [key: string]: Texture;
  12019. };
  12020. /** @hidden */
  12021. protected _fallbackTexture: Nullable<Texture>;
  12022. private _size;
  12023. private _currentRefreshId;
  12024. private _frameId;
  12025. private _refreshRate;
  12026. private _vertexBuffers;
  12027. private _indexBuffer;
  12028. private _uniforms;
  12029. private _samplers;
  12030. private _fragment;
  12031. private _floats;
  12032. private _ints;
  12033. private _floatsArrays;
  12034. private _colors3;
  12035. private _colors4;
  12036. private _vectors2;
  12037. private _vectors3;
  12038. private _matrices;
  12039. private _fallbackTextureUsed;
  12040. private _fullEngine;
  12041. private _cachedDefines;
  12042. private _contentUpdateId;
  12043. private _contentData;
  12044. /**
  12045. * Instantiates a new procedural texture.
  12046. * 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.
  12047. * This is the base class of any Procedural texture and contains most of the shareable code.
  12048. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12049. * @param name Define the name of the texture
  12050. * @param size Define the size of the texture to create
  12051. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12052. * @param scene Define the scene the texture belongs to
  12053. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12054. * @param generateMipMaps Define if the texture should creates mip maps or not
  12055. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12056. */
  12057. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  12058. /**
  12059. * The effect that is created when initializing the post process.
  12060. * @returns The created effect corresponding the the postprocess.
  12061. */
  12062. getEffect(): Effect;
  12063. /**
  12064. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12065. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12066. */
  12067. getContent(): Nullable<ArrayBufferView>;
  12068. private _createIndexBuffer;
  12069. /** @hidden */
  12070. _rebuild(): void;
  12071. /**
  12072. * Resets the texture in order to recreate its associated resources.
  12073. * This can be called in case of context loss
  12074. */
  12075. reset(): void;
  12076. protected _getDefines(): string;
  12077. /**
  12078. * Is the texture ready to be used ? (rendered at least once)
  12079. * @returns true if ready, otherwise, false.
  12080. */
  12081. isReady(): boolean;
  12082. /**
  12083. * Resets the refresh counter of the texture and start bak from scratch.
  12084. * Could be useful to regenerate the texture if it is setup to render only once.
  12085. */
  12086. resetRefreshCounter(): void;
  12087. /**
  12088. * Set the fragment shader to use in order to render the texture.
  12089. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12090. */
  12091. setFragment(fragment: any): void;
  12092. /**
  12093. * Define the refresh rate of the texture or the rendering frequency.
  12094. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12095. */
  12096. get refreshRate(): number;
  12097. set refreshRate(value: number);
  12098. /** @hidden */
  12099. _shouldRender(): boolean;
  12100. /**
  12101. * Get the size the texture is rendering at.
  12102. * @returns the size (on cube texture it is always squared)
  12103. */
  12104. getRenderSize(): RenderTargetTextureSize;
  12105. /**
  12106. * Resize the texture to new value.
  12107. * @param size Define the new size the texture should have
  12108. * @param generateMipMaps Define whether the new texture should create mip maps
  12109. */
  12110. resize(size: number, generateMipMaps: boolean): void;
  12111. private _checkUniform;
  12112. /**
  12113. * Set a texture in the shader program used to render.
  12114. * @param name Define the name of the uniform samplers as defined in the shader
  12115. * @param texture Define the texture to bind to this sampler
  12116. * @return the texture itself allowing "fluent" like uniform updates
  12117. */
  12118. setTexture(name: string, texture: Texture): ProceduralTexture;
  12119. /**
  12120. * Set a float in the shader.
  12121. * @param name Define the name of the uniform as defined in the shader
  12122. * @param value Define the value to give to the uniform
  12123. * @return the texture itself allowing "fluent" like uniform updates
  12124. */
  12125. setFloat(name: string, value: number): ProceduralTexture;
  12126. /**
  12127. * Set a int in the shader.
  12128. * @param name Define the name of the uniform as defined in the shader
  12129. * @param value Define the value to give to the uniform
  12130. * @return the texture itself allowing "fluent" like uniform updates
  12131. */
  12132. setInt(name: string, value: number): ProceduralTexture;
  12133. /**
  12134. * Set an array of floats in the shader.
  12135. * @param name Define the name of the uniform as defined in the shader
  12136. * @param value Define the value to give to the uniform
  12137. * @return the texture itself allowing "fluent" like uniform updates
  12138. */
  12139. setFloats(name: string, value: number[]): ProceduralTexture;
  12140. /**
  12141. * Set a vec3 in the shader from a Color3.
  12142. * @param name Define the name of the uniform as defined in the shader
  12143. * @param value Define the value to give to the uniform
  12144. * @return the texture itself allowing "fluent" like uniform updates
  12145. */
  12146. setColor3(name: string, value: Color3): ProceduralTexture;
  12147. /**
  12148. * Set a vec4 in the shader from a Color4.
  12149. * @param name Define the name of the uniform as defined in the shader
  12150. * @param value Define the value to give to the uniform
  12151. * @return the texture itself allowing "fluent" like uniform updates
  12152. */
  12153. setColor4(name: string, value: Color4): ProceduralTexture;
  12154. /**
  12155. * Set a vec2 in the shader from a Vector2.
  12156. * @param name Define the name of the uniform as defined in the shader
  12157. * @param value Define the value to give to the uniform
  12158. * @return the texture itself allowing "fluent" like uniform updates
  12159. */
  12160. setVector2(name: string, value: Vector2): ProceduralTexture;
  12161. /**
  12162. * Set a vec3 in the shader from a Vector3.
  12163. * @param name Define the name of the uniform as defined in the shader
  12164. * @param value Define the value to give to the uniform
  12165. * @return the texture itself allowing "fluent" like uniform updates
  12166. */
  12167. setVector3(name: string, value: Vector3): ProceduralTexture;
  12168. /**
  12169. * Set a mat4 in the shader from a MAtrix.
  12170. * @param name Define the name of the uniform as defined in the shader
  12171. * @param value Define the value to give to the uniform
  12172. * @return the texture itself allowing "fluent" like uniform updates
  12173. */
  12174. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12175. /**
  12176. * Render the texture to its associated render target.
  12177. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12178. */
  12179. render(useCameraPostProcess?: boolean): void;
  12180. /**
  12181. * Clone the texture.
  12182. * @returns the cloned texture
  12183. */
  12184. clone(): ProceduralTexture;
  12185. /**
  12186. * Dispose the texture and release its asoociated resources.
  12187. */
  12188. dispose(): void;
  12189. }
  12190. }
  12191. declare module "babylonjs/Particles/baseParticleSystem" {
  12192. import { Nullable } from "babylonjs/types";
  12193. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12195. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12196. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12197. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12199. import { Color4 } from "babylonjs/Maths/math.color";
  12200. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12201. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12202. import { Animation } from "babylonjs/Animations/animation";
  12203. import { Scene } from "babylonjs/scene";
  12204. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12205. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12206. /**
  12207. * This represents the base class for particle system in Babylon.
  12208. * 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.
  12209. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12210. * @example https://doc.babylonjs.com/babylon101/particles
  12211. */
  12212. export class BaseParticleSystem {
  12213. /**
  12214. * Source color is added to the destination color without alpha affecting the result
  12215. */
  12216. static BLENDMODE_ONEONE: number;
  12217. /**
  12218. * Blend current color and particle color using particle’s alpha
  12219. */
  12220. static BLENDMODE_STANDARD: number;
  12221. /**
  12222. * Add current color and particle color multiplied by particle’s alpha
  12223. */
  12224. static BLENDMODE_ADD: number;
  12225. /**
  12226. * Multiply current color with particle color
  12227. */
  12228. static BLENDMODE_MULTIPLY: number;
  12229. /**
  12230. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12231. */
  12232. static BLENDMODE_MULTIPLYADD: number;
  12233. /**
  12234. * List of animations used by the particle system.
  12235. */
  12236. animations: Animation[];
  12237. /**
  12238. * Gets or sets the unique id of the particle system
  12239. */
  12240. uniqueId: number;
  12241. /**
  12242. * The id of the Particle system.
  12243. */
  12244. id: string;
  12245. /**
  12246. * The friendly name of the Particle system.
  12247. */
  12248. name: string;
  12249. /**
  12250. * Snippet ID if the particle system was created from the snippet server
  12251. */
  12252. snippetId: string;
  12253. /**
  12254. * The rendering group used by the Particle system to chose when to render.
  12255. */
  12256. renderingGroupId: number;
  12257. /**
  12258. * The emitter represents the Mesh or position we are attaching the particle system to.
  12259. */
  12260. emitter: Nullable<AbstractMesh | Vector3>;
  12261. /**
  12262. * The maximum number of particles to emit per frame
  12263. */
  12264. emitRate: number;
  12265. /**
  12266. * If you want to launch only a few particles at once, that can be done, as well.
  12267. */
  12268. manualEmitCount: number;
  12269. /**
  12270. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12271. */
  12272. updateSpeed: number;
  12273. /**
  12274. * The amount of time the particle system is running (depends of the overall update speed).
  12275. */
  12276. targetStopDuration: number;
  12277. /**
  12278. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12279. */
  12280. disposeOnStop: boolean;
  12281. /**
  12282. * Minimum power of emitting particles.
  12283. */
  12284. minEmitPower: number;
  12285. /**
  12286. * Maximum power of emitting particles.
  12287. */
  12288. maxEmitPower: number;
  12289. /**
  12290. * Minimum life time of emitting particles.
  12291. */
  12292. minLifeTime: number;
  12293. /**
  12294. * Maximum life time of emitting particles.
  12295. */
  12296. maxLifeTime: number;
  12297. /**
  12298. * Minimum Size of emitting particles.
  12299. */
  12300. minSize: number;
  12301. /**
  12302. * Maximum Size of emitting particles.
  12303. */
  12304. maxSize: number;
  12305. /**
  12306. * Minimum scale of emitting particles on X axis.
  12307. */
  12308. minScaleX: number;
  12309. /**
  12310. * Maximum scale of emitting particles on X axis.
  12311. */
  12312. maxScaleX: number;
  12313. /**
  12314. * Minimum scale of emitting particles on Y axis.
  12315. */
  12316. minScaleY: number;
  12317. /**
  12318. * Maximum scale of emitting particles on Y axis.
  12319. */
  12320. maxScaleY: number;
  12321. /**
  12322. * Gets or sets the minimal initial rotation in radians.
  12323. */
  12324. minInitialRotation: number;
  12325. /**
  12326. * Gets or sets the maximal initial rotation in radians.
  12327. */
  12328. maxInitialRotation: number;
  12329. /**
  12330. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12331. */
  12332. minAngularSpeed: number;
  12333. /**
  12334. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12335. */
  12336. maxAngularSpeed: number;
  12337. /**
  12338. * The texture used to render each particle. (this can be a spritesheet)
  12339. */
  12340. particleTexture: Nullable<BaseTexture>;
  12341. /**
  12342. * The layer mask we are rendering the particles through.
  12343. */
  12344. layerMask: number;
  12345. /**
  12346. * This can help using your own shader to render the particle system.
  12347. * The according effect will be created
  12348. */
  12349. customShader: any;
  12350. /**
  12351. * By default particle system starts as soon as they are created. This prevents the
  12352. * automatic start to happen and let you decide when to start emitting particles.
  12353. */
  12354. preventAutoStart: boolean;
  12355. private _noiseTexture;
  12356. /**
  12357. * Gets or sets a texture used to add random noise to particle positions
  12358. */
  12359. get noiseTexture(): Nullable<ProceduralTexture>;
  12360. set noiseTexture(value: Nullable<ProceduralTexture>);
  12361. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12362. noiseStrength: Vector3;
  12363. /**
  12364. * Callback triggered when the particle animation is ending.
  12365. */
  12366. onAnimationEnd: Nullable<() => void>;
  12367. /**
  12368. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12369. */
  12370. blendMode: number;
  12371. /**
  12372. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12373. * to override the particles.
  12374. */
  12375. forceDepthWrite: boolean;
  12376. /** 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 */
  12377. preWarmCycles: number;
  12378. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12379. preWarmStepOffset: number;
  12380. /**
  12381. * 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)
  12382. */
  12383. spriteCellChangeSpeed: number;
  12384. /**
  12385. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12386. */
  12387. startSpriteCellID: number;
  12388. /**
  12389. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12390. */
  12391. endSpriteCellID: number;
  12392. /**
  12393. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12394. */
  12395. spriteCellWidth: number;
  12396. /**
  12397. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12398. */
  12399. spriteCellHeight: number;
  12400. /**
  12401. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12402. */
  12403. spriteRandomStartCell: boolean;
  12404. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12405. translationPivot: Vector2;
  12406. /** @hidden */
  12407. protected _isAnimationSheetEnabled: boolean;
  12408. /**
  12409. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12410. */
  12411. beginAnimationOnStart: boolean;
  12412. /**
  12413. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12414. */
  12415. beginAnimationFrom: number;
  12416. /**
  12417. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12418. */
  12419. beginAnimationTo: number;
  12420. /**
  12421. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12422. */
  12423. beginAnimationLoop: boolean;
  12424. /**
  12425. * Gets or sets a world offset applied to all particles
  12426. */
  12427. worldOffset: Vector3;
  12428. /**
  12429. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12430. */
  12431. get isAnimationSheetEnabled(): boolean;
  12432. set isAnimationSheetEnabled(value: boolean);
  12433. /**
  12434. * Get hosting scene
  12435. * @returns the scene
  12436. */
  12437. getScene(): Nullable<Scene>;
  12438. /**
  12439. * You can use gravity if you want to give an orientation to your particles.
  12440. */
  12441. gravity: Vector3;
  12442. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12443. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12444. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12445. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12446. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12447. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12448. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12449. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12450. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12451. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12452. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12453. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12454. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12455. /**
  12456. * Defines the delay in milliseconds before starting the system (0 by default)
  12457. */
  12458. startDelay: number;
  12459. /**
  12460. * Gets the current list of drag gradients.
  12461. * You must use addDragGradient and removeDragGradient to udpate this list
  12462. * @returns the list of drag gradients
  12463. */
  12464. getDragGradients(): Nullable<Array<FactorGradient>>;
  12465. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12466. limitVelocityDamping: number;
  12467. /**
  12468. * Gets the current list of limit velocity gradients.
  12469. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12470. * @returns the list of limit velocity gradients
  12471. */
  12472. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12473. /**
  12474. * Gets the current list of color gradients.
  12475. * You must use addColorGradient and removeColorGradient to udpate this list
  12476. * @returns the list of color gradients
  12477. */
  12478. getColorGradients(): Nullable<Array<ColorGradient>>;
  12479. /**
  12480. * Gets the current list of size gradients.
  12481. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12482. * @returns the list of size gradients
  12483. */
  12484. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12485. /**
  12486. * Gets the current list of color remap gradients.
  12487. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12488. * @returns the list of color remap gradients
  12489. */
  12490. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12491. /**
  12492. * Gets the current list of alpha remap gradients.
  12493. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12494. * @returns the list of alpha remap gradients
  12495. */
  12496. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12497. /**
  12498. * Gets the current list of life time gradients.
  12499. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12500. * @returns the list of life time gradients
  12501. */
  12502. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12503. /**
  12504. * Gets the current list of angular speed gradients.
  12505. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12506. * @returns the list of angular speed gradients
  12507. */
  12508. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12509. /**
  12510. * Gets the current list of velocity gradients.
  12511. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12512. * @returns the list of velocity gradients
  12513. */
  12514. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12515. /**
  12516. * Gets the current list of start size gradients.
  12517. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12518. * @returns the list of start size gradients
  12519. */
  12520. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12521. /**
  12522. * Gets the current list of emit rate gradients.
  12523. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12524. * @returns the list of emit rate gradients
  12525. */
  12526. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12527. /**
  12528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12529. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12530. */
  12531. get direction1(): Vector3;
  12532. set direction1(value: Vector3);
  12533. /**
  12534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12535. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12536. */
  12537. get direction2(): Vector3;
  12538. set direction2(value: Vector3);
  12539. /**
  12540. * 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.
  12541. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12542. */
  12543. get minEmitBox(): Vector3;
  12544. set minEmitBox(value: Vector3);
  12545. /**
  12546. * 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.
  12547. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12548. */
  12549. get maxEmitBox(): Vector3;
  12550. set maxEmitBox(value: Vector3);
  12551. /**
  12552. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12553. */
  12554. color1: Color4;
  12555. /**
  12556. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12557. */
  12558. color2: Color4;
  12559. /**
  12560. * Color the particle will have at the end of its lifetime
  12561. */
  12562. colorDead: Color4;
  12563. /**
  12564. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12565. */
  12566. textureMask: Color4;
  12567. /**
  12568. * The particle emitter type defines the emitter used by the particle system.
  12569. * It can be for example box, sphere, or cone...
  12570. */
  12571. particleEmitterType: IParticleEmitterType;
  12572. /** @hidden */
  12573. _isSubEmitter: boolean;
  12574. /**
  12575. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12576. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12577. */
  12578. billboardMode: number;
  12579. protected _isBillboardBased: boolean;
  12580. /**
  12581. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12582. */
  12583. get isBillboardBased(): boolean;
  12584. set isBillboardBased(value: boolean);
  12585. /**
  12586. * The scene the particle system belongs to.
  12587. */
  12588. protected _scene: Nullable<Scene>;
  12589. /**
  12590. * The engine the particle system belongs to.
  12591. */
  12592. protected _engine: ThinEngine;
  12593. /**
  12594. * Local cache of defines for image processing.
  12595. */
  12596. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12597. /**
  12598. * Default configuration related to image processing available in the standard Material.
  12599. */
  12600. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12601. /**
  12602. * Gets the image processing configuration used either in this material.
  12603. */
  12604. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12605. /**
  12606. * Sets the Default image processing configuration used either in the this material.
  12607. *
  12608. * If sets to null, the scene one is in use.
  12609. */
  12610. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12611. /**
  12612. * Attaches a new image processing configuration to the Standard Material.
  12613. * @param configuration
  12614. */
  12615. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12616. /** @hidden */
  12617. protected _reset(): void;
  12618. /** @hidden */
  12619. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12620. /**
  12621. * Instantiates a particle system.
  12622. * 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.
  12623. * @param name The name of the particle system
  12624. */
  12625. constructor(name: string);
  12626. /**
  12627. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12628. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12629. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12630. * @returns the emitter
  12631. */
  12632. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12633. /**
  12634. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12635. * @param radius The radius of the hemisphere to emit from
  12636. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12637. * @returns the emitter
  12638. */
  12639. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12640. /**
  12641. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12642. * @param radius The radius of the sphere to emit from
  12643. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12644. * @returns the emitter
  12645. */
  12646. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12647. /**
  12648. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12649. * @param radius The radius of the sphere to emit from
  12650. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12651. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12652. * @returns the emitter
  12653. */
  12654. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12655. /**
  12656. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12657. * @param radius The radius of the emission cylinder
  12658. * @param height The height of the emission cylinder
  12659. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12660. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12661. * @returns the emitter
  12662. */
  12663. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12664. /**
  12665. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12666. * @param radius The radius of the cylinder to emit from
  12667. * @param height The height of the emission cylinder
  12668. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12671. * @returns the emitter
  12672. */
  12673. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12674. /**
  12675. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12676. * @param radius The radius of the cone to emit from
  12677. * @param angle The base angle of the cone
  12678. * @returns the emitter
  12679. */
  12680. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12681. /**
  12682. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12683. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12684. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12685. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12686. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12687. * @returns the emitter
  12688. */
  12689. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12690. }
  12691. }
  12692. declare module "babylonjs/Particles/subEmitter" {
  12693. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12694. import { Scene } from "babylonjs/scene";
  12695. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12696. /**
  12697. * Type of sub emitter
  12698. */
  12699. export enum SubEmitterType {
  12700. /**
  12701. * Attached to the particle over it's lifetime
  12702. */
  12703. ATTACHED = 0,
  12704. /**
  12705. * Created when the particle dies
  12706. */
  12707. END = 1
  12708. }
  12709. /**
  12710. * Sub emitter class used to emit particles from an existing particle
  12711. */
  12712. export class SubEmitter {
  12713. /**
  12714. * the particle system to be used by the sub emitter
  12715. */
  12716. particleSystem: ParticleSystem;
  12717. /**
  12718. * Type of the submitter (Default: END)
  12719. */
  12720. type: SubEmitterType;
  12721. /**
  12722. * 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)
  12723. * Note: This only is supported when using an emitter of type Mesh
  12724. */
  12725. inheritDirection: boolean;
  12726. /**
  12727. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12728. */
  12729. inheritedVelocityAmount: number;
  12730. /**
  12731. * Creates a sub emitter
  12732. * @param particleSystem the particle system to be used by the sub emitter
  12733. */
  12734. constructor(
  12735. /**
  12736. * the particle system to be used by the sub emitter
  12737. */
  12738. particleSystem: ParticleSystem);
  12739. /**
  12740. * Clones the sub emitter
  12741. * @returns the cloned sub emitter
  12742. */
  12743. clone(): SubEmitter;
  12744. /**
  12745. * Serialize current object to a JSON object
  12746. * @returns the serialized object
  12747. */
  12748. serialize(): any;
  12749. /** @hidden */
  12750. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12751. /**
  12752. * Creates a new SubEmitter from a serialized JSON version
  12753. * @param serializationObject defines the JSON object to read from
  12754. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12755. * @param rootUrl defines the rootUrl for data loading
  12756. * @returns a new SubEmitter
  12757. */
  12758. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12759. /** Release associated resources */
  12760. dispose(): void;
  12761. }
  12762. }
  12763. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12764. /** @hidden */
  12765. export var imageProcessingDeclaration: {
  12766. name: string;
  12767. shader: string;
  12768. };
  12769. }
  12770. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12771. /** @hidden */
  12772. export var imageProcessingFunctions: {
  12773. name: string;
  12774. shader: string;
  12775. };
  12776. }
  12777. declare module "babylonjs/Shaders/particles.fragment" {
  12778. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12779. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12780. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12781. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12782. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12783. /** @hidden */
  12784. export var particlesPixelShader: {
  12785. name: string;
  12786. shader: string;
  12787. };
  12788. }
  12789. declare module "babylonjs/Shaders/particles.vertex" {
  12790. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12791. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12792. /** @hidden */
  12793. export var particlesVertexShader: {
  12794. name: string;
  12795. shader: string;
  12796. };
  12797. }
  12798. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12799. import { Nullable } from "babylonjs/types";
  12800. import { Plane } from "babylonjs/Maths/math";
  12801. /**
  12802. * Interface used to define entities containing multiple clip planes
  12803. */
  12804. export interface IClipPlanesHolder {
  12805. /**
  12806. * Gets or sets the active clipplane 1
  12807. */
  12808. clipPlane: Nullable<Plane>;
  12809. /**
  12810. * Gets or sets the active clipplane 2
  12811. */
  12812. clipPlane2: Nullable<Plane>;
  12813. /**
  12814. * Gets or sets the active clipplane 3
  12815. */
  12816. clipPlane3: Nullable<Plane>;
  12817. /**
  12818. * Gets or sets the active clipplane 4
  12819. */
  12820. clipPlane4: Nullable<Plane>;
  12821. /**
  12822. * Gets or sets the active clipplane 5
  12823. */
  12824. clipPlane5: Nullable<Plane>;
  12825. /**
  12826. * Gets or sets the active clipplane 6
  12827. */
  12828. clipPlane6: Nullable<Plane>;
  12829. }
  12830. }
  12831. declare module "babylonjs/Materials/thinMaterialHelper" {
  12832. import { Effect } from "babylonjs/Materials/effect";
  12833. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12834. /**
  12835. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12836. *
  12837. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12838. *
  12839. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12840. */
  12841. export class ThinMaterialHelper {
  12842. /**
  12843. * Binds the clip plane information from the holder to the effect.
  12844. * @param effect The effect we are binding the data to
  12845. * @param holder The entity containing the clip plane information
  12846. */
  12847. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12848. }
  12849. }
  12850. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12851. module "babylonjs/Engines/thinEngine" {
  12852. interface ThinEngine {
  12853. /**
  12854. * Sets alpha constants used by some alpha blending modes
  12855. * @param r defines the red component
  12856. * @param g defines the green component
  12857. * @param b defines the blue component
  12858. * @param a defines the alpha component
  12859. */
  12860. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12861. /**
  12862. * Sets the current alpha mode
  12863. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12864. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12865. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12866. */
  12867. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12868. /**
  12869. * Gets the current alpha mode
  12870. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12871. * @returns the current alpha mode
  12872. */
  12873. getAlphaMode(): number;
  12874. /**
  12875. * Sets the current alpha equation
  12876. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12877. */
  12878. setAlphaEquation(equation: number): void;
  12879. /**
  12880. * Gets the current alpha equation.
  12881. * @returns the current alpha equation
  12882. */
  12883. getAlphaEquation(): number;
  12884. }
  12885. }
  12886. }
  12887. declare module "babylonjs/Particles/particleSystem" {
  12888. import { Nullable } from "babylonjs/types";
  12889. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12890. import { Observable } from "babylonjs/Misc/observable";
  12891. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12892. import { Effect } from "babylonjs/Materials/effect";
  12893. import { IDisposable } from "babylonjs/scene";
  12894. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12895. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12896. import { Particle } from "babylonjs/Particles/particle";
  12897. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12898. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12899. import "babylonjs/Shaders/particles.fragment";
  12900. import "babylonjs/Shaders/particles.vertex";
  12901. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12902. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12903. import "babylonjs/Engines/Extensions/engine.alpha";
  12904. import { Scene } from "babylonjs/scene";
  12905. /**
  12906. * This represents a particle system in Babylon.
  12907. * 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.
  12908. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12909. * @example https://doc.babylonjs.com/babylon101/particles
  12910. */
  12911. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12912. /**
  12913. * Billboard mode will only apply to Y axis
  12914. */
  12915. static readonly BILLBOARDMODE_Y: number;
  12916. /**
  12917. * Billboard mode will apply to all axes
  12918. */
  12919. static readonly BILLBOARDMODE_ALL: number;
  12920. /**
  12921. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12922. */
  12923. static readonly BILLBOARDMODE_STRETCHED: number;
  12924. /**
  12925. * This function can be defined to provide custom update for active particles.
  12926. * This function will be called instead of regular update (age, position, color, etc.).
  12927. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12928. */
  12929. updateFunction: (particles: Particle[]) => void;
  12930. private _emitterWorldMatrix;
  12931. /**
  12932. * This function can be defined to specify initial direction for every new particle.
  12933. * It by default use the emitterType defined function
  12934. */
  12935. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12936. /**
  12937. * This function can be defined to specify initial position for every new particle.
  12938. * It by default use the emitterType defined function
  12939. */
  12940. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12941. /**
  12942. * @hidden
  12943. */
  12944. _inheritedVelocityOffset: Vector3;
  12945. /**
  12946. * An event triggered when the system is disposed
  12947. */
  12948. onDisposeObservable: Observable<IParticleSystem>;
  12949. private _onDisposeObserver;
  12950. /**
  12951. * Sets a callback that will be triggered when the system is disposed
  12952. */
  12953. set onDispose(callback: () => void);
  12954. private _particles;
  12955. private _epsilon;
  12956. private _capacity;
  12957. private _stockParticles;
  12958. private _newPartsExcess;
  12959. private _vertexData;
  12960. private _vertexBuffer;
  12961. private _vertexBuffers;
  12962. private _spriteBuffer;
  12963. private _indexBuffer;
  12964. private _effect;
  12965. private _customEffect;
  12966. private _cachedDefines;
  12967. private _scaledColorStep;
  12968. private _colorDiff;
  12969. private _scaledDirection;
  12970. private _scaledGravity;
  12971. private _currentRenderId;
  12972. private _alive;
  12973. private _useInstancing;
  12974. private _started;
  12975. private _stopped;
  12976. private _actualFrame;
  12977. private _scaledUpdateSpeed;
  12978. private _vertexBufferSize;
  12979. /** @hidden */
  12980. _currentEmitRateGradient: Nullable<FactorGradient>;
  12981. /** @hidden */
  12982. _currentEmitRate1: number;
  12983. /** @hidden */
  12984. _currentEmitRate2: number;
  12985. /** @hidden */
  12986. _currentStartSizeGradient: Nullable<FactorGradient>;
  12987. /** @hidden */
  12988. _currentStartSize1: number;
  12989. /** @hidden */
  12990. _currentStartSize2: number;
  12991. private readonly _rawTextureWidth;
  12992. private _rampGradientsTexture;
  12993. private _useRampGradients;
  12994. /** Gets or sets a matrix to use to compute projection */
  12995. defaultProjectionMatrix: Matrix;
  12996. /** Gets or sets a matrix to use to compute view */
  12997. defaultViewMatrix: Matrix;
  12998. /** Gets or sets a boolean indicating that ramp gradients must be used
  12999. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13000. */
  13001. get useRampGradients(): boolean;
  13002. set useRampGradients(value: boolean);
  13003. /**
  13004. * 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.
  13005. * 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: [])
  13006. */
  13007. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13008. private _subEmitters;
  13009. /**
  13010. * @hidden
  13011. * If the particle systems emitter should be disposed when the particle system is disposed
  13012. */
  13013. _disposeEmitterOnDispose: boolean;
  13014. /**
  13015. * The current active Sub-systems, this property is used by the root particle system only.
  13016. */
  13017. activeSubSystems: Array<ParticleSystem>;
  13018. /**
  13019. * Specifies if the particles are updated in emitter local space or world space
  13020. */
  13021. isLocal: boolean;
  13022. private _rootParticleSystem;
  13023. /**
  13024. * Gets the current list of active particles
  13025. */
  13026. get particles(): Particle[];
  13027. /**
  13028. * Gets the number of particles active at the same time.
  13029. * @returns The number of active particles.
  13030. */
  13031. getActiveCount(): number;
  13032. /**
  13033. * Returns the string "ParticleSystem"
  13034. * @returns a string containing the class name
  13035. */
  13036. getClassName(): string;
  13037. /**
  13038. * Gets a boolean indicating that the system is stopping
  13039. * @returns true if the system is currently stopping
  13040. */
  13041. isStopping(): boolean;
  13042. /**
  13043. * Gets the custom effect used to render the particles
  13044. * @param blendMode Blend mode for which the effect should be retrieved
  13045. * @returns The effect
  13046. */
  13047. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13048. /**
  13049. * Sets the custom effect used to render the particles
  13050. * @param effect The effect to set
  13051. * @param blendMode Blend mode for which the effect should be set
  13052. */
  13053. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13054. /** @hidden */
  13055. private _onBeforeDrawParticlesObservable;
  13056. /**
  13057. * Observable that will be called just before the particles are drawn
  13058. */
  13059. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13060. /**
  13061. * Gets the name of the particle vertex shader
  13062. */
  13063. get vertexShaderName(): string;
  13064. /**
  13065. * Instantiates a particle system.
  13066. * 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.
  13067. * @param name The name of the particle system
  13068. * @param capacity The max number of particles alive at the same time
  13069. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13070. * @param customEffect a custom effect used to change the way particles are rendered by default
  13071. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13072. * @param epsilon Offset used to render the particles
  13073. */
  13074. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13075. private _addFactorGradient;
  13076. private _removeFactorGradient;
  13077. /**
  13078. * Adds a new life time gradient
  13079. * @param gradient defines the gradient to use (between 0 and 1)
  13080. * @param factor defines the life time factor to affect to the specified gradient
  13081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13082. * @returns the current particle system
  13083. */
  13084. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13085. /**
  13086. * Remove a specific life time gradient
  13087. * @param gradient defines the gradient to remove
  13088. * @returns the current particle system
  13089. */
  13090. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13091. /**
  13092. * Adds a new size gradient
  13093. * @param gradient defines the gradient to use (between 0 and 1)
  13094. * @param factor defines the size factor to affect to the specified gradient
  13095. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13096. * @returns the current particle system
  13097. */
  13098. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13099. /**
  13100. * Remove a specific size gradient
  13101. * @param gradient defines the gradient to remove
  13102. * @returns the current particle system
  13103. */
  13104. removeSizeGradient(gradient: number): IParticleSystem;
  13105. /**
  13106. * Adds a new color remap gradient
  13107. * @param gradient defines the gradient to use (between 0 and 1)
  13108. * @param min defines the color remap minimal range
  13109. * @param max defines the color remap maximal range
  13110. * @returns the current particle system
  13111. */
  13112. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13113. /**
  13114. * Remove a specific color remap gradient
  13115. * @param gradient defines the gradient to remove
  13116. * @returns the current particle system
  13117. */
  13118. removeColorRemapGradient(gradient: number): IParticleSystem;
  13119. /**
  13120. * Adds a new alpha remap gradient
  13121. * @param gradient defines the gradient to use (between 0 and 1)
  13122. * @param min defines the alpha remap minimal range
  13123. * @param max defines the alpha remap maximal range
  13124. * @returns the current particle system
  13125. */
  13126. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13127. /**
  13128. * Remove a specific alpha remap gradient
  13129. * @param gradient defines the gradient to remove
  13130. * @returns the current particle system
  13131. */
  13132. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13133. /**
  13134. * Adds a new angular speed gradient
  13135. * @param gradient defines the gradient to use (between 0 and 1)
  13136. * @param factor defines the angular speed to affect to the specified gradient
  13137. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13138. * @returns the current particle system
  13139. */
  13140. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13141. /**
  13142. * Remove a specific angular speed gradient
  13143. * @param gradient defines the gradient to remove
  13144. * @returns the current particle system
  13145. */
  13146. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13147. /**
  13148. * Adds a new velocity gradient
  13149. * @param gradient defines the gradient to use (between 0 and 1)
  13150. * @param factor defines the velocity to affect to the specified gradient
  13151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13152. * @returns the current particle system
  13153. */
  13154. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13155. /**
  13156. * Remove a specific velocity gradient
  13157. * @param gradient defines the gradient to remove
  13158. * @returns the current particle system
  13159. */
  13160. removeVelocityGradient(gradient: number): IParticleSystem;
  13161. /**
  13162. * Adds a new limit velocity gradient
  13163. * @param gradient defines the gradient to use (between 0 and 1)
  13164. * @param factor defines the limit velocity value to affect to the specified gradient
  13165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13166. * @returns the current particle system
  13167. */
  13168. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13169. /**
  13170. * Remove a specific limit velocity gradient
  13171. * @param gradient defines the gradient to remove
  13172. * @returns the current particle system
  13173. */
  13174. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13175. /**
  13176. * Adds a new drag gradient
  13177. * @param gradient defines the gradient to use (between 0 and 1)
  13178. * @param factor defines the drag value to affect to the specified gradient
  13179. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13180. * @returns the current particle system
  13181. */
  13182. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13183. /**
  13184. * Remove a specific drag gradient
  13185. * @param gradient defines the gradient to remove
  13186. * @returns the current particle system
  13187. */
  13188. removeDragGradient(gradient: number): IParticleSystem;
  13189. /**
  13190. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13191. * @param gradient defines the gradient to use (between 0 and 1)
  13192. * @param factor defines the emit rate value to affect to the specified gradient
  13193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13194. * @returns the current particle system
  13195. */
  13196. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13197. /**
  13198. * Remove a specific emit rate gradient
  13199. * @param gradient defines the gradient to remove
  13200. * @returns the current particle system
  13201. */
  13202. removeEmitRateGradient(gradient: number): IParticleSystem;
  13203. /**
  13204. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13205. * @param gradient defines the gradient to use (between 0 and 1)
  13206. * @param factor defines the start size value to affect to the specified gradient
  13207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13208. * @returns the current particle system
  13209. */
  13210. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13211. /**
  13212. * Remove a specific start size gradient
  13213. * @param gradient defines the gradient to remove
  13214. * @returns the current particle system
  13215. */
  13216. removeStartSizeGradient(gradient: number): IParticleSystem;
  13217. private _createRampGradientTexture;
  13218. /**
  13219. * Gets the current list of ramp gradients.
  13220. * You must use addRampGradient and removeRampGradient to udpate this list
  13221. * @returns the list of ramp gradients
  13222. */
  13223. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13224. /** Force the system to rebuild all gradients that need to be resync */
  13225. forceRefreshGradients(): void;
  13226. private _syncRampGradientTexture;
  13227. /**
  13228. * Adds a new ramp gradient used to remap particle colors
  13229. * @param gradient defines the gradient to use (between 0 and 1)
  13230. * @param color defines the color to affect to the specified gradient
  13231. * @returns the current particle system
  13232. */
  13233. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13234. /**
  13235. * Remove a specific ramp gradient
  13236. * @param gradient defines the gradient to remove
  13237. * @returns the current particle system
  13238. */
  13239. removeRampGradient(gradient: number): ParticleSystem;
  13240. /**
  13241. * Adds a new color gradient
  13242. * @param gradient defines the gradient to use (between 0 and 1)
  13243. * @param color1 defines the color to affect to the specified gradient
  13244. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13245. * @returns this particle system
  13246. */
  13247. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13248. /**
  13249. * Remove a specific color gradient
  13250. * @param gradient defines the gradient to remove
  13251. * @returns this particle system
  13252. */
  13253. removeColorGradient(gradient: number): IParticleSystem;
  13254. private _fetchR;
  13255. protected _reset(): void;
  13256. private _resetEffect;
  13257. private _createVertexBuffers;
  13258. private _createIndexBuffer;
  13259. /**
  13260. * Gets the maximum number of particles active at the same time.
  13261. * @returns The max number of active particles.
  13262. */
  13263. getCapacity(): number;
  13264. /**
  13265. * Gets whether there are still active particles in the system.
  13266. * @returns True if it is alive, otherwise false.
  13267. */
  13268. isAlive(): boolean;
  13269. /**
  13270. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13271. * @returns True if it has been started, otherwise false.
  13272. */
  13273. isStarted(): boolean;
  13274. private _prepareSubEmitterInternalArray;
  13275. /**
  13276. * Starts the particle system and begins to emit
  13277. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13278. */
  13279. start(delay?: number): void;
  13280. /**
  13281. * Stops the particle system.
  13282. * @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.
  13283. */
  13284. stop(stopSubEmitters?: boolean): void;
  13285. /**
  13286. * Remove all active particles
  13287. */
  13288. reset(): void;
  13289. /**
  13290. * @hidden (for internal use only)
  13291. */
  13292. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13293. /**
  13294. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13295. * Its lifetime will start back at 0.
  13296. */
  13297. recycleParticle: (particle: Particle) => void;
  13298. private _stopSubEmitters;
  13299. private _createParticle;
  13300. private _removeFromRoot;
  13301. private _emitFromParticle;
  13302. private _update;
  13303. /** @hidden */
  13304. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13305. /** @hidden */
  13306. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13307. /**
  13308. * Fill the defines array according to the current settings of the particle system
  13309. * @param defines Array to be updated
  13310. * @param blendMode blend mode to take into account when updating the array
  13311. */
  13312. fillDefines(defines: Array<string>, blendMode: number): void;
  13313. /**
  13314. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13315. * @param uniforms Uniforms array to fill
  13316. * @param attributes Attributes array to fill
  13317. * @param samplers Samplers array to fill
  13318. */
  13319. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13320. /** @hidden */
  13321. private _getEffect;
  13322. /**
  13323. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13324. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13325. */
  13326. animate(preWarmOnly?: boolean): void;
  13327. private _appendParticleVertices;
  13328. /**
  13329. * Rebuilds the particle system.
  13330. */
  13331. rebuild(): void;
  13332. /**
  13333. * Is this system ready to be used/rendered
  13334. * @return true if the system is ready
  13335. */
  13336. isReady(): boolean;
  13337. private _render;
  13338. /**
  13339. * Renders the particle system in its current state.
  13340. * @returns the current number of particles
  13341. */
  13342. render(): number;
  13343. /**
  13344. * Disposes the particle system and free the associated resources
  13345. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13346. */
  13347. dispose(disposeTexture?: boolean): void;
  13348. /**
  13349. * Clones the particle system.
  13350. * @param name The name of the cloned object
  13351. * @param newEmitter The new emitter to use
  13352. * @returns the cloned particle system
  13353. */
  13354. clone(name: string, newEmitter: any): ParticleSystem;
  13355. /**
  13356. * Serializes the particle system to a JSON object
  13357. * @param serializeTexture defines if the texture must be serialized as well
  13358. * @returns the JSON object
  13359. */
  13360. serialize(serializeTexture?: boolean): any;
  13361. /** @hidden */
  13362. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13363. /** @hidden */
  13364. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13365. /**
  13366. * Parses a JSON object to create a particle system.
  13367. * @param parsedParticleSystem The JSON object to parse
  13368. * @param sceneOrEngine The scene or the engine to create the particle system in
  13369. * @param rootUrl The root url to use to load external dependencies like texture
  13370. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13371. * @returns the Parsed particle system
  13372. */
  13373. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13374. }
  13375. }
  13376. declare module "babylonjs/Particles/particle" {
  13377. import { Nullable } from "babylonjs/types";
  13378. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13379. import { Color4 } from "babylonjs/Maths/math.color";
  13380. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13381. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13382. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13383. /**
  13384. * A particle represents one of the element emitted by a particle system.
  13385. * This is mainly define by its coordinates, direction, velocity and age.
  13386. */
  13387. export class Particle {
  13388. /**
  13389. * The particle system the particle belongs to.
  13390. */
  13391. particleSystem: ParticleSystem;
  13392. private static _Count;
  13393. /**
  13394. * Unique ID of the particle
  13395. */
  13396. id: number;
  13397. /**
  13398. * The world position of the particle in the scene.
  13399. */
  13400. position: Vector3;
  13401. /**
  13402. * The world direction of the particle in the scene.
  13403. */
  13404. direction: Vector3;
  13405. /**
  13406. * The color of the particle.
  13407. */
  13408. color: Color4;
  13409. /**
  13410. * The color change of the particle per step.
  13411. */
  13412. colorStep: Color4;
  13413. /**
  13414. * Defines how long will the life of the particle be.
  13415. */
  13416. lifeTime: number;
  13417. /**
  13418. * The current age of the particle.
  13419. */
  13420. age: number;
  13421. /**
  13422. * The current size of the particle.
  13423. */
  13424. size: number;
  13425. /**
  13426. * The current scale of the particle.
  13427. */
  13428. scale: Vector2;
  13429. /**
  13430. * The current angle of the particle.
  13431. */
  13432. angle: number;
  13433. /**
  13434. * Defines how fast is the angle changing.
  13435. */
  13436. angularSpeed: number;
  13437. /**
  13438. * Defines the cell index used by the particle to be rendered from a sprite.
  13439. */
  13440. cellIndex: number;
  13441. /**
  13442. * The information required to support color remapping
  13443. */
  13444. remapData: Vector4;
  13445. /** @hidden */
  13446. _randomCellOffset?: number;
  13447. /** @hidden */
  13448. _initialDirection: Nullable<Vector3>;
  13449. /** @hidden */
  13450. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13451. /** @hidden */
  13452. _initialStartSpriteCellID: number;
  13453. /** @hidden */
  13454. _initialEndSpriteCellID: number;
  13455. /** @hidden */
  13456. _currentColorGradient: Nullable<ColorGradient>;
  13457. /** @hidden */
  13458. _currentColor1: Color4;
  13459. /** @hidden */
  13460. _currentColor2: Color4;
  13461. /** @hidden */
  13462. _currentSizeGradient: Nullable<FactorGradient>;
  13463. /** @hidden */
  13464. _currentSize1: number;
  13465. /** @hidden */
  13466. _currentSize2: number;
  13467. /** @hidden */
  13468. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13469. /** @hidden */
  13470. _currentAngularSpeed1: number;
  13471. /** @hidden */
  13472. _currentAngularSpeed2: number;
  13473. /** @hidden */
  13474. _currentVelocityGradient: Nullable<FactorGradient>;
  13475. /** @hidden */
  13476. _currentVelocity1: number;
  13477. /** @hidden */
  13478. _currentVelocity2: number;
  13479. /** @hidden */
  13480. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13481. /** @hidden */
  13482. _currentLimitVelocity1: number;
  13483. /** @hidden */
  13484. _currentLimitVelocity2: number;
  13485. /** @hidden */
  13486. _currentDragGradient: Nullable<FactorGradient>;
  13487. /** @hidden */
  13488. _currentDrag1: number;
  13489. /** @hidden */
  13490. _currentDrag2: number;
  13491. /** @hidden */
  13492. _randomNoiseCoordinates1: Vector3;
  13493. /** @hidden */
  13494. _randomNoiseCoordinates2: Vector3;
  13495. /** @hidden */
  13496. _localPosition?: Vector3;
  13497. /**
  13498. * Creates a new instance Particle
  13499. * @param particleSystem the particle system the particle belongs to
  13500. */
  13501. constructor(
  13502. /**
  13503. * The particle system the particle belongs to.
  13504. */
  13505. particleSystem: ParticleSystem);
  13506. private updateCellInfoFromSystem;
  13507. /**
  13508. * Defines how the sprite cell index is updated for the particle
  13509. */
  13510. updateCellIndex(): void;
  13511. /** @hidden */
  13512. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13513. /** @hidden */
  13514. _inheritParticleInfoToSubEmitters(): void;
  13515. /** @hidden */
  13516. _reset(): void;
  13517. /**
  13518. * Copy the properties of particle to another one.
  13519. * @param other the particle to copy the information to.
  13520. */
  13521. copyTo(other: Particle): void;
  13522. }
  13523. }
  13524. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13525. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13526. import { Effect } from "babylonjs/Materials/effect";
  13527. import { Particle } from "babylonjs/Particles/particle";
  13528. import { Nullable } from "babylonjs/types";
  13529. import { Scene } from "babylonjs/scene";
  13530. /**
  13531. * Particle emitter represents a volume emitting particles.
  13532. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13533. */
  13534. export interface IParticleEmitterType {
  13535. /**
  13536. * Called by the particle System when the direction is computed for the created particle.
  13537. * @param worldMatrix is the world matrix of the particle system
  13538. * @param directionToUpdate is the direction vector to update with the result
  13539. * @param particle is the particle we are computed the direction for
  13540. * @param isLocal defines if the direction should be set in local space
  13541. */
  13542. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13543. /**
  13544. * Called by the particle System when the position is computed for the created particle.
  13545. * @param worldMatrix is the world matrix of the particle system
  13546. * @param positionToUpdate is the position vector to update with the result
  13547. * @param particle is the particle we are computed the position for
  13548. * @param isLocal defines if the position should be set in local space
  13549. */
  13550. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13551. /**
  13552. * Clones the current emitter and returns a copy of it
  13553. * @returns the new emitter
  13554. */
  13555. clone(): IParticleEmitterType;
  13556. /**
  13557. * Called by the GPUParticleSystem to setup the update shader
  13558. * @param effect defines the update shader
  13559. */
  13560. applyToShader(effect: Effect): void;
  13561. /**
  13562. * Returns a string to use to update the GPU particles update shader
  13563. * @returns the effect defines string
  13564. */
  13565. getEffectDefines(): string;
  13566. /**
  13567. * Returns a string representing the class name
  13568. * @returns a string containing the class name
  13569. */
  13570. getClassName(): string;
  13571. /**
  13572. * Serializes the particle system to a JSON object.
  13573. * @returns the JSON object
  13574. */
  13575. serialize(): any;
  13576. /**
  13577. * Parse properties from a JSON object
  13578. * @param serializationObject defines the JSON object
  13579. * @param scene defines the hosting scene
  13580. */
  13581. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13582. }
  13583. }
  13584. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13585. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13586. import { Effect } from "babylonjs/Materials/effect";
  13587. import { Particle } from "babylonjs/Particles/particle";
  13588. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13589. /**
  13590. * Particle emitter emitting particles from the inside of a box.
  13591. * It emits the particles randomly between 2 given directions.
  13592. */
  13593. export class BoxParticleEmitter implements IParticleEmitterType {
  13594. /**
  13595. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13596. */
  13597. direction1: Vector3;
  13598. /**
  13599. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13600. */
  13601. direction2: Vector3;
  13602. /**
  13603. * 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.
  13604. */
  13605. minEmitBox: Vector3;
  13606. /**
  13607. * 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.
  13608. */
  13609. maxEmitBox: Vector3;
  13610. /**
  13611. * Creates a new instance BoxParticleEmitter
  13612. */
  13613. constructor();
  13614. /**
  13615. * Called by the particle System when the direction is computed for the created particle.
  13616. * @param worldMatrix is the world matrix of the particle system
  13617. * @param directionToUpdate is the direction vector to update with the result
  13618. * @param particle is the particle we are computed the direction for
  13619. * @param isLocal defines if the direction should be set in local space
  13620. */
  13621. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13622. /**
  13623. * Called by the particle System when the position is computed for the created particle.
  13624. * @param worldMatrix is the world matrix of the particle system
  13625. * @param positionToUpdate is the position vector to update with the result
  13626. * @param particle is the particle we are computed the position for
  13627. * @param isLocal defines if the position should be set in local space
  13628. */
  13629. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13630. /**
  13631. * Clones the current emitter and returns a copy of it
  13632. * @returns the new emitter
  13633. */
  13634. clone(): BoxParticleEmitter;
  13635. /**
  13636. * Called by the GPUParticleSystem to setup the update shader
  13637. * @param effect defines the update shader
  13638. */
  13639. applyToShader(effect: Effect): void;
  13640. /**
  13641. * Returns a string to use to update the GPU particles update shader
  13642. * @returns a string containng the defines string
  13643. */
  13644. getEffectDefines(): string;
  13645. /**
  13646. * Returns the string "BoxParticleEmitter"
  13647. * @returns a string containing the class name
  13648. */
  13649. getClassName(): string;
  13650. /**
  13651. * Serializes the particle system to a JSON object.
  13652. * @returns the JSON object
  13653. */
  13654. serialize(): any;
  13655. /**
  13656. * Parse properties from a JSON object
  13657. * @param serializationObject defines the JSON object
  13658. */
  13659. parse(serializationObject: any): void;
  13660. }
  13661. }
  13662. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13663. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13664. import { Effect } from "babylonjs/Materials/effect";
  13665. import { Particle } from "babylonjs/Particles/particle";
  13666. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13667. /**
  13668. * Particle emitter emitting particles from the inside of a cone.
  13669. * It emits the particles alongside the cone volume from the base to the particle.
  13670. * The emission direction might be randomized.
  13671. */
  13672. export class ConeParticleEmitter implements IParticleEmitterType {
  13673. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13674. directionRandomizer: number;
  13675. private _radius;
  13676. private _angle;
  13677. private _height;
  13678. /**
  13679. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13680. */
  13681. radiusRange: number;
  13682. /**
  13683. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13684. */
  13685. heightRange: number;
  13686. /**
  13687. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13688. */
  13689. emitFromSpawnPointOnly: boolean;
  13690. /**
  13691. * Gets or sets the radius of the emission cone
  13692. */
  13693. get radius(): number;
  13694. set radius(value: number);
  13695. /**
  13696. * Gets or sets the angle of the emission cone
  13697. */
  13698. get angle(): number;
  13699. set angle(value: number);
  13700. private _buildHeight;
  13701. /**
  13702. * Creates a new instance ConeParticleEmitter
  13703. * @param radius the radius of the emission cone (1 by default)
  13704. * @param angle the cone base angle (PI by default)
  13705. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13706. */
  13707. constructor(radius?: number, angle?: number,
  13708. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13709. directionRandomizer?: number);
  13710. /**
  13711. * Called by the particle System when the direction is computed for the created particle.
  13712. * @param worldMatrix is the world matrix of the particle system
  13713. * @param directionToUpdate is the direction vector to update with the result
  13714. * @param particle is the particle we are computed the direction for
  13715. * @param isLocal defines if the direction should be set in local space
  13716. */
  13717. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13718. /**
  13719. * Called by the particle System when the position is computed for the created particle.
  13720. * @param worldMatrix is the world matrix of the particle system
  13721. * @param positionToUpdate is the position vector to update with the result
  13722. * @param particle is the particle we are computed the position for
  13723. * @param isLocal defines if the position should be set in local space
  13724. */
  13725. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13726. /**
  13727. * Clones the current emitter and returns a copy of it
  13728. * @returns the new emitter
  13729. */
  13730. clone(): ConeParticleEmitter;
  13731. /**
  13732. * Called by the GPUParticleSystem to setup the update shader
  13733. * @param effect defines the update shader
  13734. */
  13735. applyToShader(effect: Effect): void;
  13736. /**
  13737. * Returns a string to use to update the GPU particles update shader
  13738. * @returns a string containng the defines string
  13739. */
  13740. getEffectDefines(): string;
  13741. /**
  13742. * Returns the string "ConeParticleEmitter"
  13743. * @returns a string containing the class name
  13744. */
  13745. getClassName(): string;
  13746. /**
  13747. * Serializes the particle system to a JSON object.
  13748. * @returns the JSON object
  13749. */
  13750. serialize(): any;
  13751. /**
  13752. * Parse properties from a JSON object
  13753. * @param serializationObject defines the JSON object
  13754. */
  13755. parse(serializationObject: any): void;
  13756. }
  13757. }
  13758. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13760. import { Effect } from "babylonjs/Materials/effect";
  13761. import { Particle } from "babylonjs/Particles/particle";
  13762. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13763. /**
  13764. * Particle emitter emitting particles from the inside of a cylinder.
  13765. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13766. */
  13767. export class CylinderParticleEmitter implements IParticleEmitterType {
  13768. /**
  13769. * The radius of the emission cylinder.
  13770. */
  13771. radius: number;
  13772. /**
  13773. * The height of the emission cylinder.
  13774. */
  13775. height: number;
  13776. /**
  13777. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13778. */
  13779. radiusRange: number;
  13780. /**
  13781. * How much to randomize the particle direction [0-1].
  13782. */
  13783. directionRandomizer: number;
  13784. /**
  13785. * Creates a new instance CylinderParticleEmitter
  13786. * @param radius the radius of the emission cylinder (1 by default)
  13787. * @param height the height of the emission cylinder (1 by default)
  13788. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13789. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13790. */
  13791. constructor(
  13792. /**
  13793. * The radius of the emission cylinder.
  13794. */
  13795. radius?: number,
  13796. /**
  13797. * The height of the emission cylinder.
  13798. */
  13799. height?: number,
  13800. /**
  13801. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13802. */
  13803. radiusRange?: number,
  13804. /**
  13805. * How much to randomize the particle direction [0-1].
  13806. */
  13807. directionRandomizer?: number);
  13808. /**
  13809. * Called by the particle System when the direction is computed for the created particle.
  13810. * @param worldMatrix is the world matrix of the particle system
  13811. * @param directionToUpdate is the direction vector to update with the result
  13812. * @param particle is the particle we are computed the direction for
  13813. * @param isLocal defines if the direction should be set in local space
  13814. */
  13815. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13816. /**
  13817. * Called by the particle System when the position is computed for the created particle.
  13818. * @param worldMatrix is the world matrix of the particle system
  13819. * @param positionToUpdate is the position vector to update with the result
  13820. * @param particle is the particle we are computed the position for
  13821. * @param isLocal defines if the position should be set in local space
  13822. */
  13823. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13824. /**
  13825. * Clones the current emitter and returns a copy of it
  13826. * @returns the new emitter
  13827. */
  13828. clone(): CylinderParticleEmitter;
  13829. /**
  13830. * Called by the GPUParticleSystem to setup the update shader
  13831. * @param effect defines the update shader
  13832. */
  13833. applyToShader(effect: Effect): void;
  13834. /**
  13835. * Returns a string to use to update the GPU particles update shader
  13836. * @returns a string containng the defines string
  13837. */
  13838. getEffectDefines(): string;
  13839. /**
  13840. * Returns the string "CylinderParticleEmitter"
  13841. * @returns a string containing the class name
  13842. */
  13843. getClassName(): string;
  13844. /**
  13845. * Serializes the particle system to a JSON object.
  13846. * @returns the JSON object
  13847. */
  13848. serialize(): any;
  13849. /**
  13850. * Parse properties from a JSON object
  13851. * @param serializationObject defines the JSON object
  13852. */
  13853. parse(serializationObject: any): void;
  13854. }
  13855. /**
  13856. * Particle emitter emitting particles from the inside of a cylinder.
  13857. * It emits the particles randomly between two vectors.
  13858. */
  13859. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13860. /**
  13861. * The min limit of the emission direction.
  13862. */
  13863. direction1: Vector3;
  13864. /**
  13865. * The max limit of the emission direction.
  13866. */
  13867. direction2: Vector3;
  13868. /**
  13869. * Creates a new instance CylinderDirectedParticleEmitter
  13870. * @param radius the radius of the emission cylinder (1 by default)
  13871. * @param height the height of the emission cylinder (1 by default)
  13872. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13873. * @param direction1 the min limit of the emission direction (up vector by default)
  13874. * @param direction2 the max limit of the emission direction (up vector by default)
  13875. */
  13876. constructor(radius?: number, height?: number, radiusRange?: number,
  13877. /**
  13878. * The min limit of the emission direction.
  13879. */
  13880. direction1?: Vector3,
  13881. /**
  13882. * The max limit of the emission direction.
  13883. */
  13884. direction2?: Vector3);
  13885. /**
  13886. * Called by the particle System when the direction is computed for the created particle.
  13887. * @param worldMatrix is the world matrix of the particle system
  13888. * @param directionToUpdate is the direction vector to update with the result
  13889. * @param particle is the particle we are computed the direction for
  13890. */
  13891. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13892. /**
  13893. * Clones the current emitter and returns a copy of it
  13894. * @returns the new emitter
  13895. */
  13896. clone(): CylinderDirectedParticleEmitter;
  13897. /**
  13898. * Called by the GPUParticleSystem to setup the update shader
  13899. * @param effect defines the update shader
  13900. */
  13901. applyToShader(effect: Effect): void;
  13902. /**
  13903. * Returns a string to use to update the GPU particles update shader
  13904. * @returns a string containng the defines string
  13905. */
  13906. getEffectDefines(): string;
  13907. /**
  13908. * Returns the string "CylinderDirectedParticleEmitter"
  13909. * @returns a string containing the class name
  13910. */
  13911. getClassName(): string;
  13912. /**
  13913. * Serializes the particle system to a JSON object.
  13914. * @returns the JSON object
  13915. */
  13916. serialize(): any;
  13917. /**
  13918. * Parse properties from a JSON object
  13919. * @param serializationObject defines the JSON object
  13920. */
  13921. parse(serializationObject: any): void;
  13922. }
  13923. }
  13924. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13925. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13926. import { Effect } from "babylonjs/Materials/effect";
  13927. import { Particle } from "babylonjs/Particles/particle";
  13928. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13929. /**
  13930. * Particle emitter emitting particles from the inside of a hemisphere.
  13931. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13932. */
  13933. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13934. /**
  13935. * The radius of the emission hemisphere.
  13936. */
  13937. radius: number;
  13938. /**
  13939. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13940. */
  13941. radiusRange: number;
  13942. /**
  13943. * How much to randomize the particle direction [0-1].
  13944. */
  13945. directionRandomizer: number;
  13946. /**
  13947. * Creates a new instance HemisphericParticleEmitter
  13948. * @param radius the radius of the emission hemisphere (1 by default)
  13949. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13950. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13951. */
  13952. constructor(
  13953. /**
  13954. * The radius of the emission hemisphere.
  13955. */
  13956. radius?: number,
  13957. /**
  13958. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13959. */
  13960. radiusRange?: number,
  13961. /**
  13962. * How much to randomize the particle direction [0-1].
  13963. */
  13964. directionRandomizer?: number);
  13965. /**
  13966. * Called by the particle System when the direction is computed for the created particle.
  13967. * @param worldMatrix is the world matrix of the particle system
  13968. * @param directionToUpdate is the direction vector to update with the result
  13969. * @param particle is the particle we are computed the direction for
  13970. * @param isLocal defines if the direction should be set in local space
  13971. */
  13972. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13973. /**
  13974. * Called by the particle System when the position is computed for the created particle.
  13975. * @param worldMatrix is the world matrix of the particle system
  13976. * @param positionToUpdate is the position vector to update with the result
  13977. * @param particle is the particle we are computed the position for
  13978. * @param isLocal defines if the position should be set in local space
  13979. */
  13980. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13981. /**
  13982. * Clones the current emitter and returns a copy of it
  13983. * @returns the new emitter
  13984. */
  13985. clone(): HemisphericParticleEmitter;
  13986. /**
  13987. * Called by the GPUParticleSystem to setup the update shader
  13988. * @param effect defines the update shader
  13989. */
  13990. applyToShader(effect: Effect): void;
  13991. /**
  13992. * Returns a string to use to update the GPU particles update shader
  13993. * @returns a string containng the defines string
  13994. */
  13995. getEffectDefines(): string;
  13996. /**
  13997. * Returns the string "HemisphericParticleEmitter"
  13998. * @returns a string containing the class name
  13999. */
  14000. getClassName(): string;
  14001. /**
  14002. * Serializes the particle system to a JSON object.
  14003. * @returns the JSON object
  14004. */
  14005. serialize(): any;
  14006. /**
  14007. * Parse properties from a JSON object
  14008. * @param serializationObject defines the JSON object
  14009. */
  14010. parse(serializationObject: any): void;
  14011. }
  14012. }
  14013. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14014. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14015. import { Effect } from "babylonjs/Materials/effect";
  14016. import { Particle } from "babylonjs/Particles/particle";
  14017. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14018. /**
  14019. * Particle emitter emitting particles from a point.
  14020. * It emits the particles randomly between 2 given directions.
  14021. */
  14022. export class PointParticleEmitter implements IParticleEmitterType {
  14023. /**
  14024. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14025. */
  14026. direction1: Vector3;
  14027. /**
  14028. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14029. */
  14030. direction2: Vector3;
  14031. /**
  14032. * Creates a new instance PointParticleEmitter
  14033. */
  14034. constructor();
  14035. /**
  14036. * Called by the particle System when the direction is computed for the created particle.
  14037. * @param worldMatrix is the world matrix of the particle system
  14038. * @param directionToUpdate is the direction vector to update with the result
  14039. * @param particle is the particle we are computed the direction for
  14040. * @param isLocal defines if the direction should be set in local space
  14041. */
  14042. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14043. /**
  14044. * Called by the particle System when the position is computed for the created particle.
  14045. * @param worldMatrix is the world matrix of the particle system
  14046. * @param positionToUpdate is the position vector to update with the result
  14047. * @param particle is the particle we are computed the position for
  14048. * @param isLocal defines if the position should be set in local space
  14049. */
  14050. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14051. /**
  14052. * Clones the current emitter and returns a copy of it
  14053. * @returns the new emitter
  14054. */
  14055. clone(): PointParticleEmitter;
  14056. /**
  14057. * Called by the GPUParticleSystem to setup the update shader
  14058. * @param effect defines the update shader
  14059. */
  14060. applyToShader(effect: Effect): void;
  14061. /**
  14062. * Returns a string to use to update the GPU particles update shader
  14063. * @returns a string containng the defines string
  14064. */
  14065. getEffectDefines(): string;
  14066. /**
  14067. * Returns the string "PointParticleEmitter"
  14068. * @returns a string containing the class name
  14069. */
  14070. getClassName(): string;
  14071. /**
  14072. * Serializes the particle system to a JSON object.
  14073. * @returns the JSON object
  14074. */
  14075. serialize(): any;
  14076. /**
  14077. * Parse properties from a JSON object
  14078. * @param serializationObject defines the JSON object
  14079. */
  14080. parse(serializationObject: any): void;
  14081. }
  14082. }
  14083. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14084. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14085. import { Effect } from "babylonjs/Materials/effect";
  14086. import { Particle } from "babylonjs/Particles/particle";
  14087. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14088. /**
  14089. * Particle emitter emitting particles from the inside of a sphere.
  14090. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14091. */
  14092. export class SphereParticleEmitter implements IParticleEmitterType {
  14093. /**
  14094. * The radius of the emission sphere.
  14095. */
  14096. radius: number;
  14097. /**
  14098. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14099. */
  14100. radiusRange: number;
  14101. /**
  14102. * How much to randomize the particle direction [0-1].
  14103. */
  14104. directionRandomizer: number;
  14105. /**
  14106. * Creates a new instance SphereParticleEmitter
  14107. * @param radius the radius of the emission sphere (1 by default)
  14108. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14109. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14110. */
  14111. constructor(
  14112. /**
  14113. * The radius of the emission sphere.
  14114. */
  14115. radius?: number,
  14116. /**
  14117. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14118. */
  14119. radiusRange?: number,
  14120. /**
  14121. * How much to randomize the particle direction [0-1].
  14122. */
  14123. directionRandomizer?: number);
  14124. /**
  14125. * Called by the particle System when the direction is computed for the created particle.
  14126. * @param worldMatrix is the world matrix of the particle system
  14127. * @param directionToUpdate is the direction vector to update with the result
  14128. * @param particle is the particle we are computed the direction for
  14129. * @param isLocal defines if the direction should be set in local space
  14130. */
  14131. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14132. /**
  14133. * Called by the particle System when the position is computed for the created particle.
  14134. * @param worldMatrix is the world matrix of the particle system
  14135. * @param positionToUpdate is the position vector to update with the result
  14136. * @param particle is the particle we are computed the position for
  14137. * @param isLocal defines if the position should be set in local space
  14138. */
  14139. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14140. /**
  14141. * Clones the current emitter and returns a copy of it
  14142. * @returns the new emitter
  14143. */
  14144. clone(): SphereParticleEmitter;
  14145. /**
  14146. * Called by the GPUParticleSystem to setup the update shader
  14147. * @param effect defines the update shader
  14148. */
  14149. applyToShader(effect: Effect): void;
  14150. /**
  14151. * Returns a string to use to update the GPU particles update shader
  14152. * @returns a string containng the defines string
  14153. */
  14154. getEffectDefines(): string;
  14155. /**
  14156. * Returns the string "SphereParticleEmitter"
  14157. * @returns a string containing the class name
  14158. */
  14159. getClassName(): string;
  14160. /**
  14161. * Serializes the particle system to a JSON object.
  14162. * @returns the JSON object
  14163. */
  14164. serialize(): any;
  14165. /**
  14166. * Parse properties from a JSON object
  14167. * @param serializationObject defines the JSON object
  14168. */
  14169. parse(serializationObject: any): void;
  14170. }
  14171. /**
  14172. * Particle emitter emitting particles from the inside of a sphere.
  14173. * It emits the particles randomly between two vectors.
  14174. */
  14175. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14176. /**
  14177. * The min limit of the emission direction.
  14178. */
  14179. direction1: Vector3;
  14180. /**
  14181. * The max limit of the emission direction.
  14182. */
  14183. direction2: Vector3;
  14184. /**
  14185. * Creates a new instance SphereDirectedParticleEmitter
  14186. * @param radius the radius of the emission sphere (1 by default)
  14187. * @param direction1 the min limit of the emission direction (up vector by default)
  14188. * @param direction2 the max limit of the emission direction (up vector by default)
  14189. */
  14190. constructor(radius?: number,
  14191. /**
  14192. * The min limit of the emission direction.
  14193. */
  14194. direction1?: Vector3,
  14195. /**
  14196. * The max limit of the emission direction.
  14197. */
  14198. direction2?: Vector3);
  14199. /**
  14200. * Called by the particle System when the direction is computed for the created particle.
  14201. * @param worldMatrix is the world matrix of the particle system
  14202. * @param directionToUpdate is the direction vector to update with the result
  14203. * @param particle is the particle we are computed the direction for
  14204. */
  14205. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14206. /**
  14207. * Clones the current emitter and returns a copy of it
  14208. * @returns the new emitter
  14209. */
  14210. clone(): SphereDirectedParticleEmitter;
  14211. /**
  14212. * Called by the GPUParticleSystem to setup the update shader
  14213. * @param effect defines the update shader
  14214. */
  14215. applyToShader(effect: Effect): void;
  14216. /**
  14217. * Returns a string to use to update the GPU particles update shader
  14218. * @returns a string containng the defines string
  14219. */
  14220. getEffectDefines(): string;
  14221. /**
  14222. * Returns the string "SphereDirectedParticleEmitter"
  14223. * @returns a string containing the class name
  14224. */
  14225. getClassName(): string;
  14226. /**
  14227. * Serializes the particle system to a JSON object.
  14228. * @returns the JSON object
  14229. */
  14230. serialize(): any;
  14231. /**
  14232. * Parse properties from a JSON object
  14233. * @param serializationObject defines the JSON object
  14234. */
  14235. parse(serializationObject: any): void;
  14236. }
  14237. }
  14238. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14239. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14240. import { Effect } from "babylonjs/Materials/effect";
  14241. import { Particle } from "babylonjs/Particles/particle";
  14242. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14243. import { Nullable } from "babylonjs/types";
  14244. /**
  14245. * Particle emitter emitting particles from a custom list of positions.
  14246. */
  14247. export class CustomParticleEmitter implements IParticleEmitterType {
  14248. /**
  14249. * Gets or sets the position generator that will create the inital position of each particle.
  14250. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14251. */
  14252. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14253. /**
  14254. * Gets or sets the destination generator that will create the final destination of each particle.
  14255. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14256. */
  14257. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14258. /**
  14259. * Creates a new instance CustomParticleEmitter
  14260. */
  14261. constructor();
  14262. /**
  14263. * Called by the particle System when the direction is computed for the created particle.
  14264. * @param worldMatrix is the world matrix of the particle system
  14265. * @param directionToUpdate is the direction vector to update with the result
  14266. * @param particle is the particle we are computed the direction for
  14267. * @param isLocal defines if the direction should be set in local space
  14268. */
  14269. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14270. /**
  14271. * Called by the particle System when the position is computed for the created particle.
  14272. * @param worldMatrix is the world matrix of the particle system
  14273. * @param positionToUpdate is the position vector to update with the result
  14274. * @param particle is the particle we are computed the position for
  14275. * @param isLocal defines if the position should be set in local space
  14276. */
  14277. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14278. /**
  14279. * Clones the current emitter and returns a copy of it
  14280. * @returns the new emitter
  14281. */
  14282. clone(): CustomParticleEmitter;
  14283. /**
  14284. * Called by the GPUParticleSystem to setup the update shader
  14285. * @param effect defines the update shader
  14286. */
  14287. applyToShader(effect: Effect): void;
  14288. /**
  14289. * Returns a string to use to update the GPU particles update shader
  14290. * @returns a string containng the defines string
  14291. */
  14292. getEffectDefines(): string;
  14293. /**
  14294. * Returns the string "PointParticleEmitter"
  14295. * @returns a string containing the class name
  14296. */
  14297. getClassName(): string;
  14298. /**
  14299. * Serializes the particle system to a JSON object.
  14300. * @returns the JSON object
  14301. */
  14302. serialize(): any;
  14303. /**
  14304. * Parse properties from a JSON object
  14305. * @param serializationObject defines the JSON object
  14306. */
  14307. parse(serializationObject: any): void;
  14308. }
  14309. }
  14310. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14311. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14312. import { Effect } from "babylonjs/Materials/effect";
  14313. import { Particle } from "babylonjs/Particles/particle";
  14314. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14315. import { Nullable } from "babylonjs/types";
  14316. import { Scene } from "babylonjs/scene";
  14317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14318. /**
  14319. * Particle emitter emitting particles from the inside of a box.
  14320. * It emits the particles randomly between 2 given directions.
  14321. */
  14322. export class MeshParticleEmitter implements IParticleEmitterType {
  14323. private _indices;
  14324. private _positions;
  14325. private _normals;
  14326. private _storedNormal;
  14327. private _mesh;
  14328. /**
  14329. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14330. */
  14331. direction1: Vector3;
  14332. /**
  14333. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14334. */
  14335. direction2: Vector3;
  14336. /**
  14337. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14338. */
  14339. useMeshNormalsForDirection: boolean;
  14340. /** Defines the mesh to use as source */
  14341. get mesh(): Nullable<AbstractMesh>;
  14342. set mesh(value: Nullable<AbstractMesh>);
  14343. /**
  14344. * Creates a new instance MeshParticleEmitter
  14345. * @param mesh defines the mesh to use as source
  14346. */
  14347. constructor(mesh?: Nullable<AbstractMesh>);
  14348. /**
  14349. * Called by the particle System when the direction is computed for the created particle.
  14350. * @param worldMatrix is the world matrix of the particle system
  14351. * @param directionToUpdate is the direction vector to update with the result
  14352. * @param particle is the particle we are computed the direction for
  14353. * @param isLocal defines if the direction should be set in local space
  14354. */
  14355. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14356. /**
  14357. * Called by the particle System when the position is computed for the created particle.
  14358. * @param worldMatrix is the world matrix of the particle system
  14359. * @param positionToUpdate is the position vector to update with the result
  14360. * @param particle is the particle we are computed the position for
  14361. * @param isLocal defines if the position should be set in local space
  14362. */
  14363. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14364. /**
  14365. * Clones the current emitter and returns a copy of it
  14366. * @returns the new emitter
  14367. */
  14368. clone(): MeshParticleEmitter;
  14369. /**
  14370. * Called by the GPUParticleSystem to setup the update shader
  14371. * @param effect defines the update shader
  14372. */
  14373. applyToShader(effect: Effect): void;
  14374. /**
  14375. * Returns a string to use to update the GPU particles update shader
  14376. * @returns a string containng the defines string
  14377. */
  14378. getEffectDefines(): string;
  14379. /**
  14380. * Returns the string "BoxParticleEmitter"
  14381. * @returns a string containing the class name
  14382. */
  14383. getClassName(): string;
  14384. /**
  14385. * Serializes the particle system to a JSON object.
  14386. * @returns the JSON object
  14387. */
  14388. serialize(): any;
  14389. /**
  14390. * Parse properties from a JSON object
  14391. * @param serializationObject defines the JSON object
  14392. * @param scene defines the hosting scene
  14393. */
  14394. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14395. }
  14396. }
  14397. declare module "babylonjs/Particles/EmitterTypes/index" {
  14398. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14399. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14400. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14401. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14402. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14403. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14404. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14405. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14406. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14407. }
  14408. declare module "babylonjs/Particles/IParticleSystem" {
  14409. import { Nullable } from "babylonjs/types";
  14410. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14411. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14413. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14414. import { Scene } from "babylonjs/scene";
  14415. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14416. import { Effect } from "babylonjs/Materials/effect";
  14417. import { Observable } from "babylonjs/Misc/observable";
  14418. import { Animation } from "babylonjs/Animations/animation";
  14419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14420. /**
  14421. * Interface representing a particle system in Babylon.js.
  14422. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14423. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14424. */
  14425. export interface IParticleSystem {
  14426. /**
  14427. * List of animations used by the particle system.
  14428. */
  14429. animations: Animation[];
  14430. /**
  14431. * The id of the Particle system.
  14432. */
  14433. id: string;
  14434. /**
  14435. * The name of the Particle system.
  14436. */
  14437. name: string;
  14438. /**
  14439. * The emitter represents the Mesh or position we are attaching the particle system to.
  14440. */
  14441. emitter: Nullable<AbstractMesh | Vector3>;
  14442. /**
  14443. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14444. */
  14445. isBillboardBased: boolean;
  14446. /**
  14447. * The rendering group used by the Particle system to chose when to render.
  14448. */
  14449. renderingGroupId: number;
  14450. /**
  14451. * The layer mask we are rendering the particles through.
  14452. */
  14453. layerMask: number;
  14454. /**
  14455. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14456. */
  14457. updateSpeed: number;
  14458. /**
  14459. * The amount of time the particle system is running (depends of the overall update speed).
  14460. */
  14461. targetStopDuration: number;
  14462. /**
  14463. * The texture used to render each particle. (this can be a spritesheet)
  14464. */
  14465. particleTexture: Nullable<BaseTexture>;
  14466. /**
  14467. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14468. */
  14469. blendMode: number;
  14470. /**
  14471. * Minimum life time of emitting particles.
  14472. */
  14473. minLifeTime: number;
  14474. /**
  14475. * Maximum life time of emitting particles.
  14476. */
  14477. maxLifeTime: number;
  14478. /**
  14479. * Minimum Size of emitting particles.
  14480. */
  14481. minSize: number;
  14482. /**
  14483. * Maximum Size of emitting particles.
  14484. */
  14485. maxSize: number;
  14486. /**
  14487. * Minimum scale of emitting particles on X axis.
  14488. */
  14489. minScaleX: number;
  14490. /**
  14491. * Maximum scale of emitting particles on X axis.
  14492. */
  14493. maxScaleX: number;
  14494. /**
  14495. * Minimum scale of emitting particles on Y axis.
  14496. */
  14497. minScaleY: number;
  14498. /**
  14499. * Maximum scale of emitting particles on Y axis.
  14500. */
  14501. maxScaleY: number;
  14502. /**
  14503. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14504. */
  14505. color1: Color4;
  14506. /**
  14507. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14508. */
  14509. color2: Color4;
  14510. /**
  14511. * Color the particle will have at the end of its lifetime.
  14512. */
  14513. colorDead: Color4;
  14514. /**
  14515. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14516. */
  14517. emitRate: number;
  14518. /**
  14519. * You can use gravity if you want to give an orientation to your particles.
  14520. */
  14521. gravity: Vector3;
  14522. /**
  14523. * Minimum power of emitting particles.
  14524. */
  14525. minEmitPower: number;
  14526. /**
  14527. * Maximum power of emitting particles.
  14528. */
  14529. maxEmitPower: number;
  14530. /**
  14531. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14532. */
  14533. minAngularSpeed: number;
  14534. /**
  14535. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14536. */
  14537. maxAngularSpeed: number;
  14538. /**
  14539. * Gets or sets the minimal initial rotation in radians.
  14540. */
  14541. minInitialRotation: number;
  14542. /**
  14543. * Gets or sets the maximal initial rotation in radians.
  14544. */
  14545. maxInitialRotation: number;
  14546. /**
  14547. * The particle emitter type defines the emitter used by the particle system.
  14548. * It can be for example box, sphere, or cone...
  14549. */
  14550. particleEmitterType: Nullable<IParticleEmitterType>;
  14551. /**
  14552. * Defines the delay in milliseconds before starting the system (0 by default)
  14553. */
  14554. startDelay: number;
  14555. /**
  14556. * 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
  14557. */
  14558. preWarmCycles: number;
  14559. /**
  14560. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14561. */
  14562. preWarmStepOffset: number;
  14563. /**
  14564. * 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)
  14565. */
  14566. spriteCellChangeSpeed: number;
  14567. /**
  14568. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14569. */
  14570. startSpriteCellID: number;
  14571. /**
  14572. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14573. */
  14574. endSpriteCellID: number;
  14575. /**
  14576. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14577. */
  14578. spriteCellWidth: number;
  14579. /**
  14580. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14581. */
  14582. spriteCellHeight: number;
  14583. /**
  14584. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14585. */
  14586. spriteRandomStartCell: boolean;
  14587. /**
  14588. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14589. */
  14590. isAnimationSheetEnabled: boolean;
  14591. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14592. translationPivot: Vector2;
  14593. /**
  14594. * Gets or sets a texture used to add random noise to particle positions
  14595. */
  14596. noiseTexture: Nullable<BaseTexture>;
  14597. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14598. noiseStrength: Vector3;
  14599. /**
  14600. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14601. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14602. */
  14603. billboardMode: number;
  14604. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14605. limitVelocityDamping: number;
  14606. /**
  14607. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14608. */
  14609. beginAnimationOnStart: boolean;
  14610. /**
  14611. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14612. */
  14613. beginAnimationFrom: number;
  14614. /**
  14615. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14616. */
  14617. beginAnimationTo: number;
  14618. /**
  14619. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14620. */
  14621. beginAnimationLoop: boolean;
  14622. /**
  14623. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14624. */
  14625. disposeOnStop: boolean;
  14626. /**
  14627. * Specifies if the particles are updated in emitter local space or world space
  14628. */
  14629. isLocal: boolean;
  14630. /** Snippet ID if the particle system was created from the snippet server */
  14631. snippetId: string;
  14632. /** Gets or sets a matrix to use to compute projection */
  14633. defaultProjectionMatrix: Matrix;
  14634. /**
  14635. * Gets the maximum number of particles active at the same time.
  14636. * @returns The max number of active particles.
  14637. */
  14638. getCapacity(): number;
  14639. /**
  14640. * Gets the number of particles active at the same time.
  14641. * @returns The number of active particles.
  14642. */
  14643. getActiveCount(): number;
  14644. /**
  14645. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14646. * @returns True if it has been started, otherwise false.
  14647. */
  14648. isStarted(): boolean;
  14649. /**
  14650. * Animates the particle system for this frame.
  14651. */
  14652. animate(): void;
  14653. /**
  14654. * Renders the particle system in its current state.
  14655. * @returns the current number of particles
  14656. */
  14657. render(): number;
  14658. /**
  14659. * Dispose the particle system and frees its associated resources.
  14660. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14661. */
  14662. dispose(disposeTexture?: boolean): void;
  14663. /**
  14664. * An event triggered when the system is disposed
  14665. */
  14666. onDisposeObservable: Observable<IParticleSystem>;
  14667. /**
  14668. * Clones the particle system.
  14669. * @param name The name of the cloned object
  14670. * @param newEmitter The new emitter to use
  14671. * @returns the cloned particle system
  14672. */
  14673. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14674. /**
  14675. * Serializes the particle system to a JSON object
  14676. * @param serializeTexture defines if the texture must be serialized as well
  14677. * @returns the JSON object
  14678. */
  14679. serialize(serializeTexture: boolean): any;
  14680. /**
  14681. * Rebuild the particle system
  14682. */
  14683. rebuild(): void;
  14684. /** Force the system to rebuild all gradients that need to be resync */
  14685. forceRefreshGradients(): void;
  14686. /**
  14687. * Starts the particle system and begins to emit
  14688. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14689. */
  14690. start(delay?: number): void;
  14691. /**
  14692. * Stops the particle system.
  14693. */
  14694. stop(): void;
  14695. /**
  14696. * Remove all active particles
  14697. */
  14698. reset(): void;
  14699. /**
  14700. * Gets a boolean indicating that the system is stopping
  14701. * @returns true if the system is currently stopping
  14702. */
  14703. isStopping(): boolean;
  14704. /**
  14705. * Is this system ready to be used/rendered
  14706. * @return true if the system is ready
  14707. */
  14708. isReady(): boolean;
  14709. /**
  14710. * Returns the string "ParticleSystem"
  14711. * @returns a string containing the class name
  14712. */
  14713. getClassName(): string;
  14714. /**
  14715. * Gets the custom effect used to render the particles
  14716. * @param blendMode Blend mode for which the effect should be retrieved
  14717. * @returns The effect
  14718. */
  14719. getCustomEffect(blendMode: number): Nullable<Effect>;
  14720. /**
  14721. * Sets the custom effect used to render the particles
  14722. * @param effect The effect to set
  14723. * @param blendMode Blend mode for which the effect should be set
  14724. */
  14725. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14726. /**
  14727. * Fill the defines array according to the current settings of the particle system
  14728. * @param defines Array to be updated
  14729. * @param blendMode blend mode to take into account when updating the array
  14730. */
  14731. fillDefines(defines: Array<string>, blendMode: number): void;
  14732. /**
  14733. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14734. * @param uniforms Uniforms array to fill
  14735. * @param attributes Attributes array to fill
  14736. * @param samplers Samplers array to fill
  14737. */
  14738. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14739. /**
  14740. * Observable that will be called just before the particles are drawn
  14741. */
  14742. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14743. /**
  14744. * Gets the name of the particle vertex shader
  14745. */
  14746. vertexShaderName: string;
  14747. /**
  14748. * Adds a new color gradient
  14749. * @param gradient defines the gradient to use (between 0 and 1)
  14750. * @param color1 defines the color to affect to the specified gradient
  14751. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14752. * @returns the current particle system
  14753. */
  14754. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14755. /**
  14756. * Remove a specific color gradient
  14757. * @param gradient defines the gradient to remove
  14758. * @returns the current particle system
  14759. */
  14760. removeColorGradient(gradient: number): IParticleSystem;
  14761. /**
  14762. * Adds a new size gradient
  14763. * @param gradient defines the gradient to use (between 0 and 1)
  14764. * @param factor defines the size factor to affect to the specified gradient
  14765. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14766. * @returns the current particle system
  14767. */
  14768. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14769. /**
  14770. * Remove a specific size gradient
  14771. * @param gradient defines the gradient to remove
  14772. * @returns the current particle system
  14773. */
  14774. removeSizeGradient(gradient: number): IParticleSystem;
  14775. /**
  14776. * Gets the current list of color gradients.
  14777. * You must use addColorGradient and removeColorGradient to udpate this list
  14778. * @returns the list of color gradients
  14779. */
  14780. getColorGradients(): Nullable<Array<ColorGradient>>;
  14781. /**
  14782. * Gets the current list of size gradients.
  14783. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14784. * @returns the list of size gradients
  14785. */
  14786. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14787. /**
  14788. * Gets the current list of angular speed gradients.
  14789. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14790. * @returns the list of angular speed gradients
  14791. */
  14792. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14793. /**
  14794. * Adds a new angular speed gradient
  14795. * @param gradient defines the gradient to use (between 0 and 1)
  14796. * @param factor defines the angular speed to affect to the specified gradient
  14797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14798. * @returns the current particle system
  14799. */
  14800. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14801. /**
  14802. * Remove a specific angular speed gradient
  14803. * @param gradient defines the gradient to remove
  14804. * @returns the current particle system
  14805. */
  14806. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14807. /**
  14808. * Gets the current list of velocity gradients.
  14809. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14810. * @returns the list of velocity gradients
  14811. */
  14812. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14813. /**
  14814. * Adds a new velocity gradient
  14815. * @param gradient defines the gradient to use (between 0 and 1)
  14816. * @param factor defines the velocity to affect to the specified gradient
  14817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14818. * @returns the current particle system
  14819. */
  14820. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14821. /**
  14822. * Remove a specific velocity gradient
  14823. * @param gradient defines the gradient to remove
  14824. * @returns the current particle system
  14825. */
  14826. removeVelocityGradient(gradient: number): IParticleSystem;
  14827. /**
  14828. * Gets the current list of limit velocity gradients.
  14829. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14830. * @returns the list of limit velocity gradients
  14831. */
  14832. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14833. /**
  14834. * Adds a new limit velocity gradient
  14835. * @param gradient defines the gradient to use (between 0 and 1)
  14836. * @param factor defines the limit velocity to affect to the specified gradient
  14837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14838. * @returns the current particle system
  14839. */
  14840. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14841. /**
  14842. * Remove a specific limit velocity gradient
  14843. * @param gradient defines the gradient to remove
  14844. * @returns the current particle system
  14845. */
  14846. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14847. /**
  14848. * Adds a new drag gradient
  14849. * @param gradient defines the gradient to use (between 0 and 1)
  14850. * @param factor defines the drag to affect to the specified gradient
  14851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14852. * @returns the current particle system
  14853. */
  14854. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14855. /**
  14856. * Remove a specific drag gradient
  14857. * @param gradient defines the gradient to remove
  14858. * @returns the current particle system
  14859. */
  14860. removeDragGradient(gradient: number): IParticleSystem;
  14861. /**
  14862. * Gets the current list of drag gradients.
  14863. * You must use addDragGradient and removeDragGradient to udpate this list
  14864. * @returns the list of drag gradients
  14865. */
  14866. getDragGradients(): Nullable<Array<FactorGradient>>;
  14867. /**
  14868. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14869. * @param gradient defines the gradient to use (between 0 and 1)
  14870. * @param factor defines the emit rate to affect to the specified gradient
  14871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14872. * @returns the current particle system
  14873. */
  14874. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14875. /**
  14876. * Remove a specific emit rate gradient
  14877. * @param gradient defines the gradient to remove
  14878. * @returns the current particle system
  14879. */
  14880. removeEmitRateGradient(gradient: number): IParticleSystem;
  14881. /**
  14882. * Gets the current list of emit rate gradients.
  14883. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14884. * @returns the list of emit rate gradients
  14885. */
  14886. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14887. /**
  14888. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14889. * @param gradient defines the gradient to use (between 0 and 1)
  14890. * @param factor defines the start size to affect to the specified gradient
  14891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14892. * @returns the current particle system
  14893. */
  14894. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14895. /**
  14896. * Remove a specific start size gradient
  14897. * @param gradient defines the gradient to remove
  14898. * @returns the current particle system
  14899. */
  14900. removeStartSizeGradient(gradient: number): IParticleSystem;
  14901. /**
  14902. * Gets the current list of start size gradients.
  14903. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14904. * @returns the list of start size gradients
  14905. */
  14906. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14907. /**
  14908. * Adds a new life time gradient
  14909. * @param gradient defines the gradient to use (between 0 and 1)
  14910. * @param factor defines the life time factor to affect to the specified gradient
  14911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14912. * @returns the current particle system
  14913. */
  14914. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14915. /**
  14916. * Remove a specific life time gradient
  14917. * @param gradient defines the gradient to remove
  14918. * @returns the current particle system
  14919. */
  14920. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14921. /**
  14922. * Gets the current list of life time gradients.
  14923. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14924. * @returns the list of life time gradients
  14925. */
  14926. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14927. /**
  14928. * Gets the current list of color gradients.
  14929. * You must use addColorGradient and removeColorGradient to udpate this list
  14930. * @returns the list of color gradients
  14931. */
  14932. getColorGradients(): Nullable<Array<ColorGradient>>;
  14933. /**
  14934. * Adds a new ramp gradient used to remap particle colors
  14935. * @param gradient defines the gradient to use (between 0 and 1)
  14936. * @param color defines the color to affect to the specified gradient
  14937. * @returns the current particle system
  14938. */
  14939. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14940. /**
  14941. * Gets the current list of ramp gradients.
  14942. * You must use addRampGradient and removeRampGradient to udpate this list
  14943. * @returns the list of ramp gradients
  14944. */
  14945. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14946. /** Gets or sets a boolean indicating that ramp gradients must be used
  14947. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14948. */
  14949. useRampGradients: boolean;
  14950. /**
  14951. * Adds a new color remap gradient
  14952. * @param gradient defines the gradient to use (between 0 and 1)
  14953. * @param min defines the color remap minimal range
  14954. * @param max defines the color remap maximal range
  14955. * @returns the current particle system
  14956. */
  14957. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14958. /**
  14959. * Gets the current list of color remap gradients.
  14960. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14961. * @returns the list of color remap gradients
  14962. */
  14963. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14964. /**
  14965. * Adds a new alpha remap gradient
  14966. * @param gradient defines the gradient to use (between 0 and 1)
  14967. * @param min defines the alpha remap minimal range
  14968. * @param max defines the alpha remap maximal range
  14969. * @returns the current particle system
  14970. */
  14971. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14972. /**
  14973. * Gets the current list of alpha remap gradients.
  14974. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14975. * @returns the list of alpha remap gradients
  14976. */
  14977. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14978. /**
  14979. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14980. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14981. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14982. * @returns the emitter
  14983. */
  14984. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14985. /**
  14986. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14987. * @param radius The radius of the hemisphere to emit from
  14988. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14989. * @returns the emitter
  14990. */
  14991. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14992. /**
  14993. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14994. * @param radius The radius of the sphere to emit from
  14995. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14996. * @returns the emitter
  14997. */
  14998. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14999. /**
  15000. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15001. * @param radius The radius of the sphere to emit from
  15002. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15003. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15004. * @returns the emitter
  15005. */
  15006. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15007. /**
  15008. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15009. * @param radius The radius of the emission cylinder
  15010. * @param height The height of the emission cylinder
  15011. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15012. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15013. * @returns the emitter
  15014. */
  15015. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15016. /**
  15017. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15018. * @param radius The radius of the cylinder to emit from
  15019. * @param height The height of the emission cylinder
  15020. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15021. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15022. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15023. * @returns the emitter
  15024. */
  15025. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15026. /**
  15027. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15028. * @param radius The radius of the cone to emit from
  15029. * @param angle The base angle of the cone
  15030. * @returns the emitter
  15031. */
  15032. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15033. /**
  15034. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15035. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15036. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15037. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15038. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15039. * @returns the emitter
  15040. */
  15041. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15042. /**
  15043. * Get hosting scene
  15044. * @returns the scene
  15045. */
  15046. getScene(): Nullable<Scene>;
  15047. }
  15048. }
  15049. declare module "babylonjs/Meshes/transformNode" {
  15050. import { DeepImmutable } from "babylonjs/types";
  15051. import { Observable } from "babylonjs/Misc/observable";
  15052. import { Nullable } from "babylonjs/types";
  15053. import { Camera } from "babylonjs/Cameras/camera";
  15054. import { Scene } from "babylonjs/scene";
  15055. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15056. import { Node } from "babylonjs/node";
  15057. import { Bone } from "babylonjs/Bones/bone";
  15058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15059. import { Space } from "babylonjs/Maths/math.axis";
  15060. /**
  15061. * 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.
  15062. * @see https://doc.babylonjs.com/how_to/transformnode
  15063. */
  15064. export class TransformNode extends Node {
  15065. /**
  15066. * Object will not rotate to face the camera
  15067. */
  15068. static BILLBOARDMODE_NONE: number;
  15069. /**
  15070. * Object will rotate to face the camera but only on the x axis
  15071. */
  15072. static BILLBOARDMODE_X: number;
  15073. /**
  15074. * Object will rotate to face the camera but only on the y axis
  15075. */
  15076. static BILLBOARDMODE_Y: number;
  15077. /**
  15078. * Object will rotate to face the camera but only on the z axis
  15079. */
  15080. static BILLBOARDMODE_Z: number;
  15081. /**
  15082. * Object will rotate to face the camera
  15083. */
  15084. static BILLBOARDMODE_ALL: number;
  15085. /**
  15086. * Object will rotate to face the camera's position instead of orientation
  15087. */
  15088. static BILLBOARDMODE_USE_POSITION: number;
  15089. private static _TmpRotation;
  15090. private static _TmpScaling;
  15091. private static _TmpTranslation;
  15092. private _forward;
  15093. private _forwardInverted;
  15094. private _up;
  15095. private _right;
  15096. private _rightInverted;
  15097. private _position;
  15098. private _rotation;
  15099. private _rotationQuaternion;
  15100. protected _scaling: Vector3;
  15101. protected _isDirty: boolean;
  15102. private _transformToBoneReferal;
  15103. private _isAbsoluteSynced;
  15104. private _billboardMode;
  15105. /**
  15106. * Gets or sets the billboard mode. Default is 0.
  15107. *
  15108. * | Value | Type | Description |
  15109. * | --- | --- | --- |
  15110. * | 0 | BILLBOARDMODE_NONE | |
  15111. * | 1 | BILLBOARDMODE_X | |
  15112. * | 2 | BILLBOARDMODE_Y | |
  15113. * | 4 | BILLBOARDMODE_Z | |
  15114. * | 7 | BILLBOARDMODE_ALL | |
  15115. *
  15116. */
  15117. get billboardMode(): number;
  15118. set billboardMode(value: number);
  15119. private _preserveParentRotationForBillboard;
  15120. /**
  15121. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15122. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15123. */
  15124. get preserveParentRotationForBillboard(): boolean;
  15125. set preserveParentRotationForBillboard(value: boolean);
  15126. /**
  15127. * 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
  15128. */
  15129. scalingDeterminant: number;
  15130. private _infiniteDistance;
  15131. /**
  15132. * Gets or sets the distance of the object to max, often used by skybox
  15133. */
  15134. get infiniteDistance(): boolean;
  15135. set infiniteDistance(value: boolean);
  15136. /**
  15137. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15138. * By default the system will update normals to compensate
  15139. */
  15140. ignoreNonUniformScaling: boolean;
  15141. /**
  15142. * 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
  15143. */
  15144. reIntegrateRotationIntoRotationQuaternion: boolean;
  15145. /** @hidden */
  15146. _poseMatrix: Nullable<Matrix>;
  15147. /** @hidden */
  15148. _localMatrix: Matrix;
  15149. private _usePivotMatrix;
  15150. private _absolutePosition;
  15151. private _absoluteScaling;
  15152. private _absoluteRotationQuaternion;
  15153. private _pivotMatrix;
  15154. private _pivotMatrixInverse;
  15155. /** @hidden */
  15156. _postMultiplyPivotMatrix: boolean;
  15157. protected _isWorldMatrixFrozen: boolean;
  15158. /** @hidden */
  15159. _indexInSceneTransformNodesArray: number;
  15160. /**
  15161. * An event triggered after the world matrix is updated
  15162. */
  15163. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15164. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15165. /**
  15166. * Gets a string identifying the name of the class
  15167. * @returns "TransformNode" string
  15168. */
  15169. getClassName(): string;
  15170. /**
  15171. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15172. */
  15173. get position(): Vector3;
  15174. set position(newPosition: Vector3);
  15175. /**
  15176. * 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)).
  15177. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15178. */
  15179. get rotation(): Vector3;
  15180. set rotation(newRotation: Vector3);
  15181. /**
  15182. * 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)).
  15183. */
  15184. get scaling(): Vector3;
  15185. set scaling(newScaling: Vector3);
  15186. /**
  15187. * 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).
  15188. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15189. */
  15190. get rotationQuaternion(): Nullable<Quaternion>;
  15191. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15192. /**
  15193. * The forward direction of that transform in world space.
  15194. */
  15195. get forward(): Vector3;
  15196. /**
  15197. * The up direction of that transform in world space.
  15198. */
  15199. get up(): Vector3;
  15200. /**
  15201. * The right direction of that transform in world space.
  15202. */
  15203. get right(): Vector3;
  15204. /**
  15205. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15206. * @param matrix the matrix to copy the pose from
  15207. * @returns this TransformNode.
  15208. */
  15209. updatePoseMatrix(matrix: Matrix): TransformNode;
  15210. /**
  15211. * Returns the mesh Pose matrix.
  15212. * @returns the pose matrix
  15213. */
  15214. getPoseMatrix(): Matrix;
  15215. /** @hidden */
  15216. _isSynchronized(): boolean;
  15217. /** @hidden */
  15218. _initCache(): void;
  15219. /**
  15220. * Flag the transform node as dirty (Forcing it to update everything)
  15221. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15222. * @returns this transform node
  15223. */
  15224. markAsDirty(property: string): TransformNode;
  15225. /**
  15226. * Returns the current mesh absolute position.
  15227. * Returns a Vector3.
  15228. */
  15229. get absolutePosition(): Vector3;
  15230. /**
  15231. * Returns the current mesh absolute scaling.
  15232. * Returns a Vector3.
  15233. */
  15234. get absoluteScaling(): Vector3;
  15235. /**
  15236. * Returns the current mesh absolute rotation.
  15237. * Returns a Quaternion.
  15238. */
  15239. get absoluteRotationQuaternion(): Quaternion;
  15240. /**
  15241. * Sets a new matrix to apply before all other transformation
  15242. * @param matrix defines the transform matrix
  15243. * @returns the current TransformNode
  15244. */
  15245. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15246. /**
  15247. * Sets a new pivot matrix to the current node
  15248. * @param matrix defines the new pivot matrix to use
  15249. * @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
  15250. * @returns the current TransformNode
  15251. */
  15252. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15253. /**
  15254. * Returns the mesh pivot matrix.
  15255. * Default : Identity.
  15256. * @returns the matrix
  15257. */
  15258. getPivotMatrix(): Matrix;
  15259. /**
  15260. * Instantiate (when possible) or clone that node with its hierarchy
  15261. * @param newParent defines the new parent to use for the instance (or clone)
  15262. * @param options defines options to configure how copy is done
  15263. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15264. * @returns an instance (or a clone) of the current node with its hiearchy
  15265. */
  15266. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15267. doNotInstantiate: boolean;
  15268. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15269. /**
  15270. * Prevents the World matrix to be computed any longer
  15271. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15272. * @returns the TransformNode.
  15273. */
  15274. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15275. /**
  15276. * Allows back the World matrix computation.
  15277. * @returns the TransformNode.
  15278. */
  15279. unfreezeWorldMatrix(): this;
  15280. /**
  15281. * True if the World matrix has been frozen.
  15282. */
  15283. get isWorldMatrixFrozen(): boolean;
  15284. /**
  15285. * Retuns the mesh absolute position in the World.
  15286. * @returns a Vector3.
  15287. */
  15288. getAbsolutePosition(): Vector3;
  15289. /**
  15290. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15291. * @param absolutePosition the absolute position to set
  15292. * @returns the TransformNode.
  15293. */
  15294. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15295. /**
  15296. * Sets the mesh position in its local space.
  15297. * @param vector3 the position to set in localspace
  15298. * @returns the TransformNode.
  15299. */
  15300. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15301. /**
  15302. * Returns the mesh position in the local space from the current World matrix values.
  15303. * @returns a new Vector3.
  15304. */
  15305. getPositionExpressedInLocalSpace(): Vector3;
  15306. /**
  15307. * Translates the mesh along the passed Vector3 in its local space.
  15308. * @param vector3 the distance to translate in localspace
  15309. * @returns the TransformNode.
  15310. */
  15311. locallyTranslate(vector3: Vector3): TransformNode;
  15312. private static _lookAtVectorCache;
  15313. /**
  15314. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15315. * @param targetPoint the position (must be in same space as current mesh) to look at
  15316. * @param yawCor optional yaw (y-axis) correction in radians
  15317. * @param pitchCor optional pitch (x-axis) correction in radians
  15318. * @param rollCor optional roll (z-axis) correction in radians
  15319. * @param space the choosen space of the target
  15320. * @returns the TransformNode.
  15321. */
  15322. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15323. /**
  15324. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15325. * This Vector3 is expressed in the World space.
  15326. * @param localAxis axis to rotate
  15327. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15328. */
  15329. getDirection(localAxis: Vector3): Vector3;
  15330. /**
  15331. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15332. * localAxis is expressed in the mesh local space.
  15333. * result is computed in the Wordl space from the mesh World matrix.
  15334. * @param localAxis axis to rotate
  15335. * @param result the resulting transformnode
  15336. * @returns this TransformNode.
  15337. */
  15338. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15339. /**
  15340. * Sets this transform node rotation to the given local axis.
  15341. * @param localAxis the axis in local space
  15342. * @param yawCor optional yaw (y-axis) correction in radians
  15343. * @param pitchCor optional pitch (x-axis) correction in radians
  15344. * @param rollCor optional roll (z-axis) correction in radians
  15345. * @returns this TransformNode
  15346. */
  15347. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15348. /**
  15349. * Sets a new pivot point to the current node
  15350. * @param point defines the new pivot point to use
  15351. * @param space defines if the point is in world or local space (local by default)
  15352. * @returns the current TransformNode
  15353. */
  15354. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15355. /**
  15356. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15357. * @returns the pivot point
  15358. */
  15359. getPivotPoint(): Vector3;
  15360. /**
  15361. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15362. * @param result the vector3 to store the result
  15363. * @returns this TransformNode.
  15364. */
  15365. getPivotPointToRef(result: Vector3): TransformNode;
  15366. /**
  15367. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15368. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15369. */
  15370. getAbsolutePivotPoint(): Vector3;
  15371. /**
  15372. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15373. * @param result vector3 to store the result
  15374. * @returns this TransformNode.
  15375. */
  15376. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15377. /**
  15378. * Defines the passed node as the parent of the current node.
  15379. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15380. * @see https://doc.babylonjs.com/how_to/parenting
  15381. * @param node the node ot set as the parent
  15382. * @returns this TransformNode.
  15383. */
  15384. setParent(node: Nullable<Node>): TransformNode;
  15385. private _nonUniformScaling;
  15386. /**
  15387. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15388. */
  15389. get nonUniformScaling(): boolean;
  15390. /** @hidden */
  15391. _updateNonUniformScalingState(value: boolean): boolean;
  15392. /**
  15393. * Attach the current TransformNode to another TransformNode associated with a bone
  15394. * @param bone Bone affecting the TransformNode
  15395. * @param affectedTransformNode TransformNode associated with the bone
  15396. * @returns this object
  15397. */
  15398. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15399. /**
  15400. * Detach the transform node if its associated with a bone
  15401. * @returns this object
  15402. */
  15403. detachFromBone(): TransformNode;
  15404. private static _rotationAxisCache;
  15405. /**
  15406. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15407. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15408. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15409. * The passed axis is also normalized.
  15410. * @param axis the axis to rotate around
  15411. * @param amount the amount to rotate in radians
  15412. * @param space Space to rotate in (Default: local)
  15413. * @returns the TransformNode.
  15414. */
  15415. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15416. /**
  15417. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15418. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15419. * The passed axis is also normalized. .
  15420. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15421. * @param point the point to rotate around
  15422. * @param axis the axis to rotate around
  15423. * @param amount the amount to rotate in radians
  15424. * @returns the TransformNode
  15425. */
  15426. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15427. /**
  15428. * Translates the mesh along the axis vector for the passed distance in the given space.
  15429. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15430. * @param axis the axis to translate in
  15431. * @param distance the distance to translate
  15432. * @param space Space to rotate in (Default: local)
  15433. * @returns the TransformNode.
  15434. */
  15435. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15436. /**
  15437. * Adds a rotation step to the mesh current rotation.
  15438. * x, y, z are Euler angles expressed in radians.
  15439. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15440. * This means this rotation is made in the mesh local space only.
  15441. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15442. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15443. * ```javascript
  15444. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15445. * ```
  15446. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15447. * 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.
  15448. * @param x Rotation to add
  15449. * @param y Rotation to add
  15450. * @param z Rotation to add
  15451. * @returns the TransformNode.
  15452. */
  15453. addRotation(x: number, y: number, z: number): TransformNode;
  15454. /**
  15455. * @hidden
  15456. */
  15457. protected _getEffectiveParent(): Nullable<Node>;
  15458. /**
  15459. * Computes the world matrix of the node
  15460. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15461. * @returns the world matrix
  15462. */
  15463. computeWorldMatrix(force?: boolean): Matrix;
  15464. /**
  15465. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15466. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15467. */
  15468. resetLocalMatrix(independentOfChildren?: boolean): void;
  15469. protected _afterComputeWorldMatrix(): void;
  15470. /**
  15471. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15472. * @param func callback function to add
  15473. *
  15474. * @returns the TransformNode.
  15475. */
  15476. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15477. /**
  15478. * Removes a registered callback function.
  15479. * @param func callback function to remove
  15480. * @returns the TransformNode.
  15481. */
  15482. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15483. /**
  15484. * Gets the position of the current mesh in camera space
  15485. * @param camera defines the camera to use
  15486. * @returns a position
  15487. */
  15488. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15489. /**
  15490. * Returns the distance from the mesh to the active camera
  15491. * @param camera defines the camera to use
  15492. * @returns the distance
  15493. */
  15494. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15495. /**
  15496. * Clone the current transform node
  15497. * @param name Name of the new clone
  15498. * @param newParent New parent for the clone
  15499. * @param doNotCloneChildren Do not clone children hierarchy
  15500. * @returns the new transform node
  15501. */
  15502. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15503. /**
  15504. * Serializes the objects information.
  15505. * @param currentSerializationObject defines the object to serialize in
  15506. * @returns the serialized object
  15507. */
  15508. serialize(currentSerializationObject?: any): any;
  15509. /**
  15510. * Returns a new TransformNode object parsed from the source provided.
  15511. * @param parsedTransformNode is the source.
  15512. * @param scene the scne the object belongs to
  15513. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15514. * @returns a new TransformNode object parsed from the source provided.
  15515. */
  15516. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15517. /**
  15518. * Get all child-transformNodes of this node
  15519. * @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
  15520. * @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
  15521. * @returns an array of TransformNode
  15522. */
  15523. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15524. /**
  15525. * Releases resources associated with this transform node.
  15526. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15527. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15528. */
  15529. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15530. /**
  15531. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15532. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15533. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15534. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15535. * @returns the current mesh
  15536. */
  15537. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15538. private _syncAbsoluteScalingAndRotation;
  15539. }
  15540. }
  15541. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15542. /**
  15543. * Class used to override all child animations of a given target
  15544. */
  15545. export class AnimationPropertiesOverride {
  15546. /**
  15547. * Gets or sets a value indicating if animation blending must be used
  15548. */
  15549. enableBlending: boolean;
  15550. /**
  15551. * Gets or sets the blending speed to use when enableBlending is true
  15552. */
  15553. blendingSpeed: number;
  15554. /**
  15555. * Gets or sets the default loop mode to use
  15556. */
  15557. loopMode: number;
  15558. }
  15559. }
  15560. declare module "babylonjs/Bones/bone" {
  15561. import { Skeleton } from "babylonjs/Bones/skeleton";
  15562. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15563. import { Nullable } from "babylonjs/types";
  15564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15565. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15566. import { Node } from "babylonjs/node";
  15567. import { Space } from "babylonjs/Maths/math.axis";
  15568. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15569. /**
  15570. * Class used to store bone information
  15571. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15572. */
  15573. export class Bone extends Node {
  15574. /**
  15575. * defines the bone name
  15576. */
  15577. name: string;
  15578. private static _tmpVecs;
  15579. private static _tmpQuat;
  15580. private static _tmpMats;
  15581. /**
  15582. * Gets the list of child bones
  15583. */
  15584. children: Bone[];
  15585. /** Gets the animations associated with this bone */
  15586. animations: import("babylonjs/Animations/animation").Animation[];
  15587. /**
  15588. * Gets or sets bone length
  15589. */
  15590. length: number;
  15591. /**
  15592. * @hidden Internal only
  15593. * Set this value to map this bone to a different index in the transform matrices
  15594. * Set this value to -1 to exclude the bone from the transform matrices
  15595. */
  15596. _index: Nullable<number>;
  15597. private _skeleton;
  15598. private _localMatrix;
  15599. private _restPose;
  15600. private _bindPose;
  15601. private _baseMatrix;
  15602. private _absoluteTransform;
  15603. private _invertedAbsoluteTransform;
  15604. private _parent;
  15605. private _scalingDeterminant;
  15606. private _worldTransform;
  15607. private _localScaling;
  15608. private _localRotation;
  15609. private _localPosition;
  15610. private _needToDecompose;
  15611. private _needToCompose;
  15612. /** @hidden */
  15613. _linkedTransformNode: Nullable<TransformNode>;
  15614. /** @hidden */
  15615. _waitingTransformNodeId: Nullable<string>;
  15616. /** @hidden */
  15617. get _matrix(): Matrix;
  15618. /** @hidden */
  15619. set _matrix(value: Matrix);
  15620. /**
  15621. * Create a new bone
  15622. * @param name defines the bone name
  15623. * @param skeleton defines the parent skeleton
  15624. * @param parentBone defines the parent (can be null if the bone is the root)
  15625. * @param localMatrix defines the local matrix
  15626. * @param restPose defines the rest pose matrix
  15627. * @param baseMatrix defines the base matrix
  15628. * @param index defines index of the bone in the hiearchy
  15629. */
  15630. constructor(
  15631. /**
  15632. * defines the bone name
  15633. */
  15634. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15635. /**
  15636. * Gets the current object class name.
  15637. * @return the class name
  15638. */
  15639. getClassName(): string;
  15640. /**
  15641. * Gets the parent skeleton
  15642. * @returns a skeleton
  15643. */
  15644. getSkeleton(): Skeleton;
  15645. /**
  15646. * Gets parent bone
  15647. * @returns a bone or null if the bone is the root of the bone hierarchy
  15648. */
  15649. getParent(): Nullable<Bone>;
  15650. /**
  15651. * Returns an array containing the root bones
  15652. * @returns an array containing the root bones
  15653. */
  15654. getChildren(): Array<Bone>;
  15655. /**
  15656. * Gets the node index in matrix array generated for rendering
  15657. * @returns the node index
  15658. */
  15659. getIndex(): number;
  15660. /**
  15661. * Sets the parent bone
  15662. * @param parent defines the parent (can be null if the bone is the root)
  15663. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15664. */
  15665. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15666. /**
  15667. * Gets the local matrix
  15668. * @returns a matrix
  15669. */
  15670. getLocalMatrix(): Matrix;
  15671. /**
  15672. * Gets the base matrix (initial matrix which remains unchanged)
  15673. * @returns a matrix
  15674. */
  15675. getBaseMatrix(): Matrix;
  15676. /**
  15677. * Gets the rest pose matrix
  15678. * @returns a matrix
  15679. */
  15680. getRestPose(): Matrix;
  15681. /**
  15682. * Sets the rest pose matrix
  15683. * @param matrix the local-space rest pose to set for this bone
  15684. */
  15685. setRestPose(matrix: Matrix): void;
  15686. /**
  15687. * Gets the bind pose matrix
  15688. * @returns the bind pose matrix
  15689. */
  15690. getBindPose(): Matrix;
  15691. /**
  15692. * Sets the bind pose matrix
  15693. * @param matrix the local-space bind pose to set for this bone
  15694. */
  15695. setBindPose(matrix: Matrix): void;
  15696. /**
  15697. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15698. */
  15699. getWorldMatrix(): Matrix;
  15700. /**
  15701. * Sets the local matrix to rest pose matrix
  15702. */
  15703. returnToRest(): void;
  15704. /**
  15705. * Gets the inverse of the absolute transform matrix.
  15706. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15707. * @returns a matrix
  15708. */
  15709. getInvertedAbsoluteTransform(): Matrix;
  15710. /**
  15711. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15712. * @returns a matrix
  15713. */
  15714. getAbsoluteTransform(): Matrix;
  15715. /**
  15716. * Links with the given transform node.
  15717. * The local matrix of this bone is copied from the transform node every frame.
  15718. * @param transformNode defines the transform node to link to
  15719. */
  15720. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15721. /**
  15722. * Gets the node used to drive the bone's transformation
  15723. * @returns a transform node or null
  15724. */
  15725. getTransformNode(): Nullable<TransformNode>;
  15726. /** Gets or sets current position (in local space) */
  15727. get position(): Vector3;
  15728. set position(newPosition: Vector3);
  15729. /** Gets or sets current rotation (in local space) */
  15730. get rotation(): Vector3;
  15731. set rotation(newRotation: Vector3);
  15732. /** Gets or sets current rotation quaternion (in local space) */
  15733. get rotationQuaternion(): Quaternion;
  15734. set rotationQuaternion(newRotation: Quaternion);
  15735. /** Gets or sets current scaling (in local space) */
  15736. get scaling(): Vector3;
  15737. set scaling(newScaling: Vector3);
  15738. /**
  15739. * Gets the animation properties override
  15740. */
  15741. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15742. private _decompose;
  15743. private _compose;
  15744. /**
  15745. * Update the base and local matrices
  15746. * @param matrix defines the new base or local matrix
  15747. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15748. * @param updateLocalMatrix defines if the local matrix should be updated
  15749. */
  15750. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15751. /** @hidden */
  15752. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15753. /**
  15754. * Flag the bone as dirty (Forcing it to update everything)
  15755. */
  15756. markAsDirty(): void;
  15757. /** @hidden */
  15758. _markAsDirtyAndCompose(): void;
  15759. private _markAsDirtyAndDecompose;
  15760. /**
  15761. * Translate the bone in local or world space
  15762. * @param vec The amount to translate the bone
  15763. * @param space The space that the translation is in
  15764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15765. */
  15766. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15767. /**
  15768. * Set the postion of the bone in local or world space
  15769. * @param position The position to set the bone
  15770. * @param space The space that the position is in
  15771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15772. */
  15773. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15774. /**
  15775. * Set the absolute position of the bone (world space)
  15776. * @param position The position to set the bone
  15777. * @param mesh The mesh that this bone is attached to
  15778. */
  15779. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15780. /**
  15781. * Scale the bone on the x, y and z axes (in local space)
  15782. * @param x The amount to scale the bone on the x axis
  15783. * @param y The amount to scale the bone on the y axis
  15784. * @param z The amount to scale the bone on the z axis
  15785. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15786. */
  15787. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15788. /**
  15789. * Set the bone scaling in local space
  15790. * @param scale defines the scaling vector
  15791. */
  15792. setScale(scale: Vector3): void;
  15793. /**
  15794. * Gets the current scaling in local space
  15795. * @returns the current scaling vector
  15796. */
  15797. getScale(): Vector3;
  15798. /**
  15799. * Gets the current scaling in local space and stores it in a target vector
  15800. * @param result defines the target vector
  15801. */
  15802. getScaleToRef(result: Vector3): void;
  15803. /**
  15804. * Set the yaw, pitch, and roll of the bone in local or world space
  15805. * @param yaw The rotation of the bone on the y axis
  15806. * @param pitch The rotation of the bone on the x axis
  15807. * @param roll The rotation of the bone on the z axis
  15808. * @param space The space that the axes of rotation are in
  15809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15810. */
  15811. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15812. /**
  15813. * Add a rotation to the bone on an axis in local or world space
  15814. * @param axis The axis to rotate the bone on
  15815. * @param amount The amount to rotate the bone
  15816. * @param space The space that the axis is in
  15817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15818. */
  15819. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15820. /**
  15821. * Set the rotation of the bone to a particular axis angle in local or world space
  15822. * @param axis The axis to rotate the bone on
  15823. * @param angle The angle that the bone should be rotated to
  15824. * @param space The space that the axis is in
  15825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15826. */
  15827. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15828. /**
  15829. * Set the euler rotation of the bone in local or world space
  15830. * @param rotation The euler rotation that the bone should be set to
  15831. * @param space The space that the rotation is in
  15832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15833. */
  15834. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15835. /**
  15836. * Set the quaternion rotation of the bone in local or world space
  15837. * @param quat The quaternion rotation that the bone should be set to
  15838. * @param space The space that the rotation is in
  15839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15840. */
  15841. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15842. /**
  15843. * Set the rotation matrix of the bone in local or world space
  15844. * @param rotMat The rotation matrix that the bone should be set to
  15845. * @param space The space that the rotation is in
  15846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15847. */
  15848. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15849. private _rotateWithMatrix;
  15850. private _getNegativeRotationToRef;
  15851. /**
  15852. * Get the position of the bone in local or world space
  15853. * @param space The space that the returned position is in
  15854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15855. * @returns The position of the bone
  15856. */
  15857. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15858. /**
  15859. * Copy the position of the bone to a vector3 in local or world space
  15860. * @param space The space that the returned position is in
  15861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15862. * @param result The vector3 to copy the position to
  15863. */
  15864. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15865. /**
  15866. * Get the absolute position of the bone (world space)
  15867. * @param mesh The mesh that this bone is attached to
  15868. * @returns The absolute position of the bone
  15869. */
  15870. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15871. /**
  15872. * Copy the absolute position of the bone (world space) to the result param
  15873. * @param mesh The mesh that this bone is attached to
  15874. * @param result The vector3 to copy the absolute position to
  15875. */
  15876. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15877. /**
  15878. * Compute the absolute transforms of this bone and its children
  15879. */
  15880. computeAbsoluteTransforms(): void;
  15881. /**
  15882. * Get the world direction from an axis that is in the local space of the bone
  15883. * @param localAxis The local direction that is used to compute the world direction
  15884. * @param mesh The mesh that this bone is attached to
  15885. * @returns The world direction
  15886. */
  15887. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15888. /**
  15889. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15890. * @param localAxis The local direction that is used to compute the world direction
  15891. * @param mesh The mesh that this bone is attached to
  15892. * @param result The vector3 that the world direction will be copied to
  15893. */
  15894. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15895. /**
  15896. * Get the euler rotation of the bone in local or world space
  15897. * @param space The space that the rotation should be in
  15898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15899. * @returns The euler rotation
  15900. */
  15901. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15902. /**
  15903. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15904. * @param space The space that the rotation should be in
  15905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15906. * @param result The vector3 that the rotation should be copied to
  15907. */
  15908. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15909. /**
  15910. * Get the quaternion rotation of the bone in either local or world space
  15911. * @param space The space that the rotation should be in
  15912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15913. * @returns The quaternion rotation
  15914. */
  15915. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15916. /**
  15917. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15918. * @param space The space that the rotation should be in
  15919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15920. * @param result The quaternion that the rotation should be copied to
  15921. */
  15922. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15923. /**
  15924. * Get the rotation matrix of the bone in local or world space
  15925. * @param space The space that the rotation should be in
  15926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15927. * @returns The rotation matrix
  15928. */
  15929. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15930. /**
  15931. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15932. * @param space The space that the rotation should be in
  15933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15934. * @param result The quaternion that the rotation should be copied to
  15935. */
  15936. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15937. /**
  15938. * Get the world position of a point that is in the local space of the bone
  15939. * @param position The local position
  15940. * @param mesh The mesh that this bone is attached to
  15941. * @returns The world position
  15942. */
  15943. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15944. /**
  15945. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15946. * @param position The local position
  15947. * @param mesh The mesh that this bone is attached to
  15948. * @param result The vector3 that the world position should be copied to
  15949. */
  15950. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15951. /**
  15952. * Get the local position of a point that is in world space
  15953. * @param position The world position
  15954. * @param mesh The mesh that this bone is attached to
  15955. * @returns The local position
  15956. */
  15957. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15958. /**
  15959. * Get the local position of a point that is in world space and copy it to the result param
  15960. * @param position The world position
  15961. * @param mesh The mesh that this bone is attached to
  15962. * @param result The vector3 that the local position should be copied to
  15963. */
  15964. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15965. /**
  15966. * Set the current local matrix as the restPose for this bone.
  15967. */
  15968. setCurrentPoseAsRest(): void;
  15969. }
  15970. }
  15971. declare module "babylonjs/Animations/runtimeAnimation" {
  15972. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15973. import { Animatable } from "babylonjs/Animations/animatable";
  15974. import { Scene } from "babylonjs/scene";
  15975. /**
  15976. * Defines a runtime animation
  15977. */
  15978. export class RuntimeAnimation {
  15979. private _events;
  15980. /**
  15981. * The current frame of the runtime animation
  15982. */
  15983. private _currentFrame;
  15984. /**
  15985. * The animation used by the runtime animation
  15986. */
  15987. private _animation;
  15988. /**
  15989. * The target of the runtime animation
  15990. */
  15991. private _target;
  15992. /**
  15993. * The initiating animatable
  15994. */
  15995. private _host;
  15996. /**
  15997. * The original value of the runtime animation
  15998. */
  15999. private _originalValue;
  16000. /**
  16001. * The original blend value of the runtime animation
  16002. */
  16003. private _originalBlendValue;
  16004. /**
  16005. * The offsets cache of the runtime animation
  16006. */
  16007. private _offsetsCache;
  16008. /**
  16009. * The high limits cache of the runtime animation
  16010. */
  16011. private _highLimitsCache;
  16012. /**
  16013. * Specifies if the runtime animation has been stopped
  16014. */
  16015. private _stopped;
  16016. /**
  16017. * The blending factor of the runtime animation
  16018. */
  16019. private _blendingFactor;
  16020. /**
  16021. * The BabylonJS scene
  16022. */
  16023. private _scene;
  16024. /**
  16025. * The current value of the runtime animation
  16026. */
  16027. private _currentValue;
  16028. /** @hidden */
  16029. _animationState: _IAnimationState;
  16030. /**
  16031. * The active target of the runtime animation
  16032. */
  16033. private _activeTargets;
  16034. private _currentActiveTarget;
  16035. private _directTarget;
  16036. /**
  16037. * The target path of the runtime animation
  16038. */
  16039. private _targetPath;
  16040. /**
  16041. * The weight of the runtime animation
  16042. */
  16043. private _weight;
  16044. /**
  16045. * The ratio offset of the runtime animation
  16046. */
  16047. private _ratioOffset;
  16048. /**
  16049. * The previous delay of the runtime animation
  16050. */
  16051. private _previousDelay;
  16052. /**
  16053. * The previous ratio of the runtime animation
  16054. */
  16055. private _previousRatio;
  16056. private _enableBlending;
  16057. private _keys;
  16058. private _minFrame;
  16059. private _maxFrame;
  16060. private _minValue;
  16061. private _maxValue;
  16062. private _targetIsArray;
  16063. /**
  16064. * Gets the current frame of the runtime animation
  16065. */
  16066. get currentFrame(): number;
  16067. /**
  16068. * Gets the weight of the runtime animation
  16069. */
  16070. get weight(): number;
  16071. /**
  16072. * Gets the current value of the runtime animation
  16073. */
  16074. get currentValue(): any;
  16075. /**
  16076. * Gets the target path of the runtime animation
  16077. */
  16078. get targetPath(): string;
  16079. /**
  16080. * Gets the actual target of the runtime animation
  16081. */
  16082. get target(): any;
  16083. /**
  16084. * Gets the additive state of the runtime animation
  16085. */
  16086. get isAdditive(): boolean;
  16087. /** @hidden */
  16088. _onLoop: () => void;
  16089. /**
  16090. * Create a new RuntimeAnimation object
  16091. * @param target defines the target of the animation
  16092. * @param animation defines the source animation object
  16093. * @param scene defines the hosting scene
  16094. * @param host defines the initiating Animatable
  16095. */
  16096. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16097. private _preparePath;
  16098. /**
  16099. * Gets the animation from the runtime animation
  16100. */
  16101. get animation(): Animation;
  16102. /**
  16103. * Resets the runtime animation to the beginning
  16104. * @param restoreOriginal defines whether to restore the target property to the original value
  16105. */
  16106. reset(restoreOriginal?: boolean): void;
  16107. /**
  16108. * Specifies if the runtime animation is stopped
  16109. * @returns Boolean specifying if the runtime animation is stopped
  16110. */
  16111. isStopped(): boolean;
  16112. /**
  16113. * Disposes of the runtime animation
  16114. */
  16115. dispose(): void;
  16116. /**
  16117. * Apply the interpolated value to the target
  16118. * @param currentValue defines the value computed by the animation
  16119. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16120. */
  16121. setValue(currentValue: any, weight: number): void;
  16122. private _getOriginalValues;
  16123. private _setValue;
  16124. /**
  16125. * Gets the loop pmode of the runtime animation
  16126. * @returns Loop Mode
  16127. */
  16128. private _getCorrectLoopMode;
  16129. /**
  16130. * Move the current animation to a given frame
  16131. * @param frame defines the frame to move to
  16132. */
  16133. goToFrame(frame: number): void;
  16134. /**
  16135. * @hidden Internal use only
  16136. */
  16137. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16138. /**
  16139. * Execute the current animation
  16140. * @param delay defines the delay to add to the current frame
  16141. * @param from defines the lower bound of the animation range
  16142. * @param to defines the upper bound of the animation range
  16143. * @param loop defines if the current animation must loop
  16144. * @param speedRatio defines the current speed ratio
  16145. * @param weight defines the weight of the animation (default is -1 so no weight)
  16146. * @param onLoop optional callback called when animation loops
  16147. * @returns a boolean indicating if the animation is running
  16148. */
  16149. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16150. }
  16151. }
  16152. declare module "babylonjs/Animations/animatable" {
  16153. import { Animation } from "babylonjs/Animations/animation";
  16154. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16155. import { Nullable } from "babylonjs/types";
  16156. import { Observable } from "babylonjs/Misc/observable";
  16157. import { Scene } from "babylonjs/scene";
  16158. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16159. import { Node } from "babylonjs/node";
  16160. /**
  16161. * Class used to store an actual running animation
  16162. */
  16163. export class Animatable {
  16164. /** defines the target object */
  16165. target: any;
  16166. /** defines the starting frame number (default is 0) */
  16167. fromFrame: number;
  16168. /** defines the ending frame number (default is 100) */
  16169. toFrame: number;
  16170. /** defines if the animation must loop (default is false) */
  16171. loopAnimation: boolean;
  16172. /** defines a callback to call when animation ends if it is not looping */
  16173. onAnimationEnd?: (() => void) | null | undefined;
  16174. /** defines a callback to call when animation loops */
  16175. onAnimationLoop?: (() => void) | null | undefined;
  16176. /** defines whether the animation should be evaluated additively */
  16177. isAdditive: boolean;
  16178. private _localDelayOffset;
  16179. private _pausedDelay;
  16180. private _runtimeAnimations;
  16181. private _paused;
  16182. private _scene;
  16183. private _speedRatio;
  16184. private _weight;
  16185. private _syncRoot;
  16186. /**
  16187. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16188. * This will only apply for non looping animation (default is true)
  16189. */
  16190. disposeOnEnd: boolean;
  16191. /**
  16192. * Gets a boolean indicating if the animation has started
  16193. */
  16194. animationStarted: boolean;
  16195. /**
  16196. * Observer raised when the animation ends
  16197. */
  16198. onAnimationEndObservable: Observable<Animatable>;
  16199. /**
  16200. * Observer raised when the animation loops
  16201. */
  16202. onAnimationLoopObservable: Observable<Animatable>;
  16203. /**
  16204. * Gets the root Animatable used to synchronize and normalize animations
  16205. */
  16206. get syncRoot(): Nullable<Animatable>;
  16207. /**
  16208. * Gets the current frame of the first RuntimeAnimation
  16209. * Used to synchronize Animatables
  16210. */
  16211. get masterFrame(): number;
  16212. /**
  16213. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16214. */
  16215. get weight(): number;
  16216. set weight(value: number);
  16217. /**
  16218. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16219. */
  16220. get speedRatio(): number;
  16221. set speedRatio(value: number);
  16222. /**
  16223. * Creates a new Animatable
  16224. * @param scene defines the hosting scene
  16225. * @param target defines the target object
  16226. * @param fromFrame defines the starting frame number (default is 0)
  16227. * @param toFrame defines the ending frame number (default is 100)
  16228. * @param loopAnimation defines if the animation must loop (default is false)
  16229. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16230. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16231. * @param animations defines a group of animation to add to the new Animatable
  16232. * @param onAnimationLoop defines a callback to call when animation loops
  16233. * @param isAdditive defines whether the animation should be evaluated additively
  16234. */
  16235. constructor(scene: Scene,
  16236. /** defines the target object */
  16237. target: any,
  16238. /** defines the starting frame number (default is 0) */
  16239. fromFrame?: number,
  16240. /** defines the ending frame number (default is 100) */
  16241. toFrame?: number,
  16242. /** defines if the animation must loop (default is false) */
  16243. loopAnimation?: boolean, speedRatio?: number,
  16244. /** defines a callback to call when animation ends if it is not looping */
  16245. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16246. /** defines a callback to call when animation loops */
  16247. onAnimationLoop?: (() => void) | null | undefined,
  16248. /** defines whether the animation should be evaluated additively */
  16249. isAdditive?: boolean);
  16250. /**
  16251. * Synchronize and normalize current Animatable with a source Animatable
  16252. * This is useful when using animation weights and when animations are not of the same length
  16253. * @param root defines the root Animatable to synchronize with
  16254. * @returns the current Animatable
  16255. */
  16256. syncWith(root: Animatable): Animatable;
  16257. /**
  16258. * Gets the list of runtime animations
  16259. * @returns an array of RuntimeAnimation
  16260. */
  16261. getAnimations(): RuntimeAnimation[];
  16262. /**
  16263. * Adds more animations to the current animatable
  16264. * @param target defines the target of the animations
  16265. * @param animations defines the new animations to add
  16266. */
  16267. appendAnimations(target: any, animations: Animation[]): void;
  16268. /**
  16269. * Gets the source animation for a specific property
  16270. * @param property defines the propertyu to look for
  16271. * @returns null or the source animation for the given property
  16272. */
  16273. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16274. /**
  16275. * Gets the runtime animation for a specific property
  16276. * @param property defines the propertyu to look for
  16277. * @returns null or the runtime animation for the given property
  16278. */
  16279. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16280. /**
  16281. * Resets the animatable to its original state
  16282. */
  16283. reset(): void;
  16284. /**
  16285. * Allows the animatable to blend with current running animations
  16286. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16287. * @param blendingSpeed defines the blending speed to use
  16288. */
  16289. enableBlending(blendingSpeed: number): void;
  16290. /**
  16291. * Disable animation blending
  16292. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16293. */
  16294. disableBlending(): void;
  16295. /**
  16296. * Jump directly to a given frame
  16297. * @param frame defines the frame to jump to
  16298. */
  16299. goToFrame(frame: number): void;
  16300. /**
  16301. * Pause the animation
  16302. */
  16303. pause(): void;
  16304. /**
  16305. * Restart the animation
  16306. */
  16307. restart(): void;
  16308. private _raiseOnAnimationEnd;
  16309. /**
  16310. * Stop and delete the current animation
  16311. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16312. * @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)
  16313. */
  16314. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16315. /**
  16316. * Wait asynchronously for the animation to end
  16317. * @returns a promise which will be fullfilled when the animation ends
  16318. */
  16319. waitAsync(): Promise<Animatable>;
  16320. /** @hidden */
  16321. _animate(delay: number): boolean;
  16322. }
  16323. module "babylonjs/scene" {
  16324. interface Scene {
  16325. /** @hidden */
  16326. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16327. /** @hidden */
  16328. _processLateAnimationBindingsForMatrices(holder: {
  16329. totalWeight: number;
  16330. totalAdditiveWeight: number;
  16331. animations: RuntimeAnimation[];
  16332. additiveAnimations: RuntimeAnimation[];
  16333. originalValue: Matrix;
  16334. }): any;
  16335. /** @hidden */
  16336. _processLateAnimationBindingsForQuaternions(holder: {
  16337. totalWeight: number;
  16338. totalAdditiveWeight: number;
  16339. animations: RuntimeAnimation[];
  16340. additiveAnimations: RuntimeAnimation[];
  16341. originalValue: Quaternion;
  16342. }, refQuaternion: Quaternion): Quaternion;
  16343. /** @hidden */
  16344. _processLateAnimationBindings(): void;
  16345. /**
  16346. * Will start the animation sequence of a given target
  16347. * @param target defines the target
  16348. * @param from defines from which frame should animation start
  16349. * @param to defines until which frame should animation run.
  16350. * @param weight defines the weight to apply to the animation (1.0 by default)
  16351. * @param loop defines if the animation loops
  16352. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16353. * @param onAnimationEnd defines the function to be executed when the animation ends
  16354. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16355. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16356. * @param onAnimationLoop defines the callback to call when an animation loops
  16357. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16358. * @returns the animatable object created for this animation
  16359. */
  16360. 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;
  16361. /**
  16362. * Will start the animation sequence of a given target
  16363. * @param target defines the target
  16364. * @param from defines from which frame should animation start
  16365. * @param to defines until which frame should animation run.
  16366. * @param loop defines if the animation loops
  16367. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16368. * @param onAnimationEnd defines the function to be executed when the animation ends
  16369. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16370. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16371. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16372. * @param onAnimationLoop defines the callback to call when an animation loops
  16373. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16374. * @returns the animatable object created for this animation
  16375. */
  16376. 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;
  16377. /**
  16378. * Will start the animation sequence of a given target and its hierarchy
  16379. * @param target defines the target
  16380. * @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.
  16381. * @param from defines from which frame should animation start
  16382. * @param to defines until which frame should animation run.
  16383. * @param loop defines if the animation loops
  16384. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16385. * @param onAnimationEnd defines the function to be executed when the animation ends
  16386. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16387. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16388. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16389. * @param onAnimationLoop defines the callback to call when an animation loops
  16390. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16391. * @returns the list of created animatables
  16392. */
  16393. 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[];
  16394. /**
  16395. * Begin a new animation on a given node
  16396. * @param target defines the target where the animation will take place
  16397. * @param animations defines the list of animations to start
  16398. * @param from defines the initial value
  16399. * @param to defines the final value
  16400. * @param loop defines if you want animation to loop (off by default)
  16401. * @param speedRatio defines the speed ratio to apply to all animations
  16402. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16403. * @param onAnimationLoop defines the callback to call when an animation loops
  16404. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16405. * @returns the list of created animatables
  16406. */
  16407. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16408. /**
  16409. * Begin a new animation on a given node and its hierarchy
  16410. * @param target defines the root node where the animation will take place
  16411. * @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.
  16412. * @param animations defines the list of animations to start
  16413. * @param from defines the initial value
  16414. * @param to defines the final value
  16415. * @param loop defines if you want animation to loop (off by default)
  16416. * @param speedRatio defines the speed ratio to apply to all animations
  16417. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16418. * @param onAnimationLoop defines the callback to call when an animation loops
  16419. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16420. * @returns the list of animatables created for all nodes
  16421. */
  16422. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16423. /**
  16424. * Gets the animatable associated with a specific target
  16425. * @param target defines the target of the animatable
  16426. * @returns the required animatable if found
  16427. */
  16428. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16429. /**
  16430. * Gets all animatables associated with a given target
  16431. * @param target defines the target to look animatables for
  16432. * @returns an array of Animatables
  16433. */
  16434. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16435. /**
  16436. * Stops and removes all animations that have been applied to the scene
  16437. */
  16438. stopAllAnimations(): void;
  16439. /**
  16440. * Gets the current delta time used by animation engine
  16441. */
  16442. deltaTime: number;
  16443. }
  16444. }
  16445. module "babylonjs/Bones/bone" {
  16446. interface Bone {
  16447. /**
  16448. * Copy an animation range from another bone
  16449. * @param source defines the source bone
  16450. * @param rangeName defines the range name to copy
  16451. * @param frameOffset defines the frame offset
  16452. * @param rescaleAsRequired defines if rescaling must be applied if required
  16453. * @param skelDimensionsRatio defines the scaling ratio
  16454. * @returns true if operation was successful
  16455. */
  16456. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16457. }
  16458. }
  16459. }
  16460. declare module "babylonjs/Bones/skeleton" {
  16461. import { Bone } from "babylonjs/Bones/bone";
  16462. import { Observable } from "babylonjs/Misc/observable";
  16463. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16464. import { Scene } from "babylonjs/scene";
  16465. import { Nullable } from "babylonjs/types";
  16466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16467. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16468. import { Animatable } from "babylonjs/Animations/animatable";
  16469. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16470. import { Animation } from "babylonjs/Animations/animation";
  16471. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16472. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16473. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16474. /**
  16475. * Class used to handle skinning animations
  16476. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16477. */
  16478. export class Skeleton implements IAnimatable {
  16479. /** defines the skeleton name */
  16480. name: string;
  16481. /** defines the skeleton Id */
  16482. id: string;
  16483. /**
  16484. * Defines the list of child bones
  16485. */
  16486. bones: Bone[];
  16487. /**
  16488. * Defines an estimate of the dimension of the skeleton at rest
  16489. */
  16490. dimensionsAtRest: Vector3;
  16491. /**
  16492. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16493. */
  16494. needInitialSkinMatrix: boolean;
  16495. /**
  16496. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16497. */
  16498. overrideMesh: Nullable<AbstractMesh>;
  16499. /**
  16500. * Gets the list of animations attached to this skeleton
  16501. */
  16502. animations: Array<Animation>;
  16503. private _scene;
  16504. private _isDirty;
  16505. private _transformMatrices;
  16506. private _transformMatrixTexture;
  16507. private _meshesWithPoseMatrix;
  16508. private _animatables;
  16509. private _identity;
  16510. private _synchronizedWithMesh;
  16511. private _ranges;
  16512. private _lastAbsoluteTransformsUpdateId;
  16513. private _canUseTextureForBones;
  16514. private _uniqueId;
  16515. /** @hidden */
  16516. _numBonesWithLinkedTransformNode: number;
  16517. /** @hidden */
  16518. _hasWaitingData: Nullable<boolean>;
  16519. /** @hidden */
  16520. _waitingOverrideMeshId: Nullable<string>;
  16521. /**
  16522. * Specifies if the skeleton should be serialized
  16523. */
  16524. doNotSerialize: boolean;
  16525. private _useTextureToStoreBoneMatrices;
  16526. /**
  16527. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16528. * Please note that this option is not available if the hardware does not support it
  16529. */
  16530. get useTextureToStoreBoneMatrices(): boolean;
  16531. set useTextureToStoreBoneMatrices(value: boolean);
  16532. private _animationPropertiesOverride;
  16533. /**
  16534. * Gets or sets the animation properties override
  16535. */
  16536. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16537. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16538. /**
  16539. * List of inspectable custom properties (used by the Inspector)
  16540. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16541. */
  16542. inspectableCustomProperties: IInspectable[];
  16543. /**
  16544. * An observable triggered before computing the skeleton's matrices
  16545. */
  16546. onBeforeComputeObservable: Observable<Skeleton>;
  16547. /**
  16548. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16549. */
  16550. get isUsingTextureForMatrices(): boolean;
  16551. /**
  16552. * Gets the unique ID of this skeleton
  16553. */
  16554. get uniqueId(): number;
  16555. /**
  16556. * Creates a new skeleton
  16557. * @param name defines the skeleton name
  16558. * @param id defines the skeleton Id
  16559. * @param scene defines the hosting scene
  16560. */
  16561. constructor(
  16562. /** defines the skeleton name */
  16563. name: string,
  16564. /** defines the skeleton Id */
  16565. id: string, scene: Scene);
  16566. /**
  16567. * Gets the current object class name.
  16568. * @return the class name
  16569. */
  16570. getClassName(): string;
  16571. /**
  16572. * Returns an array containing the root bones
  16573. * @returns an array containing the root bones
  16574. */
  16575. getChildren(): Array<Bone>;
  16576. /**
  16577. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16578. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16579. * @returns a Float32Array containing matrices data
  16580. */
  16581. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16582. /**
  16583. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16584. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16585. * @returns a raw texture containing the data
  16586. */
  16587. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16588. /**
  16589. * Gets the current hosting scene
  16590. * @returns a scene object
  16591. */
  16592. getScene(): Scene;
  16593. /**
  16594. * Gets a string representing the current skeleton data
  16595. * @param fullDetails defines a boolean indicating if we want a verbose version
  16596. * @returns a string representing the current skeleton data
  16597. */
  16598. toString(fullDetails?: boolean): string;
  16599. /**
  16600. * Get bone's index searching by name
  16601. * @param name defines bone's name to search for
  16602. * @return the indice of the bone. Returns -1 if not found
  16603. */
  16604. getBoneIndexByName(name: string): number;
  16605. /**
  16606. * Creater a new animation range
  16607. * @param name defines the name of the range
  16608. * @param from defines the start key
  16609. * @param to defines the end key
  16610. */
  16611. createAnimationRange(name: string, from: number, to: number): void;
  16612. /**
  16613. * Delete a specific animation range
  16614. * @param name defines the name of the range
  16615. * @param deleteFrames defines if frames must be removed as well
  16616. */
  16617. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16618. /**
  16619. * Gets a specific animation range
  16620. * @param name defines the name of the range to look for
  16621. * @returns the requested animation range or null if not found
  16622. */
  16623. getAnimationRange(name: string): Nullable<AnimationRange>;
  16624. /**
  16625. * Gets the list of all animation ranges defined on this skeleton
  16626. * @returns an array
  16627. */
  16628. getAnimationRanges(): Nullable<AnimationRange>[];
  16629. /**
  16630. * Copy animation range from a source skeleton.
  16631. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16632. * @param source defines the source skeleton
  16633. * @param name defines the name of the range to copy
  16634. * @param rescaleAsRequired defines if rescaling must be applied if required
  16635. * @returns true if operation was successful
  16636. */
  16637. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16638. /**
  16639. * Forces the skeleton to go to rest pose
  16640. */
  16641. returnToRest(): void;
  16642. private _getHighestAnimationFrame;
  16643. /**
  16644. * Begin a specific animation range
  16645. * @param name defines the name of the range to start
  16646. * @param loop defines if looping must be turned on (false by default)
  16647. * @param speedRatio defines the speed ratio to apply (1 by default)
  16648. * @param onAnimationEnd defines a callback which will be called when animation will end
  16649. * @returns a new animatable
  16650. */
  16651. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16652. /**
  16653. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16654. * @param skeleton defines the Skeleton containing the animation range to convert
  16655. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16656. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16657. * @returns the original skeleton
  16658. */
  16659. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16660. /** @hidden */
  16661. _markAsDirty(): void;
  16662. /** @hidden */
  16663. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16664. /** @hidden */
  16665. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16666. private _computeTransformMatrices;
  16667. /**
  16668. * Build all resources required to render a skeleton
  16669. */
  16670. prepare(): void;
  16671. /**
  16672. * Gets the list of animatables currently running for this skeleton
  16673. * @returns an array of animatables
  16674. */
  16675. getAnimatables(): IAnimatable[];
  16676. /**
  16677. * Clone the current skeleton
  16678. * @param name defines the name of the new skeleton
  16679. * @param id defines the id of the new skeleton
  16680. * @returns the new skeleton
  16681. */
  16682. clone(name: string, id?: string): Skeleton;
  16683. /**
  16684. * Enable animation blending for this skeleton
  16685. * @param blendingSpeed defines the blending speed to apply
  16686. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16687. */
  16688. enableBlending(blendingSpeed?: number): void;
  16689. /**
  16690. * Releases all resources associated with the current skeleton
  16691. */
  16692. dispose(): void;
  16693. /**
  16694. * Serialize the skeleton in a JSON object
  16695. * @returns a JSON object
  16696. */
  16697. serialize(): any;
  16698. /**
  16699. * Creates a new skeleton from serialized data
  16700. * @param parsedSkeleton defines the serialized data
  16701. * @param scene defines the hosting scene
  16702. * @returns a new skeleton
  16703. */
  16704. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16705. /**
  16706. * Compute all node absolute transforms
  16707. * @param forceUpdate defines if computation must be done even if cache is up to date
  16708. */
  16709. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16710. /**
  16711. * Gets the root pose matrix
  16712. * @returns a matrix
  16713. */
  16714. getPoseMatrix(): Nullable<Matrix>;
  16715. /**
  16716. * Sorts bones per internal index
  16717. */
  16718. sortBones(): void;
  16719. private _sortBones;
  16720. /**
  16721. * Set the current local matrix as the restPose for all bones in the skeleton.
  16722. */
  16723. setCurrentPoseAsRest(): void;
  16724. }
  16725. }
  16726. declare module "babylonjs/Meshes/instancedMesh" {
  16727. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16728. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16729. import { Camera } from "babylonjs/Cameras/camera";
  16730. import { Node } from "babylonjs/node";
  16731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16732. import { Mesh } from "babylonjs/Meshes/mesh";
  16733. import { Material } from "babylonjs/Materials/material";
  16734. import { Skeleton } from "babylonjs/Bones/skeleton";
  16735. import { Light } from "babylonjs/Lights/light";
  16736. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16737. /**
  16738. * Creates an instance based on a source mesh.
  16739. */
  16740. export class InstancedMesh extends AbstractMesh {
  16741. private _sourceMesh;
  16742. private _currentLOD;
  16743. /** @hidden */
  16744. _indexInSourceMeshInstanceArray: number;
  16745. constructor(name: string, source: Mesh);
  16746. /**
  16747. * Returns the string "InstancedMesh".
  16748. */
  16749. getClassName(): string;
  16750. /** Gets the list of lights affecting that mesh */
  16751. get lightSources(): Light[];
  16752. _resyncLightSources(): void;
  16753. _resyncLightSource(light: Light): void;
  16754. _removeLightSource(light: Light, dispose: boolean): void;
  16755. /**
  16756. * If the source mesh receives shadows
  16757. */
  16758. get receiveShadows(): boolean;
  16759. /**
  16760. * The material of the source mesh
  16761. */
  16762. get material(): Nullable<Material>;
  16763. /**
  16764. * Visibility of the source mesh
  16765. */
  16766. get visibility(): number;
  16767. /**
  16768. * Skeleton of the source mesh
  16769. */
  16770. get skeleton(): Nullable<Skeleton>;
  16771. /**
  16772. * Rendering ground id of the source mesh
  16773. */
  16774. get renderingGroupId(): number;
  16775. set renderingGroupId(value: number);
  16776. /**
  16777. * Returns the total number of vertices (integer).
  16778. */
  16779. getTotalVertices(): number;
  16780. /**
  16781. * Returns a positive integer : the total number of indices in this mesh geometry.
  16782. * @returns the numner of indices or zero if the mesh has no geometry.
  16783. */
  16784. getTotalIndices(): number;
  16785. /**
  16786. * The source mesh of the instance
  16787. */
  16788. get sourceMesh(): Mesh;
  16789. /**
  16790. * Creates a new InstancedMesh object from the mesh model.
  16791. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16792. * @param name defines the name of the new instance
  16793. * @returns a new InstancedMesh
  16794. */
  16795. createInstance(name: string): InstancedMesh;
  16796. /**
  16797. * Is this node ready to be used/rendered
  16798. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16799. * @return {boolean} is it ready
  16800. */
  16801. isReady(completeCheck?: boolean): boolean;
  16802. /**
  16803. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16804. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16805. * @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.
  16806. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16807. */
  16808. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16809. /**
  16810. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16811. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16812. * The `data` are either a numeric array either a Float32Array.
  16813. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16814. * 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).
  16815. * Note that a new underlying VertexBuffer object is created each call.
  16816. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16817. *
  16818. * Possible `kind` values :
  16819. * - VertexBuffer.PositionKind
  16820. * - VertexBuffer.UVKind
  16821. * - VertexBuffer.UV2Kind
  16822. * - VertexBuffer.UV3Kind
  16823. * - VertexBuffer.UV4Kind
  16824. * - VertexBuffer.UV5Kind
  16825. * - VertexBuffer.UV6Kind
  16826. * - VertexBuffer.ColorKind
  16827. * - VertexBuffer.MatricesIndicesKind
  16828. * - VertexBuffer.MatricesIndicesExtraKind
  16829. * - VertexBuffer.MatricesWeightsKind
  16830. * - VertexBuffer.MatricesWeightsExtraKind
  16831. *
  16832. * Returns the Mesh.
  16833. */
  16834. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16835. /**
  16836. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16837. * If the mesh has no geometry, it is simply returned as it is.
  16838. * The `data` are either a numeric array either a Float32Array.
  16839. * No new underlying VertexBuffer object is created.
  16840. * 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.
  16841. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16842. *
  16843. * Possible `kind` values :
  16844. * - VertexBuffer.PositionKind
  16845. * - VertexBuffer.UVKind
  16846. * - VertexBuffer.UV2Kind
  16847. * - VertexBuffer.UV3Kind
  16848. * - VertexBuffer.UV4Kind
  16849. * - VertexBuffer.UV5Kind
  16850. * - VertexBuffer.UV6Kind
  16851. * - VertexBuffer.ColorKind
  16852. * - VertexBuffer.MatricesIndicesKind
  16853. * - VertexBuffer.MatricesIndicesExtraKind
  16854. * - VertexBuffer.MatricesWeightsKind
  16855. * - VertexBuffer.MatricesWeightsExtraKind
  16856. *
  16857. * Returns the Mesh.
  16858. */
  16859. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16860. /**
  16861. * Sets the mesh indices.
  16862. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16863. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16864. * This method creates a new index buffer each call.
  16865. * Returns the Mesh.
  16866. */
  16867. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16868. /**
  16869. * Boolean : True if the mesh owns the requested kind of data.
  16870. */
  16871. isVerticesDataPresent(kind: string): boolean;
  16872. /**
  16873. * Returns an array of indices (IndicesArray).
  16874. */
  16875. getIndices(): Nullable<IndicesArray>;
  16876. get _positions(): Nullable<Vector3[]>;
  16877. /**
  16878. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16879. * This means the mesh underlying bounding box and sphere are recomputed.
  16880. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16881. * @returns the current mesh
  16882. */
  16883. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16884. /** @hidden */
  16885. _preActivate(): InstancedMesh;
  16886. /** @hidden */
  16887. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16888. /** @hidden */
  16889. _postActivate(): void;
  16890. getWorldMatrix(): Matrix;
  16891. get isAnInstance(): boolean;
  16892. /**
  16893. * Returns the current associated LOD AbstractMesh.
  16894. */
  16895. getLOD(camera: Camera): AbstractMesh;
  16896. /** @hidden */
  16897. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16898. /** @hidden */
  16899. _syncSubMeshes(): InstancedMesh;
  16900. /** @hidden */
  16901. _generatePointsArray(): boolean;
  16902. /** @hidden */
  16903. _updateBoundingInfo(): AbstractMesh;
  16904. /**
  16905. * Creates a new InstancedMesh from the current mesh.
  16906. * - name (string) : the cloned mesh name
  16907. * - newParent (optional Node) : the optional Node to parent the clone to.
  16908. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16909. *
  16910. * Returns the clone.
  16911. */
  16912. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16913. /**
  16914. * Disposes the InstancedMesh.
  16915. * Returns nothing.
  16916. */
  16917. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16918. }
  16919. module "babylonjs/Meshes/mesh" {
  16920. interface Mesh {
  16921. /**
  16922. * Register a custom buffer that will be instanced
  16923. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16924. * @param kind defines the buffer kind
  16925. * @param stride defines the stride in floats
  16926. */
  16927. registerInstancedBuffer(kind: string, stride: number): void;
  16928. /**
  16929. * true to use the edge renderer for all instances of this mesh
  16930. */
  16931. edgesShareWithInstances: boolean;
  16932. /** @hidden */
  16933. _userInstancedBuffersStorage: {
  16934. data: {
  16935. [key: string]: Float32Array;
  16936. };
  16937. sizes: {
  16938. [key: string]: number;
  16939. };
  16940. vertexBuffers: {
  16941. [key: string]: Nullable<VertexBuffer>;
  16942. };
  16943. strides: {
  16944. [key: string]: number;
  16945. };
  16946. };
  16947. }
  16948. }
  16949. module "babylonjs/Meshes/abstractMesh" {
  16950. interface AbstractMesh {
  16951. /**
  16952. * Object used to store instanced buffers defined by user
  16953. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16954. */
  16955. instancedBuffers: {
  16956. [key: string]: any;
  16957. };
  16958. }
  16959. }
  16960. }
  16961. declare module "babylonjs/Materials/shaderMaterial" {
  16962. import { Nullable } from "babylonjs/types";
  16963. import { Scene } from "babylonjs/scene";
  16964. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16966. import { Mesh } from "babylonjs/Meshes/mesh";
  16967. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16969. import { Effect } from "babylonjs/Materials/effect";
  16970. import { Material } from "babylonjs/Materials/material";
  16971. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16972. /**
  16973. * Defines the options associated with the creation of a shader material.
  16974. */
  16975. export interface IShaderMaterialOptions {
  16976. /**
  16977. * Does the material work in alpha blend mode
  16978. */
  16979. needAlphaBlending: boolean;
  16980. /**
  16981. * Does the material work in alpha test mode
  16982. */
  16983. needAlphaTesting: boolean;
  16984. /**
  16985. * The list of attribute names used in the shader
  16986. */
  16987. attributes: string[];
  16988. /**
  16989. * The list of unifrom names used in the shader
  16990. */
  16991. uniforms: string[];
  16992. /**
  16993. * The list of UBO names used in the shader
  16994. */
  16995. uniformBuffers: string[];
  16996. /**
  16997. * The list of sampler names used in the shader
  16998. */
  16999. samplers: string[];
  17000. /**
  17001. * The list of defines used in the shader
  17002. */
  17003. defines: string[];
  17004. }
  17005. /**
  17006. * 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.
  17007. *
  17008. * This returned material effects how the mesh will look based on the code in the shaders.
  17009. *
  17010. * @see https://doc.babylonjs.com/how_to/shader_material
  17011. */
  17012. export class ShaderMaterial extends Material {
  17013. private _shaderPath;
  17014. private _options;
  17015. private _textures;
  17016. private _textureArrays;
  17017. private _floats;
  17018. private _ints;
  17019. private _floatsArrays;
  17020. private _colors3;
  17021. private _colors3Arrays;
  17022. private _colors4;
  17023. private _colors4Arrays;
  17024. private _vectors2;
  17025. private _vectors3;
  17026. private _vectors4;
  17027. private _matrices;
  17028. private _matrixArrays;
  17029. private _matrices3x3;
  17030. private _matrices2x2;
  17031. private _vectors2Arrays;
  17032. private _vectors3Arrays;
  17033. private _vectors4Arrays;
  17034. private _cachedWorldViewMatrix;
  17035. private _cachedWorldViewProjectionMatrix;
  17036. private _renderId;
  17037. private _multiview;
  17038. private _cachedDefines;
  17039. /** Define the Url to load snippets */
  17040. static SnippetUrl: string;
  17041. /** Snippet ID if the material was created from the snippet server */
  17042. snippetId: string;
  17043. /**
  17044. * Instantiate a new shader material.
  17045. * 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.
  17046. * This returned material effects how the mesh will look based on the code in the shaders.
  17047. * @see https://doc.babylonjs.com/how_to/shader_material
  17048. * @param name Define the name of the material in the scene
  17049. * @param scene Define the scene the material belongs to
  17050. * @param shaderPath Defines the route to the shader code in one of three ways:
  17051. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17052. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17053. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17054. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17055. * @param options Define the options used to create the shader
  17056. */
  17057. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17058. /**
  17059. * Gets the shader path used to define the shader code
  17060. * It can be modified to trigger a new compilation
  17061. */
  17062. get shaderPath(): any;
  17063. /**
  17064. * Sets the shader path used to define the shader code
  17065. * It can be modified to trigger a new compilation
  17066. */
  17067. set shaderPath(shaderPath: any);
  17068. /**
  17069. * Gets the options used to compile the shader.
  17070. * They can be modified to trigger a new compilation
  17071. */
  17072. get options(): IShaderMaterialOptions;
  17073. /**
  17074. * Gets the current class name of the material e.g. "ShaderMaterial"
  17075. * Mainly use in serialization.
  17076. * @returns the class name
  17077. */
  17078. getClassName(): string;
  17079. /**
  17080. * Specifies if the material will require alpha blending
  17081. * @returns a boolean specifying if alpha blending is needed
  17082. */
  17083. needAlphaBlending(): boolean;
  17084. /**
  17085. * Specifies if this material should be rendered in alpha test mode
  17086. * @returns a boolean specifying if an alpha test is needed.
  17087. */
  17088. needAlphaTesting(): boolean;
  17089. private _checkUniform;
  17090. /**
  17091. * Set a texture in the shader.
  17092. * @param name Define the name of the uniform samplers as defined in the shader
  17093. * @param texture Define the texture to bind to this sampler
  17094. * @return the material itself allowing "fluent" like uniform updates
  17095. */
  17096. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17097. /**
  17098. * Set a texture array in the shader.
  17099. * @param name Define the name of the uniform sampler array as defined in the shader
  17100. * @param textures Define the list of textures to bind to this sampler
  17101. * @return the material itself allowing "fluent" like uniform updates
  17102. */
  17103. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17104. /**
  17105. * Set a float in the shader.
  17106. * @param name Define the name of the uniform as defined in the shader
  17107. * @param value Define the value to give to the uniform
  17108. * @return the material itself allowing "fluent" like uniform updates
  17109. */
  17110. setFloat(name: string, value: number): ShaderMaterial;
  17111. /**
  17112. * Set a int in the shader.
  17113. * @param name Define the name of the uniform as defined in the shader
  17114. * @param value Define the value to give to the uniform
  17115. * @return the material itself allowing "fluent" like uniform updates
  17116. */
  17117. setInt(name: string, value: number): ShaderMaterial;
  17118. /**
  17119. * Set an array of floats in the shader.
  17120. * @param name Define the name of the uniform as defined in the shader
  17121. * @param value Define the value to give to the uniform
  17122. * @return the material itself allowing "fluent" like uniform updates
  17123. */
  17124. setFloats(name: string, value: number[]): ShaderMaterial;
  17125. /**
  17126. * Set a vec3 in the shader from a Color3.
  17127. * @param name Define the name of the uniform as defined in the shader
  17128. * @param value Define the value to give to the uniform
  17129. * @return the material itself allowing "fluent" like uniform updates
  17130. */
  17131. setColor3(name: string, value: Color3): ShaderMaterial;
  17132. /**
  17133. * Set a vec3 array in the shader from a Color3 array.
  17134. * @param name Define the name of the uniform as defined in the shader
  17135. * @param value Define the value to give to the uniform
  17136. * @return the material itself allowing "fluent" like uniform updates
  17137. */
  17138. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17139. /**
  17140. * Set a vec4 in the shader from a Color4.
  17141. * @param name Define the name of the uniform as defined in the shader
  17142. * @param value Define the value to give to the uniform
  17143. * @return the material itself allowing "fluent" like uniform updates
  17144. */
  17145. setColor4(name: string, value: Color4): ShaderMaterial;
  17146. /**
  17147. * Set a vec4 array in the shader from a Color4 array.
  17148. * @param name Define the name of the uniform as defined in the shader
  17149. * @param value Define the value to give to the uniform
  17150. * @return the material itself allowing "fluent" like uniform updates
  17151. */
  17152. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17153. /**
  17154. * Set a vec2 in the shader from a Vector2.
  17155. * @param name Define the name of the uniform as defined in the shader
  17156. * @param value Define the value to give to the uniform
  17157. * @return the material itself allowing "fluent" like uniform updates
  17158. */
  17159. setVector2(name: string, value: Vector2): ShaderMaterial;
  17160. /**
  17161. * Set a vec3 in the shader from a Vector3.
  17162. * @param name Define the name of the uniform as defined in the shader
  17163. * @param value Define the value to give to the uniform
  17164. * @return the material itself allowing "fluent" like uniform updates
  17165. */
  17166. setVector3(name: string, value: Vector3): ShaderMaterial;
  17167. /**
  17168. * Set a vec4 in the shader from a Vector4.
  17169. * @param name Define the name of the uniform as defined in the shader
  17170. * @param value Define the value to give to the uniform
  17171. * @return the material itself allowing "fluent" like uniform updates
  17172. */
  17173. setVector4(name: string, value: Vector4): ShaderMaterial;
  17174. /**
  17175. * Set a mat4 in the shader from a Matrix.
  17176. * @param name Define the name of the uniform as defined in the shader
  17177. * @param value Define the value to give to the uniform
  17178. * @return the material itself allowing "fluent" like uniform updates
  17179. */
  17180. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17181. /**
  17182. * Set a float32Array in the shader from a matrix array.
  17183. * @param name Define the name of the uniform as defined in the shader
  17184. * @param value Define the value to give to the uniform
  17185. * @return the material itself allowing "fluent" like uniform updates
  17186. */
  17187. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17188. /**
  17189. * Set a mat3 in the shader from a Float32Array.
  17190. * @param name Define the name of the uniform as defined in the shader
  17191. * @param value Define the value to give to the uniform
  17192. * @return the material itself allowing "fluent" like uniform updates
  17193. */
  17194. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17195. /**
  17196. * Set a mat2 in the shader from a Float32Array.
  17197. * @param name Define the name of the uniform as defined in the shader
  17198. * @param value Define the value to give to the uniform
  17199. * @return the material itself allowing "fluent" like uniform updates
  17200. */
  17201. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17202. /**
  17203. * Set a vec2 array in the shader from a number array.
  17204. * @param name Define the name of the uniform as defined in the shader
  17205. * @param value Define the value to give to the uniform
  17206. * @return the material itself allowing "fluent" like uniform updates
  17207. */
  17208. setArray2(name: string, value: number[]): ShaderMaterial;
  17209. /**
  17210. * Set a vec3 array in the shader from a number array.
  17211. * @param name Define the name of the uniform as defined in the shader
  17212. * @param value Define the value to give to the uniform
  17213. * @return the material itself allowing "fluent" like uniform updates
  17214. */
  17215. setArray3(name: string, value: number[]): ShaderMaterial;
  17216. /**
  17217. * Set a vec4 array in the shader from a number array.
  17218. * @param name Define the name of the uniform as defined in the shader
  17219. * @param value Define the value to give to the uniform
  17220. * @return the material itself allowing "fluent" like uniform updates
  17221. */
  17222. setArray4(name: string, value: number[]): ShaderMaterial;
  17223. private _checkCache;
  17224. /**
  17225. * Specifies that the submesh is ready to be used
  17226. * @param mesh defines the mesh to check
  17227. * @param subMesh defines which submesh to check
  17228. * @param useInstances specifies that instances should be used
  17229. * @returns a boolean indicating that the submesh is ready or not
  17230. */
  17231. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17232. /**
  17233. * Checks if the material is ready to render the requested mesh
  17234. * @param mesh Define the mesh to render
  17235. * @param useInstances Define whether or not the material is used with instances
  17236. * @returns true if ready, otherwise false
  17237. */
  17238. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17239. /**
  17240. * Binds the world matrix to the material
  17241. * @param world defines the world transformation matrix
  17242. * @param effectOverride - If provided, use this effect instead of internal effect
  17243. */
  17244. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17245. /**
  17246. * Binds the submesh to this material by preparing the effect and shader to draw
  17247. * @param world defines the world transformation matrix
  17248. * @param mesh defines the mesh containing the submesh
  17249. * @param subMesh defines the submesh to bind the material to
  17250. */
  17251. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17252. /**
  17253. * Binds the material to the mesh
  17254. * @param world defines the world transformation matrix
  17255. * @param mesh defines the mesh to bind the material to
  17256. * @param effectOverride - If provided, use this effect instead of internal effect
  17257. */
  17258. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17259. protected _afterBind(mesh?: Mesh): void;
  17260. /**
  17261. * Gets the active textures from the material
  17262. * @returns an array of textures
  17263. */
  17264. getActiveTextures(): BaseTexture[];
  17265. /**
  17266. * Specifies if the material uses a texture
  17267. * @param texture defines the texture to check against the material
  17268. * @returns a boolean specifying if the material uses the texture
  17269. */
  17270. hasTexture(texture: BaseTexture): boolean;
  17271. /**
  17272. * Makes a duplicate of the material, and gives it a new name
  17273. * @param name defines the new name for the duplicated material
  17274. * @returns the cloned material
  17275. */
  17276. clone(name: string): ShaderMaterial;
  17277. /**
  17278. * Disposes the material
  17279. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17280. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17281. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17282. */
  17283. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17284. /**
  17285. * Serializes this material in a JSON representation
  17286. * @returns the serialized material object
  17287. */
  17288. serialize(): any;
  17289. /**
  17290. * Creates a shader material from parsed shader material data
  17291. * @param source defines the JSON represnetation of the material
  17292. * @param scene defines the hosting scene
  17293. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17294. * @returns a new material
  17295. */
  17296. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17297. /**
  17298. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17299. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17300. * @param url defines the url to load from
  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 promise that will resolve to the new ShaderMaterial
  17304. */
  17305. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17306. /**
  17307. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17308. * @param snippetId defines the snippet to load
  17309. * @param scene defines the hosting scene
  17310. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17311. * @returns a promise that will resolve to the new ShaderMaterial
  17312. */
  17313. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17314. }
  17315. }
  17316. declare module "babylonjs/Shaders/color.fragment" {
  17317. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17318. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17319. /** @hidden */
  17320. export var colorPixelShader: {
  17321. name: string;
  17322. shader: string;
  17323. };
  17324. }
  17325. declare module "babylonjs/Shaders/color.vertex" {
  17326. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17327. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17328. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17329. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17330. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17331. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17332. /** @hidden */
  17333. export var colorVertexShader: {
  17334. name: string;
  17335. shader: string;
  17336. };
  17337. }
  17338. declare module "babylonjs/Meshes/linesMesh" {
  17339. import { Nullable } from "babylonjs/types";
  17340. import { Scene } from "babylonjs/scene";
  17341. import { Color3 } from "babylonjs/Maths/math.color";
  17342. import { Node } from "babylonjs/node";
  17343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17344. import { Mesh } from "babylonjs/Meshes/mesh";
  17345. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17346. import { Effect } from "babylonjs/Materials/effect";
  17347. import { Material } from "babylonjs/Materials/material";
  17348. import "babylonjs/Shaders/color.fragment";
  17349. import "babylonjs/Shaders/color.vertex";
  17350. /**
  17351. * Line mesh
  17352. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17353. */
  17354. export class LinesMesh extends Mesh {
  17355. /**
  17356. * If vertex color should be applied to the mesh
  17357. */
  17358. readonly useVertexColor?: boolean | undefined;
  17359. /**
  17360. * If vertex alpha should be applied to the mesh
  17361. */
  17362. readonly useVertexAlpha?: boolean | undefined;
  17363. /**
  17364. * Color of the line (Default: White)
  17365. */
  17366. color: Color3;
  17367. /**
  17368. * Alpha of the line (Default: 1)
  17369. */
  17370. alpha: number;
  17371. /**
  17372. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17373. * This margin is expressed in world space coordinates, so its value may vary.
  17374. * Default value is 0.1
  17375. */
  17376. intersectionThreshold: number;
  17377. private _colorShader;
  17378. private color4;
  17379. /**
  17380. * Creates a new LinesMesh
  17381. * @param name defines the name
  17382. * @param scene defines the hosting scene
  17383. * @param parent defines the parent mesh if any
  17384. * @param source defines the optional source LinesMesh used to clone data from
  17385. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17386. * When false, achieved by calling a clone(), also passing False.
  17387. * This will make creation of children, recursive.
  17388. * @param useVertexColor defines if this LinesMesh supports vertex color
  17389. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17390. */
  17391. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17392. /**
  17393. * If vertex color should be applied to the mesh
  17394. */
  17395. useVertexColor?: boolean | undefined,
  17396. /**
  17397. * If vertex alpha should be applied to the mesh
  17398. */
  17399. useVertexAlpha?: boolean | undefined);
  17400. private _addClipPlaneDefine;
  17401. private _removeClipPlaneDefine;
  17402. isReady(): boolean;
  17403. /**
  17404. * Returns the string "LineMesh"
  17405. */
  17406. getClassName(): string;
  17407. /**
  17408. * @hidden
  17409. */
  17410. get material(): Material;
  17411. /**
  17412. * @hidden
  17413. */
  17414. set material(value: Material);
  17415. /**
  17416. * @hidden
  17417. */
  17418. get checkCollisions(): boolean;
  17419. /** @hidden */
  17420. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17421. /** @hidden */
  17422. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17423. /**
  17424. * Disposes of the line mesh
  17425. * @param doNotRecurse If children should be disposed
  17426. */
  17427. dispose(doNotRecurse?: boolean): void;
  17428. /**
  17429. * Returns a new LineMesh object cloned from the current one.
  17430. */
  17431. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17432. /**
  17433. * Creates a new InstancedLinesMesh object from the mesh model.
  17434. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17435. * @param name defines the name of the new instance
  17436. * @returns a new InstancedLinesMesh
  17437. */
  17438. createInstance(name: string): InstancedLinesMesh;
  17439. }
  17440. /**
  17441. * Creates an instance based on a source LinesMesh
  17442. */
  17443. export class InstancedLinesMesh extends InstancedMesh {
  17444. /**
  17445. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17446. * This margin is expressed in world space coordinates, so its value may vary.
  17447. * Initilized with the intersectionThreshold value of the source LinesMesh
  17448. */
  17449. intersectionThreshold: number;
  17450. constructor(name: string, source: LinesMesh);
  17451. /**
  17452. * Returns the string "InstancedLinesMesh".
  17453. */
  17454. getClassName(): string;
  17455. }
  17456. }
  17457. declare module "babylonjs/Shaders/line.fragment" {
  17458. /** @hidden */
  17459. export var linePixelShader: {
  17460. name: string;
  17461. shader: string;
  17462. };
  17463. }
  17464. declare module "babylonjs/Shaders/line.vertex" {
  17465. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17467. /** @hidden */
  17468. export var lineVertexShader: {
  17469. name: string;
  17470. shader: string;
  17471. };
  17472. }
  17473. declare module "babylonjs/Rendering/edgesRenderer" {
  17474. import { Nullable } from "babylonjs/types";
  17475. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17477. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17478. import { IDisposable } from "babylonjs/scene";
  17479. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17480. import "babylonjs/Shaders/line.fragment";
  17481. import "babylonjs/Shaders/line.vertex";
  17482. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17483. import { SmartArray } from "babylonjs/Misc/smartArray";
  17484. module "babylonjs/scene" {
  17485. interface Scene {
  17486. /** @hidden */
  17487. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17488. }
  17489. }
  17490. module "babylonjs/Meshes/abstractMesh" {
  17491. interface AbstractMesh {
  17492. /**
  17493. * Gets the edgesRenderer associated with the mesh
  17494. */
  17495. edgesRenderer: Nullable<EdgesRenderer>;
  17496. }
  17497. }
  17498. module "babylonjs/Meshes/linesMesh" {
  17499. interface LinesMesh {
  17500. /**
  17501. * Enables the edge rendering mode on the mesh.
  17502. * This mode makes the mesh edges visible
  17503. * @param epsilon defines the maximal distance between two angles to detect a face
  17504. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17505. * @returns the currentAbstractMesh
  17506. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17507. */
  17508. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17509. }
  17510. }
  17511. module "babylonjs/Meshes/linesMesh" {
  17512. interface InstancedLinesMesh {
  17513. /**
  17514. * Enables the edge rendering mode on the mesh.
  17515. * This mode makes the mesh edges visible
  17516. * @param epsilon defines the maximal distance between two angles to detect a face
  17517. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17518. * @returns the current InstancedLinesMesh
  17519. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17520. */
  17521. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17522. }
  17523. }
  17524. /**
  17525. * Defines the minimum contract an Edges renderer should follow.
  17526. */
  17527. export interface IEdgesRenderer extends IDisposable {
  17528. /**
  17529. * Gets or sets a boolean indicating if the edgesRenderer is active
  17530. */
  17531. isEnabled: boolean;
  17532. /**
  17533. * Renders the edges of the attached mesh,
  17534. */
  17535. render(): void;
  17536. /**
  17537. * Checks wether or not the edges renderer is ready to render.
  17538. * @return true if ready, otherwise false.
  17539. */
  17540. isReady(): boolean;
  17541. /**
  17542. * List of instances to render in case the source mesh has instances
  17543. */
  17544. customInstances: SmartArray<Matrix>;
  17545. }
  17546. /**
  17547. * Defines the additional options of the edges renderer
  17548. */
  17549. export interface IEdgesRendererOptions {
  17550. /**
  17551. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17552. * If not defined, the default value is true
  17553. */
  17554. useAlternateEdgeFinder?: boolean;
  17555. /**
  17556. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17557. * If not defined, the default value is true.
  17558. * 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)
  17559. * This option is used only if useAlternateEdgeFinder = true
  17560. */
  17561. useFastVertexMerger?: boolean;
  17562. /**
  17563. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17564. * The default value is 1e-6
  17565. * This option is used only if useAlternateEdgeFinder = true
  17566. */
  17567. epsilonVertexMerge?: number;
  17568. /**
  17569. * 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
  17570. * 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.
  17571. * This option is used only if useAlternateEdgeFinder = true
  17572. */
  17573. applyTessellation?: boolean;
  17574. /**
  17575. * 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
  17576. * The default value is 1e-6
  17577. * This option is used only if useAlternateEdgeFinder = true
  17578. */
  17579. epsilonVertexAligned?: number;
  17580. }
  17581. /**
  17582. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17583. */
  17584. export class EdgesRenderer implements IEdgesRenderer {
  17585. /**
  17586. * Define the size of the edges with an orthographic camera
  17587. */
  17588. edgesWidthScalerForOrthographic: number;
  17589. /**
  17590. * Define the size of the edges with a perspective camera
  17591. */
  17592. edgesWidthScalerForPerspective: number;
  17593. protected _source: AbstractMesh;
  17594. protected _linesPositions: number[];
  17595. protected _linesNormals: number[];
  17596. protected _linesIndices: number[];
  17597. protected _epsilon: number;
  17598. protected _indicesCount: number;
  17599. protected _lineShader: ShaderMaterial;
  17600. protected _ib: DataBuffer;
  17601. protected _buffers: {
  17602. [key: string]: Nullable<VertexBuffer>;
  17603. };
  17604. protected _buffersForInstances: {
  17605. [key: string]: Nullable<VertexBuffer>;
  17606. };
  17607. protected _checkVerticesInsteadOfIndices: boolean;
  17608. protected _options: Nullable<IEdgesRendererOptions>;
  17609. private _meshRebuildObserver;
  17610. private _meshDisposeObserver;
  17611. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17612. isEnabled: boolean;
  17613. /**
  17614. * List of instances to render in case the source mesh has instances
  17615. */
  17616. customInstances: SmartArray<Matrix>;
  17617. private static GetShader;
  17618. /**
  17619. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17620. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17621. * @param source Mesh used to create edges
  17622. * @param epsilon sum of angles in adjacency to check for edge
  17623. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17624. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17625. * @param options The options to apply when generating the edges
  17626. */
  17627. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17628. protected _prepareRessources(): void;
  17629. /** @hidden */
  17630. _rebuild(): void;
  17631. /**
  17632. * Releases the required resources for the edges renderer
  17633. */
  17634. dispose(): void;
  17635. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17636. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17637. /**
  17638. * Checks if the pair of p0 and p1 is en edge
  17639. * @param faceIndex
  17640. * @param edge
  17641. * @param faceNormals
  17642. * @param p0
  17643. * @param p1
  17644. * @private
  17645. */
  17646. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17647. /**
  17648. * push line into the position, normal and index buffer
  17649. * @protected
  17650. */
  17651. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17652. /**
  17653. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17654. */
  17655. private _tessellateTriangle;
  17656. private _generateEdgesLinesAlternate;
  17657. /**
  17658. * Generates lines edges from adjacencjes
  17659. * @private
  17660. */
  17661. _generateEdgesLines(): void;
  17662. /**
  17663. * Checks wether or not the edges renderer is ready to render.
  17664. * @return true if ready, otherwise false.
  17665. */
  17666. isReady(): boolean;
  17667. /**
  17668. * Renders the edges of the attached mesh,
  17669. */
  17670. render(): void;
  17671. }
  17672. /**
  17673. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17674. */
  17675. export class LineEdgesRenderer extends EdgesRenderer {
  17676. /**
  17677. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17678. * @param source LineMesh used to generate edges
  17679. * @param epsilon not important (specified angle for edge detection)
  17680. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17681. */
  17682. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17683. /**
  17684. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17685. */
  17686. _generateEdgesLines(): void;
  17687. }
  17688. }
  17689. declare module "babylonjs/Rendering/renderingGroup" {
  17690. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17691. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17693. import { Nullable } from "babylonjs/types";
  17694. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17695. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17696. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17697. import { Material } from "babylonjs/Materials/material";
  17698. import { Scene } from "babylonjs/scene";
  17699. /**
  17700. * This represents the object necessary to create a rendering group.
  17701. * This is exclusively used and created by the rendering manager.
  17702. * To modify the behavior, you use the available helpers in your scene or meshes.
  17703. * @hidden
  17704. */
  17705. export class RenderingGroup {
  17706. index: number;
  17707. private static _zeroVector;
  17708. private _scene;
  17709. private _opaqueSubMeshes;
  17710. private _transparentSubMeshes;
  17711. private _alphaTestSubMeshes;
  17712. private _depthOnlySubMeshes;
  17713. private _particleSystems;
  17714. private _spriteManagers;
  17715. private _opaqueSortCompareFn;
  17716. private _alphaTestSortCompareFn;
  17717. private _transparentSortCompareFn;
  17718. private _renderOpaque;
  17719. private _renderAlphaTest;
  17720. private _renderTransparent;
  17721. /** @hidden */
  17722. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17723. onBeforeTransparentRendering: () => void;
  17724. /**
  17725. * Set the opaque sort comparison function.
  17726. * If null the sub meshes will be render in the order they were created
  17727. */
  17728. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17729. /**
  17730. * Set the alpha test sort comparison function.
  17731. * If null the sub meshes will be render in the order they were created
  17732. */
  17733. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17734. /**
  17735. * Set the transparent sort comparison function.
  17736. * If null the sub meshes will be render in the order they were created
  17737. */
  17738. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17739. /**
  17740. * Creates a new rendering group.
  17741. * @param index The rendering group index
  17742. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17743. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17744. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17745. */
  17746. 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>);
  17747. /**
  17748. * Render all the sub meshes contained in the group.
  17749. * @param customRenderFunction Used to override the default render behaviour of the group.
  17750. * @returns true if rendered some submeshes.
  17751. */
  17752. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17753. /**
  17754. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17755. * @param subMeshes The submeshes to render
  17756. */
  17757. private renderOpaqueSorted;
  17758. /**
  17759. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17760. * @param subMeshes The submeshes to render
  17761. */
  17762. private renderAlphaTestSorted;
  17763. /**
  17764. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17765. * @param subMeshes The submeshes to render
  17766. */
  17767. private renderTransparentSorted;
  17768. /**
  17769. * Renders the submeshes in a specified order.
  17770. * @param subMeshes The submeshes to sort before render
  17771. * @param sortCompareFn The comparison function use to sort
  17772. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17773. * @param transparent Specifies to activate blending if true
  17774. */
  17775. private static renderSorted;
  17776. /**
  17777. * Renders the submeshes in the order they were dispatched (no sort applied).
  17778. * @param subMeshes The submeshes to render
  17779. */
  17780. private static renderUnsorted;
  17781. /**
  17782. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17783. * are rendered back to front if in the same alpha index.
  17784. *
  17785. * @param a The first submesh
  17786. * @param b The second submesh
  17787. * @returns The result of the comparison
  17788. */
  17789. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  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.
  17793. *
  17794. * @param a The first submesh
  17795. * @param b The second submesh
  17796. * @returns The result of the comparison
  17797. */
  17798. static backToFrontSortCompare(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 front to back (prevent overdraw).
  17802. *
  17803. * @param a The first submesh
  17804. * @param b The second submesh
  17805. * @returns The result of the comparison
  17806. */
  17807. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17808. /**
  17809. * Resets the different lists of submeshes to prepare a new frame.
  17810. */
  17811. prepare(): void;
  17812. dispose(): void;
  17813. /**
  17814. * Inserts the submesh in its correct queue depending on its material.
  17815. * @param subMesh The submesh to dispatch
  17816. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17817. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17818. */
  17819. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17820. dispatchSprites(spriteManager: ISpriteManager): void;
  17821. dispatchParticles(particleSystem: IParticleSystem): void;
  17822. private _renderParticles;
  17823. private _renderSprites;
  17824. }
  17825. }
  17826. declare module "babylonjs/Rendering/renderingManager" {
  17827. import { Nullable } from "babylonjs/types";
  17828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17829. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17830. import { SmartArray } from "babylonjs/Misc/smartArray";
  17831. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17832. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17833. import { Material } from "babylonjs/Materials/material";
  17834. import { Scene } from "babylonjs/scene";
  17835. import { Camera } from "babylonjs/Cameras/camera";
  17836. /**
  17837. * Interface describing the different options available in the rendering manager
  17838. * regarding Auto Clear between groups.
  17839. */
  17840. export interface IRenderingManagerAutoClearSetup {
  17841. /**
  17842. * Defines whether or not autoclear is enable.
  17843. */
  17844. autoClear: boolean;
  17845. /**
  17846. * Defines whether or not to autoclear the depth buffer.
  17847. */
  17848. depth: boolean;
  17849. /**
  17850. * Defines whether or not to autoclear the stencil buffer.
  17851. */
  17852. stencil: boolean;
  17853. }
  17854. /**
  17855. * This class is used by the onRenderingGroupObservable
  17856. */
  17857. export class RenderingGroupInfo {
  17858. /**
  17859. * The Scene that being rendered
  17860. */
  17861. scene: Scene;
  17862. /**
  17863. * The camera currently used for the rendering pass
  17864. */
  17865. camera: Nullable<Camera>;
  17866. /**
  17867. * The ID of the renderingGroup being processed
  17868. */
  17869. renderingGroupId: number;
  17870. }
  17871. /**
  17872. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17873. * It is enable to manage the different groups as well as the different necessary sort functions.
  17874. * This should not be used directly aside of the few static configurations
  17875. */
  17876. export class RenderingManager {
  17877. /**
  17878. * The max id used for rendering groups (not included)
  17879. */
  17880. static MAX_RENDERINGGROUPS: number;
  17881. /**
  17882. * The min id used for rendering groups (included)
  17883. */
  17884. static MIN_RENDERINGGROUPS: number;
  17885. /**
  17886. * Used to globally prevent autoclearing scenes.
  17887. */
  17888. static AUTOCLEAR: boolean;
  17889. /**
  17890. * @hidden
  17891. */
  17892. _useSceneAutoClearSetup: boolean;
  17893. private _scene;
  17894. private _renderingGroups;
  17895. private _depthStencilBufferAlreadyCleaned;
  17896. private _autoClearDepthStencil;
  17897. private _customOpaqueSortCompareFn;
  17898. private _customAlphaTestSortCompareFn;
  17899. private _customTransparentSortCompareFn;
  17900. private _renderingGroupInfo;
  17901. /**
  17902. * Instantiates a new rendering group for a particular scene
  17903. * @param scene Defines the scene the groups belongs to
  17904. */
  17905. constructor(scene: Scene);
  17906. private _clearDepthStencilBuffer;
  17907. /**
  17908. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17909. * @hidden
  17910. */
  17911. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17912. /**
  17913. * Resets the different information of the group to prepare a new frame
  17914. * @hidden
  17915. */
  17916. reset(): void;
  17917. /**
  17918. * Dispose and release the group and its associated resources.
  17919. * @hidden
  17920. */
  17921. dispose(): void;
  17922. /**
  17923. * Clear the info related to rendering groups preventing retention points during dispose.
  17924. */
  17925. freeRenderingGroups(): void;
  17926. private _prepareRenderingGroup;
  17927. /**
  17928. * Add a sprite manager to the rendering manager in order to render it this frame.
  17929. * @param spriteManager Define the sprite manager to render
  17930. */
  17931. dispatchSprites(spriteManager: ISpriteManager): void;
  17932. /**
  17933. * Add a particle system to the rendering manager in order to render it this frame.
  17934. * @param particleSystem Define the particle system to render
  17935. */
  17936. dispatchParticles(particleSystem: IParticleSystem): void;
  17937. /**
  17938. * Add a submesh to the manager in order to render it this frame
  17939. * @param subMesh The submesh to dispatch
  17940. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17941. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17942. */
  17943. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17944. /**
  17945. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17946. * This allowed control for front to back rendering or reversly depending of the special needs.
  17947. *
  17948. * @param renderingGroupId The rendering group id corresponding to its index
  17949. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17950. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17951. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17952. */
  17953. 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;
  17954. /**
  17955. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17956. *
  17957. * @param renderingGroupId The rendering group id corresponding to its index
  17958. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17959. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17960. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17961. */
  17962. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17963. /**
  17964. * Gets the current auto clear configuration for one rendering group of the rendering
  17965. * manager.
  17966. * @param index the rendering group index to get the information for
  17967. * @returns The auto clear setup for the requested rendering group
  17968. */
  17969. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17970. }
  17971. }
  17972. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17973. import { SmartArray } from "babylonjs/Misc/smartArray";
  17974. import { Nullable } from "babylonjs/types";
  17975. import { Scene } from "babylonjs/scene";
  17976. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17979. import { Mesh } from "babylonjs/Meshes/mesh";
  17980. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17981. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17982. import { Effect } from "babylonjs/Materials/effect";
  17983. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17984. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17985. import "babylonjs/Shaders/shadowMap.fragment";
  17986. import "babylonjs/Shaders/shadowMap.vertex";
  17987. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17988. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17989. import { Observable } from "babylonjs/Misc/observable";
  17990. /**
  17991. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17992. */
  17993. export interface ICustomShaderOptions {
  17994. /**
  17995. * Gets or sets the custom shader name to use
  17996. */
  17997. shaderName: string;
  17998. /**
  17999. * The list of attribute names used in the shader
  18000. */
  18001. attributes?: string[];
  18002. /**
  18003. * The list of unifrom names used in the shader
  18004. */
  18005. uniforms?: string[];
  18006. /**
  18007. * The list of sampler names used in the shader
  18008. */
  18009. samplers?: string[];
  18010. /**
  18011. * The list of defines used in the shader
  18012. */
  18013. defines?: string[];
  18014. }
  18015. /**
  18016. * Interface to implement to create a shadow generator compatible with BJS.
  18017. */
  18018. export interface IShadowGenerator {
  18019. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18020. id: string;
  18021. /**
  18022. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18023. * @returns The render target texture if present otherwise, null
  18024. */
  18025. getShadowMap(): Nullable<RenderTargetTexture>;
  18026. /**
  18027. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18028. * @param subMesh The submesh we want to render in the shadow map
  18029. * @param useInstances Defines wether will draw in the map using instances
  18030. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18031. * @returns true if ready otherwise, false
  18032. */
  18033. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18034. /**
  18035. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18036. * @param defines Defines of the material we want to update
  18037. * @param lightIndex Index of the light in the enabled light list of the material
  18038. */
  18039. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18040. /**
  18041. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18042. * defined in the generator but impacting the effect).
  18043. * It implies the unifroms available on the materials are the standard BJS ones.
  18044. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18045. * @param effect The effect we are binfing the information for
  18046. */
  18047. bindShadowLight(lightIndex: string, effect: Effect): void;
  18048. /**
  18049. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18050. * (eq to shadow prjection matrix * light transform matrix)
  18051. * @returns The transform matrix used to create the shadow map
  18052. */
  18053. getTransformMatrix(): Matrix;
  18054. /**
  18055. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18056. * Cube and 2D textures for instance.
  18057. */
  18058. recreateShadowMap(): void;
  18059. /**
  18060. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18061. * @param onCompiled Callback triggered at the and of the effects compilation
  18062. * @param options Sets of optional options forcing the compilation with different modes
  18063. */
  18064. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18065. useInstances: boolean;
  18066. }>): void;
  18067. /**
  18068. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18069. * @param options Sets of optional options forcing the compilation with different modes
  18070. * @returns A promise that resolves when the compilation completes
  18071. */
  18072. forceCompilationAsync(options?: Partial<{
  18073. useInstances: boolean;
  18074. }>): Promise<void>;
  18075. /**
  18076. * Serializes the shadow generator setup to a json object.
  18077. * @returns The serialized JSON object
  18078. */
  18079. serialize(): any;
  18080. /**
  18081. * Disposes the Shadow map and related Textures and effects.
  18082. */
  18083. dispose(): void;
  18084. }
  18085. /**
  18086. * Default implementation IShadowGenerator.
  18087. * This is the main object responsible of generating shadows in the framework.
  18088. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18089. */
  18090. export class ShadowGenerator implements IShadowGenerator {
  18091. /**
  18092. * Name of the shadow generator class
  18093. */
  18094. static CLASSNAME: string;
  18095. /**
  18096. * Shadow generator mode None: no filtering applied.
  18097. */
  18098. static readonly FILTER_NONE: number;
  18099. /**
  18100. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18101. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18102. */
  18103. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18104. /**
  18105. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18106. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18107. */
  18108. static readonly FILTER_POISSONSAMPLING: number;
  18109. /**
  18110. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18111. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18112. */
  18113. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18114. /**
  18115. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18116. * edge artifacts on steep falloff.
  18117. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18118. */
  18119. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18120. /**
  18121. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18122. * edge artifacts on steep falloff.
  18123. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18124. */
  18125. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18126. /**
  18127. * Shadow generator mode PCF: Percentage Closer Filtering
  18128. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18129. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18130. */
  18131. static readonly FILTER_PCF: number;
  18132. /**
  18133. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18134. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18135. * Contact Hardening
  18136. */
  18137. static readonly FILTER_PCSS: number;
  18138. /**
  18139. * Reserved for PCF and PCSS
  18140. * Highest Quality.
  18141. *
  18142. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18143. *
  18144. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18145. */
  18146. static readonly QUALITY_HIGH: number;
  18147. /**
  18148. * Reserved for PCF and PCSS
  18149. * Good tradeoff for quality/perf cross devices
  18150. *
  18151. * Execute PCF on a 3*3 kernel.
  18152. *
  18153. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18154. */
  18155. static readonly QUALITY_MEDIUM: number;
  18156. /**
  18157. * Reserved for PCF and PCSS
  18158. * The lowest quality but the fastest.
  18159. *
  18160. * Execute PCF on a 1*1 kernel.
  18161. *
  18162. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18163. */
  18164. static readonly QUALITY_LOW: number;
  18165. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18166. id: string;
  18167. /** Gets or sets the custom shader name to use */
  18168. customShaderOptions: ICustomShaderOptions;
  18169. /**
  18170. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18171. */
  18172. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18173. /**
  18174. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18175. */
  18176. onAfterShadowMapRenderObservable: Observable<Effect>;
  18177. /**
  18178. * Observable triggered before a mesh is rendered in the shadow map.
  18179. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18180. */
  18181. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18182. /**
  18183. * Observable triggered after a mesh is rendered in the shadow map.
  18184. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18185. */
  18186. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18187. protected _bias: number;
  18188. /**
  18189. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18190. */
  18191. get bias(): number;
  18192. /**
  18193. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18194. */
  18195. set bias(bias: number);
  18196. protected _normalBias: number;
  18197. /**
  18198. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18199. */
  18200. get normalBias(): number;
  18201. /**
  18202. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18203. */
  18204. set normalBias(normalBias: number);
  18205. protected _blurBoxOffset: number;
  18206. /**
  18207. * Gets the blur box offset: offset applied during the blur pass.
  18208. * Only useful if useKernelBlur = false
  18209. */
  18210. get blurBoxOffset(): number;
  18211. /**
  18212. * Sets the blur box offset: offset applied during the blur pass.
  18213. * Only useful if useKernelBlur = false
  18214. */
  18215. set blurBoxOffset(value: number);
  18216. protected _blurScale: number;
  18217. /**
  18218. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18219. * 2 means half of the size.
  18220. */
  18221. get blurScale(): number;
  18222. /**
  18223. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18224. * 2 means half of the size.
  18225. */
  18226. set blurScale(value: number);
  18227. protected _blurKernel: number;
  18228. /**
  18229. * Gets the blur kernel: kernel size of the blur pass.
  18230. * Only useful if useKernelBlur = true
  18231. */
  18232. get blurKernel(): number;
  18233. /**
  18234. * Sets the blur kernel: kernel size of the blur pass.
  18235. * Only useful if useKernelBlur = true
  18236. */
  18237. set blurKernel(value: number);
  18238. protected _useKernelBlur: boolean;
  18239. /**
  18240. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18241. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18242. */
  18243. get useKernelBlur(): boolean;
  18244. /**
  18245. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18246. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18247. */
  18248. set useKernelBlur(value: boolean);
  18249. protected _depthScale: number;
  18250. /**
  18251. * Gets the depth scale used in ESM mode.
  18252. */
  18253. get depthScale(): number;
  18254. /**
  18255. * Sets the depth scale used in ESM mode.
  18256. * This can override the scale stored on the light.
  18257. */
  18258. set depthScale(value: number);
  18259. protected _validateFilter(filter: number): number;
  18260. protected _filter: number;
  18261. /**
  18262. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18263. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18264. */
  18265. get filter(): number;
  18266. /**
  18267. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18268. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18269. */
  18270. set filter(value: number);
  18271. /**
  18272. * Gets if the current filter is set to Poisson Sampling.
  18273. */
  18274. get usePoissonSampling(): boolean;
  18275. /**
  18276. * Sets the current filter to Poisson Sampling.
  18277. */
  18278. set usePoissonSampling(value: boolean);
  18279. /**
  18280. * Gets if the current filter is set to ESM.
  18281. */
  18282. get useExponentialShadowMap(): boolean;
  18283. /**
  18284. * Sets the current filter is to ESM.
  18285. */
  18286. set useExponentialShadowMap(value: boolean);
  18287. /**
  18288. * Gets if the current filter is set to filtered ESM.
  18289. */
  18290. get useBlurExponentialShadowMap(): boolean;
  18291. /**
  18292. * Gets if the current filter is set to filtered ESM.
  18293. */
  18294. set useBlurExponentialShadowMap(value: boolean);
  18295. /**
  18296. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18297. * exponential to prevent steep falloff artifacts).
  18298. */
  18299. get useCloseExponentialShadowMap(): boolean;
  18300. /**
  18301. * Sets the current filter to "close ESM" (using the inverse of the
  18302. * exponential to prevent steep falloff artifacts).
  18303. */
  18304. set useCloseExponentialShadowMap(value: boolean);
  18305. /**
  18306. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18307. * exponential to prevent steep falloff artifacts).
  18308. */
  18309. get useBlurCloseExponentialShadowMap(): boolean;
  18310. /**
  18311. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18312. * exponential to prevent steep falloff artifacts).
  18313. */
  18314. set useBlurCloseExponentialShadowMap(value: boolean);
  18315. /**
  18316. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18317. */
  18318. get usePercentageCloserFiltering(): boolean;
  18319. /**
  18320. * Sets the current filter to "PCF" (percentage closer filtering).
  18321. */
  18322. set usePercentageCloserFiltering(value: boolean);
  18323. protected _filteringQuality: number;
  18324. /**
  18325. * Gets the PCF or PCSS Quality.
  18326. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18327. */
  18328. get filteringQuality(): number;
  18329. /**
  18330. * Sets the PCF or PCSS Quality.
  18331. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18332. */
  18333. set filteringQuality(filteringQuality: number);
  18334. /**
  18335. * Gets if the current filter is set to "PCSS" (contact hardening).
  18336. */
  18337. get useContactHardeningShadow(): boolean;
  18338. /**
  18339. * Sets the current filter to "PCSS" (contact hardening).
  18340. */
  18341. set useContactHardeningShadow(value: boolean);
  18342. protected _contactHardeningLightSizeUVRatio: number;
  18343. /**
  18344. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18345. * Using a ratio helps keeping shape stability independently of the map size.
  18346. *
  18347. * It does not account for the light projection as it was having too much
  18348. * instability during the light setup or during light position changes.
  18349. *
  18350. * Only valid if useContactHardeningShadow is true.
  18351. */
  18352. get contactHardeningLightSizeUVRatio(): number;
  18353. /**
  18354. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18355. * Using a ratio helps keeping shape stability independently of the map size.
  18356. *
  18357. * It does not account for the light projection as it was having too much
  18358. * instability during the light setup or during light position changes.
  18359. *
  18360. * Only valid if useContactHardeningShadow is true.
  18361. */
  18362. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18363. protected _darkness: number;
  18364. /** Gets or sets the actual darkness of a shadow */
  18365. get darkness(): number;
  18366. set darkness(value: number);
  18367. /**
  18368. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18369. * 0 means strongest and 1 would means no shadow.
  18370. * @returns the darkness.
  18371. */
  18372. getDarkness(): number;
  18373. /**
  18374. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18375. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18376. * @returns the shadow generator allowing fluent coding.
  18377. */
  18378. setDarkness(darkness: number): ShadowGenerator;
  18379. protected _transparencyShadow: boolean;
  18380. /** Gets or sets the ability to have transparent shadow */
  18381. get transparencyShadow(): boolean;
  18382. set transparencyShadow(value: boolean);
  18383. /**
  18384. * Sets the ability to have transparent shadow (boolean).
  18385. * @param transparent True if transparent else False
  18386. * @returns the shadow generator allowing fluent coding
  18387. */
  18388. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18389. /**
  18390. * Enables or disables shadows with varying strength based on the transparency
  18391. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18392. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18393. * mesh.visibility * alphaTexture.a
  18394. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18395. */
  18396. enableSoftTransparentShadow: boolean;
  18397. protected _shadowMap: Nullable<RenderTargetTexture>;
  18398. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18399. /**
  18400. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18401. * @returns The render target texture if present otherwise, null
  18402. */
  18403. getShadowMap(): Nullable<RenderTargetTexture>;
  18404. /**
  18405. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18406. * @returns The render target texture if the shadow map is present otherwise, null
  18407. */
  18408. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18409. /**
  18410. * Gets the class name of that object
  18411. * @returns "ShadowGenerator"
  18412. */
  18413. getClassName(): string;
  18414. /**
  18415. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18416. * @param mesh Mesh to add
  18417. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18418. * @returns the Shadow Generator itself
  18419. */
  18420. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18421. /**
  18422. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18423. * @param mesh Mesh to remove
  18424. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18425. * @returns the Shadow Generator itself
  18426. */
  18427. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18428. /**
  18429. * Controls the extent to which the shadows fade out at the edge of the frustum
  18430. */
  18431. frustumEdgeFalloff: number;
  18432. protected _light: IShadowLight;
  18433. /**
  18434. * Returns the associated light object.
  18435. * @returns the light generating the shadow
  18436. */
  18437. getLight(): IShadowLight;
  18438. /**
  18439. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18440. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18441. * It might on the other hand introduce peter panning.
  18442. */
  18443. forceBackFacesOnly: boolean;
  18444. protected _scene: Scene;
  18445. protected _lightDirection: Vector3;
  18446. protected _effect: Effect;
  18447. protected _viewMatrix: Matrix;
  18448. protected _projectionMatrix: Matrix;
  18449. protected _transformMatrix: Matrix;
  18450. protected _cachedPosition: Vector3;
  18451. protected _cachedDirection: Vector3;
  18452. protected _cachedDefines: string;
  18453. protected _currentRenderID: number;
  18454. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18455. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18456. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18457. protected _blurPostProcesses: PostProcess[];
  18458. protected _mapSize: number;
  18459. protected _currentFaceIndex: number;
  18460. protected _currentFaceIndexCache: number;
  18461. protected _textureType: number;
  18462. protected _defaultTextureMatrix: Matrix;
  18463. protected _storedUniqueId: Nullable<number>;
  18464. /** @hidden */
  18465. static _SceneComponentInitialization: (scene: Scene) => void;
  18466. /**
  18467. * Creates a ShadowGenerator object.
  18468. * A ShadowGenerator is the required tool to use the shadows.
  18469. * Each light casting shadows needs to use its own ShadowGenerator.
  18470. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18471. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18472. * @param light The light object generating the shadows.
  18473. * @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.
  18474. */
  18475. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18476. protected _initializeGenerator(): void;
  18477. protected _createTargetRenderTexture(): void;
  18478. protected _initializeShadowMap(): void;
  18479. protected _initializeBlurRTTAndPostProcesses(): void;
  18480. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18481. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18482. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18483. protected _applyFilterValues(): void;
  18484. /**
  18485. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18486. * @param onCompiled Callback triggered at the and of the effects compilation
  18487. * @param options Sets of optional options forcing the compilation with different modes
  18488. */
  18489. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18490. useInstances: boolean;
  18491. }>): void;
  18492. /**
  18493. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18494. * @param options Sets of optional options forcing the compilation with different modes
  18495. * @returns A promise that resolves when the compilation completes
  18496. */
  18497. forceCompilationAsync(options?: Partial<{
  18498. useInstances: boolean;
  18499. }>): Promise<void>;
  18500. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18501. private _prepareShadowDefines;
  18502. /**
  18503. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18504. * @param subMesh The submesh we want to render in the shadow map
  18505. * @param useInstances Defines wether will draw in the map using instances
  18506. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18507. * @returns true if ready otherwise, false
  18508. */
  18509. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18510. /**
  18511. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18512. * @param defines Defines of the material we want to update
  18513. * @param lightIndex Index of the light in the enabled light list of the material
  18514. */
  18515. prepareDefines(defines: any, lightIndex: number): void;
  18516. /**
  18517. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18518. * defined in the generator but impacting the effect).
  18519. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18520. * @param effect The effect we are binfing the information for
  18521. */
  18522. bindShadowLight(lightIndex: string, effect: Effect): void;
  18523. /**
  18524. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18525. * (eq to shadow prjection matrix * light transform matrix)
  18526. * @returns The transform matrix used to create the shadow map
  18527. */
  18528. getTransformMatrix(): Matrix;
  18529. /**
  18530. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18531. * Cube and 2D textures for instance.
  18532. */
  18533. recreateShadowMap(): void;
  18534. protected _disposeBlurPostProcesses(): void;
  18535. protected _disposeRTTandPostProcesses(): void;
  18536. /**
  18537. * Disposes the ShadowGenerator.
  18538. * Returns nothing.
  18539. */
  18540. dispose(): void;
  18541. /**
  18542. * Serializes the shadow generator setup to a json object.
  18543. * @returns The serialized JSON object
  18544. */
  18545. serialize(): any;
  18546. /**
  18547. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18548. * @param parsedShadowGenerator The JSON object to parse
  18549. * @param scene The scene to create the shadow map for
  18550. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18551. * @returns The parsed shadow generator
  18552. */
  18553. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18554. }
  18555. }
  18556. declare module "babylonjs/Lights/light" {
  18557. import { Nullable } from "babylonjs/types";
  18558. import { Scene } from "babylonjs/scene";
  18559. import { Vector3 } from "babylonjs/Maths/math.vector";
  18560. import { Color3 } from "babylonjs/Maths/math.color";
  18561. import { Node } from "babylonjs/node";
  18562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18563. import { Effect } from "babylonjs/Materials/effect";
  18564. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18565. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18566. /**
  18567. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18568. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18569. * 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.
  18570. */
  18571. export abstract class Light extends Node {
  18572. /**
  18573. * Falloff Default: light is falling off following the material specification:
  18574. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18575. */
  18576. static readonly FALLOFF_DEFAULT: number;
  18577. /**
  18578. * Falloff Physical: light is falling off following the inverse squared distance law.
  18579. */
  18580. static readonly FALLOFF_PHYSICAL: number;
  18581. /**
  18582. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18583. * to enhance interoperability with other engines.
  18584. */
  18585. static readonly FALLOFF_GLTF: number;
  18586. /**
  18587. * Falloff Standard: light is falling off like in the standard material
  18588. * to enhance interoperability with other materials.
  18589. */
  18590. static readonly FALLOFF_STANDARD: number;
  18591. /**
  18592. * If every light affecting the material is in this lightmapMode,
  18593. * material.lightmapTexture adds or multiplies
  18594. * (depends on material.useLightmapAsShadowmap)
  18595. * after every other light calculations.
  18596. */
  18597. static readonly LIGHTMAP_DEFAULT: number;
  18598. /**
  18599. * material.lightmapTexture as only diffuse lighting from this light
  18600. * adds only specular lighting from this light
  18601. * adds dynamic shadows
  18602. */
  18603. static readonly LIGHTMAP_SPECULAR: number;
  18604. /**
  18605. * material.lightmapTexture as only lighting
  18606. * no light calculation from this light
  18607. * only adds dynamic shadows from this light
  18608. */
  18609. static readonly LIGHTMAP_SHADOWSONLY: number;
  18610. /**
  18611. * Each light type uses the default quantity according to its type:
  18612. * point/spot lights use luminous intensity
  18613. * directional lights use illuminance
  18614. */
  18615. static readonly INTENSITYMODE_AUTOMATIC: number;
  18616. /**
  18617. * lumen (lm)
  18618. */
  18619. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18620. /**
  18621. * candela (lm/sr)
  18622. */
  18623. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18624. /**
  18625. * lux (lm/m^2)
  18626. */
  18627. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18628. /**
  18629. * nit (cd/m^2)
  18630. */
  18631. static readonly INTENSITYMODE_LUMINANCE: number;
  18632. /**
  18633. * Light type const id of the point light.
  18634. */
  18635. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18636. /**
  18637. * Light type const id of the directional light.
  18638. */
  18639. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18640. /**
  18641. * Light type const id of the spot light.
  18642. */
  18643. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18644. /**
  18645. * Light type const id of the hemispheric light.
  18646. */
  18647. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18648. /**
  18649. * Diffuse gives the basic color to an object.
  18650. */
  18651. diffuse: Color3;
  18652. /**
  18653. * Specular produces a highlight color on an object.
  18654. * Note: This is note affecting PBR materials.
  18655. */
  18656. specular: Color3;
  18657. /**
  18658. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18659. * falling off base on range or angle.
  18660. * This can be set to any values in Light.FALLOFF_x.
  18661. *
  18662. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18663. * other types of materials.
  18664. */
  18665. falloffType: number;
  18666. /**
  18667. * Strength of the light.
  18668. * Note: By default it is define in the framework own unit.
  18669. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18670. */
  18671. intensity: number;
  18672. private _range;
  18673. protected _inverseSquaredRange: number;
  18674. /**
  18675. * Defines how far from the source the light is impacting in scene units.
  18676. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18677. */
  18678. get range(): number;
  18679. /**
  18680. * Defines how far from the source the light is impacting in scene units.
  18681. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18682. */
  18683. set range(value: number);
  18684. /**
  18685. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18686. * of light.
  18687. */
  18688. private _photometricScale;
  18689. private _intensityMode;
  18690. /**
  18691. * Gets the photometric scale used to interpret the intensity.
  18692. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18693. */
  18694. get intensityMode(): number;
  18695. /**
  18696. * Sets the photometric scale used to interpret the intensity.
  18697. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18698. */
  18699. set intensityMode(value: number);
  18700. private _radius;
  18701. /**
  18702. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18703. */
  18704. get radius(): number;
  18705. /**
  18706. * sets the light radius used by PBR Materials to simulate soft area lights.
  18707. */
  18708. set radius(value: number);
  18709. private _renderPriority;
  18710. /**
  18711. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18712. * exceeding the number allowed of the materials.
  18713. */
  18714. renderPriority: number;
  18715. private _shadowEnabled;
  18716. /**
  18717. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18718. * the current shadow generator.
  18719. */
  18720. get shadowEnabled(): boolean;
  18721. /**
  18722. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18723. * the current shadow generator.
  18724. */
  18725. set shadowEnabled(value: boolean);
  18726. private _includedOnlyMeshes;
  18727. /**
  18728. * Gets the only meshes impacted by this light.
  18729. */
  18730. get includedOnlyMeshes(): AbstractMesh[];
  18731. /**
  18732. * Sets the only meshes impacted by this light.
  18733. */
  18734. set includedOnlyMeshes(value: AbstractMesh[]);
  18735. private _excludedMeshes;
  18736. /**
  18737. * Gets the meshes not impacted by this light.
  18738. */
  18739. get excludedMeshes(): AbstractMesh[];
  18740. /**
  18741. * Sets the meshes not impacted by this light.
  18742. */
  18743. set excludedMeshes(value: AbstractMesh[]);
  18744. private _excludeWithLayerMask;
  18745. /**
  18746. * Gets the layer id use to find what meshes are not impacted by the light.
  18747. * Inactive if 0
  18748. */
  18749. get excludeWithLayerMask(): number;
  18750. /**
  18751. * Sets the layer id use to find what meshes are not impacted by the light.
  18752. * Inactive if 0
  18753. */
  18754. set excludeWithLayerMask(value: number);
  18755. private _includeOnlyWithLayerMask;
  18756. /**
  18757. * Gets the layer id use to find what meshes are impacted by the light.
  18758. * Inactive if 0
  18759. */
  18760. get includeOnlyWithLayerMask(): number;
  18761. /**
  18762. * Sets the layer id use to find what meshes are impacted by the light.
  18763. * Inactive if 0
  18764. */
  18765. set includeOnlyWithLayerMask(value: number);
  18766. private _lightmapMode;
  18767. /**
  18768. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18769. */
  18770. get lightmapMode(): number;
  18771. /**
  18772. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18773. */
  18774. set lightmapMode(value: number);
  18775. /**
  18776. * Shadow generator associted to the light.
  18777. * @hidden Internal use only.
  18778. */
  18779. _shadowGenerator: Nullable<IShadowGenerator>;
  18780. /**
  18781. * @hidden Internal use only.
  18782. */
  18783. _excludedMeshesIds: string[];
  18784. /**
  18785. * @hidden Internal use only.
  18786. */
  18787. _includedOnlyMeshesIds: string[];
  18788. /**
  18789. * The current light unifom buffer.
  18790. * @hidden Internal use only.
  18791. */
  18792. _uniformBuffer: UniformBuffer;
  18793. /** @hidden */
  18794. _renderId: number;
  18795. /**
  18796. * Creates a Light object in the scene.
  18797. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18798. * @param name The firendly name of the light
  18799. * @param scene The scene the light belongs too
  18800. */
  18801. constructor(name: string, scene: Scene);
  18802. protected abstract _buildUniformLayout(): void;
  18803. /**
  18804. * Sets the passed Effect "effect" with the Light information.
  18805. * @param effect The effect to update
  18806. * @param lightIndex The index of the light in the effect to update
  18807. * @returns The light
  18808. */
  18809. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18810. /**
  18811. * Sets the passed Effect "effect" with the Light textures.
  18812. * @param effect The effect to update
  18813. * @param lightIndex The index of the light in the effect to update
  18814. * @returns The light
  18815. */
  18816. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18817. /**
  18818. * Binds the lights information from the scene to the effect for the given mesh.
  18819. * @param lightIndex Light index
  18820. * @param scene The scene where the light belongs to
  18821. * @param effect The effect we are binding the data to
  18822. * @param useSpecular Defines if specular is supported
  18823. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18824. */
  18825. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18826. /**
  18827. * Sets the passed Effect "effect" with the Light information.
  18828. * @param effect The effect to update
  18829. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18830. * @returns The light
  18831. */
  18832. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18833. /**
  18834. * Returns the string "Light".
  18835. * @returns the class name
  18836. */
  18837. getClassName(): string;
  18838. /** @hidden */
  18839. readonly _isLight: boolean;
  18840. /**
  18841. * Converts the light information to a readable string for debug purpose.
  18842. * @param fullDetails Supports for multiple levels of logging within scene loading
  18843. * @returns the human readable light info
  18844. */
  18845. toString(fullDetails?: boolean): string;
  18846. /** @hidden */
  18847. protected _syncParentEnabledState(): void;
  18848. /**
  18849. * Set the enabled state of this node.
  18850. * @param value - the new enabled state
  18851. */
  18852. setEnabled(value: boolean): void;
  18853. /**
  18854. * Returns the Light associated shadow generator if any.
  18855. * @return the associated shadow generator.
  18856. */
  18857. getShadowGenerator(): Nullable<IShadowGenerator>;
  18858. /**
  18859. * Returns a Vector3, the absolute light position in the World.
  18860. * @returns the world space position of the light
  18861. */
  18862. getAbsolutePosition(): Vector3;
  18863. /**
  18864. * Specifies if the light will affect the passed mesh.
  18865. * @param mesh The mesh to test against the light
  18866. * @return true the mesh is affected otherwise, false.
  18867. */
  18868. canAffectMesh(mesh: AbstractMesh): boolean;
  18869. /**
  18870. * Sort function to order lights for rendering.
  18871. * @param a First Light object to compare to second.
  18872. * @param b Second Light object to compare first.
  18873. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18874. */
  18875. static CompareLightsPriority(a: Light, b: Light): number;
  18876. /**
  18877. * Releases resources associated with this node.
  18878. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18879. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18880. */
  18881. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18882. /**
  18883. * Returns the light type ID (integer).
  18884. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18885. */
  18886. getTypeID(): number;
  18887. /**
  18888. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18889. * @returns the scaled intensity in intensity mode unit
  18890. */
  18891. getScaledIntensity(): number;
  18892. /**
  18893. * Returns a new Light object, named "name", from the current one.
  18894. * @param name The name of the cloned light
  18895. * @param newParent The parent of this light, if it has one
  18896. * @returns the new created light
  18897. */
  18898. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18899. /**
  18900. * Serializes the current light into a Serialization object.
  18901. * @returns the serialized object.
  18902. */
  18903. serialize(): any;
  18904. /**
  18905. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18906. * This new light is named "name" and added to the passed scene.
  18907. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18908. * @param name The friendly name of the light
  18909. * @param scene The scene the new light will belong to
  18910. * @returns the constructor function
  18911. */
  18912. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18913. /**
  18914. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18915. * @param parsedLight The JSON representation of the light
  18916. * @param scene The scene to create the parsed light in
  18917. * @returns the created light after parsing
  18918. */
  18919. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18920. private _hookArrayForExcluded;
  18921. private _hookArrayForIncludedOnly;
  18922. private _resyncMeshes;
  18923. /**
  18924. * Forces the meshes to update their light related information in their rendering used effects
  18925. * @hidden Internal Use Only
  18926. */
  18927. _markMeshesAsLightDirty(): void;
  18928. /**
  18929. * Recomputes the cached photometric scale if needed.
  18930. */
  18931. private _computePhotometricScale;
  18932. /**
  18933. * Returns the Photometric Scale according to the light type and intensity mode.
  18934. */
  18935. private _getPhotometricScale;
  18936. /**
  18937. * Reorder the light in the scene according to their defined priority.
  18938. * @hidden Internal Use Only
  18939. */
  18940. _reorderLightsInScene(): void;
  18941. /**
  18942. * Prepares the list of defines specific to the light type.
  18943. * @param defines the list of defines
  18944. * @param lightIndex defines the index of the light for the effect
  18945. */
  18946. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18947. }
  18948. }
  18949. declare module "babylonjs/Cameras/targetCamera" {
  18950. import { Nullable } from "babylonjs/types";
  18951. import { Camera } from "babylonjs/Cameras/camera";
  18952. import { Scene } from "babylonjs/scene";
  18953. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18954. /**
  18955. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18956. * This is the base of the follow, arc rotate cameras and Free camera
  18957. * @see https://doc.babylonjs.com/features/cameras
  18958. */
  18959. export class TargetCamera extends Camera {
  18960. private static _RigCamTransformMatrix;
  18961. private static _TargetTransformMatrix;
  18962. private static _TargetFocalPoint;
  18963. private _tmpUpVector;
  18964. private _tmpTargetVector;
  18965. /**
  18966. * Define the current direction the camera is moving to
  18967. */
  18968. cameraDirection: Vector3;
  18969. /**
  18970. * Define the current rotation the camera is rotating to
  18971. */
  18972. cameraRotation: Vector2;
  18973. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18974. ignoreParentScaling: boolean;
  18975. /**
  18976. * When set, the up vector of the camera will be updated by the rotation of the camera
  18977. */
  18978. updateUpVectorFromRotation: boolean;
  18979. private _tmpQuaternion;
  18980. /**
  18981. * Define the current rotation of the camera
  18982. */
  18983. rotation: Vector3;
  18984. /**
  18985. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18986. */
  18987. rotationQuaternion: Quaternion;
  18988. /**
  18989. * Define the current speed of the camera
  18990. */
  18991. speed: number;
  18992. /**
  18993. * Add constraint to the camera to prevent it to move freely in all directions and
  18994. * around all axis.
  18995. */
  18996. noRotationConstraint: boolean;
  18997. /**
  18998. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18999. * panning
  19000. */
  19001. invertRotation: boolean;
  19002. /**
  19003. * Speed multiplier for inverse camera panning
  19004. */
  19005. inverseRotationSpeed: number;
  19006. /**
  19007. * Define the current target of the camera as an object or a position.
  19008. */
  19009. lockedTarget: any;
  19010. /** @hidden */
  19011. _currentTarget: Vector3;
  19012. /** @hidden */
  19013. _initialFocalDistance: number;
  19014. /** @hidden */
  19015. _viewMatrix: Matrix;
  19016. /** @hidden */
  19017. _camMatrix: Matrix;
  19018. /** @hidden */
  19019. _cameraTransformMatrix: Matrix;
  19020. /** @hidden */
  19021. _cameraRotationMatrix: Matrix;
  19022. /** @hidden */
  19023. _referencePoint: Vector3;
  19024. /** @hidden */
  19025. _transformedReferencePoint: Vector3;
  19026. /** @hidden */
  19027. _reset: () => void;
  19028. private _defaultUp;
  19029. /**
  19030. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19031. * This is the base of the follow, arc rotate cameras and Free camera
  19032. * @see https://doc.babylonjs.com/features/cameras
  19033. * @param name Defines the name of the camera in the scene
  19034. * @param position Defines the start position of the camera in the scene
  19035. * @param scene Defines the scene the camera belongs to
  19036. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19037. */
  19038. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19039. /**
  19040. * Gets the position in front of the camera at a given distance.
  19041. * @param distance The distance from the camera we want the position to be
  19042. * @returns the position
  19043. */
  19044. getFrontPosition(distance: number): Vector3;
  19045. /** @hidden */
  19046. _getLockedTargetPosition(): Nullable<Vector3>;
  19047. private _storedPosition;
  19048. private _storedRotation;
  19049. private _storedRotationQuaternion;
  19050. /**
  19051. * Store current camera state of the camera (fov, position, rotation, etc..)
  19052. * @returns the camera
  19053. */
  19054. storeState(): Camera;
  19055. /**
  19056. * Restored camera state. You must call storeState() first
  19057. * @returns whether it was successful or not
  19058. * @hidden
  19059. */
  19060. _restoreStateValues(): boolean;
  19061. /** @hidden */
  19062. _initCache(): void;
  19063. /** @hidden */
  19064. _updateCache(ignoreParentClass?: boolean): void;
  19065. /** @hidden */
  19066. _isSynchronizedViewMatrix(): boolean;
  19067. /** @hidden */
  19068. _computeLocalCameraSpeed(): number;
  19069. /**
  19070. * Defines the target the camera should look at.
  19071. * @param target Defines the new target as a Vector or a mesh
  19072. */
  19073. setTarget(target: Vector3): void;
  19074. /**
  19075. * Defines the target point of the camera.
  19076. * The camera looks towards it form the radius distance.
  19077. */
  19078. get target(): Vector3;
  19079. set target(value: Vector3);
  19080. /**
  19081. * Return the current target position of the camera. This value is expressed in local space.
  19082. * @returns the target position
  19083. */
  19084. getTarget(): Vector3;
  19085. /** @hidden */
  19086. _decideIfNeedsToMove(): boolean;
  19087. /** @hidden */
  19088. _updatePosition(): void;
  19089. /** @hidden */
  19090. _checkInputs(): void;
  19091. protected _updateCameraRotationMatrix(): void;
  19092. /**
  19093. * 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)
  19094. * @returns the current camera
  19095. */
  19096. private _rotateUpVectorWithCameraRotationMatrix;
  19097. private _cachedRotationZ;
  19098. private _cachedQuaternionRotationZ;
  19099. /** @hidden */
  19100. _getViewMatrix(): Matrix;
  19101. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19102. /**
  19103. * @hidden
  19104. */
  19105. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19106. /**
  19107. * @hidden
  19108. */
  19109. _updateRigCameras(): void;
  19110. private _getRigCamPositionAndTarget;
  19111. /**
  19112. * Gets the current object class name.
  19113. * @return the class name
  19114. */
  19115. getClassName(): string;
  19116. }
  19117. }
  19118. declare module "babylonjs/Events/keyboardEvents" {
  19119. /**
  19120. * Gather the list of keyboard event types as constants.
  19121. */
  19122. export class KeyboardEventTypes {
  19123. /**
  19124. * The keydown event is fired when a key becomes active (pressed).
  19125. */
  19126. static readonly KEYDOWN: number;
  19127. /**
  19128. * The keyup event is fired when a key has been released.
  19129. */
  19130. static readonly KEYUP: number;
  19131. }
  19132. /**
  19133. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19134. */
  19135. export class KeyboardInfo {
  19136. /**
  19137. * Defines the type of event (KeyboardEventTypes)
  19138. */
  19139. type: number;
  19140. /**
  19141. * Defines the related dom event
  19142. */
  19143. event: KeyboardEvent;
  19144. /**
  19145. * Instantiates a new keyboard info.
  19146. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19147. * @param type Defines the type of event (KeyboardEventTypes)
  19148. * @param event Defines the related dom event
  19149. */
  19150. constructor(
  19151. /**
  19152. * Defines the type of event (KeyboardEventTypes)
  19153. */
  19154. type: number,
  19155. /**
  19156. * Defines the related dom event
  19157. */
  19158. event: KeyboardEvent);
  19159. }
  19160. /**
  19161. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19162. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19163. */
  19164. export class KeyboardInfoPre extends KeyboardInfo {
  19165. /**
  19166. * Defines the type of event (KeyboardEventTypes)
  19167. */
  19168. type: number;
  19169. /**
  19170. * Defines the related dom event
  19171. */
  19172. event: KeyboardEvent;
  19173. /**
  19174. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19175. */
  19176. skipOnPointerObservable: boolean;
  19177. /**
  19178. * Instantiates a new keyboard pre info.
  19179. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19180. * @param type Defines the type of event (KeyboardEventTypes)
  19181. * @param event Defines the related dom event
  19182. */
  19183. constructor(
  19184. /**
  19185. * Defines the type of event (KeyboardEventTypes)
  19186. */
  19187. type: number,
  19188. /**
  19189. * Defines the related dom event
  19190. */
  19191. event: KeyboardEvent);
  19192. }
  19193. }
  19194. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19195. import { Nullable } from "babylonjs/types";
  19196. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19197. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19198. /**
  19199. * Manage the keyboard inputs to control the movement of a free camera.
  19200. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19201. */
  19202. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19203. /**
  19204. * Defines the camera the input is attached to.
  19205. */
  19206. camera: FreeCamera;
  19207. /**
  19208. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19209. */
  19210. keysUp: number[];
  19211. /**
  19212. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19213. */
  19214. keysUpward: number[];
  19215. /**
  19216. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19217. */
  19218. keysDown: number[];
  19219. /**
  19220. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19221. */
  19222. keysDownward: number[];
  19223. /**
  19224. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19225. */
  19226. keysLeft: number[];
  19227. /**
  19228. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19229. */
  19230. keysRight: number[];
  19231. private _keys;
  19232. private _onCanvasBlurObserver;
  19233. private _onKeyboardObserver;
  19234. private _engine;
  19235. private _scene;
  19236. /**
  19237. * Attach the input controls to a specific dom element to get the input from.
  19238. * @param element Defines the element the controls should be listened from
  19239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19240. */
  19241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19242. /**
  19243. * Detach the current controls from the specified dom element.
  19244. * @param element Defines the element to stop listening the inputs from
  19245. */
  19246. detachControl(element: Nullable<HTMLElement>): void;
  19247. /**
  19248. * Update the current camera state depending on the inputs that have been used this frame.
  19249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19250. */
  19251. checkInputs(): void;
  19252. /**
  19253. * Gets the class name of the current intput.
  19254. * @returns the class name
  19255. */
  19256. getClassName(): string;
  19257. /** @hidden */
  19258. _onLostFocus(): void;
  19259. /**
  19260. * Get the friendly name associated with the input class.
  19261. * @returns the input friendly name
  19262. */
  19263. getSimpleName(): string;
  19264. }
  19265. }
  19266. declare module "babylonjs/Events/pointerEvents" {
  19267. import { Nullable } from "babylonjs/types";
  19268. import { Vector2 } from "babylonjs/Maths/math.vector";
  19269. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19270. import { Ray } from "babylonjs/Culling/ray";
  19271. /**
  19272. * Gather the list of pointer event types as constants.
  19273. */
  19274. export class PointerEventTypes {
  19275. /**
  19276. * 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.
  19277. */
  19278. static readonly POINTERDOWN: number;
  19279. /**
  19280. * The pointerup event is fired when a pointer is no longer active.
  19281. */
  19282. static readonly POINTERUP: number;
  19283. /**
  19284. * The pointermove event is fired when a pointer changes coordinates.
  19285. */
  19286. static readonly POINTERMOVE: number;
  19287. /**
  19288. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19289. */
  19290. static readonly POINTERWHEEL: number;
  19291. /**
  19292. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19293. */
  19294. static readonly POINTERPICK: number;
  19295. /**
  19296. * The pointertap event is fired when a the object has been touched and released without drag.
  19297. */
  19298. static readonly POINTERTAP: number;
  19299. /**
  19300. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19301. */
  19302. static readonly POINTERDOUBLETAP: number;
  19303. }
  19304. /**
  19305. * Base class of pointer info types.
  19306. */
  19307. export class PointerInfoBase {
  19308. /**
  19309. * Defines the type of event (PointerEventTypes)
  19310. */
  19311. type: number;
  19312. /**
  19313. * Defines the related dom event
  19314. */
  19315. event: PointerEvent | MouseWheelEvent;
  19316. /**
  19317. * Instantiates the base class of pointers info.
  19318. * @param type Defines the type of event (PointerEventTypes)
  19319. * @param event Defines the related dom event
  19320. */
  19321. constructor(
  19322. /**
  19323. * Defines the type of event (PointerEventTypes)
  19324. */
  19325. type: number,
  19326. /**
  19327. * Defines the related dom event
  19328. */
  19329. event: PointerEvent | MouseWheelEvent);
  19330. }
  19331. /**
  19332. * This class is used to store pointer related info for the onPrePointerObservable event.
  19333. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19334. */
  19335. export class PointerInfoPre extends PointerInfoBase {
  19336. /**
  19337. * Ray from a pointer if availible (eg. 6dof controller)
  19338. */
  19339. ray: Nullable<Ray>;
  19340. /**
  19341. * Defines the local position of the pointer on the canvas.
  19342. */
  19343. localPosition: Vector2;
  19344. /**
  19345. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19346. */
  19347. skipOnPointerObservable: boolean;
  19348. /**
  19349. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19350. * @param type Defines the type of event (PointerEventTypes)
  19351. * @param event Defines the related dom event
  19352. * @param localX Defines the local x coordinates of the pointer when the event occured
  19353. * @param localY Defines the local y coordinates of the pointer when the event occured
  19354. */
  19355. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19356. }
  19357. /**
  19358. * This type contains all the data related to a pointer event in Babylon.js.
  19359. * 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.
  19360. */
  19361. export class PointerInfo extends PointerInfoBase {
  19362. /**
  19363. * Defines the picking info associated to the info (if any)\
  19364. */
  19365. pickInfo: Nullable<PickingInfo>;
  19366. /**
  19367. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19368. * @param type Defines the type of event (PointerEventTypes)
  19369. * @param event Defines the related dom event
  19370. * @param pickInfo Defines the picking info associated to the info (if any)\
  19371. */
  19372. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19373. /**
  19374. * Defines the picking info associated to the info (if any)\
  19375. */
  19376. pickInfo: Nullable<PickingInfo>);
  19377. }
  19378. /**
  19379. * Data relating to a touch event on the screen.
  19380. */
  19381. export interface PointerTouch {
  19382. /**
  19383. * X coordinate of touch.
  19384. */
  19385. x: number;
  19386. /**
  19387. * Y coordinate of touch.
  19388. */
  19389. y: number;
  19390. /**
  19391. * Id of touch. Unique for each finger.
  19392. */
  19393. pointerId: number;
  19394. /**
  19395. * Event type passed from DOM.
  19396. */
  19397. type: any;
  19398. }
  19399. }
  19400. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19401. import { Observable } from "babylonjs/Misc/observable";
  19402. import { Nullable } from "babylonjs/types";
  19403. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19404. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19405. /**
  19406. * Manage the mouse inputs to control the movement of a free camera.
  19407. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19408. */
  19409. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19410. /**
  19411. * Define if touch is enabled in the mouse input
  19412. */
  19413. touchEnabled: boolean;
  19414. /**
  19415. * Defines the camera the input is attached to.
  19416. */
  19417. camera: FreeCamera;
  19418. /**
  19419. * Defines the buttons associated with the input to handle camera move.
  19420. */
  19421. buttons: number[];
  19422. /**
  19423. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19424. */
  19425. angularSensibility: number;
  19426. private _pointerInput;
  19427. private _onMouseMove;
  19428. private _observer;
  19429. private previousPosition;
  19430. /**
  19431. * Observable for when a pointer move event occurs containing the move offset
  19432. */
  19433. onPointerMovedObservable: Observable<{
  19434. offsetX: number;
  19435. offsetY: number;
  19436. }>;
  19437. /**
  19438. * @hidden
  19439. * If the camera should be rotated automatically based on pointer movement
  19440. */
  19441. _allowCameraRotation: boolean;
  19442. /**
  19443. * Manage the mouse inputs to control the movement of a free camera.
  19444. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19445. * @param touchEnabled Defines if touch is enabled or not
  19446. */
  19447. constructor(
  19448. /**
  19449. * Define if touch is enabled in the mouse input
  19450. */
  19451. touchEnabled?: boolean);
  19452. /**
  19453. * Attach the input controls to a specific dom element to get the input from.
  19454. * @param element Defines the element the controls should be listened from
  19455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19456. */
  19457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19458. /**
  19459. * Called on JS contextmenu event.
  19460. * Override this method to provide functionality.
  19461. */
  19462. protected onContextMenu(evt: PointerEvent): void;
  19463. /**
  19464. * Detach the current controls from the specified dom element.
  19465. * @param element Defines the element to stop listening the inputs from
  19466. */
  19467. detachControl(element: Nullable<HTMLElement>): void;
  19468. /**
  19469. * Gets the class name of the current intput.
  19470. * @returns the class name
  19471. */
  19472. getClassName(): string;
  19473. /**
  19474. * Get the friendly name associated with the input class.
  19475. * @returns the input friendly name
  19476. */
  19477. getSimpleName(): string;
  19478. }
  19479. }
  19480. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19481. import { Nullable } from "babylonjs/types";
  19482. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19483. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19484. /**
  19485. * Manage the touch inputs to control the movement of a free camera.
  19486. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19487. */
  19488. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19489. /**
  19490. * Define if mouse events can be treated as touch events
  19491. */
  19492. allowMouse: boolean;
  19493. /**
  19494. * Defines the camera the input is attached to.
  19495. */
  19496. camera: FreeCamera;
  19497. /**
  19498. * Defines the touch sensibility for rotation.
  19499. * The higher the faster.
  19500. */
  19501. touchAngularSensibility: number;
  19502. /**
  19503. * Defines the touch sensibility for move.
  19504. * The higher the faster.
  19505. */
  19506. touchMoveSensibility: number;
  19507. private _offsetX;
  19508. private _offsetY;
  19509. private _pointerPressed;
  19510. private _pointerInput;
  19511. private _observer;
  19512. private _onLostFocus;
  19513. /**
  19514. * Manage the touch inputs to control the movement of a free camera.
  19515. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19516. * @param allowMouse Defines if mouse events can be treated as touch events
  19517. */
  19518. constructor(
  19519. /**
  19520. * Define if mouse events can be treated as touch events
  19521. */
  19522. allowMouse?: boolean);
  19523. /**
  19524. * Attach the input controls to a specific dom element to get the input from.
  19525. * @param element Defines the element the controls should be listened from
  19526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19527. */
  19528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19529. /**
  19530. * Detach the current controls from the specified dom element.
  19531. * @param element Defines the element to stop listening the inputs from
  19532. */
  19533. detachControl(element: Nullable<HTMLElement>): void;
  19534. /**
  19535. * Update the current camera state depending on the inputs that have been used this frame.
  19536. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19537. */
  19538. checkInputs(): void;
  19539. /**
  19540. * Gets the class name of the current intput.
  19541. * @returns the class name
  19542. */
  19543. getClassName(): string;
  19544. /**
  19545. * Get the friendly name associated with the input class.
  19546. * @returns the input friendly name
  19547. */
  19548. getSimpleName(): string;
  19549. }
  19550. }
  19551. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19552. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19553. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19554. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19555. import { Nullable } from "babylonjs/types";
  19556. /**
  19557. * Default Inputs manager for the FreeCamera.
  19558. * It groups all the default supported inputs for ease of use.
  19559. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19560. */
  19561. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19562. /**
  19563. * @hidden
  19564. */
  19565. _mouseInput: Nullable<FreeCameraMouseInput>;
  19566. /**
  19567. * Instantiates a new FreeCameraInputsManager.
  19568. * @param camera Defines the camera the inputs belong to
  19569. */
  19570. constructor(camera: FreeCamera);
  19571. /**
  19572. * Add keyboard input support to the input manager.
  19573. * @returns the current input manager
  19574. */
  19575. addKeyboard(): FreeCameraInputsManager;
  19576. /**
  19577. * Add mouse input support to the input manager.
  19578. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19579. * @returns the current input manager
  19580. */
  19581. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19582. /**
  19583. * Removes the mouse input support from the manager
  19584. * @returns the current input manager
  19585. */
  19586. removeMouse(): FreeCameraInputsManager;
  19587. /**
  19588. * Add touch input support to the input manager.
  19589. * @returns the current input manager
  19590. */
  19591. addTouch(): FreeCameraInputsManager;
  19592. /**
  19593. * Remove all attached input methods from a camera
  19594. */
  19595. clear(): void;
  19596. }
  19597. }
  19598. declare module "babylonjs/Cameras/freeCamera" {
  19599. import { Vector3 } from "babylonjs/Maths/math.vector";
  19600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19601. import { Scene } from "babylonjs/scene";
  19602. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19603. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19604. /**
  19605. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19606. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19607. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19608. */
  19609. export class FreeCamera extends TargetCamera {
  19610. /**
  19611. * Define the collision ellipsoid of the camera.
  19612. * This is helpful to simulate a camera body like the player body around the camera
  19613. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19614. */
  19615. ellipsoid: Vector3;
  19616. /**
  19617. * Define an offset for the position of the ellipsoid around the camera.
  19618. * This can be helpful to determine the center of the body near the gravity center of the body
  19619. * instead of its head.
  19620. */
  19621. ellipsoidOffset: Vector3;
  19622. /**
  19623. * Enable or disable collisions of the camera with the rest of the scene objects.
  19624. */
  19625. checkCollisions: boolean;
  19626. /**
  19627. * Enable or disable gravity on the camera.
  19628. */
  19629. applyGravity: boolean;
  19630. /**
  19631. * Define the input manager associated to the camera.
  19632. */
  19633. inputs: FreeCameraInputsManager;
  19634. /**
  19635. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19636. * Higher values reduce sensitivity.
  19637. */
  19638. get angularSensibility(): number;
  19639. /**
  19640. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19641. * Higher values reduce sensitivity.
  19642. */
  19643. set angularSensibility(value: number);
  19644. /**
  19645. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19646. */
  19647. get keysUp(): number[];
  19648. set keysUp(value: number[]);
  19649. /**
  19650. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19651. */
  19652. get keysUpward(): number[];
  19653. set keysUpward(value: number[]);
  19654. /**
  19655. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19656. */
  19657. get keysDown(): number[];
  19658. set keysDown(value: number[]);
  19659. /**
  19660. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19661. */
  19662. get keysDownward(): number[];
  19663. set keysDownward(value: number[]);
  19664. /**
  19665. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19666. */
  19667. get keysLeft(): number[];
  19668. set keysLeft(value: number[]);
  19669. /**
  19670. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19671. */
  19672. get keysRight(): number[];
  19673. set keysRight(value: number[]);
  19674. /**
  19675. * Event raised when the camera collide with a mesh in the scene.
  19676. */
  19677. onCollide: (collidedMesh: AbstractMesh) => void;
  19678. private _collider;
  19679. private _needMoveForGravity;
  19680. private _oldPosition;
  19681. private _diffPosition;
  19682. private _newPosition;
  19683. /** @hidden */
  19684. _localDirection: Vector3;
  19685. /** @hidden */
  19686. _transformedDirection: Vector3;
  19687. /**
  19688. * Instantiates a Free Camera.
  19689. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19690. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19691. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19692. * @param name Define the name of the camera in the scene
  19693. * @param position Define the start position of the camera in the scene
  19694. * @param scene Define the scene the camera belongs to
  19695. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19696. */
  19697. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19698. /**
  19699. * Attached controls to the current camera.
  19700. * @param element Defines the element the controls should be listened from
  19701. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19702. */
  19703. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19704. /**
  19705. * Detach the current controls from the camera.
  19706. * The camera will stop reacting to inputs.
  19707. * @param element Defines the element to stop listening the inputs from
  19708. */
  19709. detachControl(element: HTMLElement): void;
  19710. private _collisionMask;
  19711. /**
  19712. * Define a collision mask to limit the list of object the camera can collide with
  19713. */
  19714. get collisionMask(): number;
  19715. set collisionMask(mask: number);
  19716. /** @hidden */
  19717. _collideWithWorld(displacement: Vector3): void;
  19718. private _onCollisionPositionChange;
  19719. /** @hidden */
  19720. _checkInputs(): void;
  19721. /** @hidden */
  19722. _decideIfNeedsToMove(): boolean;
  19723. /** @hidden */
  19724. _updatePosition(): void;
  19725. /**
  19726. * Destroy the camera and release the current resources hold by it.
  19727. */
  19728. dispose(): void;
  19729. /**
  19730. * Gets the current object class name.
  19731. * @return the class name
  19732. */
  19733. getClassName(): string;
  19734. }
  19735. }
  19736. declare module "babylonjs/Gamepads/gamepad" {
  19737. import { Observable } from "babylonjs/Misc/observable";
  19738. /**
  19739. * Represents a gamepad control stick position
  19740. */
  19741. export class StickValues {
  19742. /**
  19743. * The x component of the control stick
  19744. */
  19745. x: number;
  19746. /**
  19747. * The y component of the control stick
  19748. */
  19749. y: number;
  19750. /**
  19751. * Initializes the gamepad x and y control stick values
  19752. * @param x The x component of the gamepad control stick value
  19753. * @param y The y component of the gamepad control stick value
  19754. */
  19755. constructor(
  19756. /**
  19757. * The x component of the control stick
  19758. */
  19759. x: number,
  19760. /**
  19761. * The y component of the control stick
  19762. */
  19763. y: number);
  19764. }
  19765. /**
  19766. * An interface which manages callbacks for gamepad button changes
  19767. */
  19768. export interface GamepadButtonChanges {
  19769. /**
  19770. * Called when a gamepad has been changed
  19771. */
  19772. changed: boolean;
  19773. /**
  19774. * Called when a gamepad press event has been triggered
  19775. */
  19776. pressChanged: boolean;
  19777. /**
  19778. * Called when a touch event has been triggered
  19779. */
  19780. touchChanged: boolean;
  19781. /**
  19782. * Called when a value has changed
  19783. */
  19784. valueChanged: boolean;
  19785. }
  19786. /**
  19787. * Represents a gamepad
  19788. */
  19789. export class Gamepad {
  19790. /**
  19791. * The id of the gamepad
  19792. */
  19793. id: string;
  19794. /**
  19795. * The index of the gamepad
  19796. */
  19797. index: number;
  19798. /**
  19799. * The browser gamepad
  19800. */
  19801. browserGamepad: any;
  19802. /**
  19803. * Specifies what type of gamepad this represents
  19804. */
  19805. type: number;
  19806. private _leftStick;
  19807. private _rightStick;
  19808. /** @hidden */
  19809. _isConnected: boolean;
  19810. private _leftStickAxisX;
  19811. private _leftStickAxisY;
  19812. private _rightStickAxisX;
  19813. private _rightStickAxisY;
  19814. /**
  19815. * Triggered when the left control stick has been changed
  19816. */
  19817. private _onleftstickchanged;
  19818. /**
  19819. * Triggered when the right control stick has been changed
  19820. */
  19821. private _onrightstickchanged;
  19822. /**
  19823. * Represents a gamepad controller
  19824. */
  19825. static GAMEPAD: number;
  19826. /**
  19827. * Represents a generic controller
  19828. */
  19829. static GENERIC: number;
  19830. /**
  19831. * Represents an XBox controller
  19832. */
  19833. static XBOX: number;
  19834. /**
  19835. * Represents a pose-enabled controller
  19836. */
  19837. static POSE_ENABLED: number;
  19838. /**
  19839. * Represents an Dual Shock controller
  19840. */
  19841. static DUALSHOCK: number;
  19842. /**
  19843. * Specifies whether the left control stick should be Y-inverted
  19844. */
  19845. protected _invertLeftStickY: boolean;
  19846. /**
  19847. * Specifies if the gamepad has been connected
  19848. */
  19849. get isConnected(): boolean;
  19850. /**
  19851. * Initializes the gamepad
  19852. * @param id The id of the gamepad
  19853. * @param index The index of the gamepad
  19854. * @param browserGamepad The browser gamepad
  19855. * @param leftStickX The x component of the left joystick
  19856. * @param leftStickY The y component of the left joystick
  19857. * @param rightStickX The x component of the right joystick
  19858. * @param rightStickY The y component of the right joystick
  19859. */
  19860. constructor(
  19861. /**
  19862. * The id of the gamepad
  19863. */
  19864. id: string,
  19865. /**
  19866. * The index of the gamepad
  19867. */
  19868. index: number,
  19869. /**
  19870. * The browser gamepad
  19871. */
  19872. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19873. /**
  19874. * Callback triggered when the left joystick has changed
  19875. * @param callback
  19876. */
  19877. onleftstickchanged(callback: (values: StickValues) => void): void;
  19878. /**
  19879. * Callback triggered when the right joystick has changed
  19880. * @param callback
  19881. */
  19882. onrightstickchanged(callback: (values: StickValues) => void): void;
  19883. /**
  19884. * Gets the left joystick
  19885. */
  19886. get leftStick(): StickValues;
  19887. /**
  19888. * Sets the left joystick values
  19889. */
  19890. set leftStick(newValues: StickValues);
  19891. /**
  19892. * Gets the right joystick
  19893. */
  19894. get rightStick(): StickValues;
  19895. /**
  19896. * Sets the right joystick value
  19897. */
  19898. set rightStick(newValues: StickValues);
  19899. /**
  19900. * Updates the gamepad joystick positions
  19901. */
  19902. update(): void;
  19903. /**
  19904. * Disposes the gamepad
  19905. */
  19906. dispose(): void;
  19907. }
  19908. /**
  19909. * Represents a generic gamepad
  19910. */
  19911. export class GenericPad extends Gamepad {
  19912. private _buttons;
  19913. private _onbuttondown;
  19914. private _onbuttonup;
  19915. /**
  19916. * Observable triggered when a button has been pressed
  19917. */
  19918. onButtonDownObservable: Observable<number>;
  19919. /**
  19920. * Observable triggered when a button has been released
  19921. */
  19922. onButtonUpObservable: Observable<number>;
  19923. /**
  19924. * Callback triggered when a button has been pressed
  19925. * @param callback Called when a button has been pressed
  19926. */
  19927. onbuttondown(callback: (buttonPressed: number) => void): void;
  19928. /**
  19929. * Callback triggered when a button has been released
  19930. * @param callback Called when a button has been released
  19931. */
  19932. onbuttonup(callback: (buttonReleased: number) => void): void;
  19933. /**
  19934. * Initializes the generic gamepad
  19935. * @param id The id of the generic gamepad
  19936. * @param index The index of the generic gamepad
  19937. * @param browserGamepad The browser gamepad
  19938. */
  19939. constructor(id: string, index: number, browserGamepad: any);
  19940. private _setButtonValue;
  19941. /**
  19942. * Updates the generic gamepad
  19943. */
  19944. update(): void;
  19945. /**
  19946. * Disposes the generic gamepad
  19947. */
  19948. dispose(): void;
  19949. }
  19950. }
  19951. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19952. import { Observable } from "babylonjs/Misc/observable";
  19953. import { Nullable } from "babylonjs/types";
  19954. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19955. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19957. import { Ray } from "babylonjs/Culling/ray";
  19958. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19959. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19960. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19961. /**
  19962. * Defines the types of pose enabled controllers that are supported
  19963. */
  19964. export enum PoseEnabledControllerType {
  19965. /**
  19966. * HTC Vive
  19967. */
  19968. VIVE = 0,
  19969. /**
  19970. * Oculus Rift
  19971. */
  19972. OCULUS = 1,
  19973. /**
  19974. * Windows mixed reality
  19975. */
  19976. WINDOWS = 2,
  19977. /**
  19978. * Samsung gear VR
  19979. */
  19980. GEAR_VR = 3,
  19981. /**
  19982. * Google Daydream
  19983. */
  19984. DAYDREAM = 4,
  19985. /**
  19986. * Generic
  19987. */
  19988. GENERIC = 5
  19989. }
  19990. /**
  19991. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19992. */
  19993. export interface MutableGamepadButton {
  19994. /**
  19995. * Value of the button/trigger
  19996. */
  19997. value: number;
  19998. /**
  19999. * If the button/trigger is currently touched
  20000. */
  20001. touched: boolean;
  20002. /**
  20003. * If the button/trigger is currently pressed
  20004. */
  20005. pressed: boolean;
  20006. }
  20007. /**
  20008. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20009. * @hidden
  20010. */
  20011. export interface ExtendedGamepadButton extends GamepadButton {
  20012. /**
  20013. * If the button/trigger is currently pressed
  20014. */
  20015. readonly pressed: boolean;
  20016. /**
  20017. * If the button/trigger is currently touched
  20018. */
  20019. readonly touched: boolean;
  20020. /**
  20021. * Value of the button/trigger
  20022. */
  20023. readonly value: number;
  20024. }
  20025. /** @hidden */
  20026. export interface _GamePadFactory {
  20027. /**
  20028. * Returns whether or not the current gamepad can be created for this type of controller.
  20029. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20030. * @returns true if it can be created, otherwise false
  20031. */
  20032. canCreate(gamepadInfo: any): boolean;
  20033. /**
  20034. * Creates a new instance of the Gamepad.
  20035. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20036. * @returns the new gamepad instance
  20037. */
  20038. create(gamepadInfo: any): Gamepad;
  20039. }
  20040. /**
  20041. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20042. */
  20043. export class PoseEnabledControllerHelper {
  20044. /** @hidden */
  20045. static _ControllerFactories: _GamePadFactory[];
  20046. /** @hidden */
  20047. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20048. /**
  20049. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20050. * @param vrGamepad the gamepad to initialized
  20051. * @returns a vr controller of the type the gamepad identified as
  20052. */
  20053. static InitiateController(vrGamepad: any): Gamepad;
  20054. }
  20055. /**
  20056. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20057. */
  20058. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20059. /**
  20060. * If the controller is used in a webXR session
  20061. */
  20062. isXR: boolean;
  20063. private _deviceRoomPosition;
  20064. private _deviceRoomRotationQuaternion;
  20065. /**
  20066. * The device position in babylon space
  20067. */
  20068. devicePosition: Vector3;
  20069. /**
  20070. * The device rotation in babylon space
  20071. */
  20072. deviceRotationQuaternion: Quaternion;
  20073. /**
  20074. * The scale factor of the device in babylon space
  20075. */
  20076. deviceScaleFactor: number;
  20077. /**
  20078. * (Likely devicePosition should be used instead) The device position in its room space
  20079. */
  20080. position: Vector3;
  20081. /**
  20082. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20083. */
  20084. rotationQuaternion: Quaternion;
  20085. /**
  20086. * The type of controller (Eg. Windows mixed reality)
  20087. */
  20088. controllerType: PoseEnabledControllerType;
  20089. protected _calculatedPosition: Vector3;
  20090. private _calculatedRotation;
  20091. /**
  20092. * The raw pose from the device
  20093. */
  20094. rawPose: DevicePose;
  20095. private _trackPosition;
  20096. private _maxRotationDistFromHeadset;
  20097. private _draggedRoomRotation;
  20098. /**
  20099. * @hidden
  20100. */
  20101. _disableTrackPosition(fixedPosition: Vector3): void;
  20102. /**
  20103. * Internal, the mesh attached to the controller
  20104. * @hidden
  20105. */
  20106. _mesh: Nullable<AbstractMesh>;
  20107. private _poseControlledCamera;
  20108. private _leftHandSystemQuaternion;
  20109. /**
  20110. * Internal, matrix used to convert room space to babylon space
  20111. * @hidden
  20112. */
  20113. _deviceToWorld: Matrix;
  20114. /**
  20115. * Node to be used when casting a ray from the controller
  20116. * @hidden
  20117. */
  20118. _pointingPoseNode: Nullable<TransformNode>;
  20119. /**
  20120. * Name of the child mesh that can be used to cast a ray from the controller
  20121. */
  20122. static readonly POINTING_POSE: string;
  20123. /**
  20124. * Creates a new PoseEnabledController from a gamepad
  20125. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20126. */
  20127. constructor(browserGamepad: any);
  20128. private _workingMatrix;
  20129. /**
  20130. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20131. */
  20132. update(): void;
  20133. /**
  20134. * Updates only the pose device and mesh without doing any button event checking
  20135. */
  20136. protected _updatePoseAndMesh(): void;
  20137. /**
  20138. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20139. * @param poseData raw pose fromthe device
  20140. */
  20141. updateFromDevice(poseData: DevicePose): void;
  20142. /**
  20143. * @hidden
  20144. */
  20145. _meshAttachedObservable: Observable<AbstractMesh>;
  20146. /**
  20147. * Attaches a mesh to the controller
  20148. * @param mesh the mesh to be attached
  20149. */
  20150. attachToMesh(mesh: AbstractMesh): void;
  20151. /**
  20152. * Attaches the controllers mesh to a camera
  20153. * @param camera the camera the mesh should be attached to
  20154. */
  20155. attachToPoseControlledCamera(camera: TargetCamera): void;
  20156. /**
  20157. * Disposes of the controller
  20158. */
  20159. dispose(): void;
  20160. /**
  20161. * The mesh that is attached to the controller
  20162. */
  20163. get mesh(): Nullable<AbstractMesh>;
  20164. /**
  20165. * Gets the ray of the controller in the direction the controller is pointing
  20166. * @param length the length the resulting ray should be
  20167. * @returns a ray in the direction the controller is pointing
  20168. */
  20169. getForwardRay(length?: number): Ray;
  20170. }
  20171. }
  20172. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20173. import { Observable } from "babylonjs/Misc/observable";
  20174. import { Scene } from "babylonjs/scene";
  20175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20176. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20177. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20178. import { Nullable } from "babylonjs/types";
  20179. /**
  20180. * Defines the WebVRController object that represents controllers tracked in 3D space
  20181. */
  20182. export abstract class WebVRController extends PoseEnabledController {
  20183. /**
  20184. * Internal, the default controller model for the controller
  20185. */
  20186. protected _defaultModel: Nullable<AbstractMesh>;
  20187. /**
  20188. * Fired when the trigger state has changed
  20189. */
  20190. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20191. /**
  20192. * Fired when the main button state has changed
  20193. */
  20194. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20195. /**
  20196. * Fired when the secondary button state has changed
  20197. */
  20198. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20199. /**
  20200. * Fired when the pad state has changed
  20201. */
  20202. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20203. /**
  20204. * Fired when controllers stick values have changed
  20205. */
  20206. onPadValuesChangedObservable: Observable<StickValues>;
  20207. /**
  20208. * Array of button availible on the controller
  20209. */
  20210. protected _buttons: Array<MutableGamepadButton>;
  20211. private _onButtonStateChange;
  20212. /**
  20213. * Fired when a controller button's state has changed
  20214. * @param callback the callback containing the button that was modified
  20215. */
  20216. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20217. /**
  20218. * X and Y axis corresponding to the controllers joystick
  20219. */
  20220. pad: StickValues;
  20221. /**
  20222. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20223. */
  20224. hand: string;
  20225. /**
  20226. * The default controller model for the controller
  20227. */
  20228. get defaultModel(): Nullable<AbstractMesh>;
  20229. /**
  20230. * Creates a new WebVRController from a gamepad
  20231. * @param vrGamepad the gamepad that the WebVRController should be created from
  20232. */
  20233. constructor(vrGamepad: any);
  20234. /**
  20235. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20236. */
  20237. update(): void;
  20238. /**
  20239. * Function to be called when a button is modified
  20240. */
  20241. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20242. /**
  20243. * Loads a mesh and attaches it to the controller
  20244. * @param scene the scene the mesh should be added to
  20245. * @param meshLoaded callback for when the mesh has been loaded
  20246. */
  20247. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20248. private _setButtonValue;
  20249. private _changes;
  20250. private _checkChanges;
  20251. /**
  20252. * Disposes of th webVRCOntroller
  20253. */
  20254. dispose(): void;
  20255. }
  20256. }
  20257. declare module "babylonjs/Lights/hemisphericLight" {
  20258. import { Nullable } from "babylonjs/types";
  20259. import { Scene } from "babylonjs/scene";
  20260. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20261. import { Color3 } from "babylonjs/Maths/math.color";
  20262. import { Effect } from "babylonjs/Materials/effect";
  20263. import { Light } from "babylonjs/Lights/light";
  20264. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20265. /**
  20266. * The HemisphericLight simulates the ambient environment light,
  20267. * so the passed direction is the light reflection direction, not the incoming direction.
  20268. */
  20269. export class HemisphericLight extends Light {
  20270. /**
  20271. * The groundColor is the light in the opposite direction to the one specified during creation.
  20272. * 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.
  20273. */
  20274. groundColor: Color3;
  20275. /**
  20276. * The light reflection direction, not the incoming direction.
  20277. */
  20278. direction: Vector3;
  20279. /**
  20280. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20281. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20282. * The HemisphericLight can't cast shadows.
  20283. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20284. * @param name The friendly name of the light
  20285. * @param direction The direction of the light reflection
  20286. * @param scene The scene the light belongs to
  20287. */
  20288. constructor(name: string, direction: Vector3, scene: Scene);
  20289. protected _buildUniformLayout(): void;
  20290. /**
  20291. * Returns the string "HemisphericLight".
  20292. * @return The class name
  20293. */
  20294. getClassName(): string;
  20295. /**
  20296. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20297. * Returns the updated direction.
  20298. * @param target The target the direction should point to
  20299. * @return The computed direction
  20300. */
  20301. setDirectionToTarget(target: Vector3): Vector3;
  20302. /**
  20303. * Returns the shadow generator associated to the light.
  20304. * @returns Always null for hemispheric lights because it does not support shadows.
  20305. */
  20306. getShadowGenerator(): Nullable<IShadowGenerator>;
  20307. /**
  20308. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20309. * @param effect The effect to update
  20310. * @param lightIndex The index of the light in the effect to update
  20311. * @returns The hemispheric light
  20312. */
  20313. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20314. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20315. /**
  20316. * Computes the world matrix of the node
  20317. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20318. * @param useWasUpdatedFlag defines a reserved property
  20319. * @returns the world matrix
  20320. */
  20321. computeWorldMatrix(): Matrix;
  20322. /**
  20323. * Returns the integer 3.
  20324. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20325. */
  20326. getTypeID(): number;
  20327. /**
  20328. * Prepares the list of defines specific to the light type.
  20329. * @param defines the list of defines
  20330. * @param lightIndex defines the index of the light for the effect
  20331. */
  20332. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20333. }
  20334. }
  20335. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20336. /** @hidden */
  20337. export var vrMultiviewToSingleviewPixelShader: {
  20338. name: string;
  20339. shader: string;
  20340. };
  20341. }
  20342. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20343. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20344. import { Scene } from "babylonjs/scene";
  20345. /**
  20346. * Renders to multiple views with a single draw call
  20347. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20348. */
  20349. export class MultiviewRenderTarget extends RenderTargetTexture {
  20350. /**
  20351. * Creates a multiview render target
  20352. * @param scene scene used with the render target
  20353. * @param size the size of the render target (used for each view)
  20354. */
  20355. constructor(scene: Scene, size?: number | {
  20356. width: number;
  20357. height: number;
  20358. } | {
  20359. ratio: number;
  20360. });
  20361. /**
  20362. * @hidden
  20363. * @param faceIndex the face index, if its a cube texture
  20364. */
  20365. _bindFrameBuffer(faceIndex?: number): void;
  20366. /**
  20367. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20368. * @returns the view count
  20369. */
  20370. getViewCount(): number;
  20371. }
  20372. }
  20373. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20374. import { Camera } from "babylonjs/Cameras/camera";
  20375. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20376. import { Nullable } from "babylonjs/types";
  20377. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20378. import { Matrix } from "babylonjs/Maths/math.vector";
  20379. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20380. module "babylonjs/Engines/engine" {
  20381. interface Engine {
  20382. /**
  20383. * Creates a new multiview render target
  20384. * @param width defines the width of the texture
  20385. * @param height defines the height of the texture
  20386. * @returns the created multiview texture
  20387. */
  20388. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20389. /**
  20390. * Binds a multiview framebuffer to be drawn to
  20391. * @param multiviewTexture texture to bind
  20392. */
  20393. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20394. }
  20395. }
  20396. module "babylonjs/Cameras/camera" {
  20397. interface Camera {
  20398. /**
  20399. * @hidden
  20400. * 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)
  20401. */
  20402. _useMultiviewToSingleView: boolean;
  20403. /**
  20404. * @hidden
  20405. * 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)
  20406. */
  20407. _multiviewTexture: Nullable<RenderTargetTexture>;
  20408. /**
  20409. * @hidden
  20410. * ensures the multiview texture of the camera exists and has the specified width/height
  20411. * @param width height to set on the multiview texture
  20412. * @param height width to set on the multiview texture
  20413. */
  20414. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20415. }
  20416. }
  20417. module "babylonjs/scene" {
  20418. interface Scene {
  20419. /** @hidden */
  20420. _transformMatrixR: Matrix;
  20421. /** @hidden */
  20422. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20423. /** @hidden */
  20424. _createMultiviewUbo(): void;
  20425. /** @hidden */
  20426. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20427. /** @hidden */
  20428. _renderMultiviewToSingleView(camera: Camera): void;
  20429. }
  20430. }
  20431. }
  20432. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20433. import { Camera } from "babylonjs/Cameras/camera";
  20434. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20435. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20436. import "babylonjs/Engines/Extensions/engine.multiview";
  20437. /**
  20438. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20439. * This will not be used for webXR as it supports displaying texture arrays directly
  20440. */
  20441. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20442. /**
  20443. * Gets a string identifying the name of the class
  20444. * @returns "VRMultiviewToSingleviewPostProcess" string
  20445. */
  20446. getClassName(): string;
  20447. /**
  20448. * Initializes a VRMultiviewToSingleview
  20449. * @param name name of the post process
  20450. * @param camera camera to be applied to
  20451. * @param scaleFactor scaling factor to the size of the output texture
  20452. */
  20453. constructor(name: string, camera: Camera, scaleFactor: number);
  20454. }
  20455. }
  20456. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20457. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20458. import { Nullable } from "babylonjs/types";
  20459. import { Size } from "babylonjs/Maths/math.size";
  20460. import { Observable } from "babylonjs/Misc/observable";
  20461. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20462. /**
  20463. * Interface used to define additional presentation attributes
  20464. */
  20465. export interface IVRPresentationAttributes {
  20466. /**
  20467. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20468. */
  20469. highRefreshRate: boolean;
  20470. /**
  20471. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20472. */
  20473. foveationLevel: number;
  20474. }
  20475. module "babylonjs/Engines/engine" {
  20476. interface Engine {
  20477. /** @hidden */
  20478. _vrDisplay: any;
  20479. /** @hidden */
  20480. _vrSupported: boolean;
  20481. /** @hidden */
  20482. _oldSize: Size;
  20483. /** @hidden */
  20484. _oldHardwareScaleFactor: number;
  20485. /** @hidden */
  20486. _vrExclusivePointerMode: boolean;
  20487. /** @hidden */
  20488. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20489. /** @hidden */
  20490. _onVRDisplayPointerRestricted: () => void;
  20491. /** @hidden */
  20492. _onVRDisplayPointerUnrestricted: () => void;
  20493. /** @hidden */
  20494. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20495. /** @hidden */
  20496. _onVrDisplayDisconnect: Nullable<() => void>;
  20497. /** @hidden */
  20498. _onVrDisplayPresentChange: Nullable<() => void>;
  20499. /**
  20500. * Observable signaled when VR display mode changes
  20501. */
  20502. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20503. /**
  20504. * Observable signaled when VR request present is complete
  20505. */
  20506. onVRRequestPresentComplete: Observable<boolean>;
  20507. /**
  20508. * Observable signaled when VR request present starts
  20509. */
  20510. onVRRequestPresentStart: Observable<Engine>;
  20511. /**
  20512. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20513. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20514. */
  20515. isInVRExclusivePointerMode: boolean;
  20516. /**
  20517. * Gets a boolean indicating if a webVR device was detected
  20518. * @returns true if a webVR device was detected
  20519. */
  20520. isVRDevicePresent(): boolean;
  20521. /**
  20522. * Gets the current webVR device
  20523. * @returns the current webVR device (or null)
  20524. */
  20525. getVRDevice(): any;
  20526. /**
  20527. * Initializes a webVR display and starts listening to display change events
  20528. * The onVRDisplayChangedObservable will be notified upon these changes
  20529. * @returns A promise containing a VRDisplay and if vr is supported
  20530. */
  20531. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20532. /** @hidden */
  20533. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20534. /**
  20535. * Gets or sets the presentation attributes used to configure VR rendering
  20536. */
  20537. vrPresentationAttributes?: IVRPresentationAttributes;
  20538. /**
  20539. * Call this function to switch to webVR mode
  20540. * Will do nothing if webVR is not supported or if there is no webVR device
  20541. * @param options the webvr options provided to the camera. mainly used for multiview
  20542. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20543. */
  20544. enableVR(options: WebVROptions): void;
  20545. /** @hidden */
  20546. _onVRFullScreenTriggered(): void;
  20547. }
  20548. }
  20549. }
  20550. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20551. import { Nullable } from "babylonjs/types";
  20552. import { Observable } from "babylonjs/Misc/observable";
  20553. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20554. import { Scene } from "babylonjs/scene";
  20555. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20556. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20557. import { Node } from "babylonjs/node";
  20558. import { Ray } from "babylonjs/Culling/ray";
  20559. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20560. import "babylonjs/Engines/Extensions/engine.webVR";
  20561. /**
  20562. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20563. * IMPORTANT!! The data is right-hand data.
  20564. * @export
  20565. * @interface DevicePose
  20566. */
  20567. export interface DevicePose {
  20568. /**
  20569. * The position of the device, values in array are [x,y,z].
  20570. */
  20571. readonly position: Nullable<Float32Array>;
  20572. /**
  20573. * The linearVelocity of the device, values in array are [x,y,z].
  20574. */
  20575. readonly linearVelocity: Nullable<Float32Array>;
  20576. /**
  20577. * The linearAcceleration of the device, values in array are [x,y,z].
  20578. */
  20579. readonly linearAcceleration: Nullable<Float32Array>;
  20580. /**
  20581. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20582. */
  20583. readonly orientation: Nullable<Float32Array>;
  20584. /**
  20585. * The angularVelocity of the device, values in array are [x,y,z].
  20586. */
  20587. readonly angularVelocity: Nullable<Float32Array>;
  20588. /**
  20589. * The angularAcceleration of the device, values in array are [x,y,z].
  20590. */
  20591. readonly angularAcceleration: Nullable<Float32Array>;
  20592. }
  20593. /**
  20594. * Interface representing a pose controlled object in Babylon.
  20595. * A pose controlled object has both regular pose values as well as pose values
  20596. * from an external device such as a VR head mounted display
  20597. */
  20598. export interface PoseControlled {
  20599. /**
  20600. * The position of the object in babylon space.
  20601. */
  20602. position: Vector3;
  20603. /**
  20604. * The rotation quaternion of the object in babylon space.
  20605. */
  20606. rotationQuaternion: Quaternion;
  20607. /**
  20608. * The position of the device in babylon space.
  20609. */
  20610. devicePosition?: Vector3;
  20611. /**
  20612. * The rotation quaternion of the device in babylon space.
  20613. */
  20614. deviceRotationQuaternion: Quaternion;
  20615. /**
  20616. * The raw pose coming from the device.
  20617. */
  20618. rawPose: Nullable<DevicePose>;
  20619. /**
  20620. * The scale of the device to be used when translating from device space to babylon space.
  20621. */
  20622. deviceScaleFactor: number;
  20623. /**
  20624. * Updates the poseControlled values based on the input device pose.
  20625. * @param poseData the pose data to update the object with
  20626. */
  20627. updateFromDevice(poseData: DevicePose): void;
  20628. }
  20629. /**
  20630. * Set of options to customize the webVRCamera
  20631. */
  20632. export interface WebVROptions {
  20633. /**
  20634. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20635. */
  20636. trackPosition?: boolean;
  20637. /**
  20638. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20639. */
  20640. positionScale?: number;
  20641. /**
  20642. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20643. */
  20644. displayName?: string;
  20645. /**
  20646. * Should the native controller meshes be initialized. (default: true)
  20647. */
  20648. controllerMeshes?: boolean;
  20649. /**
  20650. * Creating a default HemiLight only on controllers. (default: true)
  20651. */
  20652. defaultLightingOnControllers?: boolean;
  20653. /**
  20654. * If you don't want to use the default VR button of the helper. (default: false)
  20655. */
  20656. useCustomVRButton?: boolean;
  20657. /**
  20658. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20659. */
  20660. customVRButton?: HTMLButtonElement;
  20661. /**
  20662. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20663. */
  20664. rayLength?: number;
  20665. /**
  20666. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20667. */
  20668. defaultHeight?: number;
  20669. /**
  20670. * If multiview should be used if availible (default: false)
  20671. */
  20672. useMultiview?: boolean;
  20673. }
  20674. /**
  20675. * This represents a WebVR camera.
  20676. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20677. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20678. */
  20679. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20680. private webVROptions;
  20681. /**
  20682. * @hidden
  20683. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20684. */
  20685. _vrDevice: any;
  20686. /**
  20687. * The rawPose of the vrDevice.
  20688. */
  20689. rawPose: Nullable<DevicePose>;
  20690. private _onVREnabled;
  20691. private _specsVersion;
  20692. private _attached;
  20693. private _frameData;
  20694. protected _descendants: Array<Node>;
  20695. private _deviceRoomPosition;
  20696. /** @hidden */
  20697. _deviceRoomRotationQuaternion: Quaternion;
  20698. private _standingMatrix;
  20699. /**
  20700. * Represents device position in babylon space.
  20701. */
  20702. devicePosition: Vector3;
  20703. /**
  20704. * Represents device rotation in babylon space.
  20705. */
  20706. deviceRotationQuaternion: Quaternion;
  20707. /**
  20708. * The scale of the device to be used when translating from device space to babylon space.
  20709. */
  20710. deviceScaleFactor: number;
  20711. private _deviceToWorld;
  20712. private _worldToDevice;
  20713. /**
  20714. * References to the webVR controllers for the vrDevice.
  20715. */
  20716. controllers: Array<WebVRController>;
  20717. /**
  20718. * Emits an event when a controller is attached.
  20719. */
  20720. onControllersAttachedObservable: Observable<WebVRController[]>;
  20721. /**
  20722. * Emits an event when a controller's mesh has been loaded;
  20723. */
  20724. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20725. /**
  20726. * Emits an event when the HMD's pose has been updated.
  20727. */
  20728. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20729. private _poseSet;
  20730. /**
  20731. * If the rig cameras be used as parent instead of this camera.
  20732. */
  20733. rigParenting: boolean;
  20734. private _lightOnControllers;
  20735. private _defaultHeight?;
  20736. /**
  20737. * Instantiates a WebVRFreeCamera.
  20738. * @param name The name of the WebVRFreeCamera
  20739. * @param position The starting anchor position for the camera
  20740. * @param scene The scene the camera belongs to
  20741. * @param webVROptions a set of customizable options for the webVRCamera
  20742. */
  20743. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20744. /**
  20745. * Gets the device distance from the ground in meters.
  20746. * @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.
  20747. */
  20748. deviceDistanceToRoomGround(): number;
  20749. /**
  20750. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20751. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20752. */
  20753. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20754. /**
  20755. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20756. * @returns A promise with a boolean set to if the standing matrix is supported.
  20757. */
  20758. useStandingMatrixAsync(): Promise<boolean>;
  20759. /**
  20760. * Disposes the camera
  20761. */
  20762. dispose(): void;
  20763. /**
  20764. * Gets a vrController by name.
  20765. * @param name The name of the controller to retreive
  20766. * @returns the controller matching the name specified or null if not found
  20767. */
  20768. getControllerByName(name: string): Nullable<WebVRController>;
  20769. private _leftController;
  20770. /**
  20771. * The controller corresponding to the users left hand.
  20772. */
  20773. get leftController(): Nullable<WebVRController>;
  20774. private _rightController;
  20775. /**
  20776. * The controller corresponding to the users right hand.
  20777. */
  20778. get rightController(): Nullable<WebVRController>;
  20779. /**
  20780. * Casts a ray forward from the vrCamera's gaze.
  20781. * @param length Length of the ray (default: 100)
  20782. * @returns the ray corresponding to the gaze
  20783. */
  20784. getForwardRay(length?: number): Ray;
  20785. /**
  20786. * @hidden
  20787. * Updates the camera based on device's frame data
  20788. */
  20789. _checkInputs(): void;
  20790. /**
  20791. * Updates the poseControlled values based on the input device pose.
  20792. * @param poseData Pose coming from the device
  20793. */
  20794. updateFromDevice(poseData: DevicePose): void;
  20795. private _htmlElementAttached;
  20796. private _detachIfAttached;
  20797. /**
  20798. * WebVR's attach control will start broadcasting frames to the device.
  20799. * Note that in certain browsers (chrome for example) this function must be called
  20800. * within a user-interaction callback. Example:
  20801. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20802. *
  20803. * @param element html element to attach the vrDevice to
  20804. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20805. */
  20806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20807. /**
  20808. * Detaches the camera from the html element and disables VR
  20809. *
  20810. * @param element html element to detach from
  20811. */
  20812. detachControl(element: HTMLElement): void;
  20813. /**
  20814. * @returns the name of this class
  20815. */
  20816. getClassName(): string;
  20817. /**
  20818. * Calls resetPose on the vrDisplay
  20819. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20820. */
  20821. resetToCurrentRotation(): void;
  20822. /**
  20823. * @hidden
  20824. * Updates the rig cameras (left and right eye)
  20825. */
  20826. _updateRigCameras(): void;
  20827. private _workingVector;
  20828. private _oneVector;
  20829. private _workingMatrix;
  20830. private updateCacheCalled;
  20831. private _correctPositionIfNotTrackPosition;
  20832. /**
  20833. * @hidden
  20834. * Updates the cached values of the camera
  20835. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20836. */
  20837. _updateCache(ignoreParentClass?: boolean): void;
  20838. /**
  20839. * @hidden
  20840. * Get current device position in babylon world
  20841. */
  20842. _computeDevicePosition(): void;
  20843. /**
  20844. * Updates the current device position and rotation in the babylon world
  20845. */
  20846. update(): void;
  20847. /**
  20848. * @hidden
  20849. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20850. * @returns an identity matrix
  20851. */
  20852. _getViewMatrix(): Matrix;
  20853. private _tmpMatrix;
  20854. /**
  20855. * This function is called by the two RIG cameras.
  20856. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20857. * @hidden
  20858. */
  20859. _getWebVRViewMatrix(): Matrix;
  20860. /** @hidden */
  20861. _getWebVRProjectionMatrix(): Matrix;
  20862. private _onGamepadConnectedObserver;
  20863. private _onGamepadDisconnectedObserver;
  20864. private _updateCacheWhenTrackingDisabledObserver;
  20865. /**
  20866. * Initializes the controllers and their meshes
  20867. */
  20868. initControllers(): void;
  20869. }
  20870. }
  20871. declare module "babylonjs/Materials/materialHelper" {
  20872. import { Nullable } from "babylonjs/types";
  20873. import { Scene } from "babylonjs/scene";
  20874. import { Engine } from "babylonjs/Engines/engine";
  20875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20876. import { Light } from "babylonjs/Lights/light";
  20877. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20878. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20880. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20881. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20882. /**
  20883. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20884. *
  20885. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20886. *
  20887. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20888. */
  20889. export class MaterialHelper {
  20890. /**
  20891. * Bind the current view position to an effect.
  20892. * @param effect The effect to be bound
  20893. * @param scene The scene the eyes position is used from
  20894. * @param variableName name of the shader variable that will hold the eye position
  20895. */
  20896. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20897. /**
  20898. * Helps preparing the defines values about the UVs in used in the effect.
  20899. * UVs are shared as much as we can accross channels in the shaders.
  20900. * @param texture The texture we are preparing the UVs for
  20901. * @param defines The defines to update
  20902. * @param key The channel key "diffuse", "specular"... used in the shader
  20903. */
  20904. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20905. /**
  20906. * Binds a texture matrix value to its corrsponding uniform
  20907. * @param texture The texture to bind the matrix for
  20908. * @param uniformBuffer The uniform buffer receivin the data
  20909. * @param key The channel key "diffuse", "specular"... used in the shader
  20910. */
  20911. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20912. /**
  20913. * Gets the current status of the fog (should it be enabled?)
  20914. * @param mesh defines the mesh to evaluate for fog support
  20915. * @param scene defines the hosting scene
  20916. * @returns true if fog must be enabled
  20917. */
  20918. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20919. /**
  20920. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20921. * @param mesh defines the current mesh
  20922. * @param scene defines the current scene
  20923. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20924. * @param pointsCloud defines if point cloud rendering has to be turned on
  20925. * @param fogEnabled defines if fog has to be turned on
  20926. * @param alphaTest defines if alpha testing has to be turned on
  20927. * @param defines defines the current list of defines
  20928. */
  20929. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20930. /**
  20931. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20932. * @param scene defines the current scene
  20933. * @param engine defines the current engine
  20934. * @param defines specifies the list of active defines
  20935. * @param useInstances defines if instances have to be turned on
  20936. * @param useClipPlane defines if clip plane have to be turned on
  20937. * @param useInstances defines if instances have to be turned on
  20938. * @param useThinInstances defines if thin instances have to be turned on
  20939. */
  20940. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20941. /**
  20942. * Prepares the defines for bones
  20943. * @param mesh The mesh containing the geometry data we will draw
  20944. * @param defines The defines to update
  20945. */
  20946. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20947. /**
  20948. * Prepares the defines for morph targets
  20949. * @param mesh The mesh containing the geometry data we will draw
  20950. * @param defines The defines to update
  20951. */
  20952. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20953. /**
  20954. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20955. * @param mesh The mesh containing the geometry data we will draw
  20956. * @param defines The defines to update
  20957. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20958. * @param useBones Precise whether bones should be used or not (override mesh info)
  20959. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20960. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20961. * @returns false if defines are considered not dirty and have not been checked
  20962. */
  20963. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20964. /**
  20965. * Prepares the defines related to multiview
  20966. * @param scene The scene we are intending to draw
  20967. * @param defines The defines to update
  20968. */
  20969. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20970. /**
  20971. * Prepares the defines related to the prepass
  20972. * @param scene The scene we are intending to draw
  20973. * @param defines The defines to update
  20974. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20975. */
  20976. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20977. /**
  20978. * Prepares the defines related to the light information passed in parameter
  20979. * @param scene The scene we are intending to draw
  20980. * @param mesh The mesh the effect is compiling for
  20981. * @param light The light the effect is compiling for
  20982. * @param lightIndex The index of the light
  20983. * @param defines The defines to update
  20984. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20985. * @param state Defines the current state regarding what is needed (normals, etc...)
  20986. */
  20987. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20988. needNormals: boolean;
  20989. needRebuild: boolean;
  20990. shadowEnabled: boolean;
  20991. specularEnabled: boolean;
  20992. lightmapMode: boolean;
  20993. }): void;
  20994. /**
  20995. * Prepares the defines related to the light information passed in parameter
  20996. * @param scene The scene we are intending to draw
  20997. * @param mesh The mesh the effect is compiling for
  20998. * @param defines The defines to update
  20999. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21000. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21001. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21002. * @returns true if normals will be required for the rest of the effect
  21003. */
  21004. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21005. /**
  21006. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21007. * @param lightIndex defines the light index
  21008. * @param uniformsList The uniform list
  21009. * @param samplersList The sampler list
  21010. * @param projectedLightTexture defines if projected texture must be used
  21011. * @param uniformBuffersList defines an optional list of uniform buffers
  21012. */
  21013. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21014. /**
  21015. * Prepares the uniforms and samplers list to be used in the effect
  21016. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21017. * @param samplersList The sampler list
  21018. * @param defines The defines helping in the list generation
  21019. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21020. */
  21021. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21022. /**
  21023. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21024. * @param defines The defines to update while falling back
  21025. * @param fallbacks The authorized effect fallbacks
  21026. * @param maxSimultaneousLights The maximum number of lights allowed
  21027. * @param rank the current rank of the Effect
  21028. * @returns The newly affected rank
  21029. */
  21030. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21031. private static _TmpMorphInfluencers;
  21032. /**
  21033. * Prepares the list of attributes required for morph targets according to the effect defines.
  21034. * @param attribs The current list of supported attribs
  21035. * @param mesh The mesh to prepare the morph targets attributes for
  21036. * @param influencers The number of influencers
  21037. */
  21038. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21039. /**
  21040. * Prepares the list of attributes required for morph targets according to the effect defines.
  21041. * @param attribs The current list of supported attribs
  21042. * @param mesh The mesh to prepare the morph targets attributes for
  21043. * @param defines The current Defines of the effect
  21044. */
  21045. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21046. /**
  21047. * Prepares the list of attributes required for bones according to the effect defines.
  21048. * @param attribs The current list of supported attribs
  21049. * @param mesh The mesh to prepare the bones attributes for
  21050. * @param defines The current Defines of the effect
  21051. * @param fallbacks The current efffect fallback strategy
  21052. */
  21053. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21054. /**
  21055. * Check and prepare the list of attributes required for instances according to the effect defines.
  21056. * @param attribs The current list of supported attribs
  21057. * @param defines The current MaterialDefines of the effect
  21058. */
  21059. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21060. /**
  21061. * Add the list of attributes required for instances to the attribs array.
  21062. * @param attribs The current list of supported attribs
  21063. */
  21064. static PushAttributesForInstances(attribs: string[]): void;
  21065. /**
  21066. * Binds the light information to the effect.
  21067. * @param light The light containing the generator
  21068. * @param effect The effect we are binding the data to
  21069. * @param lightIndex The light index in the effect used to render
  21070. */
  21071. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21072. /**
  21073. * Binds the lights information from the scene to the effect for the given mesh.
  21074. * @param light Light to bind
  21075. * @param lightIndex Light index
  21076. * @param scene The scene where the light belongs to
  21077. * @param effect The effect we are binding the data to
  21078. * @param useSpecular Defines if specular is supported
  21079. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21080. */
  21081. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21082. /**
  21083. * Binds the lights information from the scene to the effect for the given mesh.
  21084. * @param scene The scene the lights belongs to
  21085. * @param mesh The mesh we are binding the information to render
  21086. * @param effect The effect we are binding the data to
  21087. * @param defines The generated defines for the effect
  21088. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21089. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21090. */
  21091. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21092. private static _tempFogColor;
  21093. /**
  21094. * Binds the fog information from the scene to the effect for the given mesh.
  21095. * @param scene The scene the lights belongs to
  21096. * @param mesh The mesh we are binding the information to render
  21097. * @param effect The effect we are binding the data to
  21098. * @param linearSpace Defines if the fog effect is applied in linear space
  21099. */
  21100. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21101. /**
  21102. * Binds the bones information from the mesh to the effect.
  21103. * @param mesh The mesh we are binding the information to render
  21104. * @param effect The effect we are binding the data to
  21105. */
  21106. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21107. /**
  21108. * Binds the morph targets information from the mesh to the effect.
  21109. * @param abstractMesh The mesh we are binding the information to render
  21110. * @param effect The effect we are binding the data to
  21111. */
  21112. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21113. /**
  21114. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21115. * @param defines The generated defines used in the effect
  21116. * @param effect The effect we are binding the data to
  21117. * @param scene The scene we are willing to render with logarithmic scale for
  21118. */
  21119. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21120. /**
  21121. * Binds the clip plane information from the scene to the effect.
  21122. * @param scene The scene the clip plane information are extracted from
  21123. * @param effect The effect we are binding the data to
  21124. */
  21125. static BindClipPlane(effect: Effect, scene: Scene): void;
  21126. }
  21127. }
  21128. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21130. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21131. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21132. import { Nullable } from "babylonjs/types";
  21133. import { Effect } from "babylonjs/Materials/effect";
  21134. import { Matrix } from "babylonjs/Maths/math.vector";
  21135. import { Scene } from "babylonjs/scene";
  21136. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21138. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21139. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21140. import { Observable } from "babylonjs/Misc/observable";
  21141. /**
  21142. * Block used to expose an input value
  21143. */
  21144. export class InputBlock extends NodeMaterialBlock {
  21145. private _mode;
  21146. private _associatedVariableName;
  21147. private _storedValue;
  21148. private _valueCallback;
  21149. private _type;
  21150. private _animationType;
  21151. /** Gets or set a value used to limit the range of float values */
  21152. min: number;
  21153. /** Gets or set a value used to limit the range of float values */
  21154. max: number;
  21155. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21156. isBoolean: boolean;
  21157. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21158. matrixMode: number;
  21159. /** @hidden */
  21160. _systemValue: Nullable<NodeMaterialSystemValues>;
  21161. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21162. isConstant: boolean;
  21163. /** Gets or sets the group to use to display this block in the Inspector */
  21164. groupInInspector: string;
  21165. /** Gets an observable raised when the value is changed */
  21166. onValueChangedObservable: Observable<InputBlock>;
  21167. /**
  21168. * Gets or sets the connection point type (default is float)
  21169. */
  21170. get type(): NodeMaterialBlockConnectionPointTypes;
  21171. /**
  21172. * Creates a new InputBlock
  21173. * @param name defines the block name
  21174. * @param target defines the target of that block (Vertex by default)
  21175. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21176. */
  21177. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21178. /**
  21179. * Validates if a name is a reserve word.
  21180. * @param newName the new name to be given to the node.
  21181. * @returns false if the name is a reserve word, else true.
  21182. */
  21183. validateBlockName(newName: string): boolean;
  21184. /**
  21185. * Gets the output component
  21186. */
  21187. get output(): NodeMaterialConnectionPoint;
  21188. /**
  21189. * Set the source of this connection point to a vertex attribute
  21190. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21191. * @returns the current connection point
  21192. */
  21193. setAsAttribute(attributeName?: string): InputBlock;
  21194. /**
  21195. * Set the source of this connection point to a system value
  21196. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21197. * @returns the current connection point
  21198. */
  21199. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21200. /**
  21201. * Gets or sets the value of that point.
  21202. * Please note that this value will be ignored if valueCallback is defined
  21203. */
  21204. get value(): any;
  21205. set value(value: any);
  21206. /**
  21207. * Gets or sets a callback used to get the value of that point.
  21208. * Please note that setting this value will force the connection point to ignore the value property
  21209. */
  21210. get valueCallback(): () => any;
  21211. set valueCallback(value: () => any);
  21212. /**
  21213. * Gets or sets the associated variable name in the shader
  21214. */
  21215. get associatedVariableName(): string;
  21216. set associatedVariableName(value: string);
  21217. /** Gets or sets the type of animation applied to the input */
  21218. get animationType(): AnimatedInputBlockTypes;
  21219. set animationType(value: AnimatedInputBlockTypes);
  21220. /**
  21221. * Gets a boolean indicating that this connection point not defined yet
  21222. */
  21223. get isUndefined(): boolean;
  21224. /**
  21225. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21226. * In this case the connection point name must be the name of the uniform to use.
  21227. * Can only be set on inputs
  21228. */
  21229. get isUniform(): boolean;
  21230. set isUniform(value: boolean);
  21231. /**
  21232. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21233. * In this case the connection point name must be the name of the attribute to use
  21234. * Can only be set on inputs
  21235. */
  21236. get isAttribute(): boolean;
  21237. set isAttribute(value: boolean);
  21238. /**
  21239. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21240. * Can only be set on exit points
  21241. */
  21242. get isVarying(): boolean;
  21243. set isVarying(value: boolean);
  21244. /**
  21245. * Gets a boolean indicating that the current connection point is a system value
  21246. */
  21247. get isSystemValue(): boolean;
  21248. /**
  21249. * Gets or sets the current well known value or null if not defined as a system value
  21250. */
  21251. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21252. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21253. /**
  21254. * Gets the current class name
  21255. * @returns the class name
  21256. */
  21257. getClassName(): string;
  21258. /**
  21259. * Animate the input if animationType !== None
  21260. * @param scene defines the rendering scene
  21261. */
  21262. animate(scene: Scene): void;
  21263. private _emitDefine;
  21264. initialize(state: NodeMaterialBuildState): void;
  21265. /**
  21266. * Set the input block to its default value (based on its type)
  21267. */
  21268. setDefaultValue(): void;
  21269. private _emitConstant;
  21270. /** @hidden */
  21271. get _noContextSwitch(): boolean;
  21272. private _emit;
  21273. /** @hidden */
  21274. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21275. /** @hidden */
  21276. _transmit(effect: Effect, scene: Scene): void;
  21277. protected _buildBlock(state: NodeMaterialBuildState): void;
  21278. protected _dumpPropertiesCode(): string;
  21279. dispose(): void;
  21280. serialize(): any;
  21281. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21282. }
  21283. }
  21284. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21285. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21286. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21287. import { Nullable } from "babylonjs/types";
  21288. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21289. import { Observable } from "babylonjs/Misc/observable";
  21290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21291. /**
  21292. * Enum used to define the compatibility state between two connection points
  21293. */
  21294. export enum NodeMaterialConnectionPointCompatibilityStates {
  21295. /** Points are compatibles */
  21296. Compatible = 0,
  21297. /** Points are incompatible because of their types */
  21298. TypeIncompatible = 1,
  21299. /** Points are incompatible because of their targets (vertex vs fragment) */
  21300. TargetIncompatible = 2
  21301. }
  21302. /**
  21303. * Defines the direction of a connection point
  21304. */
  21305. export enum NodeMaterialConnectionPointDirection {
  21306. /** Input */
  21307. Input = 0,
  21308. /** Output */
  21309. Output = 1
  21310. }
  21311. /**
  21312. * Defines a connection point for a block
  21313. */
  21314. export class NodeMaterialConnectionPoint {
  21315. /** @hidden */
  21316. _ownerBlock: NodeMaterialBlock;
  21317. /** @hidden */
  21318. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21319. private _endpoints;
  21320. private _associatedVariableName;
  21321. private _direction;
  21322. /** @hidden */
  21323. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21324. /** @hidden */
  21325. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21326. private _type;
  21327. /** @hidden */
  21328. _enforceAssociatedVariableName: boolean;
  21329. /** Gets the direction of the point */
  21330. get direction(): NodeMaterialConnectionPointDirection;
  21331. /** Indicates that this connection point needs dual validation before being connected to another point */
  21332. needDualDirectionValidation: boolean;
  21333. /**
  21334. * Gets or sets the additional types supported by this connection point
  21335. */
  21336. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21337. /**
  21338. * Gets or sets the additional types excluded by this connection point
  21339. */
  21340. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21341. /**
  21342. * Observable triggered when this point is connected
  21343. */
  21344. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21345. /**
  21346. * Gets or sets the associated variable name in the shader
  21347. */
  21348. get associatedVariableName(): string;
  21349. set associatedVariableName(value: string);
  21350. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21351. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21352. /**
  21353. * Gets or sets the connection point type (default is float)
  21354. */
  21355. get type(): NodeMaterialBlockConnectionPointTypes;
  21356. set type(value: NodeMaterialBlockConnectionPointTypes);
  21357. /**
  21358. * Gets or sets the connection point name
  21359. */
  21360. name: string;
  21361. /**
  21362. * Gets or sets the connection point name
  21363. */
  21364. displayName: string;
  21365. /**
  21366. * Gets or sets a boolean indicating that this connection point can be omitted
  21367. */
  21368. isOptional: boolean;
  21369. /**
  21370. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21371. */
  21372. isExposedOnFrame: boolean;
  21373. /**
  21374. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21375. */
  21376. define: string;
  21377. /** @hidden */
  21378. _prioritizeVertex: boolean;
  21379. private _target;
  21380. /** Gets or sets the target of that connection point */
  21381. get target(): NodeMaterialBlockTargets;
  21382. set target(value: NodeMaterialBlockTargets);
  21383. /**
  21384. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21385. */
  21386. get isConnected(): boolean;
  21387. /**
  21388. * Gets a boolean indicating that the current point is connected to an input block
  21389. */
  21390. get isConnectedToInputBlock(): boolean;
  21391. /**
  21392. * Gets a the connected input block (if any)
  21393. */
  21394. get connectInputBlock(): Nullable<InputBlock>;
  21395. /** Get the other side of the connection (if any) */
  21396. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21397. /** Get the block that owns this connection point */
  21398. get ownerBlock(): NodeMaterialBlock;
  21399. /** Get the block connected on the other side of this connection (if any) */
  21400. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21401. /** Get the block connected on the endpoints of this connection (if any) */
  21402. get connectedBlocks(): Array<NodeMaterialBlock>;
  21403. /** Gets the list of connected endpoints */
  21404. get endpoints(): NodeMaterialConnectionPoint[];
  21405. /** Gets a boolean indicating if that output point is connected to at least one input */
  21406. get hasEndpoints(): boolean;
  21407. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21408. get isConnectedInVertexShader(): boolean;
  21409. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21410. get isConnectedInFragmentShader(): boolean;
  21411. /**
  21412. * Creates a block suitable to be used as an input for this input point.
  21413. * If null is returned, a block based on the point type will be created.
  21414. * @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
  21415. */
  21416. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21417. /**
  21418. * Creates a new connection point
  21419. * @param name defines the connection point name
  21420. * @param ownerBlock defines the block hosting this connection point
  21421. * @param direction defines the direction of the connection point
  21422. */
  21423. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21424. /**
  21425. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21426. * @returns the class name
  21427. */
  21428. getClassName(): string;
  21429. /**
  21430. * Gets a boolean indicating if the current point can be connected to another point
  21431. * @param connectionPoint defines the other connection point
  21432. * @returns a boolean
  21433. */
  21434. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21435. /**
  21436. * Gets a number indicating if the current point can be connected to another point
  21437. * @param connectionPoint defines the other connection point
  21438. * @returns a number defining the compatibility state
  21439. */
  21440. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21441. /**
  21442. * Connect this point to another connection point
  21443. * @param connectionPoint defines the other connection point
  21444. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21445. * @returns the current connection point
  21446. */
  21447. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21448. /**
  21449. * Disconnect this point from one of his endpoint
  21450. * @param endpoint defines the other connection point
  21451. * @returns the current connection point
  21452. */
  21453. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21454. /**
  21455. * Serializes this point in a JSON representation
  21456. * @param isInput defines if the connection point is an input (default is true)
  21457. * @returns the serialized point object
  21458. */
  21459. serialize(isInput?: boolean): any;
  21460. /**
  21461. * Release resources
  21462. */
  21463. dispose(): void;
  21464. }
  21465. }
  21466. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21467. /**
  21468. * Enum used to define the material modes
  21469. */
  21470. export enum NodeMaterialModes {
  21471. /** Regular material */
  21472. Material = 0,
  21473. /** For post process */
  21474. PostProcess = 1,
  21475. /** For particle system */
  21476. Particle = 2,
  21477. /** For procedural texture */
  21478. ProceduralTexture = 3
  21479. }
  21480. }
  21481. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21484. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21487. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21488. import { Effect } from "babylonjs/Materials/effect";
  21489. import { Mesh } from "babylonjs/Meshes/mesh";
  21490. import { Nullable } from "babylonjs/types";
  21491. import { Texture } from "babylonjs/Materials/Textures/texture";
  21492. import { Scene } from "babylonjs/scene";
  21493. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21494. /**
  21495. * Block used to read a texture from a sampler
  21496. */
  21497. export class TextureBlock extends NodeMaterialBlock {
  21498. private _defineName;
  21499. private _linearDefineName;
  21500. private _gammaDefineName;
  21501. private _tempTextureRead;
  21502. private _samplerName;
  21503. private _transformedUVName;
  21504. private _textureTransformName;
  21505. private _textureInfoName;
  21506. private _mainUVName;
  21507. private _mainUVDefineName;
  21508. private _fragmentOnly;
  21509. /**
  21510. * Gets or sets the texture associated with the node
  21511. */
  21512. texture: Nullable<Texture>;
  21513. /**
  21514. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21515. */
  21516. convertToGammaSpace: boolean;
  21517. /**
  21518. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21519. */
  21520. convertToLinearSpace: boolean;
  21521. /**
  21522. * Create a new TextureBlock
  21523. * @param name defines the block name
  21524. */
  21525. constructor(name: string, fragmentOnly?: boolean);
  21526. /**
  21527. * Gets the current class name
  21528. * @returns the class name
  21529. */
  21530. getClassName(): string;
  21531. /**
  21532. * Gets the uv input component
  21533. */
  21534. get uv(): NodeMaterialConnectionPoint;
  21535. /**
  21536. * Gets the rgba output component
  21537. */
  21538. get rgba(): NodeMaterialConnectionPoint;
  21539. /**
  21540. * Gets the rgb output component
  21541. */
  21542. get rgb(): NodeMaterialConnectionPoint;
  21543. /**
  21544. * Gets the r output component
  21545. */
  21546. get r(): NodeMaterialConnectionPoint;
  21547. /**
  21548. * Gets the g output component
  21549. */
  21550. get g(): NodeMaterialConnectionPoint;
  21551. /**
  21552. * Gets the b output component
  21553. */
  21554. get b(): NodeMaterialConnectionPoint;
  21555. /**
  21556. * Gets the a output component
  21557. */
  21558. get a(): NodeMaterialConnectionPoint;
  21559. get target(): NodeMaterialBlockTargets;
  21560. autoConfigure(material: NodeMaterial): void;
  21561. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21562. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21563. isReady(): boolean;
  21564. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21565. private get _isMixed();
  21566. private _injectVertexCode;
  21567. private _writeTextureRead;
  21568. private _writeOutput;
  21569. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21570. protected _dumpPropertiesCode(): string;
  21571. serialize(): any;
  21572. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21573. }
  21574. }
  21575. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21576. /** @hidden */
  21577. export var reflectionFunction: {
  21578. name: string;
  21579. shader: string;
  21580. };
  21581. }
  21582. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21588. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21589. import { Effect } from "babylonjs/Materials/effect";
  21590. import { Mesh } from "babylonjs/Meshes/mesh";
  21591. import { Nullable } from "babylonjs/types";
  21592. import { Scene } from "babylonjs/scene";
  21593. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21594. /**
  21595. * Base block used to read a reflection texture from a sampler
  21596. */
  21597. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21598. /** @hidden */
  21599. _define3DName: string;
  21600. /** @hidden */
  21601. _defineCubicName: string;
  21602. /** @hidden */
  21603. _defineExplicitName: string;
  21604. /** @hidden */
  21605. _defineProjectionName: string;
  21606. /** @hidden */
  21607. _defineLocalCubicName: string;
  21608. /** @hidden */
  21609. _defineSphericalName: string;
  21610. /** @hidden */
  21611. _definePlanarName: string;
  21612. /** @hidden */
  21613. _defineEquirectangularName: string;
  21614. /** @hidden */
  21615. _defineMirroredEquirectangularFixedName: string;
  21616. /** @hidden */
  21617. _defineEquirectangularFixedName: string;
  21618. /** @hidden */
  21619. _defineSkyboxName: string;
  21620. /** @hidden */
  21621. _defineOppositeZ: string;
  21622. /** @hidden */
  21623. _cubeSamplerName: string;
  21624. /** @hidden */
  21625. _2DSamplerName: string;
  21626. protected _positionUVWName: string;
  21627. protected _directionWName: string;
  21628. protected _reflectionVectorName: string;
  21629. /** @hidden */
  21630. _reflectionCoordsName: string;
  21631. /** @hidden */
  21632. _reflectionMatrixName: string;
  21633. protected _reflectionColorName: string;
  21634. /**
  21635. * Gets or sets the texture associated with the node
  21636. */
  21637. texture: Nullable<BaseTexture>;
  21638. /**
  21639. * Create a new ReflectionTextureBaseBlock
  21640. * @param name defines the block name
  21641. */
  21642. constructor(name: string);
  21643. /**
  21644. * Gets the current class name
  21645. * @returns the class name
  21646. */
  21647. getClassName(): string;
  21648. /**
  21649. * Gets the world position input component
  21650. */
  21651. abstract get position(): NodeMaterialConnectionPoint;
  21652. /**
  21653. * Gets the world position input component
  21654. */
  21655. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21656. /**
  21657. * Gets the world normal input component
  21658. */
  21659. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21660. /**
  21661. * Gets the world input component
  21662. */
  21663. abstract get world(): NodeMaterialConnectionPoint;
  21664. /**
  21665. * Gets the camera (or eye) position component
  21666. */
  21667. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21668. /**
  21669. * Gets the view input component
  21670. */
  21671. abstract get view(): NodeMaterialConnectionPoint;
  21672. protected _getTexture(): Nullable<BaseTexture>;
  21673. autoConfigure(material: NodeMaterial): void;
  21674. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21675. isReady(): boolean;
  21676. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21677. /**
  21678. * Gets the code to inject in the vertex shader
  21679. * @param state current state of the node material building
  21680. * @returns the shader code
  21681. */
  21682. handleVertexSide(state: NodeMaterialBuildState): string;
  21683. /**
  21684. * Handles the inits for the fragment code path
  21685. * @param state node material build state
  21686. */
  21687. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21688. /**
  21689. * Generates the reflection coords code for the fragment code path
  21690. * @param worldNormalVarName name of the world normal variable
  21691. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21692. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21693. * @returns the shader code
  21694. */
  21695. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21696. /**
  21697. * Generates the reflection color code for the fragment code path
  21698. * @param lodVarName name of the lod variable
  21699. * @param swizzleLookupTexture swizzle to use for the final color variable
  21700. * @returns the shader code
  21701. */
  21702. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21703. /**
  21704. * Generates the code corresponding to the connected output points
  21705. * @param state node material build state
  21706. * @param varName name of the variable to output
  21707. * @returns the shader code
  21708. */
  21709. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21710. protected _buildBlock(state: NodeMaterialBuildState): this;
  21711. protected _dumpPropertiesCode(): string;
  21712. serialize(): any;
  21713. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21714. }
  21715. }
  21716. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21717. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21718. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21719. import { Nullable } from "babylonjs/types";
  21720. /**
  21721. * Defines a connection point to be used for points with a custom object type
  21722. */
  21723. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21724. private _blockType;
  21725. private _blockName;
  21726. private _nameForCheking?;
  21727. /**
  21728. * Creates a new connection point
  21729. * @param name defines the connection point name
  21730. * @param ownerBlock defines the block hosting this connection point
  21731. * @param direction defines the direction of the connection point
  21732. */
  21733. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21734. /**
  21735. * Gets a number indicating if the current point can be connected to another point
  21736. * @param connectionPoint defines the other connection point
  21737. * @returns a number defining the compatibility state
  21738. */
  21739. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21740. /**
  21741. * Creates a block suitable to be used as an input for this input point.
  21742. * If null is returned, a block based on the point type will be created.
  21743. * @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
  21744. */
  21745. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21746. }
  21747. }
  21748. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21749. /**
  21750. * Enum defining the type of properties that can be edited in the property pages in the NME
  21751. */
  21752. export enum PropertyTypeForEdition {
  21753. /** property is a boolean */
  21754. Boolean = 0,
  21755. /** property is a float */
  21756. Float = 1,
  21757. /** property is a Vector2 */
  21758. Vector2 = 2,
  21759. /** property is a list of values */
  21760. List = 3
  21761. }
  21762. /**
  21763. * Interface that defines an option in a variable of type list
  21764. */
  21765. export interface IEditablePropertyListOption {
  21766. /** label of the option */
  21767. "label": string;
  21768. /** value of the option */
  21769. "value": number;
  21770. }
  21771. /**
  21772. * Interface that defines the options available for an editable property
  21773. */
  21774. export interface IEditablePropertyOption {
  21775. /** min value */
  21776. "min"?: number;
  21777. /** max value */
  21778. "max"?: number;
  21779. /** notifiers: indicates which actions to take when the property is changed */
  21780. "notifiers"?: {
  21781. /** the material should be rebuilt */
  21782. "rebuild"?: boolean;
  21783. /** the preview should be updated */
  21784. "update"?: boolean;
  21785. };
  21786. /** list of the options for a variable of type list */
  21787. "options"?: IEditablePropertyListOption[];
  21788. }
  21789. /**
  21790. * Interface that describes an editable property
  21791. */
  21792. export interface IPropertyDescriptionForEdition {
  21793. /** name of the property */
  21794. "propertyName": string;
  21795. /** display name of the property */
  21796. "displayName": string;
  21797. /** type of the property */
  21798. "type": PropertyTypeForEdition;
  21799. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21800. "groupName": string;
  21801. /** options for the property */
  21802. "options": IEditablePropertyOption;
  21803. }
  21804. /**
  21805. * Decorator that flags a property in a node material block as being editable
  21806. */
  21807. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21808. }
  21809. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21812. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21814. import { Nullable } from "babylonjs/types";
  21815. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21816. import { Mesh } from "babylonjs/Meshes/mesh";
  21817. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21818. import { Effect } from "babylonjs/Materials/effect";
  21819. import { Scene } from "babylonjs/scene";
  21820. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21821. /**
  21822. * Block used to implement the refraction part of the sub surface module of the PBR material
  21823. */
  21824. export class RefractionBlock extends NodeMaterialBlock {
  21825. /** @hidden */
  21826. _define3DName: string;
  21827. /** @hidden */
  21828. _refractionMatrixName: string;
  21829. /** @hidden */
  21830. _defineLODRefractionAlpha: string;
  21831. /** @hidden */
  21832. _defineLinearSpecularRefraction: string;
  21833. /** @hidden */
  21834. _defineOppositeZ: string;
  21835. /** @hidden */
  21836. _cubeSamplerName: string;
  21837. /** @hidden */
  21838. _2DSamplerName: string;
  21839. /** @hidden */
  21840. _vRefractionMicrosurfaceInfosName: string;
  21841. /** @hidden */
  21842. _vRefractionInfosName: string;
  21843. private _scene;
  21844. /**
  21845. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21846. * Materials half opaque for instance using refraction could benefit from this control.
  21847. */
  21848. linkRefractionWithTransparency: boolean;
  21849. /**
  21850. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21851. */
  21852. invertRefractionY: boolean;
  21853. /**
  21854. * Gets or sets the texture associated with the node
  21855. */
  21856. texture: Nullable<BaseTexture>;
  21857. /**
  21858. * Create a new RefractionBlock
  21859. * @param name defines the block name
  21860. */
  21861. constructor(name: string);
  21862. /**
  21863. * Gets the current class name
  21864. * @returns the class name
  21865. */
  21866. getClassName(): string;
  21867. /**
  21868. * Gets the intensity input component
  21869. */
  21870. get intensity(): NodeMaterialConnectionPoint;
  21871. /**
  21872. * Gets the index of refraction input component
  21873. */
  21874. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21875. /**
  21876. * Gets the tint at distance input component
  21877. */
  21878. get tintAtDistance(): NodeMaterialConnectionPoint;
  21879. /**
  21880. * Gets the view input component
  21881. */
  21882. get view(): NodeMaterialConnectionPoint;
  21883. /**
  21884. * Gets the refraction object output component
  21885. */
  21886. get refraction(): NodeMaterialConnectionPoint;
  21887. /**
  21888. * Returns true if the block has a texture
  21889. */
  21890. get hasTexture(): boolean;
  21891. protected _getTexture(): Nullable<BaseTexture>;
  21892. autoConfigure(material: NodeMaterial): void;
  21893. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21894. isReady(): boolean;
  21895. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21896. /**
  21897. * Gets the main code of the block (fragment side)
  21898. * @param state current state of the node material building
  21899. * @returns the shader code
  21900. */
  21901. getCode(state: NodeMaterialBuildState): string;
  21902. protected _buildBlock(state: NodeMaterialBuildState): this;
  21903. protected _dumpPropertiesCode(): string;
  21904. serialize(): any;
  21905. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21906. }
  21907. }
  21908. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21911. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21914. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21916. import { Nullable } from "babylonjs/types";
  21917. import { Scene } from "babylonjs/scene";
  21918. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21919. /**
  21920. * Base block used as input for post process
  21921. */
  21922. export class CurrentScreenBlock extends NodeMaterialBlock {
  21923. private _samplerName;
  21924. private _linearDefineName;
  21925. private _gammaDefineName;
  21926. private _mainUVName;
  21927. private _tempTextureRead;
  21928. /**
  21929. * Gets or sets the texture associated with the node
  21930. */
  21931. texture: Nullable<BaseTexture>;
  21932. /**
  21933. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21934. */
  21935. convertToGammaSpace: boolean;
  21936. /**
  21937. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21938. */
  21939. convertToLinearSpace: boolean;
  21940. /**
  21941. * Create a new CurrentScreenBlock
  21942. * @param name defines the block name
  21943. */
  21944. constructor(name: string);
  21945. /**
  21946. * Gets the current class name
  21947. * @returns the class name
  21948. */
  21949. getClassName(): string;
  21950. /**
  21951. * Gets the uv input component
  21952. */
  21953. get uv(): NodeMaterialConnectionPoint;
  21954. /**
  21955. * Gets the rgba output component
  21956. */
  21957. get rgba(): NodeMaterialConnectionPoint;
  21958. /**
  21959. * Gets the rgb output component
  21960. */
  21961. get rgb(): NodeMaterialConnectionPoint;
  21962. /**
  21963. * Gets the r output component
  21964. */
  21965. get r(): NodeMaterialConnectionPoint;
  21966. /**
  21967. * Gets the g output component
  21968. */
  21969. get g(): NodeMaterialConnectionPoint;
  21970. /**
  21971. * Gets the b output component
  21972. */
  21973. get b(): NodeMaterialConnectionPoint;
  21974. /**
  21975. * Gets the a output component
  21976. */
  21977. get a(): NodeMaterialConnectionPoint;
  21978. /**
  21979. * Initialize the block and prepare the context for build
  21980. * @param state defines the state that will be used for the build
  21981. */
  21982. initialize(state: NodeMaterialBuildState): void;
  21983. get target(): NodeMaterialBlockTargets;
  21984. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21985. isReady(): boolean;
  21986. private _injectVertexCode;
  21987. private _writeTextureRead;
  21988. private _writeOutput;
  21989. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21990. serialize(): any;
  21991. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21992. }
  21993. }
  21994. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21999. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22000. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22001. import { Nullable } from "babylonjs/types";
  22002. import { Scene } from "babylonjs/scene";
  22003. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22004. /**
  22005. * Base block used for the particle texture
  22006. */
  22007. export class ParticleTextureBlock extends NodeMaterialBlock {
  22008. private _samplerName;
  22009. private _linearDefineName;
  22010. private _gammaDefineName;
  22011. private _tempTextureRead;
  22012. /**
  22013. * Gets or sets the texture associated with the node
  22014. */
  22015. texture: Nullable<BaseTexture>;
  22016. /**
  22017. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22018. */
  22019. convertToGammaSpace: boolean;
  22020. /**
  22021. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22022. */
  22023. convertToLinearSpace: boolean;
  22024. /**
  22025. * Create a new ParticleTextureBlock
  22026. * @param name defines the block name
  22027. */
  22028. constructor(name: string);
  22029. /**
  22030. * Gets the current class name
  22031. * @returns the class name
  22032. */
  22033. getClassName(): string;
  22034. /**
  22035. * Gets the uv input component
  22036. */
  22037. get uv(): NodeMaterialConnectionPoint;
  22038. /**
  22039. * Gets the rgba output component
  22040. */
  22041. get rgba(): NodeMaterialConnectionPoint;
  22042. /**
  22043. * Gets the rgb output component
  22044. */
  22045. get rgb(): NodeMaterialConnectionPoint;
  22046. /**
  22047. * Gets the r output component
  22048. */
  22049. get r(): NodeMaterialConnectionPoint;
  22050. /**
  22051. * Gets the g output component
  22052. */
  22053. get g(): NodeMaterialConnectionPoint;
  22054. /**
  22055. * Gets the b output component
  22056. */
  22057. get b(): NodeMaterialConnectionPoint;
  22058. /**
  22059. * Gets the a output component
  22060. */
  22061. get a(): NodeMaterialConnectionPoint;
  22062. /**
  22063. * Initialize the block and prepare the context for build
  22064. * @param state defines the state that will be used for the build
  22065. */
  22066. initialize(state: NodeMaterialBuildState): void;
  22067. autoConfigure(material: NodeMaterial): void;
  22068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22069. isReady(): boolean;
  22070. private _writeOutput;
  22071. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22072. serialize(): any;
  22073. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22074. }
  22075. }
  22076. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22078. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22079. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22080. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22081. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22082. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22083. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22084. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22085. import { Scene } from "babylonjs/scene";
  22086. /**
  22087. * Class used to store shared data between 2 NodeMaterialBuildState
  22088. */
  22089. export class NodeMaterialBuildStateSharedData {
  22090. /**
  22091. * Gets the list of emitted varyings
  22092. */
  22093. temps: string[];
  22094. /**
  22095. * Gets the list of emitted varyings
  22096. */
  22097. varyings: string[];
  22098. /**
  22099. * Gets the varying declaration string
  22100. */
  22101. varyingDeclaration: string;
  22102. /**
  22103. * Input blocks
  22104. */
  22105. inputBlocks: InputBlock[];
  22106. /**
  22107. * Input blocks
  22108. */
  22109. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22110. /**
  22111. * Bindable blocks (Blocks that need to set data to the effect)
  22112. */
  22113. bindableBlocks: NodeMaterialBlock[];
  22114. /**
  22115. * List of blocks that can provide a compilation fallback
  22116. */
  22117. blocksWithFallbacks: NodeMaterialBlock[];
  22118. /**
  22119. * List of blocks that can provide a define update
  22120. */
  22121. blocksWithDefines: NodeMaterialBlock[];
  22122. /**
  22123. * List of blocks that can provide a repeatable content
  22124. */
  22125. repeatableContentBlocks: NodeMaterialBlock[];
  22126. /**
  22127. * List of blocks that can provide a dynamic list of uniforms
  22128. */
  22129. dynamicUniformBlocks: NodeMaterialBlock[];
  22130. /**
  22131. * List of blocks that can block the isReady function for the material
  22132. */
  22133. blockingBlocks: NodeMaterialBlock[];
  22134. /**
  22135. * Gets the list of animated inputs
  22136. */
  22137. animatedInputs: InputBlock[];
  22138. /**
  22139. * Build Id used to avoid multiple recompilations
  22140. */
  22141. buildId: number;
  22142. /** List of emitted variables */
  22143. variableNames: {
  22144. [key: string]: number;
  22145. };
  22146. /** List of emitted defines */
  22147. defineNames: {
  22148. [key: string]: number;
  22149. };
  22150. /** Should emit comments? */
  22151. emitComments: boolean;
  22152. /** Emit build activity */
  22153. verbose: boolean;
  22154. /** Gets or sets the hosting scene */
  22155. scene: Scene;
  22156. /**
  22157. * Gets the compilation hints emitted at compilation time
  22158. */
  22159. hints: {
  22160. needWorldViewMatrix: boolean;
  22161. needWorldViewProjectionMatrix: boolean;
  22162. needAlphaBlending: boolean;
  22163. needAlphaTesting: boolean;
  22164. };
  22165. /**
  22166. * List of compilation checks
  22167. */
  22168. checks: {
  22169. emitVertex: boolean;
  22170. emitFragment: boolean;
  22171. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22172. };
  22173. /**
  22174. * Is vertex program allowed to be empty?
  22175. */
  22176. allowEmptyVertexProgram: boolean;
  22177. /** Creates a new shared data */
  22178. constructor();
  22179. /**
  22180. * Emits console errors and exceptions if there is a failing check
  22181. */
  22182. emitErrors(): void;
  22183. }
  22184. }
  22185. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22186. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22187. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22188. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22189. /**
  22190. * Class used to store node based material build state
  22191. */
  22192. export class NodeMaterialBuildState {
  22193. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22194. supportUniformBuffers: boolean;
  22195. /**
  22196. * Gets the list of emitted attributes
  22197. */
  22198. attributes: string[];
  22199. /**
  22200. * Gets the list of emitted uniforms
  22201. */
  22202. uniforms: string[];
  22203. /**
  22204. * Gets the list of emitted constants
  22205. */
  22206. constants: string[];
  22207. /**
  22208. * Gets the list of emitted samplers
  22209. */
  22210. samplers: string[];
  22211. /**
  22212. * Gets the list of emitted functions
  22213. */
  22214. functions: {
  22215. [key: string]: string;
  22216. };
  22217. /**
  22218. * Gets the list of emitted extensions
  22219. */
  22220. extensions: {
  22221. [key: string]: string;
  22222. };
  22223. /**
  22224. * Gets the target of the compilation state
  22225. */
  22226. target: NodeMaterialBlockTargets;
  22227. /**
  22228. * Gets the list of emitted counters
  22229. */
  22230. counters: {
  22231. [key: string]: number;
  22232. };
  22233. /**
  22234. * Shared data between multiple NodeMaterialBuildState instances
  22235. */
  22236. sharedData: NodeMaterialBuildStateSharedData;
  22237. /** @hidden */
  22238. _vertexState: NodeMaterialBuildState;
  22239. /** @hidden */
  22240. _attributeDeclaration: string;
  22241. /** @hidden */
  22242. _uniformDeclaration: string;
  22243. /** @hidden */
  22244. _constantDeclaration: string;
  22245. /** @hidden */
  22246. _samplerDeclaration: string;
  22247. /** @hidden */
  22248. _varyingTransfer: string;
  22249. /** @hidden */
  22250. _injectAtEnd: string;
  22251. private _repeatableContentAnchorIndex;
  22252. /** @hidden */
  22253. _builtCompilationString: string;
  22254. /**
  22255. * Gets the emitted compilation strings
  22256. */
  22257. compilationString: string;
  22258. /**
  22259. * Finalize the compilation strings
  22260. * @param state defines the current compilation state
  22261. */
  22262. finalize(state: NodeMaterialBuildState): void;
  22263. /** @hidden */
  22264. get _repeatableContentAnchor(): string;
  22265. /** @hidden */
  22266. _getFreeVariableName(prefix: string): string;
  22267. /** @hidden */
  22268. _getFreeDefineName(prefix: string): string;
  22269. /** @hidden */
  22270. _excludeVariableName(name: string): void;
  22271. /** @hidden */
  22272. _emit2DSampler(name: string): void;
  22273. /** @hidden */
  22274. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22275. /** @hidden */
  22276. _emitExtension(name: string, extension: string, define?: string): void;
  22277. /** @hidden */
  22278. _emitFunction(name: string, code: string, comments: string): void;
  22279. /** @hidden */
  22280. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22281. replaceStrings?: {
  22282. search: RegExp;
  22283. replace: string;
  22284. }[];
  22285. repeatKey?: string;
  22286. }): string;
  22287. /** @hidden */
  22288. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22289. repeatKey?: string;
  22290. removeAttributes?: boolean;
  22291. removeUniforms?: boolean;
  22292. removeVaryings?: boolean;
  22293. removeIfDef?: boolean;
  22294. replaceStrings?: {
  22295. search: RegExp;
  22296. replace: string;
  22297. }[];
  22298. }, storeKey?: string): void;
  22299. /** @hidden */
  22300. _registerTempVariable(name: string): boolean;
  22301. /** @hidden */
  22302. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22303. /** @hidden */
  22304. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22305. /** @hidden */
  22306. _emitFloat(value: number): string;
  22307. }
  22308. }
  22309. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22310. /**
  22311. * Helper class used to generate session unique ID
  22312. */
  22313. export class UniqueIdGenerator {
  22314. private static _UniqueIdCounter;
  22315. /**
  22316. * Gets an unique (relatively to the current scene) Id
  22317. */
  22318. static get UniqueId(): number;
  22319. }
  22320. }
  22321. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22322. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22323. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22324. import { Nullable } from "babylonjs/types";
  22325. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22326. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22327. import { Effect } from "babylonjs/Materials/effect";
  22328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22329. import { Mesh } from "babylonjs/Meshes/mesh";
  22330. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22331. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22332. import { Scene } from "babylonjs/scene";
  22333. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22334. /**
  22335. * Defines a block that can be used inside a node based material
  22336. */
  22337. export class NodeMaterialBlock {
  22338. private _buildId;
  22339. private _buildTarget;
  22340. private _target;
  22341. private _isFinalMerger;
  22342. private _isInput;
  22343. private _name;
  22344. protected _isUnique: boolean;
  22345. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22346. inputsAreExclusive: boolean;
  22347. /** @hidden */
  22348. _codeVariableName: string;
  22349. /** @hidden */
  22350. _inputs: NodeMaterialConnectionPoint[];
  22351. /** @hidden */
  22352. _outputs: NodeMaterialConnectionPoint[];
  22353. /** @hidden */
  22354. _preparationId: number;
  22355. /**
  22356. * Gets the name of the block
  22357. */
  22358. get name(): string;
  22359. /**
  22360. * Sets the name of the block. Will check if the name is valid.
  22361. */
  22362. set name(newName: string);
  22363. /**
  22364. * Gets or sets the unique id of the node
  22365. */
  22366. uniqueId: number;
  22367. /**
  22368. * Gets or sets the comments associated with this block
  22369. */
  22370. comments: string;
  22371. /**
  22372. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22373. */
  22374. get isUnique(): boolean;
  22375. /**
  22376. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22377. */
  22378. get isFinalMerger(): boolean;
  22379. /**
  22380. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22381. */
  22382. get isInput(): boolean;
  22383. /**
  22384. * Gets or sets the build Id
  22385. */
  22386. get buildId(): number;
  22387. set buildId(value: number);
  22388. /**
  22389. * Gets or sets the target of the block
  22390. */
  22391. get target(): NodeMaterialBlockTargets;
  22392. set target(value: NodeMaterialBlockTargets);
  22393. /**
  22394. * Gets the list of input points
  22395. */
  22396. get inputs(): NodeMaterialConnectionPoint[];
  22397. /** Gets the list of output points */
  22398. get outputs(): NodeMaterialConnectionPoint[];
  22399. /**
  22400. * Find an input by its name
  22401. * @param name defines the name of the input to look for
  22402. * @returns the input or null if not found
  22403. */
  22404. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22405. /**
  22406. * Find an output by its name
  22407. * @param name defines the name of the outputto look for
  22408. * @returns the output or null if not found
  22409. */
  22410. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22411. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22412. visibleInInspector: boolean;
  22413. /**
  22414. * Creates a new NodeMaterialBlock
  22415. * @param name defines the block name
  22416. * @param target defines the target of that block (Vertex by default)
  22417. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22418. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22419. */
  22420. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22421. /**
  22422. * Initialize the block and prepare the context for build
  22423. * @param state defines the state that will be used for the build
  22424. */
  22425. initialize(state: NodeMaterialBuildState): void;
  22426. /**
  22427. * Bind data to effect. Will only be called for blocks with isBindable === true
  22428. * @param effect defines the effect to bind data to
  22429. * @param nodeMaterial defines the hosting NodeMaterial
  22430. * @param mesh defines the mesh that will be rendered
  22431. * @param subMesh defines the submesh that will be rendered
  22432. */
  22433. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22434. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22435. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22436. protected _writeFloat(value: number): string;
  22437. /**
  22438. * Gets the current class name e.g. "NodeMaterialBlock"
  22439. * @returns the class name
  22440. */
  22441. getClassName(): string;
  22442. /**
  22443. * Register a new input. Must be called inside a block constructor
  22444. * @param name defines the connection point name
  22445. * @param type defines the connection point type
  22446. * @param isOptional defines a boolean indicating that this input can be omitted
  22447. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22448. * @param point an already created connection point. If not provided, create a new one
  22449. * @returns the current block
  22450. */
  22451. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22452. /**
  22453. * Register a new output. Must be called inside a block constructor
  22454. * @param name defines the connection point name
  22455. * @param type defines the connection point type
  22456. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22457. * @param point an already created connection point. If not provided, create a new one
  22458. * @returns the current block
  22459. */
  22460. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22461. /**
  22462. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22463. * @param forOutput defines an optional connection point to check compatibility with
  22464. * @returns the first available input or null
  22465. */
  22466. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22467. /**
  22468. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22469. * @param forBlock defines an optional block to check compatibility with
  22470. * @returns the first available input or null
  22471. */
  22472. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22473. /**
  22474. * Gets the sibling of the given output
  22475. * @param current defines the current output
  22476. * @returns the next output in the list or null
  22477. */
  22478. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22479. /**
  22480. * Connect current block with another block
  22481. * @param other defines the block to connect with
  22482. * @param options define the various options to help pick the right connections
  22483. * @returns the current block
  22484. */
  22485. connectTo(other: NodeMaterialBlock, options?: {
  22486. input?: string;
  22487. output?: string;
  22488. outputSwizzle?: string;
  22489. }): this | undefined;
  22490. protected _buildBlock(state: NodeMaterialBuildState): void;
  22491. /**
  22492. * Add uniforms, samplers and uniform buffers at compilation time
  22493. * @param state defines the state to update
  22494. * @param nodeMaterial defines the node material requesting the update
  22495. * @param defines defines the material defines to update
  22496. * @param uniformBuffers defines the list of uniform buffer names
  22497. */
  22498. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22499. /**
  22500. * Add potential fallbacks if shader compilation fails
  22501. * @param mesh defines the mesh to be rendered
  22502. * @param fallbacks defines the current prioritized list of fallbacks
  22503. */
  22504. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22505. /**
  22506. * Initialize defines for shader compilation
  22507. * @param mesh defines the mesh to be rendered
  22508. * @param nodeMaterial defines the node material requesting the update
  22509. * @param defines defines the material defines to update
  22510. * @param useInstances specifies that instances should be used
  22511. */
  22512. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22513. /**
  22514. * Update defines for shader compilation
  22515. * @param mesh defines the mesh to be rendered
  22516. * @param nodeMaterial defines the node material requesting the update
  22517. * @param defines defines the material defines to update
  22518. * @param useInstances specifies that instances should be used
  22519. * @param subMesh defines which submesh to render
  22520. */
  22521. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22522. /**
  22523. * Lets the block try to connect some inputs automatically
  22524. * @param material defines the hosting NodeMaterial
  22525. */
  22526. autoConfigure(material: NodeMaterial): void;
  22527. /**
  22528. * Function called when a block is declared as repeatable content generator
  22529. * @param vertexShaderState defines the current compilation state for the vertex shader
  22530. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22531. * @param mesh defines the mesh to be rendered
  22532. * @param defines defines the material defines to update
  22533. */
  22534. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22535. /**
  22536. * Checks if the block is ready
  22537. * @param mesh defines the mesh to be rendered
  22538. * @param nodeMaterial defines the node material requesting the update
  22539. * @param defines defines the material defines to update
  22540. * @param useInstances specifies that instances should be used
  22541. * @returns true if the block is ready
  22542. */
  22543. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22544. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22545. private _processBuild;
  22546. /**
  22547. * Validates the new name for the block node.
  22548. * @param newName the new name to be given to the node.
  22549. * @returns false if the name is a reserve word, else true.
  22550. */
  22551. validateBlockName(newName: string): boolean;
  22552. /**
  22553. * Compile the current node and generate the shader code
  22554. * @param state defines the current compilation state (uniforms, samplers, current string)
  22555. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22556. * @returns true if already built
  22557. */
  22558. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22559. protected _inputRename(name: string): string;
  22560. protected _outputRename(name: string): string;
  22561. protected _dumpPropertiesCode(): string;
  22562. /** @hidden */
  22563. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22564. /** @hidden */
  22565. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22566. /**
  22567. * Clone the current block to a new identical block
  22568. * @param scene defines the hosting scene
  22569. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22570. * @returns a copy of the current block
  22571. */
  22572. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22573. /**
  22574. * Serializes this block in a JSON representation
  22575. * @returns the serialized block object
  22576. */
  22577. serialize(): any;
  22578. /** @hidden */
  22579. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22580. private _deserializePortDisplayNamesAndExposedOnFrame;
  22581. /**
  22582. * Release resources
  22583. */
  22584. dispose(): void;
  22585. }
  22586. }
  22587. declare module "babylonjs/Materials/pushMaterial" {
  22588. import { Nullable } from "babylonjs/types";
  22589. import { Scene } from "babylonjs/scene";
  22590. import { Matrix } from "babylonjs/Maths/math.vector";
  22591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22592. import { Mesh } from "babylonjs/Meshes/mesh";
  22593. import { Material } from "babylonjs/Materials/material";
  22594. import { Effect } from "babylonjs/Materials/effect";
  22595. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22596. /**
  22597. * Base class of materials working in push mode in babylon JS
  22598. * @hidden
  22599. */
  22600. export class PushMaterial extends Material {
  22601. protected _activeEffect: Effect;
  22602. protected _normalMatrix: Matrix;
  22603. constructor(name: string, scene: Scene);
  22604. getEffect(): Effect;
  22605. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22606. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22607. /**
  22608. * Binds the given world matrix to the active effect
  22609. *
  22610. * @param world the matrix to bind
  22611. */
  22612. bindOnlyWorldMatrix(world: Matrix): void;
  22613. /**
  22614. * Binds the given normal matrix to the active effect
  22615. *
  22616. * @param normalMatrix the matrix to bind
  22617. */
  22618. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22619. bind(world: Matrix, mesh?: Mesh): void;
  22620. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22621. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22622. }
  22623. }
  22624. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22625. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22626. /**
  22627. * Root class for all node material optimizers
  22628. */
  22629. export class NodeMaterialOptimizer {
  22630. /**
  22631. * Function used to optimize a NodeMaterial graph
  22632. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22633. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22634. */
  22635. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22636. }
  22637. }
  22638. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22640. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22641. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22642. import { Scene } from "babylonjs/scene";
  22643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22644. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22645. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22646. /**
  22647. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22648. */
  22649. export class TransformBlock extends NodeMaterialBlock {
  22650. /**
  22651. * Defines the value to use to complement W value to transform it to a Vector4
  22652. */
  22653. complementW: number;
  22654. /**
  22655. * Defines the value to use to complement z value to transform it to a Vector4
  22656. */
  22657. complementZ: number;
  22658. /**
  22659. * Creates a new TransformBlock
  22660. * @param name defines the block name
  22661. */
  22662. constructor(name: string);
  22663. /**
  22664. * Gets the current class name
  22665. * @returns the class name
  22666. */
  22667. getClassName(): string;
  22668. /**
  22669. * Gets the vector input
  22670. */
  22671. get vector(): NodeMaterialConnectionPoint;
  22672. /**
  22673. * Gets the output component
  22674. */
  22675. get output(): NodeMaterialConnectionPoint;
  22676. /**
  22677. * Gets the xyz output component
  22678. */
  22679. get xyz(): NodeMaterialConnectionPoint;
  22680. /**
  22681. * Gets the matrix transform input
  22682. */
  22683. get transform(): NodeMaterialConnectionPoint;
  22684. protected _buildBlock(state: NodeMaterialBuildState): this;
  22685. /**
  22686. * Update defines for shader compilation
  22687. * @param mesh defines the mesh to be rendered
  22688. * @param nodeMaterial defines the node material requesting the update
  22689. * @param defines defines the material defines to update
  22690. * @param useInstances specifies that instances should be used
  22691. * @param subMesh defines which submesh to render
  22692. */
  22693. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22694. serialize(): any;
  22695. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22696. protected _dumpPropertiesCode(): string;
  22697. }
  22698. }
  22699. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22700. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22701. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22702. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22703. /**
  22704. * Block used to output the vertex position
  22705. */
  22706. export class VertexOutputBlock extends NodeMaterialBlock {
  22707. /**
  22708. * Creates a new VertexOutputBlock
  22709. * @param name defines the block name
  22710. */
  22711. constructor(name: string);
  22712. /**
  22713. * Gets the current class name
  22714. * @returns the class name
  22715. */
  22716. getClassName(): string;
  22717. /**
  22718. * Gets the vector input component
  22719. */
  22720. get vector(): NodeMaterialConnectionPoint;
  22721. protected _buildBlock(state: NodeMaterialBuildState): this;
  22722. }
  22723. }
  22724. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22725. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22726. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22728. /**
  22729. * Block used to output the final color
  22730. */
  22731. export class FragmentOutputBlock extends NodeMaterialBlock {
  22732. /**
  22733. * Create a new FragmentOutputBlock
  22734. * @param name defines the block name
  22735. */
  22736. constructor(name: string);
  22737. /**
  22738. * Gets the current class name
  22739. * @returns the class name
  22740. */
  22741. getClassName(): string;
  22742. /**
  22743. * Gets the rgba input component
  22744. */
  22745. get rgba(): NodeMaterialConnectionPoint;
  22746. /**
  22747. * Gets the rgb input component
  22748. */
  22749. get rgb(): NodeMaterialConnectionPoint;
  22750. /**
  22751. * Gets the a input component
  22752. */
  22753. get a(): NodeMaterialConnectionPoint;
  22754. protected _buildBlock(state: NodeMaterialBuildState): this;
  22755. }
  22756. }
  22757. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22759. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22760. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22761. /**
  22762. * Block used for the particle ramp gradient section
  22763. */
  22764. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22765. /**
  22766. * Create a new ParticleRampGradientBlock
  22767. * @param name defines the block name
  22768. */
  22769. constructor(name: string);
  22770. /**
  22771. * Gets the current class name
  22772. * @returns the class name
  22773. */
  22774. getClassName(): string;
  22775. /**
  22776. * Gets the color input component
  22777. */
  22778. get color(): NodeMaterialConnectionPoint;
  22779. /**
  22780. * Gets the rampColor output component
  22781. */
  22782. get rampColor(): NodeMaterialConnectionPoint;
  22783. /**
  22784. * Initialize the block and prepare the context for build
  22785. * @param state defines the state that will be used for the build
  22786. */
  22787. initialize(state: NodeMaterialBuildState): void;
  22788. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22789. }
  22790. }
  22791. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22792. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22793. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22794. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22795. /**
  22796. * Block used for the particle blend multiply section
  22797. */
  22798. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22799. /**
  22800. * Create a new ParticleBlendMultiplyBlock
  22801. * @param name defines the block name
  22802. */
  22803. constructor(name: string);
  22804. /**
  22805. * Gets the current class name
  22806. * @returns the class name
  22807. */
  22808. getClassName(): string;
  22809. /**
  22810. * Gets the color input component
  22811. */
  22812. get color(): NodeMaterialConnectionPoint;
  22813. /**
  22814. * Gets the alphaTexture input component
  22815. */
  22816. get alphaTexture(): NodeMaterialConnectionPoint;
  22817. /**
  22818. * Gets the alphaColor input component
  22819. */
  22820. get alphaColor(): NodeMaterialConnectionPoint;
  22821. /**
  22822. * Gets the blendColor output component
  22823. */
  22824. get blendColor(): NodeMaterialConnectionPoint;
  22825. /**
  22826. * Initialize the block and prepare the context for build
  22827. * @param state defines the state that will be used for the build
  22828. */
  22829. initialize(state: NodeMaterialBuildState): void;
  22830. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22831. }
  22832. }
  22833. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22837. /**
  22838. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22839. */
  22840. export class VectorMergerBlock extends NodeMaterialBlock {
  22841. /**
  22842. * Create a new VectorMergerBlock
  22843. * @param name defines the block name
  22844. */
  22845. constructor(name: string);
  22846. /**
  22847. * Gets the current class name
  22848. * @returns the class name
  22849. */
  22850. getClassName(): string;
  22851. /**
  22852. * Gets the xyz component (input)
  22853. */
  22854. get xyzIn(): NodeMaterialConnectionPoint;
  22855. /**
  22856. * Gets the xy component (input)
  22857. */
  22858. get xyIn(): NodeMaterialConnectionPoint;
  22859. /**
  22860. * Gets the x component (input)
  22861. */
  22862. get x(): NodeMaterialConnectionPoint;
  22863. /**
  22864. * Gets the y component (input)
  22865. */
  22866. get y(): NodeMaterialConnectionPoint;
  22867. /**
  22868. * Gets the z component (input)
  22869. */
  22870. get z(): NodeMaterialConnectionPoint;
  22871. /**
  22872. * Gets the w component (input)
  22873. */
  22874. get w(): NodeMaterialConnectionPoint;
  22875. /**
  22876. * Gets the xyzw component (output)
  22877. */
  22878. get xyzw(): NodeMaterialConnectionPoint;
  22879. /**
  22880. * Gets the xyz component (output)
  22881. */
  22882. get xyzOut(): NodeMaterialConnectionPoint;
  22883. /**
  22884. * Gets the xy component (output)
  22885. */
  22886. get xyOut(): NodeMaterialConnectionPoint;
  22887. /**
  22888. * Gets the xy component (output)
  22889. * @deprecated Please use xyOut instead.
  22890. */
  22891. get xy(): NodeMaterialConnectionPoint;
  22892. /**
  22893. * Gets the xyz component (output)
  22894. * @deprecated Please use xyzOut instead.
  22895. */
  22896. get xyz(): NodeMaterialConnectionPoint;
  22897. protected _buildBlock(state: NodeMaterialBuildState): this;
  22898. }
  22899. }
  22900. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22902. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22904. import { Vector2 } from "babylonjs/Maths/math.vector";
  22905. import { Scene } from "babylonjs/scene";
  22906. /**
  22907. * Block used to remap a float from a range to a new one
  22908. */
  22909. export class RemapBlock extends NodeMaterialBlock {
  22910. /**
  22911. * Gets or sets the source range
  22912. */
  22913. sourceRange: Vector2;
  22914. /**
  22915. * Gets or sets the target range
  22916. */
  22917. targetRange: Vector2;
  22918. /**
  22919. * Creates a new RemapBlock
  22920. * @param name defines the block name
  22921. */
  22922. constructor(name: string);
  22923. /**
  22924. * Gets the current class name
  22925. * @returns the class name
  22926. */
  22927. getClassName(): string;
  22928. /**
  22929. * Gets the input component
  22930. */
  22931. get input(): NodeMaterialConnectionPoint;
  22932. /**
  22933. * Gets the source min input component
  22934. */
  22935. get sourceMin(): NodeMaterialConnectionPoint;
  22936. /**
  22937. * Gets the source max input component
  22938. */
  22939. get sourceMax(): NodeMaterialConnectionPoint;
  22940. /**
  22941. * Gets the target min input component
  22942. */
  22943. get targetMin(): NodeMaterialConnectionPoint;
  22944. /**
  22945. * Gets the target max input component
  22946. */
  22947. get targetMax(): NodeMaterialConnectionPoint;
  22948. /**
  22949. * Gets the output component
  22950. */
  22951. get output(): NodeMaterialConnectionPoint;
  22952. protected _buildBlock(state: NodeMaterialBuildState): this;
  22953. protected _dumpPropertiesCode(): string;
  22954. serialize(): any;
  22955. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22956. }
  22957. }
  22958. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22959. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22960. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22961. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22962. /**
  22963. * Block used to multiply 2 values
  22964. */
  22965. export class MultiplyBlock extends NodeMaterialBlock {
  22966. /**
  22967. * Creates a new MultiplyBlock
  22968. * @param name defines the block name
  22969. */
  22970. constructor(name: string);
  22971. /**
  22972. * Gets the current class name
  22973. * @returns the class name
  22974. */
  22975. getClassName(): string;
  22976. /**
  22977. * Gets the left operand input component
  22978. */
  22979. get left(): NodeMaterialConnectionPoint;
  22980. /**
  22981. * Gets the right operand input component
  22982. */
  22983. get right(): NodeMaterialConnectionPoint;
  22984. /**
  22985. * Gets the output component
  22986. */
  22987. get output(): NodeMaterialConnectionPoint;
  22988. protected _buildBlock(state: NodeMaterialBuildState): this;
  22989. }
  22990. }
  22991. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22992. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22995. /**
  22996. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22997. */
  22998. export class ColorSplitterBlock extends NodeMaterialBlock {
  22999. /**
  23000. * Create a new ColorSplitterBlock
  23001. * @param name defines the block name
  23002. */
  23003. constructor(name: string);
  23004. /**
  23005. * Gets the current class name
  23006. * @returns the class name
  23007. */
  23008. getClassName(): string;
  23009. /**
  23010. * Gets the rgba component (input)
  23011. */
  23012. get rgba(): NodeMaterialConnectionPoint;
  23013. /**
  23014. * Gets the rgb component (input)
  23015. */
  23016. get rgbIn(): NodeMaterialConnectionPoint;
  23017. /**
  23018. * Gets the rgb component (output)
  23019. */
  23020. get rgbOut(): NodeMaterialConnectionPoint;
  23021. /**
  23022. * Gets the r component (output)
  23023. */
  23024. get r(): NodeMaterialConnectionPoint;
  23025. /**
  23026. * Gets the g component (output)
  23027. */
  23028. get g(): NodeMaterialConnectionPoint;
  23029. /**
  23030. * Gets the b component (output)
  23031. */
  23032. get b(): NodeMaterialConnectionPoint;
  23033. /**
  23034. * Gets the a component (output)
  23035. */
  23036. get a(): NodeMaterialConnectionPoint;
  23037. protected _inputRename(name: string): string;
  23038. protected _outputRename(name: string): string;
  23039. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23040. }
  23041. }
  23042. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23046. import { Scene } from "babylonjs/scene";
  23047. /**
  23048. * Operations supported by the Trigonometry block
  23049. */
  23050. export enum TrigonometryBlockOperations {
  23051. /** Cos */
  23052. Cos = 0,
  23053. /** Sin */
  23054. Sin = 1,
  23055. /** Abs */
  23056. Abs = 2,
  23057. /** Exp */
  23058. Exp = 3,
  23059. /** Exp2 */
  23060. Exp2 = 4,
  23061. /** Round */
  23062. Round = 5,
  23063. /** Floor */
  23064. Floor = 6,
  23065. /** Ceiling */
  23066. Ceiling = 7,
  23067. /** Square root */
  23068. Sqrt = 8,
  23069. /** Log */
  23070. Log = 9,
  23071. /** Tangent */
  23072. Tan = 10,
  23073. /** Arc tangent */
  23074. ArcTan = 11,
  23075. /** Arc cosinus */
  23076. ArcCos = 12,
  23077. /** Arc sinus */
  23078. ArcSin = 13,
  23079. /** Fraction */
  23080. Fract = 14,
  23081. /** Sign */
  23082. Sign = 15,
  23083. /** To radians (from degrees) */
  23084. Radians = 16,
  23085. /** To degrees (from radians) */
  23086. Degrees = 17
  23087. }
  23088. /**
  23089. * Block used to apply trigonometry operation to floats
  23090. */
  23091. export class TrigonometryBlock extends NodeMaterialBlock {
  23092. /**
  23093. * Gets or sets the operation applied by the block
  23094. */
  23095. operation: TrigonometryBlockOperations;
  23096. /**
  23097. * Creates a new TrigonometryBlock
  23098. * @param name defines the block name
  23099. */
  23100. constructor(name: string);
  23101. /**
  23102. * Gets the current class name
  23103. * @returns the class name
  23104. */
  23105. getClassName(): string;
  23106. /**
  23107. * Gets the input component
  23108. */
  23109. get input(): NodeMaterialConnectionPoint;
  23110. /**
  23111. * Gets the output component
  23112. */
  23113. get output(): NodeMaterialConnectionPoint;
  23114. protected _buildBlock(state: NodeMaterialBuildState): this;
  23115. serialize(): any;
  23116. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23117. protected _dumpPropertiesCode(): string;
  23118. }
  23119. }
  23120. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23122. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23123. import { Scene } from "babylonjs/scene";
  23124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23125. import { Matrix } from "babylonjs/Maths/math.vector";
  23126. import { Mesh } from "babylonjs/Meshes/mesh";
  23127. import { Engine } from "babylonjs/Engines/engine";
  23128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23129. import { Observable } from "babylonjs/Misc/observable";
  23130. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23131. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23132. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23133. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23134. import { Nullable } from "babylonjs/types";
  23135. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23136. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23137. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23138. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23139. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23140. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23141. import { Effect } from "babylonjs/Materials/effect";
  23142. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23143. import { Camera } from "babylonjs/Cameras/camera";
  23144. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23145. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23146. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23147. /**
  23148. * Interface used to configure the node material editor
  23149. */
  23150. export interface INodeMaterialEditorOptions {
  23151. /** Define the URl to load node editor script */
  23152. editorURL?: string;
  23153. }
  23154. /** @hidden */
  23155. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23156. NORMAL: boolean;
  23157. TANGENT: boolean;
  23158. UV1: boolean;
  23159. /** BONES */
  23160. NUM_BONE_INFLUENCERS: number;
  23161. BonesPerMesh: number;
  23162. BONETEXTURE: boolean;
  23163. /** MORPH TARGETS */
  23164. MORPHTARGETS: boolean;
  23165. MORPHTARGETS_NORMAL: boolean;
  23166. MORPHTARGETS_TANGENT: boolean;
  23167. MORPHTARGETS_UV: boolean;
  23168. NUM_MORPH_INFLUENCERS: number;
  23169. /** IMAGE PROCESSING */
  23170. IMAGEPROCESSING: boolean;
  23171. VIGNETTE: boolean;
  23172. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23173. VIGNETTEBLENDMODEOPAQUE: boolean;
  23174. TONEMAPPING: boolean;
  23175. TONEMAPPING_ACES: boolean;
  23176. CONTRAST: boolean;
  23177. EXPOSURE: boolean;
  23178. COLORCURVES: boolean;
  23179. COLORGRADING: boolean;
  23180. COLORGRADING3D: boolean;
  23181. SAMPLER3DGREENDEPTH: boolean;
  23182. SAMPLER3DBGRMAP: boolean;
  23183. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23184. /** MISC. */
  23185. BUMPDIRECTUV: number;
  23186. constructor();
  23187. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23188. }
  23189. /**
  23190. * Class used to configure NodeMaterial
  23191. */
  23192. export interface INodeMaterialOptions {
  23193. /**
  23194. * Defines if blocks should emit comments
  23195. */
  23196. emitComments: boolean;
  23197. }
  23198. /**
  23199. * Class used to create a node based material built by assembling shader blocks
  23200. */
  23201. export class NodeMaterial extends PushMaterial {
  23202. private static _BuildIdGenerator;
  23203. private _options;
  23204. private _vertexCompilationState;
  23205. private _fragmentCompilationState;
  23206. private _sharedData;
  23207. private _buildId;
  23208. private _buildWasSuccessful;
  23209. private _cachedWorldViewMatrix;
  23210. private _cachedWorldViewProjectionMatrix;
  23211. private _optimizers;
  23212. private _animationFrame;
  23213. /** Define the Url to load node editor script */
  23214. static EditorURL: string;
  23215. /** Define the Url to load snippets */
  23216. static SnippetUrl: string;
  23217. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23218. static IgnoreTexturesAtLoadTime: boolean;
  23219. private BJSNODEMATERIALEDITOR;
  23220. /** Get the inspector from bundle or global */
  23221. private _getGlobalNodeMaterialEditor;
  23222. /**
  23223. * Snippet ID if the material was created from the snippet server
  23224. */
  23225. snippetId: string;
  23226. /**
  23227. * Gets or sets data used by visual editor
  23228. * @see https://nme.babylonjs.com
  23229. */
  23230. editorData: any;
  23231. /**
  23232. * 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)
  23233. */
  23234. ignoreAlpha: boolean;
  23235. /**
  23236. * Defines the maximum number of lights that can be used in the material
  23237. */
  23238. maxSimultaneousLights: number;
  23239. /**
  23240. * Observable raised when the material is built
  23241. */
  23242. onBuildObservable: Observable<NodeMaterial>;
  23243. /**
  23244. * Gets or sets the root nodes of the material vertex shader
  23245. */
  23246. _vertexOutputNodes: NodeMaterialBlock[];
  23247. /**
  23248. * Gets or sets the root nodes of the material fragment (pixel) shader
  23249. */
  23250. _fragmentOutputNodes: NodeMaterialBlock[];
  23251. /** Gets or sets options to control the node material overall behavior */
  23252. get options(): INodeMaterialOptions;
  23253. set options(options: INodeMaterialOptions);
  23254. /**
  23255. * Default configuration related to image processing available in the standard Material.
  23256. */
  23257. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23258. /**
  23259. * Gets the image processing configuration used either in this material.
  23260. */
  23261. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23262. /**
  23263. * Sets the Default image processing configuration used either in the this material.
  23264. *
  23265. * If sets to null, the scene one is in use.
  23266. */
  23267. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23268. /**
  23269. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23270. */
  23271. attachedBlocks: NodeMaterialBlock[];
  23272. /**
  23273. * Specifies the mode of the node material
  23274. * @hidden
  23275. */
  23276. _mode: NodeMaterialModes;
  23277. /**
  23278. * Gets the mode property
  23279. */
  23280. get mode(): NodeMaterialModes;
  23281. /**
  23282. * Create a new node based material
  23283. * @param name defines the material name
  23284. * @param scene defines the hosting scene
  23285. * @param options defines creation option
  23286. */
  23287. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23288. /**
  23289. * Gets the current class name of the material e.g. "NodeMaterial"
  23290. * @returns the class name
  23291. */
  23292. getClassName(): string;
  23293. /**
  23294. * Keep track of the image processing observer to allow dispose and replace.
  23295. */
  23296. private _imageProcessingObserver;
  23297. /**
  23298. * Attaches a new image processing configuration to the Standard Material.
  23299. * @param configuration
  23300. */
  23301. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23302. /**
  23303. * Get a block by its name
  23304. * @param name defines the name of the block to retrieve
  23305. * @returns the required block or null if not found
  23306. */
  23307. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23308. /**
  23309. * Get a block by its name
  23310. * @param predicate defines the predicate used to find the good candidate
  23311. * @returns the required block or null if not found
  23312. */
  23313. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23314. /**
  23315. * Get an input block by its name
  23316. * @param predicate defines the predicate used to find the good candidate
  23317. * @returns the required input block or null if not found
  23318. */
  23319. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23320. /**
  23321. * Gets the list of input blocks attached to this material
  23322. * @returns an array of InputBlocks
  23323. */
  23324. getInputBlocks(): InputBlock[];
  23325. /**
  23326. * Adds a new optimizer to the list of optimizers
  23327. * @param optimizer defines the optimizers to add
  23328. * @returns the current material
  23329. */
  23330. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23331. /**
  23332. * Remove an optimizer from the list of optimizers
  23333. * @param optimizer defines the optimizers to remove
  23334. * @returns the current material
  23335. */
  23336. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23337. /**
  23338. * Add a new block to the list of output nodes
  23339. * @param node defines the node to add
  23340. * @returns the current material
  23341. */
  23342. addOutputNode(node: NodeMaterialBlock): this;
  23343. /**
  23344. * Remove a block from the list of root nodes
  23345. * @param node defines the node to remove
  23346. * @returns the current material
  23347. */
  23348. removeOutputNode(node: NodeMaterialBlock): this;
  23349. private _addVertexOutputNode;
  23350. private _removeVertexOutputNode;
  23351. private _addFragmentOutputNode;
  23352. private _removeFragmentOutputNode;
  23353. /**
  23354. * Specifies if the material will require alpha blending
  23355. * @returns a boolean specifying if alpha blending is needed
  23356. */
  23357. needAlphaBlending(): boolean;
  23358. /**
  23359. * Specifies if this material should be rendered in alpha test mode
  23360. * @returns a boolean specifying if an alpha test is needed.
  23361. */
  23362. needAlphaTesting(): boolean;
  23363. private _initializeBlock;
  23364. private _resetDualBlocks;
  23365. /**
  23366. * Remove a block from the current node material
  23367. * @param block defines the block to remove
  23368. */
  23369. removeBlock(block: NodeMaterialBlock): void;
  23370. /**
  23371. * Build the material and generates the inner effect
  23372. * @param verbose defines if the build should log activity
  23373. */
  23374. build(verbose?: boolean): void;
  23375. /**
  23376. * Runs an otpimization phase to try to improve the shader code
  23377. */
  23378. optimize(): void;
  23379. private _prepareDefinesForAttributes;
  23380. /**
  23381. * Create a post process from the material
  23382. * @param camera The camera to apply the render pass to.
  23383. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23385. * @param engine The engine which the post process will be applied. (default: current engine)
  23386. * @param reusable If the post process can be reused on the same frame. (default: false)
  23387. * @param textureType Type of textures used when performing the post process. (default: 0)
  23388. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23389. * @returns the post process created
  23390. */
  23391. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23392. /**
  23393. * Create the post process effect from the material
  23394. * @param postProcess The post process to create the effect for
  23395. */
  23396. createEffectForPostProcess(postProcess: PostProcess): void;
  23397. private _createEffectForPostProcess;
  23398. /**
  23399. * Create a new procedural texture based on this node material
  23400. * @param size defines the size of the texture
  23401. * @param scene defines the hosting scene
  23402. * @returns the new procedural texture attached to this node material
  23403. */
  23404. createProceduralTexture(size: number | {
  23405. width: number;
  23406. height: number;
  23407. layers?: number;
  23408. }, scene: Scene): Nullable<ProceduralTexture>;
  23409. private _createEffectForParticles;
  23410. private _checkInternals;
  23411. /**
  23412. * Create the effect to be used as the custom effect for a particle system
  23413. * @param particleSystem Particle system to create the effect for
  23414. * @param onCompiled defines a function to call when the effect creation is successful
  23415. * @param onError defines a function to call when the effect creation has failed
  23416. */
  23417. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23418. private _processDefines;
  23419. /**
  23420. * Get if the submesh is ready to be used and all its information available.
  23421. * Child classes can use it to update shaders
  23422. * @param mesh defines the mesh to check
  23423. * @param subMesh defines which submesh to check
  23424. * @param useInstances specifies that instances should be used
  23425. * @returns a boolean indicating that the submesh is ready or not
  23426. */
  23427. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23428. /**
  23429. * Get a string representing the shaders built by the current node graph
  23430. */
  23431. get compiledShaders(): string;
  23432. /**
  23433. * Binds the world matrix to the material
  23434. * @param world defines the world transformation matrix
  23435. */
  23436. bindOnlyWorldMatrix(world: Matrix): void;
  23437. /**
  23438. * Binds the submesh to this material by preparing the effect and shader to draw
  23439. * @param world defines the world transformation matrix
  23440. * @param mesh defines the mesh containing the submesh
  23441. * @param subMesh defines the submesh to bind the material to
  23442. */
  23443. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23444. /**
  23445. * Gets the active textures from the material
  23446. * @returns an array of textures
  23447. */
  23448. getActiveTextures(): BaseTexture[];
  23449. /**
  23450. * Gets the list of texture blocks
  23451. * @returns an array of texture blocks
  23452. */
  23453. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23454. /**
  23455. * Specifies if the material uses a texture
  23456. * @param texture defines the texture to check against the material
  23457. * @returns a boolean specifying if the material uses the texture
  23458. */
  23459. hasTexture(texture: BaseTexture): boolean;
  23460. /**
  23461. * Disposes the material
  23462. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23463. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23464. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23465. */
  23466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23467. /** Creates the node editor window. */
  23468. private _createNodeEditor;
  23469. /**
  23470. * Launch the node material editor
  23471. * @param config Define the configuration of the editor
  23472. * @return a promise fulfilled when the node editor is visible
  23473. */
  23474. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23475. /**
  23476. * Clear the current material
  23477. */
  23478. clear(): void;
  23479. /**
  23480. * Clear the current material and set it to a default state
  23481. */
  23482. setToDefault(): void;
  23483. /**
  23484. * Clear the current material and set it to a default state for post process
  23485. */
  23486. setToDefaultPostProcess(): void;
  23487. /**
  23488. * Clear the current material and set it to a default state for procedural texture
  23489. */
  23490. setToDefaultProceduralTexture(): void;
  23491. /**
  23492. * Clear the current material and set it to a default state for particle
  23493. */
  23494. setToDefaultParticle(): void;
  23495. /**
  23496. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23497. * @param url defines the url to load from
  23498. * @returns a promise that will fullfil when the material is fully loaded
  23499. */
  23500. loadAsync(url: string): Promise<void>;
  23501. private _gatherBlocks;
  23502. /**
  23503. * Generate a string containing the code declaration required to create an equivalent of this material
  23504. * @returns a string
  23505. */
  23506. generateCode(): string;
  23507. /**
  23508. * Serializes this material in a JSON representation
  23509. * @returns the serialized material object
  23510. */
  23511. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23512. private _restoreConnections;
  23513. /**
  23514. * Clear the current graph and load a new one from a serialization object
  23515. * @param source defines the JSON representation of the material
  23516. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23517. * @param merge defines whether or not the source must be merged or replace the current content
  23518. */
  23519. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23520. /**
  23521. * Makes a duplicate of the current material.
  23522. * @param name - name to use for the new material.
  23523. */
  23524. clone(name: string): NodeMaterial;
  23525. /**
  23526. * Creates a node material from parsed material data
  23527. * @param source defines the JSON representation of the material
  23528. * @param scene defines the hosting scene
  23529. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23530. * @returns a new node material
  23531. */
  23532. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23533. /**
  23534. * Creates a node material from a snippet saved in a remote file
  23535. * @param name defines the name of the material to create
  23536. * @param url defines the url to load from
  23537. * @param scene defines the hosting scene
  23538. * @returns a promise that will resolve to the new node material
  23539. */
  23540. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23541. /**
  23542. * Creates a node material from a snippet saved by the node material editor
  23543. * @param snippetId defines the snippet to load
  23544. * @param scene defines the hosting scene
  23545. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23546. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23547. * @returns a promise that will resolve to the new node material
  23548. */
  23549. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23550. /**
  23551. * Creates a new node material set to default basic configuration
  23552. * @param name defines the name of the material
  23553. * @param scene defines the hosting scene
  23554. * @returns a new NodeMaterial
  23555. */
  23556. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23557. }
  23558. }
  23559. declare module "babylonjs/PostProcesses/postProcess" {
  23560. import { Nullable } from "babylonjs/types";
  23561. import { SmartArray } from "babylonjs/Misc/smartArray";
  23562. import { Observable } from "babylonjs/Misc/observable";
  23563. import { Vector2 } from "babylonjs/Maths/math.vector";
  23564. import { Camera } from "babylonjs/Cameras/camera";
  23565. import { Effect } from "babylonjs/Materials/effect";
  23566. import "babylonjs/Shaders/postprocess.vertex";
  23567. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23568. import { Engine } from "babylonjs/Engines/engine";
  23569. import { Color4 } from "babylonjs/Maths/math.color";
  23570. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23571. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23572. import { Scene } from "babylonjs/scene";
  23573. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23574. /**
  23575. * Size options for a post process
  23576. */
  23577. export type PostProcessOptions = {
  23578. width: number;
  23579. height: number;
  23580. };
  23581. /**
  23582. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23583. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23584. */
  23585. export class PostProcess {
  23586. /**
  23587. * Gets or sets the unique id of the post process
  23588. */
  23589. uniqueId: number;
  23590. /** Name of the PostProcess. */
  23591. name: string;
  23592. /**
  23593. * Width of the texture to apply the post process on
  23594. */
  23595. width: number;
  23596. /**
  23597. * Height of the texture to apply the post process on
  23598. */
  23599. height: number;
  23600. /**
  23601. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23602. */
  23603. nodeMaterialSource: Nullable<NodeMaterial>;
  23604. /**
  23605. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23606. * @hidden
  23607. */
  23608. _outputTexture: Nullable<InternalTexture>;
  23609. /**
  23610. * Sampling mode used by the shader
  23611. * See https://doc.babylonjs.com/classes/3.1/texture
  23612. */
  23613. renderTargetSamplingMode: number;
  23614. /**
  23615. * Clear color to use when screen clearing
  23616. */
  23617. clearColor: Color4;
  23618. /**
  23619. * If the buffer needs to be cleared before applying the post process. (default: true)
  23620. * Should be set to false if shader will overwrite all previous pixels.
  23621. */
  23622. autoClear: boolean;
  23623. /**
  23624. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23625. */
  23626. alphaMode: number;
  23627. /**
  23628. * Sets the setAlphaBlendConstants of the babylon engine
  23629. */
  23630. alphaConstants: Color4;
  23631. /**
  23632. * Animations to be used for the post processing
  23633. */
  23634. animations: import("babylonjs/Animations/animation").Animation[];
  23635. /**
  23636. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23637. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23638. */
  23639. enablePixelPerfectMode: boolean;
  23640. /**
  23641. * Force the postprocess to be applied without taking in account viewport
  23642. */
  23643. forceFullscreenViewport: boolean;
  23644. /**
  23645. * List of inspectable custom properties (used by the Inspector)
  23646. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23647. */
  23648. inspectableCustomProperties: IInspectable[];
  23649. /**
  23650. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23651. *
  23652. * | Value | Type | Description |
  23653. * | ----- | ----------------------------------- | ----------- |
  23654. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23655. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23656. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23657. *
  23658. */
  23659. scaleMode: number;
  23660. /**
  23661. * Force textures to be a power of two (default: false)
  23662. */
  23663. alwaysForcePOT: boolean;
  23664. private _samples;
  23665. /**
  23666. * Number of sample textures (default: 1)
  23667. */
  23668. get samples(): number;
  23669. set samples(n: number);
  23670. /**
  23671. * Modify the scale of the post process to be the same as the viewport (default: false)
  23672. */
  23673. adaptScaleToCurrentViewport: boolean;
  23674. private _camera;
  23675. protected _scene: Scene;
  23676. private _engine;
  23677. private _options;
  23678. private _reusable;
  23679. private _textureType;
  23680. private _textureFormat;
  23681. /**
  23682. * Smart array of input and output textures for the post process.
  23683. * @hidden
  23684. */
  23685. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23686. /**
  23687. * The index in _textures that corresponds to the output texture.
  23688. * @hidden
  23689. */
  23690. _currentRenderTextureInd: number;
  23691. private _effect;
  23692. private _samplers;
  23693. private _fragmentUrl;
  23694. private _vertexUrl;
  23695. private _parameters;
  23696. private _scaleRatio;
  23697. protected _indexParameters: any;
  23698. private _shareOutputWithPostProcess;
  23699. private _texelSize;
  23700. private _forcedOutputTexture;
  23701. /**
  23702. * Returns the fragment url or shader name used in the post process.
  23703. * @returns the fragment url or name in the shader store.
  23704. */
  23705. getEffectName(): string;
  23706. /**
  23707. * An event triggered when the postprocess is activated.
  23708. */
  23709. onActivateObservable: Observable<Camera>;
  23710. private _onActivateObserver;
  23711. /**
  23712. * A function that is added to the onActivateObservable
  23713. */
  23714. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23715. /**
  23716. * An event triggered when the postprocess changes its size.
  23717. */
  23718. onSizeChangedObservable: Observable<PostProcess>;
  23719. private _onSizeChangedObserver;
  23720. /**
  23721. * A function that is added to the onSizeChangedObservable
  23722. */
  23723. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23724. /**
  23725. * An event triggered when the postprocess applies its effect.
  23726. */
  23727. onApplyObservable: Observable<Effect>;
  23728. private _onApplyObserver;
  23729. /**
  23730. * A function that is added to the onApplyObservable
  23731. */
  23732. set onApply(callback: (effect: Effect) => void);
  23733. /**
  23734. * An event triggered before rendering the postprocess
  23735. */
  23736. onBeforeRenderObservable: Observable<Effect>;
  23737. private _onBeforeRenderObserver;
  23738. /**
  23739. * A function that is added to the onBeforeRenderObservable
  23740. */
  23741. set onBeforeRender(callback: (effect: Effect) => void);
  23742. /**
  23743. * An event triggered after rendering the postprocess
  23744. */
  23745. onAfterRenderObservable: Observable<Effect>;
  23746. private _onAfterRenderObserver;
  23747. /**
  23748. * A function that is added to the onAfterRenderObservable
  23749. */
  23750. set onAfterRender(callback: (efect: Effect) => void);
  23751. /**
  23752. * 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
  23753. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23754. */
  23755. get inputTexture(): InternalTexture;
  23756. set inputTexture(value: InternalTexture);
  23757. /**
  23758. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23759. * the only way to unset it is to use this function to restore its internal state
  23760. */
  23761. restoreDefaultInputTexture(): void;
  23762. /**
  23763. * Gets the camera which post process is applied to.
  23764. * @returns The camera the post process is applied to.
  23765. */
  23766. getCamera(): Camera;
  23767. /**
  23768. * Gets the texel size of the postprocess.
  23769. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23770. */
  23771. get texelSize(): Vector2;
  23772. /**
  23773. * Creates a new instance PostProcess
  23774. * @param name The name of the PostProcess.
  23775. * @param fragmentUrl The url of the fragment shader to be used.
  23776. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23777. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23778. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23779. * @param camera The camera to apply the render pass to.
  23780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23781. * @param engine The engine which the post process will be applied. (default: current engine)
  23782. * @param reusable If the post process can be reused on the same frame. (default: false)
  23783. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23784. * @param textureType Type of textures used when performing the post process. (default: 0)
  23785. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23786. * @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
  23787. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23788. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23789. */
  23790. 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);
  23791. /**
  23792. * Gets a string identifying the name of the class
  23793. * @returns "PostProcess" string
  23794. */
  23795. getClassName(): string;
  23796. /**
  23797. * Gets the engine which this post process belongs to.
  23798. * @returns The engine the post process was enabled with.
  23799. */
  23800. getEngine(): Engine;
  23801. /**
  23802. * The effect that is created when initializing the post process.
  23803. * @returns The created effect corresponding the the postprocess.
  23804. */
  23805. getEffect(): Effect;
  23806. /**
  23807. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23808. * @param postProcess The post process to share the output with.
  23809. * @returns This post process.
  23810. */
  23811. shareOutputWith(postProcess: PostProcess): PostProcess;
  23812. /**
  23813. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23814. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23815. */
  23816. useOwnOutput(): void;
  23817. /**
  23818. * Updates the effect with the current post process compile time values and recompiles the shader.
  23819. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23820. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23821. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23822. * @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
  23823. * @param onCompiled Called when the shader has been compiled.
  23824. * @param onError Called if there is an error when compiling a shader.
  23825. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23826. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23827. */
  23828. 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;
  23829. /**
  23830. * The post process is reusable if it can be used multiple times within one frame.
  23831. * @returns If the post process is reusable
  23832. */
  23833. isReusable(): boolean;
  23834. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23835. markTextureDirty(): void;
  23836. /**
  23837. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23838. * 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.
  23839. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23840. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23841. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23842. * @returns The target texture that was bound to be written to.
  23843. */
  23844. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23845. /**
  23846. * If the post process is supported.
  23847. */
  23848. get isSupported(): boolean;
  23849. /**
  23850. * The aspect ratio of the output texture.
  23851. */
  23852. get aspectRatio(): number;
  23853. /**
  23854. * Get a value indicating if the post-process is ready to be used
  23855. * @returns true if the post-process is ready (shader is compiled)
  23856. */
  23857. isReady(): boolean;
  23858. /**
  23859. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23860. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23861. */
  23862. apply(): Nullable<Effect>;
  23863. private _disposeTextures;
  23864. /**
  23865. * Disposes the post process.
  23866. * @param camera The camera to dispose the post process on.
  23867. */
  23868. dispose(camera?: Camera): void;
  23869. /**
  23870. * Serializes the particle system to a JSON object
  23871. * @returns the JSON object
  23872. */
  23873. serialize(): any;
  23874. /**
  23875. * Creates a material from parsed material data
  23876. * @param parsedPostProcess defines parsed post process data
  23877. * @param scene defines the hosting scene
  23878. * @param rootUrl defines the root URL to use to load textures
  23879. * @returns a new post process
  23880. */
  23881. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23882. }
  23883. }
  23884. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23885. /** @hidden */
  23886. export var kernelBlurVaryingDeclaration: {
  23887. name: string;
  23888. shader: string;
  23889. };
  23890. }
  23891. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23892. /** @hidden */
  23893. export var kernelBlurFragment: {
  23894. name: string;
  23895. shader: string;
  23896. };
  23897. }
  23898. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23899. /** @hidden */
  23900. export var kernelBlurFragment2: {
  23901. name: string;
  23902. shader: string;
  23903. };
  23904. }
  23905. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23906. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23907. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23908. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23909. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23910. /** @hidden */
  23911. export var kernelBlurPixelShader: {
  23912. name: string;
  23913. shader: string;
  23914. };
  23915. }
  23916. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23917. /** @hidden */
  23918. export var kernelBlurVertex: {
  23919. name: string;
  23920. shader: string;
  23921. };
  23922. }
  23923. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23924. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23925. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23926. /** @hidden */
  23927. export var kernelBlurVertexShader: {
  23928. name: string;
  23929. shader: string;
  23930. };
  23931. }
  23932. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23933. import { Vector2 } from "babylonjs/Maths/math.vector";
  23934. import { Nullable } from "babylonjs/types";
  23935. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23936. import { Camera } from "babylonjs/Cameras/camera";
  23937. import { Effect } from "babylonjs/Materials/effect";
  23938. import { Engine } from "babylonjs/Engines/engine";
  23939. import "babylonjs/Shaders/kernelBlur.fragment";
  23940. import "babylonjs/Shaders/kernelBlur.vertex";
  23941. import { Scene } from "babylonjs/scene";
  23942. /**
  23943. * The Blur Post Process which blurs an image based on a kernel and direction.
  23944. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23945. */
  23946. export class BlurPostProcess extends PostProcess {
  23947. private blockCompilation;
  23948. protected _kernel: number;
  23949. protected _idealKernel: number;
  23950. protected _packedFloat: boolean;
  23951. private _staticDefines;
  23952. /** The direction in which to blur the image. */
  23953. direction: Vector2;
  23954. /**
  23955. * Sets the length in pixels of the blur sample region
  23956. */
  23957. set kernel(v: number);
  23958. /**
  23959. * Gets the length in pixels of the blur sample region
  23960. */
  23961. get kernel(): number;
  23962. /**
  23963. * Sets wether or not the blur needs to unpack/repack floats
  23964. */
  23965. set packedFloat(v: boolean);
  23966. /**
  23967. * Gets wether or not the blur is unpacking/repacking floats
  23968. */
  23969. get packedFloat(): boolean;
  23970. /**
  23971. * Gets a string identifying the name of the class
  23972. * @returns "BlurPostProcess" string
  23973. */
  23974. getClassName(): string;
  23975. /**
  23976. * Creates a new instance BlurPostProcess
  23977. * @param name The name of the effect.
  23978. * @param direction The direction in which to blur the image.
  23979. * @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.
  23980. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23981. * @param camera The camera to apply the render pass to.
  23982. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23983. * @param engine The engine which the post process will be applied. (default: current engine)
  23984. * @param reusable If the post process can be reused on the same frame. (default: false)
  23985. * @param textureType Type of textures used when performing the post process. (default: 0)
  23986. * @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)
  23987. */
  23988. 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);
  23989. /**
  23990. * Updates the effect with the current post process compile time values and recompiles the shader.
  23991. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23992. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23993. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23994. * @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
  23995. * @param onCompiled Called when the shader has been compiled.
  23996. * @param onError Called if there is an error when compiling a shader.
  23997. */
  23998. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23999. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24000. /**
  24001. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24002. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24003. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24004. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24005. * The gaps between physical kernels are compensated for in the weighting of the samples
  24006. * @param idealKernel Ideal blur kernel.
  24007. * @return Nearest best kernel.
  24008. */
  24009. protected _nearestBestKernel(idealKernel: number): number;
  24010. /**
  24011. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24012. * @param x The point on the Gaussian distribution to sample.
  24013. * @return the value of the Gaussian function at x.
  24014. */
  24015. protected _gaussianWeight(x: number): number;
  24016. /**
  24017. * Generates a string that can be used as a floating point number in GLSL.
  24018. * @param x Value to print.
  24019. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24020. * @return GLSL float string.
  24021. */
  24022. protected _glslFloat(x: number, decimalFigures?: number): string;
  24023. /** @hidden */
  24024. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24025. }
  24026. }
  24027. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24028. import { Scene } from "babylonjs/scene";
  24029. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24030. import { Plane } from "babylonjs/Maths/math.plane";
  24031. /**
  24032. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24033. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24034. * You can then easily use it as a reflectionTexture on a flat surface.
  24035. * In case the surface is not a plane, please consider relying on reflection probes.
  24036. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24037. */
  24038. export class MirrorTexture extends RenderTargetTexture {
  24039. private scene;
  24040. /**
  24041. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24042. * 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.
  24043. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24044. */
  24045. mirrorPlane: Plane;
  24046. /**
  24047. * Define the blur ratio used to blur the reflection if needed.
  24048. */
  24049. set blurRatio(value: number);
  24050. get blurRatio(): number;
  24051. /**
  24052. * Define the adaptive blur kernel used to blur the reflection if needed.
  24053. * This will autocompute the closest best match for the `blurKernel`
  24054. */
  24055. set adaptiveBlurKernel(value: number);
  24056. /**
  24057. * Define the blur kernel used to blur the reflection if needed.
  24058. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24059. */
  24060. set blurKernel(value: number);
  24061. /**
  24062. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24063. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24064. */
  24065. set blurKernelX(value: number);
  24066. get blurKernelX(): number;
  24067. /**
  24068. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24069. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24070. */
  24071. set blurKernelY(value: number);
  24072. get blurKernelY(): number;
  24073. private _autoComputeBlurKernel;
  24074. protected _onRatioRescale(): void;
  24075. private _updateGammaSpace;
  24076. private _imageProcessingConfigChangeObserver;
  24077. private _transformMatrix;
  24078. private _mirrorMatrix;
  24079. private _savedViewMatrix;
  24080. private _blurX;
  24081. private _blurY;
  24082. private _adaptiveBlurKernel;
  24083. private _blurKernelX;
  24084. private _blurKernelY;
  24085. private _blurRatio;
  24086. /**
  24087. * Instantiates a Mirror Texture.
  24088. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24089. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24090. * You can then easily use it as a reflectionTexture on a flat surface.
  24091. * In case the surface is not a plane, please consider relying on reflection probes.
  24092. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24093. * @param name
  24094. * @param size
  24095. * @param scene
  24096. * @param generateMipMaps
  24097. * @param type
  24098. * @param samplingMode
  24099. * @param generateDepthBuffer
  24100. */
  24101. constructor(name: string, size: number | {
  24102. width: number;
  24103. height: number;
  24104. } | {
  24105. ratio: number;
  24106. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24107. private _preparePostProcesses;
  24108. /**
  24109. * Clone the mirror texture.
  24110. * @returns the cloned texture
  24111. */
  24112. clone(): MirrorTexture;
  24113. /**
  24114. * Serialize the texture to a JSON representation you could use in Parse later on
  24115. * @returns the serialized JSON representation
  24116. */
  24117. serialize(): any;
  24118. /**
  24119. * Dispose the texture and release its associated resources.
  24120. */
  24121. dispose(): void;
  24122. }
  24123. }
  24124. declare module "babylonjs/Materials/Textures/texture" {
  24125. import { Observable } from "babylonjs/Misc/observable";
  24126. import { Nullable } from "babylonjs/types";
  24127. import { Matrix } from "babylonjs/Maths/math.vector";
  24128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24129. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24130. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24131. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24132. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24133. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24134. import { Scene } from "babylonjs/scene";
  24135. /**
  24136. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24137. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24138. */
  24139. export class Texture extends BaseTexture {
  24140. /**
  24141. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24142. */
  24143. static SerializeBuffers: boolean;
  24144. /** @hidden */
  24145. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24146. /** @hidden */
  24147. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24148. /** @hidden */
  24149. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24150. /** nearest is mag = nearest and min = nearest and mip = linear */
  24151. static readonly NEAREST_SAMPLINGMODE: number;
  24152. /** nearest is mag = nearest and min = nearest and mip = linear */
  24153. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24154. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24155. static readonly BILINEAR_SAMPLINGMODE: number;
  24156. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24157. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24158. /** Trilinear is mag = linear and min = linear and mip = linear */
  24159. static readonly TRILINEAR_SAMPLINGMODE: number;
  24160. /** Trilinear is mag = linear and min = linear and mip = linear */
  24161. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24162. /** mag = nearest and min = nearest and mip = nearest */
  24163. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24164. /** mag = nearest and min = linear and mip = nearest */
  24165. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24166. /** mag = nearest and min = linear and mip = linear */
  24167. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24168. /** mag = nearest and min = linear and mip = none */
  24169. static readonly NEAREST_LINEAR: number;
  24170. /** mag = nearest and min = nearest and mip = none */
  24171. static readonly NEAREST_NEAREST: number;
  24172. /** mag = linear and min = nearest and mip = nearest */
  24173. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24174. /** mag = linear and min = nearest and mip = linear */
  24175. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24176. /** mag = linear and min = linear and mip = none */
  24177. static readonly LINEAR_LINEAR: number;
  24178. /** mag = linear and min = nearest and mip = none */
  24179. static readonly LINEAR_NEAREST: number;
  24180. /** Explicit coordinates mode */
  24181. static readonly EXPLICIT_MODE: number;
  24182. /** Spherical coordinates mode */
  24183. static readonly SPHERICAL_MODE: number;
  24184. /** Planar coordinates mode */
  24185. static readonly PLANAR_MODE: number;
  24186. /** Cubic coordinates mode */
  24187. static readonly CUBIC_MODE: number;
  24188. /** Projection coordinates mode */
  24189. static readonly PROJECTION_MODE: number;
  24190. /** Inverse Cubic coordinates mode */
  24191. static readonly SKYBOX_MODE: number;
  24192. /** Inverse Cubic coordinates mode */
  24193. static readonly INVCUBIC_MODE: number;
  24194. /** Equirectangular coordinates mode */
  24195. static readonly EQUIRECTANGULAR_MODE: number;
  24196. /** Equirectangular Fixed coordinates mode */
  24197. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24198. /** Equirectangular Fixed Mirrored coordinates mode */
  24199. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24200. /** Texture is not repeating outside of 0..1 UVs */
  24201. static readonly CLAMP_ADDRESSMODE: number;
  24202. /** Texture is repeating outside of 0..1 UVs */
  24203. static readonly WRAP_ADDRESSMODE: number;
  24204. /** Texture is repeating and mirrored */
  24205. static readonly MIRROR_ADDRESSMODE: number;
  24206. /**
  24207. * 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
  24208. */
  24209. static UseSerializedUrlIfAny: boolean;
  24210. /**
  24211. * Define the url of the texture.
  24212. */
  24213. url: Nullable<string>;
  24214. /**
  24215. * Define an offset on the texture to offset the u coordinates of the UVs
  24216. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24217. */
  24218. uOffset: number;
  24219. /**
  24220. * Define an offset on the texture to offset the v coordinates of the UVs
  24221. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24222. */
  24223. vOffset: number;
  24224. /**
  24225. * Define an offset on the texture to scale the u coordinates of the UVs
  24226. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24227. */
  24228. uScale: number;
  24229. /**
  24230. * Define an offset on the texture to scale the v coordinates of the UVs
  24231. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24232. */
  24233. vScale: number;
  24234. /**
  24235. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24236. * @see https://doc.babylonjs.com/how_to/more_materials
  24237. */
  24238. uAng: number;
  24239. /**
  24240. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24241. * @see https://doc.babylonjs.com/how_to/more_materials
  24242. */
  24243. vAng: number;
  24244. /**
  24245. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24246. * @see https://doc.babylonjs.com/how_to/more_materials
  24247. */
  24248. wAng: number;
  24249. /**
  24250. * Defines the center of rotation (U)
  24251. */
  24252. uRotationCenter: number;
  24253. /**
  24254. * Defines the center of rotation (V)
  24255. */
  24256. vRotationCenter: number;
  24257. /**
  24258. * Defines the center of rotation (W)
  24259. */
  24260. wRotationCenter: number;
  24261. /**
  24262. * Are mip maps generated for this texture or not.
  24263. */
  24264. get noMipmap(): boolean;
  24265. /**
  24266. * List of inspectable custom properties (used by the Inspector)
  24267. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24268. */
  24269. inspectableCustomProperties: Nullable<IInspectable[]>;
  24270. private _noMipmap;
  24271. /** @hidden */
  24272. _invertY: boolean;
  24273. private _rowGenerationMatrix;
  24274. private _cachedTextureMatrix;
  24275. private _projectionModeMatrix;
  24276. private _t0;
  24277. private _t1;
  24278. private _t2;
  24279. private _cachedUOffset;
  24280. private _cachedVOffset;
  24281. private _cachedUScale;
  24282. private _cachedVScale;
  24283. private _cachedUAng;
  24284. private _cachedVAng;
  24285. private _cachedWAng;
  24286. private _cachedProjectionMatrixId;
  24287. private _cachedCoordinatesMode;
  24288. /** @hidden */
  24289. protected _initialSamplingMode: number;
  24290. /** @hidden */
  24291. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24292. private _deleteBuffer;
  24293. protected _format: Nullable<number>;
  24294. private _delayedOnLoad;
  24295. private _delayedOnError;
  24296. private _mimeType?;
  24297. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24298. get mimeType(): string | undefined;
  24299. /**
  24300. * Observable triggered once the texture has been loaded.
  24301. */
  24302. onLoadObservable: Observable<Texture>;
  24303. protected _isBlocking: boolean;
  24304. /**
  24305. * Is the texture preventing material to render while loading.
  24306. * If false, a default texture will be used instead of the loading one during the preparation step.
  24307. */
  24308. set isBlocking(value: boolean);
  24309. get isBlocking(): boolean;
  24310. /**
  24311. * Get the current sampling mode associated with the texture.
  24312. */
  24313. get samplingMode(): number;
  24314. /**
  24315. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24316. */
  24317. get invertY(): boolean;
  24318. /**
  24319. * Instantiates a new texture.
  24320. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24321. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24322. * @param url defines the url of the picture to load as a texture
  24323. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24324. * @param noMipmap defines if the texture will require mip maps or not
  24325. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24326. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24327. * @param onLoad defines a callback triggered when the texture has been loaded
  24328. * @param onError defines a callback triggered when an error occurred during the loading session
  24329. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24330. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24331. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24332. * @param mimeType defines an optional mime type information
  24333. */
  24334. 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);
  24335. /**
  24336. * Update the url (and optional buffer) of this texture if url was null during construction.
  24337. * @param url the url of the texture
  24338. * @param buffer the buffer of the texture (defaults to null)
  24339. * @param onLoad callback called when the texture is loaded (defaults to null)
  24340. */
  24341. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24342. /**
  24343. * Finish the loading sequence of a texture flagged as delayed load.
  24344. * @hidden
  24345. */
  24346. delayLoad(): void;
  24347. private _prepareRowForTextureGeneration;
  24348. /**
  24349. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24350. * @returns the transform matrix of the texture.
  24351. */
  24352. getTextureMatrix(uBase?: number): Matrix;
  24353. /**
  24354. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24355. * @returns The reflection texture transform
  24356. */
  24357. getReflectionTextureMatrix(): Matrix;
  24358. /**
  24359. * Clones the texture.
  24360. * @returns the cloned texture
  24361. */
  24362. clone(): Texture;
  24363. /**
  24364. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24365. * @returns The JSON representation of the texture
  24366. */
  24367. serialize(): any;
  24368. /**
  24369. * Get the current class name of the texture useful for serialization or dynamic coding.
  24370. * @returns "Texture"
  24371. */
  24372. getClassName(): string;
  24373. /**
  24374. * Dispose the texture and release its associated resources.
  24375. */
  24376. dispose(): void;
  24377. /**
  24378. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24379. * @param parsedTexture Define the JSON representation of the texture
  24380. * @param scene Define the scene the parsed texture should be instantiated in
  24381. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24382. * @returns The parsed texture if successful
  24383. */
  24384. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24385. /**
  24386. * Creates a texture from its base 64 representation.
  24387. * @param data Define the base64 payload without the data: prefix
  24388. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24389. * @param scene Define the scene the texture should belong to
  24390. * @param noMipmap Forces the texture to not create mip map information if true
  24391. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24392. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24393. * @param onLoad define a callback triggered when the texture has been loaded
  24394. * @param onError define a callback triggered when an error occurred during the loading session
  24395. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24396. * @returns the created texture
  24397. */
  24398. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24399. /**
  24400. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24401. * @param data Define the base64 payload without the data: prefix
  24402. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24403. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24404. * @param scene Define the scene the texture should belong to
  24405. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24406. * @param noMipmap Forces the texture to not create mip map information if true
  24407. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24408. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24409. * @param onLoad define a callback triggered when the texture has been loaded
  24410. * @param onError define a callback triggered when an error occurred during the loading session
  24411. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24412. * @returns the created texture
  24413. */
  24414. 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;
  24415. }
  24416. }
  24417. declare module "babylonjs/PostProcesses/postProcessManager" {
  24418. import { Nullable } from "babylonjs/types";
  24419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24420. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24421. import { Scene } from "babylonjs/scene";
  24422. /**
  24423. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24424. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24425. */
  24426. export class PostProcessManager {
  24427. private _scene;
  24428. private _indexBuffer;
  24429. private _vertexBuffers;
  24430. /**
  24431. * Creates a new instance PostProcess
  24432. * @param scene The scene that the post process is associated with.
  24433. */
  24434. constructor(scene: Scene);
  24435. private _prepareBuffers;
  24436. private _buildIndexBuffer;
  24437. /**
  24438. * Rebuilds the vertex buffers of the manager.
  24439. * @hidden
  24440. */
  24441. _rebuild(): void;
  24442. /**
  24443. * Prepares a frame to be run through a post process.
  24444. * @param sourceTexture The input texture to the post procesess. (default: null)
  24445. * @param postProcesses An array of post processes to be run. (default: null)
  24446. * @returns True if the post processes were able to be run.
  24447. * @hidden
  24448. */
  24449. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24450. /**
  24451. * Manually render a set of post processes to a texture.
  24452. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24453. * @param postProcesses An array of post processes to be run.
  24454. * @param targetTexture The target texture to render to.
  24455. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24456. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24457. * @param lodLevel defines which lod of the texture to render to
  24458. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24459. */
  24460. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24461. /**
  24462. * Finalize the result of the output of the postprocesses.
  24463. * @param doNotPresent If true the result will not be displayed to the screen.
  24464. * @param targetTexture The target texture to render to.
  24465. * @param faceIndex The index of the face to bind the target texture to.
  24466. * @param postProcesses The array of post processes to render.
  24467. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24468. * @hidden
  24469. */
  24470. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24471. /**
  24472. * Disposes of the post process manager.
  24473. */
  24474. dispose(): void;
  24475. }
  24476. }
  24477. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24478. import { Observable } from "babylonjs/Misc/observable";
  24479. import { SmartArray } from "babylonjs/Misc/smartArray";
  24480. import { Nullable, Immutable } from "babylonjs/types";
  24481. import { Camera } from "babylonjs/Cameras/camera";
  24482. import { Scene } from "babylonjs/scene";
  24483. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24484. import { Color4 } from "babylonjs/Maths/math.color";
  24485. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24487. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24488. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24489. import { Texture } from "babylonjs/Materials/Textures/texture";
  24490. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24491. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24492. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24493. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24494. import { Engine } from "babylonjs/Engines/engine";
  24495. /**
  24496. * This Helps creating a texture that will be created from a camera in your scene.
  24497. * It is basically a dynamic texture that could be used to create special effects for instance.
  24498. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24499. */
  24500. export class RenderTargetTexture extends Texture {
  24501. /**
  24502. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24503. */
  24504. static readonly REFRESHRATE_RENDER_ONCE: number;
  24505. /**
  24506. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24507. */
  24508. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24509. /**
  24510. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24511. * the central point of your effect and can save a lot of performances.
  24512. */
  24513. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24514. /**
  24515. * Use this predicate to dynamically define the list of mesh you want to render.
  24516. * If set, the renderList property will be overwritten.
  24517. */
  24518. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24519. private _renderList;
  24520. /**
  24521. * Use this list to define the list of mesh you want to render.
  24522. */
  24523. get renderList(): Nullable<Array<AbstractMesh>>;
  24524. set renderList(value: Nullable<Array<AbstractMesh>>);
  24525. /**
  24526. * Use this function to overload the renderList array at rendering time.
  24527. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24528. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24529. * the cube (if the RTT is a cube, else layerOrFace=0).
  24530. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24531. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24532. * hold dummy elements!
  24533. */
  24534. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24535. private _hookArray;
  24536. /**
  24537. * Define if particles should be rendered in your texture.
  24538. */
  24539. renderParticles: boolean;
  24540. /**
  24541. * Define if sprites should be rendered in your texture.
  24542. */
  24543. renderSprites: boolean;
  24544. /**
  24545. * Define the camera used to render the texture.
  24546. */
  24547. activeCamera: Nullable<Camera>;
  24548. /**
  24549. * Override the mesh isReady function with your own one.
  24550. */
  24551. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24552. /**
  24553. * Override the render function of the texture with your own one.
  24554. */
  24555. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24556. /**
  24557. * Define if camera post processes should be use while rendering the texture.
  24558. */
  24559. useCameraPostProcesses: boolean;
  24560. /**
  24561. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24562. */
  24563. ignoreCameraViewport: boolean;
  24564. private _postProcessManager;
  24565. private _postProcesses;
  24566. private _resizeObserver;
  24567. /**
  24568. * An event triggered when the texture is unbind.
  24569. */
  24570. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24571. /**
  24572. * An event triggered when the texture is unbind.
  24573. */
  24574. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24575. private _onAfterUnbindObserver;
  24576. /**
  24577. * Set a after unbind callback in the texture.
  24578. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24579. */
  24580. set onAfterUnbind(callback: () => void);
  24581. /**
  24582. * An event triggered before rendering the texture
  24583. */
  24584. onBeforeRenderObservable: Observable<number>;
  24585. private _onBeforeRenderObserver;
  24586. /**
  24587. * Set a before render callback in the texture.
  24588. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24589. */
  24590. set onBeforeRender(callback: (faceIndex: number) => void);
  24591. /**
  24592. * An event triggered after rendering the texture
  24593. */
  24594. onAfterRenderObservable: Observable<number>;
  24595. private _onAfterRenderObserver;
  24596. /**
  24597. * Set a after render callback in the texture.
  24598. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24599. */
  24600. set onAfterRender(callback: (faceIndex: number) => void);
  24601. /**
  24602. * An event triggered after the texture clear
  24603. */
  24604. onClearObservable: Observable<Engine>;
  24605. private _onClearObserver;
  24606. /**
  24607. * Set a clear callback in the texture.
  24608. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24609. */
  24610. set onClear(callback: (Engine: Engine) => void);
  24611. /**
  24612. * An event triggered when the texture is resized.
  24613. */
  24614. onResizeObservable: Observable<RenderTargetTexture>;
  24615. /**
  24616. * Define the clear color of the Render Target if it should be different from the scene.
  24617. */
  24618. clearColor: Color4;
  24619. protected _size: number | {
  24620. width: number;
  24621. height: number;
  24622. layers?: number;
  24623. };
  24624. protected _initialSizeParameter: number | {
  24625. width: number;
  24626. height: number;
  24627. } | {
  24628. ratio: number;
  24629. };
  24630. protected _sizeRatio: Nullable<number>;
  24631. /** @hidden */
  24632. _generateMipMaps: boolean;
  24633. protected _renderingManager: RenderingManager;
  24634. /** @hidden */
  24635. _waitingRenderList?: string[];
  24636. protected _doNotChangeAspectRatio: boolean;
  24637. protected _currentRefreshId: number;
  24638. protected _refreshRate: number;
  24639. protected _textureMatrix: Matrix;
  24640. protected _samples: number;
  24641. protected _renderTargetOptions: RenderTargetCreationOptions;
  24642. /**
  24643. * Gets render target creation options that were used.
  24644. */
  24645. get renderTargetOptions(): RenderTargetCreationOptions;
  24646. protected _onRatioRescale(): void;
  24647. /**
  24648. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24649. * It must define where the camera used to render the texture is set
  24650. */
  24651. boundingBoxPosition: Vector3;
  24652. private _boundingBoxSize;
  24653. /**
  24654. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24655. * When defined, the cubemap will switch to local mode
  24656. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24657. * @example https://www.babylonjs-playground.com/#RNASML
  24658. */
  24659. set boundingBoxSize(value: Vector3);
  24660. get boundingBoxSize(): Vector3;
  24661. /**
  24662. * In case the RTT has been created with a depth texture, get the associated
  24663. * depth texture.
  24664. * Otherwise, return null.
  24665. */
  24666. get depthStencilTexture(): Nullable<InternalTexture>;
  24667. /**
  24668. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24669. * or used a shadow, depth texture...
  24670. * @param name The friendly name of the texture
  24671. * @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)
  24672. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24673. * @param generateMipMaps True if mip maps need to be generated after render.
  24674. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24675. * @param type The type of the buffer in the RTT (int, half float, float...)
  24676. * @param isCube True if a cube texture needs to be created
  24677. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24678. * @param generateDepthBuffer True to generate a depth buffer
  24679. * @param generateStencilBuffer True to generate a stencil buffer
  24680. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24681. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24682. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24683. */
  24684. constructor(name: string, size: number | {
  24685. width: number;
  24686. height: number;
  24687. layers?: number;
  24688. } | {
  24689. ratio: number;
  24690. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24691. /**
  24692. * Creates a depth stencil texture.
  24693. * This is only available in WebGL 2 or with the depth texture extension available.
  24694. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24695. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24696. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24697. */
  24698. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24699. private _processSizeParameter;
  24700. /**
  24701. * Define the number of samples to use in case of MSAA.
  24702. * It defaults to one meaning no MSAA has been enabled.
  24703. */
  24704. get samples(): number;
  24705. set samples(value: number);
  24706. /**
  24707. * Resets the refresh counter of the texture and start bak from scratch.
  24708. * Could be useful to regenerate the texture if it is setup to render only once.
  24709. */
  24710. resetRefreshCounter(): void;
  24711. /**
  24712. * Define the refresh rate of the texture or the rendering frequency.
  24713. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24714. */
  24715. get refreshRate(): number;
  24716. set refreshRate(value: number);
  24717. /**
  24718. * Adds a post process to the render target rendering passes.
  24719. * @param postProcess define the post process to add
  24720. */
  24721. addPostProcess(postProcess: PostProcess): void;
  24722. /**
  24723. * Clear all the post processes attached to the render target
  24724. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24725. */
  24726. clearPostProcesses(dispose?: boolean): void;
  24727. /**
  24728. * Remove one of the post process from the list of attached post processes to the texture
  24729. * @param postProcess define the post process to remove from the list
  24730. */
  24731. removePostProcess(postProcess: PostProcess): void;
  24732. /** @hidden */
  24733. _shouldRender(): boolean;
  24734. /**
  24735. * Gets the actual render size of the texture.
  24736. * @returns the width of the render size
  24737. */
  24738. getRenderSize(): number;
  24739. /**
  24740. * Gets the actual render width of the texture.
  24741. * @returns the width of the render size
  24742. */
  24743. getRenderWidth(): number;
  24744. /**
  24745. * Gets the actual render height of the texture.
  24746. * @returns the height of the render size
  24747. */
  24748. getRenderHeight(): number;
  24749. /**
  24750. * Gets the actual number of layers of the texture.
  24751. * @returns the number of layers
  24752. */
  24753. getRenderLayers(): number;
  24754. /**
  24755. * Get if the texture can be rescaled or not.
  24756. */
  24757. get canRescale(): boolean;
  24758. /**
  24759. * Resize the texture using a ratio.
  24760. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24761. */
  24762. scale(ratio: number): void;
  24763. /**
  24764. * Get the texture reflection matrix used to rotate/transform the reflection.
  24765. * @returns the reflection matrix
  24766. */
  24767. getReflectionTextureMatrix(): Matrix;
  24768. /**
  24769. * Resize the texture to a new desired size.
  24770. * Be carrefull as it will recreate all the data in the new texture.
  24771. * @param size Define the new size. It can be:
  24772. * - a number for squared texture,
  24773. * - an object containing { width: number, height: number }
  24774. * - or an object containing a ratio { ratio: number }
  24775. */
  24776. resize(size: number | {
  24777. width: number;
  24778. height: number;
  24779. } | {
  24780. ratio: number;
  24781. }): void;
  24782. private _defaultRenderListPrepared;
  24783. /**
  24784. * Renders all the objects from the render list into the texture.
  24785. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24786. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24787. */
  24788. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24789. private _bestReflectionRenderTargetDimension;
  24790. private _prepareRenderingManager;
  24791. /**
  24792. * @hidden
  24793. * @param faceIndex face index to bind to if this is a cubetexture
  24794. * @param layer defines the index of the texture to bind in the array
  24795. */
  24796. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24797. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24798. private renderToTarget;
  24799. /**
  24800. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24801. * This allowed control for front to back rendering or reversly depending of the special needs.
  24802. *
  24803. * @param renderingGroupId The rendering group id corresponding to its index
  24804. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24805. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24806. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24807. */
  24808. 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;
  24809. /**
  24810. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24811. *
  24812. * @param renderingGroupId The rendering group id corresponding to its index
  24813. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24814. */
  24815. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24816. /**
  24817. * Clones the texture.
  24818. * @returns the cloned texture
  24819. */
  24820. clone(): RenderTargetTexture;
  24821. /**
  24822. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24823. * @returns The JSON representation of the texture
  24824. */
  24825. serialize(): any;
  24826. /**
  24827. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24828. */
  24829. disposeFramebufferObjects(): void;
  24830. /**
  24831. * Dispose the texture and release its associated resources.
  24832. */
  24833. dispose(): void;
  24834. /** @hidden */
  24835. _rebuild(): void;
  24836. /**
  24837. * Clear the info related to rendering groups preventing retention point in material dispose.
  24838. */
  24839. freeRenderingGroups(): void;
  24840. /**
  24841. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24842. * @returns the view count
  24843. */
  24844. getViewCount(): number;
  24845. }
  24846. }
  24847. declare module "babylonjs/Misc/guid" {
  24848. /**
  24849. * Class used to manipulate GUIDs
  24850. */
  24851. export class GUID {
  24852. /**
  24853. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24854. * Be aware Math.random() could cause collisions, but:
  24855. * "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"
  24856. * @returns a pseudo random id
  24857. */
  24858. static RandomId(): string;
  24859. }
  24860. }
  24861. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24862. import { Nullable } from "babylonjs/types";
  24863. import { Scene } from "babylonjs/scene";
  24864. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24865. import { Material } from "babylonjs/Materials/material";
  24866. import { Effect } from "babylonjs/Materials/effect";
  24867. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24868. /**
  24869. * Options to be used when creating a shadow depth material
  24870. */
  24871. export interface IIOptionShadowDepthMaterial {
  24872. /** Variables in the vertex shader code that need to have their names remapped.
  24873. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24874. * "var_name" should be either: worldPos or vNormalW
  24875. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24876. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24877. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24878. */
  24879. remappedVariables?: string[];
  24880. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24881. standalone?: boolean;
  24882. }
  24883. /**
  24884. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24885. */
  24886. export class ShadowDepthWrapper {
  24887. private _scene;
  24888. private _options?;
  24889. private _baseMaterial;
  24890. private _onEffectCreatedObserver;
  24891. private _subMeshToEffect;
  24892. private _subMeshToDepthEffect;
  24893. private _meshes;
  24894. /** @hidden */
  24895. _matriceNames: any;
  24896. /** Gets the standalone status of the wrapper */
  24897. get standalone(): boolean;
  24898. /** Gets the base material the wrapper is built upon */
  24899. get baseMaterial(): Material;
  24900. /**
  24901. * Instantiate a new shadow depth wrapper.
  24902. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24903. * generate the shadow depth map. For more information, please refer to the documentation:
  24904. * https://doc.babylonjs.com/babylon101/shadows
  24905. * @param baseMaterial Material to wrap
  24906. * @param scene Define the scene the material belongs to
  24907. * @param options Options used to create the wrapper
  24908. */
  24909. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24910. /**
  24911. * Gets the effect to use to generate the depth map
  24912. * @param subMesh subMesh to get the effect for
  24913. * @param shadowGenerator shadow generator to get the effect for
  24914. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24915. */
  24916. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24917. /**
  24918. * Specifies that the submesh is ready to be used for depth rendering
  24919. * @param subMesh submesh to check
  24920. * @param defines the list of defines to take into account when checking the effect
  24921. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24922. * @param useInstances specifies that instances should be used
  24923. * @returns a boolean indicating that the submesh is ready or not
  24924. */
  24925. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24926. /**
  24927. * Disposes the resources
  24928. */
  24929. dispose(): void;
  24930. private _makeEffect;
  24931. }
  24932. }
  24933. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24934. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24935. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24936. import { Nullable } from "babylonjs/types";
  24937. module "babylonjs/Engines/thinEngine" {
  24938. interface ThinEngine {
  24939. /**
  24940. * Unbind a list of render target textures from the webGL context
  24941. * This is used only when drawBuffer extension or webGL2 are active
  24942. * @param textures defines the render target textures to unbind
  24943. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24944. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24945. */
  24946. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24947. /**
  24948. * Create a multi render target texture
  24949. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24950. * @param size defines the size of the texture
  24951. * @param options defines the creation options
  24952. * @returns the cube texture as an InternalTexture
  24953. */
  24954. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24955. /**
  24956. * Update the sample count for a given multiple render target texture
  24957. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24958. * @param textures defines the textures to update
  24959. * @param samples defines the sample count to set
  24960. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24961. */
  24962. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24963. /**
  24964. * Select a subsets of attachments to draw to.
  24965. * @param attachments gl attachments
  24966. */
  24967. bindAttachments(attachments: number[]): void;
  24968. }
  24969. }
  24970. }
  24971. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24972. import { Scene } from "babylonjs/scene";
  24973. import { Engine } from "babylonjs/Engines/engine";
  24974. import { Texture } from "babylonjs/Materials/Textures/texture";
  24975. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24976. import "babylonjs/Engines/Extensions/engine.multiRender";
  24977. /**
  24978. * Creation options of the multi render target texture.
  24979. */
  24980. export interface IMultiRenderTargetOptions {
  24981. /**
  24982. * Define if the texture needs to create mip maps after render.
  24983. */
  24984. generateMipMaps?: boolean;
  24985. /**
  24986. * Define the types of all the draw buffers we want to create
  24987. */
  24988. types?: number[];
  24989. /**
  24990. * Define the sampling modes of all the draw buffers we want to create
  24991. */
  24992. samplingModes?: number[];
  24993. /**
  24994. * Define if a depth buffer is required
  24995. */
  24996. generateDepthBuffer?: boolean;
  24997. /**
  24998. * Define if a stencil buffer is required
  24999. */
  25000. generateStencilBuffer?: boolean;
  25001. /**
  25002. * Define if a depth texture is required instead of a depth buffer
  25003. */
  25004. generateDepthTexture?: boolean;
  25005. /**
  25006. * Define the number of desired draw buffers
  25007. */
  25008. textureCount?: number;
  25009. /**
  25010. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25011. */
  25012. doNotChangeAspectRatio?: boolean;
  25013. /**
  25014. * Define the default type of the buffers we are creating
  25015. */
  25016. defaultType?: number;
  25017. }
  25018. /**
  25019. * A multi render target, like a render target provides the ability to render to a texture.
  25020. * Unlike the render target, it can render to several draw buffers in one draw.
  25021. * This is specially interesting in deferred rendering or for any effects requiring more than
  25022. * just one color from a single pass.
  25023. */
  25024. export class MultiRenderTarget extends RenderTargetTexture {
  25025. private _internalTextures;
  25026. private _textures;
  25027. private _multiRenderTargetOptions;
  25028. private _count;
  25029. /**
  25030. * Get if draw buffers are currently supported by the used hardware and browser.
  25031. */
  25032. get isSupported(): boolean;
  25033. /**
  25034. * Get the list of textures generated by the multi render target.
  25035. */
  25036. get textures(): Texture[];
  25037. /**
  25038. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  25039. */
  25040. get count(): number;
  25041. /**
  25042. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25043. */
  25044. get depthTexture(): Texture;
  25045. /**
  25046. * Set the wrapping mode on U of all the textures we are rendering to.
  25047. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25048. */
  25049. set wrapU(wrap: number);
  25050. /**
  25051. * Set the wrapping mode on V of all the textures we are rendering to.
  25052. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25053. */
  25054. set wrapV(wrap: number);
  25055. /**
  25056. * Instantiate a new multi render target texture.
  25057. * A multi render target, like a render target provides the ability to render to a texture.
  25058. * Unlike the render target, it can render to several draw buffers in one draw.
  25059. * This is specially interesting in deferred rendering or for any effects requiring more than
  25060. * just one color from a single pass.
  25061. * @param name Define the name of the texture
  25062. * @param size Define the size of the buffers to render to
  25063. * @param count Define the number of target we are rendering into
  25064. * @param scene Define the scene the texture belongs to
  25065. * @param options Define the options used to create the multi render target
  25066. */
  25067. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25068. private _initTypes;
  25069. /** @hidden */
  25070. _rebuild(forceFullRebuild?: boolean): void;
  25071. private _createInternalTextures;
  25072. private _createTextures;
  25073. /**
  25074. * Define the number of samples used if MSAA is enabled.
  25075. */
  25076. get samples(): number;
  25077. set samples(value: number);
  25078. /**
  25079. * Resize all the textures in the multi render target.
  25080. * Be careful as it will recreate all the data in the new texture.
  25081. * @param size Define the new size
  25082. */
  25083. resize(size: any): void;
  25084. /**
  25085. * Changes the number of render targets in this MRT
  25086. * Be careful as it will recreate all the data in the new texture.
  25087. * @param count new texture count
  25088. * @param options Specifies texture types and sampling modes for new textures
  25089. */
  25090. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  25091. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25092. /**
  25093. * Dispose the render targets and their associated resources
  25094. */
  25095. dispose(): void;
  25096. /**
  25097. * Release all the underlying texture used as draw buffers.
  25098. */
  25099. releaseInternalTextures(): void;
  25100. }
  25101. }
  25102. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  25103. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  25104. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25105. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  25106. /** @hidden */
  25107. export var imageProcessingPixelShader: {
  25108. name: string;
  25109. shader: string;
  25110. };
  25111. }
  25112. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  25113. import { Nullable } from "babylonjs/types";
  25114. import { Color4 } from "babylonjs/Maths/math.color";
  25115. import { Camera } from "babylonjs/Cameras/camera";
  25116. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25117. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  25118. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  25119. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25120. import { Engine } from "babylonjs/Engines/engine";
  25121. import "babylonjs/Shaders/imageProcessing.fragment";
  25122. import "babylonjs/Shaders/postprocess.vertex";
  25123. /**
  25124. * ImageProcessingPostProcess
  25125. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  25126. */
  25127. export class ImageProcessingPostProcess extends PostProcess {
  25128. /**
  25129. * Default configuration related to image processing available in the PBR Material.
  25130. */
  25131. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25132. /**
  25133. * Gets the image processing configuration used either in this material.
  25134. */
  25135. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25136. /**
  25137. * Sets the Default image processing configuration used either in the this material.
  25138. *
  25139. * If sets to null, the scene one is in use.
  25140. */
  25141. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25142. /**
  25143. * Keep track of the image processing observer to allow dispose and replace.
  25144. */
  25145. private _imageProcessingObserver;
  25146. /**
  25147. * Attaches a new image processing configuration to the PBR Material.
  25148. * @param configuration
  25149. */
  25150. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25151. /**
  25152. * If the post process is supported.
  25153. */
  25154. get isSupported(): boolean;
  25155. /**
  25156. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25157. */
  25158. get colorCurves(): Nullable<ColorCurves>;
  25159. /**
  25160. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25161. */
  25162. set colorCurves(value: Nullable<ColorCurves>);
  25163. /**
  25164. * Gets wether the color curves effect is enabled.
  25165. */
  25166. get colorCurvesEnabled(): boolean;
  25167. /**
  25168. * Sets wether the color curves effect is enabled.
  25169. */
  25170. set colorCurvesEnabled(value: boolean);
  25171. /**
  25172. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25173. */
  25174. get colorGradingTexture(): Nullable<BaseTexture>;
  25175. /**
  25176. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25177. */
  25178. set colorGradingTexture(value: Nullable<BaseTexture>);
  25179. /**
  25180. * Gets wether the color grading effect is enabled.
  25181. */
  25182. get colorGradingEnabled(): boolean;
  25183. /**
  25184. * Gets wether the color grading effect is enabled.
  25185. */
  25186. set colorGradingEnabled(value: boolean);
  25187. /**
  25188. * Gets exposure used in the effect.
  25189. */
  25190. get exposure(): number;
  25191. /**
  25192. * Sets exposure used in the effect.
  25193. */
  25194. set exposure(value: number);
  25195. /**
  25196. * Gets wether tonemapping is enabled or not.
  25197. */
  25198. get toneMappingEnabled(): boolean;
  25199. /**
  25200. * Sets wether tonemapping is enabled or not
  25201. */
  25202. set toneMappingEnabled(value: boolean);
  25203. /**
  25204. * Gets the type of tone mapping effect.
  25205. */
  25206. get toneMappingType(): number;
  25207. /**
  25208. * Sets the type of tone mapping effect.
  25209. */
  25210. set toneMappingType(value: number);
  25211. /**
  25212. * Gets contrast used in the effect.
  25213. */
  25214. get contrast(): number;
  25215. /**
  25216. * Sets contrast used in the effect.
  25217. */
  25218. set contrast(value: number);
  25219. /**
  25220. * Gets Vignette stretch size.
  25221. */
  25222. get vignetteStretch(): number;
  25223. /**
  25224. * Sets Vignette stretch size.
  25225. */
  25226. set vignetteStretch(value: number);
  25227. /**
  25228. * Gets Vignette centre X Offset.
  25229. */
  25230. get vignetteCentreX(): number;
  25231. /**
  25232. * Sets Vignette centre X Offset.
  25233. */
  25234. set vignetteCentreX(value: number);
  25235. /**
  25236. * Gets Vignette centre Y Offset.
  25237. */
  25238. get vignetteCentreY(): number;
  25239. /**
  25240. * Sets Vignette centre Y Offset.
  25241. */
  25242. set vignetteCentreY(value: number);
  25243. /**
  25244. * Gets Vignette weight or intensity of the vignette effect.
  25245. */
  25246. get vignetteWeight(): number;
  25247. /**
  25248. * Sets Vignette weight or intensity of the vignette effect.
  25249. */
  25250. set vignetteWeight(value: number);
  25251. /**
  25252. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25253. * if vignetteEnabled is set to true.
  25254. */
  25255. get vignetteColor(): Color4;
  25256. /**
  25257. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25258. * if vignetteEnabled is set to true.
  25259. */
  25260. set vignetteColor(value: Color4);
  25261. /**
  25262. * Gets Camera field of view used by the Vignette effect.
  25263. */
  25264. get vignetteCameraFov(): number;
  25265. /**
  25266. * Sets Camera field of view used by the Vignette effect.
  25267. */
  25268. set vignetteCameraFov(value: number);
  25269. /**
  25270. * Gets the vignette blend mode allowing different kind of effect.
  25271. */
  25272. get vignetteBlendMode(): number;
  25273. /**
  25274. * Sets the vignette blend mode allowing different kind of effect.
  25275. */
  25276. set vignetteBlendMode(value: number);
  25277. /**
  25278. * Gets wether the vignette effect is enabled.
  25279. */
  25280. get vignetteEnabled(): boolean;
  25281. /**
  25282. * Sets wether the vignette effect is enabled.
  25283. */
  25284. set vignetteEnabled(value: boolean);
  25285. private _fromLinearSpace;
  25286. /**
  25287. * Gets wether the input of the processing is in Gamma or Linear Space.
  25288. */
  25289. get fromLinearSpace(): boolean;
  25290. /**
  25291. * Sets wether the input of the processing is in Gamma or Linear Space.
  25292. */
  25293. set fromLinearSpace(value: boolean);
  25294. /**
  25295. * Defines cache preventing GC.
  25296. */
  25297. private _defines;
  25298. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25299. /**
  25300. * "ImageProcessingPostProcess"
  25301. * @returns "ImageProcessingPostProcess"
  25302. */
  25303. getClassName(): string;
  25304. /**
  25305. * @hidden
  25306. */
  25307. _updateParameters(): void;
  25308. dispose(camera?: Camera): void;
  25309. }
  25310. }
  25311. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25312. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25313. /**
  25314. * Interface for defining prepass effects in the prepass post-process pipeline
  25315. */
  25316. export interface PrePassEffectConfiguration {
  25317. /**
  25318. * Name of the effect
  25319. */
  25320. name: string;
  25321. /**
  25322. * Post process to attach for this effect
  25323. */
  25324. postProcess?: PostProcess;
  25325. /**
  25326. * Textures required in the MRT
  25327. */
  25328. texturesRequired: number[];
  25329. /**
  25330. * Is the effect enabled
  25331. */
  25332. enabled: boolean;
  25333. /**
  25334. * Disposes the effect configuration
  25335. */
  25336. dispose(): void;
  25337. /**
  25338. * Creates the associated post process
  25339. */
  25340. createPostProcess?: () => PostProcess;
  25341. }
  25342. }
  25343. declare module "babylonjs/Rendering/prePassRenderer" {
  25344. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25345. import { Scene } from "babylonjs/scene";
  25346. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25347. import { Effect } from "babylonjs/Materials/effect";
  25348. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25349. /**
  25350. * Renders a pre pass of the scene
  25351. * This means every mesh in the scene will be rendered to a render target texture
  25352. * And then this texture will be composited to the rendering canvas with post processes
  25353. * It is necessary for effects like subsurface scattering or deferred shading
  25354. */
  25355. export class PrePassRenderer {
  25356. /** @hidden */
  25357. static _SceneComponentInitialization: (scene: Scene) => void;
  25358. private _textureFormats;
  25359. private _textureIndices;
  25360. private _scene;
  25361. private _engine;
  25362. private _isDirty;
  25363. /**
  25364. * Number of textures in the multi render target texture where the scene is directly rendered
  25365. */
  25366. mrtCount: number;
  25367. /**
  25368. * The render target where the scene is directly rendered
  25369. */
  25370. prePassRT: MultiRenderTarget;
  25371. private _multiRenderAttachments;
  25372. private _defaultAttachments;
  25373. private _clearAttachments;
  25374. private _postProcesses;
  25375. private readonly _clearColor;
  25376. /**
  25377. * Image processing post process for composition
  25378. */
  25379. imageProcessingPostProcess: ImageProcessingPostProcess;
  25380. /**
  25381. * Configuration for prepass effects
  25382. */
  25383. private _effectConfigurations;
  25384. /**
  25385. * Should materials render their geometry on the MRT
  25386. */
  25387. materialsShouldRenderGeometry: boolean;
  25388. /**
  25389. * Should materials render the irradiance information on the MRT
  25390. */
  25391. materialsShouldRenderIrradiance: boolean;
  25392. private _mrtFormats;
  25393. private _mrtLayout;
  25394. private _enabled;
  25395. /**
  25396. * Indicates if the prepass is enabled
  25397. */
  25398. get enabled(): boolean;
  25399. /**
  25400. * How many samples are used for MSAA of the scene render target
  25401. */
  25402. get samples(): number;
  25403. set samples(n: number);
  25404. /**
  25405. * Instanciates a prepass renderer
  25406. * @param scene The scene
  25407. */
  25408. constructor(scene: Scene);
  25409. private _initializeAttachments;
  25410. private _createCompositionEffect;
  25411. /**
  25412. * Indicates if rendering a prepass is supported
  25413. */
  25414. get isSupported(): boolean;
  25415. /**
  25416. * Sets the proper output textures to draw in the engine.
  25417. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25418. */
  25419. bindAttachmentsForEffect(effect: Effect): void;
  25420. /**
  25421. * @hidden
  25422. */
  25423. _beforeCameraDraw(): void;
  25424. /**
  25425. * @hidden
  25426. */
  25427. _afterCameraDraw(): void;
  25428. private _checkRTSize;
  25429. private _bindFrameBuffer;
  25430. /**
  25431. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25432. */
  25433. clear(): void;
  25434. private _setState;
  25435. private _checkTextureType;
  25436. /**
  25437. * Adds an effect configuration to the prepass.
  25438. * If an effect has already been added, it won't add it twice and will return the configuration
  25439. * already present.
  25440. * @param cfg the effect configuration
  25441. * @return the effect configuration now used by the prepass
  25442. */
  25443. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  25444. /**
  25445. * Returns the index of a texture in the multi render target texture array.
  25446. * @param type Texture type
  25447. * @return The index
  25448. */
  25449. getIndex(type: number): number;
  25450. private _enable;
  25451. private _disable;
  25452. private _resetLayout;
  25453. private _resetPostProcessChain;
  25454. private _bindPostProcessChain;
  25455. /**
  25456. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25457. */
  25458. markAsDirty(): void;
  25459. /**
  25460. * Enables a texture on the MultiRenderTarget for prepass
  25461. */
  25462. private _enableTextures;
  25463. private _update;
  25464. /**
  25465. * Disposes the prepass renderer.
  25466. */
  25467. dispose(): void;
  25468. }
  25469. }
  25470. declare module "babylonjs/Materials/material" {
  25471. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25472. import { SmartArray } from "babylonjs/Misc/smartArray";
  25473. import { Observable } from "babylonjs/Misc/observable";
  25474. import { Nullable } from "babylonjs/types";
  25475. import { Scene } from "babylonjs/scene";
  25476. import { Matrix } from "babylonjs/Maths/math.vector";
  25477. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25479. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25480. import { Effect } from "babylonjs/Materials/effect";
  25481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25482. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25483. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25484. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25485. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25486. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25487. import { Mesh } from "babylonjs/Meshes/mesh";
  25488. import { Animation } from "babylonjs/Animations/animation";
  25489. /**
  25490. * Options for compiling materials.
  25491. */
  25492. export interface IMaterialCompilationOptions {
  25493. /**
  25494. * Defines whether clip planes are enabled.
  25495. */
  25496. clipPlane: boolean;
  25497. /**
  25498. * Defines whether instances are enabled.
  25499. */
  25500. useInstances: boolean;
  25501. }
  25502. /**
  25503. * Options passed when calling customShaderNameResolve
  25504. */
  25505. export interface ICustomShaderNameResolveOptions {
  25506. /**
  25507. * 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
  25508. */
  25509. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25510. }
  25511. /**
  25512. * Base class for the main features of a material in Babylon.js
  25513. */
  25514. export class Material implements IAnimatable {
  25515. /**
  25516. * Returns the triangle fill mode
  25517. */
  25518. static readonly TriangleFillMode: number;
  25519. /**
  25520. * Returns the wireframe mode
  25521. */
  25522. static readonly WireFrameFillMode: number;
  25523. /**
  25524. * Returns the point fill mode
  25525. */
  25526. static readonly PointFillMode: number;
  25527. /**
  25528. * Returns the point list draw mode
  25529. */
  25530. static readonly PointListDrawMode: number;
  25531. /**
  25532. * Returns the line list draw mode
  25533. */
  25534. static readonly LineListDrawMode: number;
  25535. /**
  25536. * Returns the line loop draw mode
  25537. */
  25538. static readonly LineLoopDrawMode: number;
  25539. /**
  25540. * Returns the line strip draw mode
  25541. */
  25542. static readonly LineStripDrawMode: number;
  25543. /**
  25544. * Returns the triangle strip draw mode
  25545. */
  25546. static readonly TriangleStripDrawMode: number;
  25547. /**
  25548. * Returns the triangle fan draw mode
  25549. */
  25550. static readonly TriangleFanDrawMode: number;
  25551. /**
  25552. * Stores the clock-wise side orientation
  25553. */
  25554. static readonly ClockWiseSideOrientation: number;
  25555. /**
  25556. * Stores the counter clock-wise side orientation
  25557. */
  25558. static readonly CounterClockWiseSideOrientation: number;
  25559. /**
  25560. * The dirty texture flag value
  25561. */
  25562. static readonly TextureDirtyFlag: number;
  25563. /**
  25564. * The dirty light flag value
  25565. */
  25566. static readonly LightDirtyFlag: number;
  25567. /**
  25568. * The dirty fresnel flag value
  25569. */
  25570. static readonly FresnelDirtyFlag: number;
  25571. /**
  25572. * The dirty attribute flag value
  25573. */
  25574. static readonly AttributesDirtyFlag: number;
  25575. /**
  25576. * The dirty misc flag value
  25577. */
  25578. static readonly MiscDirtyFlag: number;
  25579. /**
  25580. * The all dirty flag value
  25581. */
  25582. static readonly AllDirtyFlag: number;
  25583. /**
  25584. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25585. */
  25586. static readonly MATERIAL_OPAQUE: number;
  25587. /**
  25588. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25589. */
  25590. static readonly MATERIAL_ALPHATEST: number;
  25591. /**
  25592. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25593. */
  25594. static readonly MATERIAL_ALPHABLEND: number;
  25595. /**
  25596. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25597. * They are also discarded below the alpha cutoff threshold to improve performances.
  25598. */
  25599. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25600. /**
  25601. * The Whiteout method is used to blend normals.
  25602. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25603. */
  25604. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25605. /**
  25606. * The Reoriented Normal Mapping method is used to blend normals.
  25607. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25608. */
  25609. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25610. /**
  25611. * Custom callback helping to override the default shader used in the material.
  25612. */
  25613. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25614. /**
  25615. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25616. */
  25617. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25618. /**
  25619. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25620. * This means that the material can keep using a previous shader while a new one is being compiled.
  25621. * This is mostly used when shader parallel compilation is supported (true by default)
  25622. */
  25623. allowShaderHotSwapping: boolean;
  25624. /**
  25625. * The ID of the material
  25626. */
  25627. id: string;
  25628. /**
  25629. * Gets or sets the unique id of the material
  25630. */
  25631. uniqueId: number;
  25632. /**
  25633. * The name of the material
  25634. */
  25635. name: string;
  25636. /**
  25637. * Gets or sets user defined metadata
  25638. */
  25639. metadata: any;
  25640. /**
  25641. * For internal use only. Please do not use.
  25642. */
  25643. reservedDataStore: any;
  25644. /**
  25645. * Specifies if the ready state should be checked on each call
  25646. */
  25647. checkReadyOnEveryCall: boolean;
  25648. /**
  25649. * Specifies if the ready state should be checked once
  25650. */
  25651. checkReadyOnlyOnce: boolean;
  25652. /**
  25653. * The state of the material
  25654. */
  25655. state: string;
  25656. /**
  25657. * If the material can be rendered to several textures with MRT extension
  25658. */
  25659. get canRenderToMRT(): boolean;
  25660. /**
  25661. * The alpha value of the material
  25662. */
  25663. protected _alpha: number;
  25664. /**
  25665. * List of inspectable custom properties (used by the Inspector)
  25666. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25667. */
  25668. inspectableCustomProperties: IInspectable[];
  25669. /**
  25670. * Sets the alpha value of the material
  25671. */
  25672. set alpha(value: number);
  25673. /**
  25674. * Gets the alpha value of the material
  25675. */
  25676. get alpha(): number;
  25677. /**
  25678. * Specifies if back face culling is enabled
  25679. */
  25680. protected _backFaceCulling: boolean;
  25681. /**
  25682. * Sets the back-face culling state
  25683. */
  25684. set backFaceCulling(value: boolean);
  25685. /**
  25686. * Gets the back-face culling state
  25687. */
  25688. get backFaceCulling(): boolean;
  25689. /**
  25690. * Stores the value for side orientation
  25691. */
  25692. sideOrientation: number;
  25693. /**
  25694. * Callback triggered when the material is compiled
  25695. */
  25696. onCompiled: Nullable<(effect: Effect) => void>;
  25697. /**
  25698. * Callback triggered when an error occurs
  25699. */
  25700. onError: Nullable<(effect: Effect, errors: string) => void>;
  25701. /**
  25702. * Callback triggered to get the render target textures
  25703. */
  25704. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25705. /**
  25706. * Gets a boolean indicating that current material needs to register RTT
  25707. */
  25708. get hasRenderTargetTextures(): boolean;
  25709. /**
  25710. * Specifies if the material should be serialized
  25711. */
  25712. doNotSerialize: boolean;
  25713. /**
  25714. * @hidden
  25715. */
  25716. _storeEffectOnSubMeshes: boolean;
  25717. /**
  25718. * Stores the animations for the material
  25719. */
  25720. animations: Nullable<Array<Animation>>;
  25721. /**
  25722. * An event triggered when the material is disposed
  25723. */
  25724. onDisposeObservable: Observable<Material>;
  25725. /**
  25726. * An observer which watches for dispose events
  25727. */
  25728. private _onDisposeObserver;
  25729. private _onUnBindObservable;
  25730. /**
  25731. * Called during a dispose event
  25732. */
  25733. set onDispose(callback: () => void);
  25734. private _onBindObservable;
  25735. /**
  25736. * An event triggered when the material is bound
  25737. */
  25738. get onBindObservable(): Observable<AbstractMesh>;
  25739. /**
  25740. * An observer which watches for bind events
  25741. */
  25742. private _onBindObserver;
  25743. /**
  25744. * Called during a bind event
  25745. */
  25746. set onBind(callback: (Mesh: AbstractMesh) => void);
  25747. /**
  25748. * An event triggered when the material is unbound
  25749. */
  25750. get onUnBindObservable(): Observable<Material>;
  25751. protected _onEffectCreatedObservable: Nullable<Observable<{
  25752. effect: Effect;
  25753. subMesh: Nullable<SubMesh>;
  25754. }>>;
  25755. /**
  25756. * An event triggered when the effect is (re)created
  25757. */
  25758. get onEffectCreatedObservable(): Observable<{
  25759. effect: Effect;
  25760. subMesh: Nullable<SubMesh>;
  25761. }>;
  25762. /**
  25763. * Stores the value of the alpha mode
  25764. */
  25765. private _alphaMode;
  25766. /**
  25767. * Sets the value of the alpha mode.
  25768. *
  25769. * | Value | Type | Description |
  25770. * | --- | --- | --- |
  25771. * | 0 | ALPHA_DISABLE | |
  25772. * | 1 | ALPHA_ADD | |
  25773. * | 2 | ALPHA_COMBINE | |
  25774. * | 3 | ALPHA_SUBTRACT | |
  25775. * | 4 | ALPHA_MULTIPLY | |
  25776. * | 5 | ALPHA_MAXIMIZED | |
  25777. * | 6 | ALPHA_ONEONE | |
  25778. * | 7 | ALPHA_PREMULTIPLIED | |
  25779. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25780. * | 9 | ALPHA_INTERPOLATE | |
  25781. * | 10 | ALPHA_SCREENMODE | |
  25782. *
  25783. */
  25784. set alphaMode(value: number);
  25785. /**
  25786. * Gets the value of the alpha mode
  25787. */
  25788. get alphaMode(): number;
  25789. /**
  25790. * Stores the state of the need depth pre-pass value
  25791. */
  25792. private _needDepthPrePass;
  25793. /**
  25794. * Sets the need depth pre-pass value
  25795. */
  25796. set needDepthPrePass(value: boolean);
  25797. /**
  25798. * Gets the depth pre-pass value
  25799. */
  25800. get needDepthPrePass(): boolean;
  25801. /**
  25802. * Specifies if depth writing should be disabled
  25803. */
  25804. disableDepthWrite: boolean;
  25805. /**
  25806. * Specifies if color writing should be disabled
  25807. */
  25808. disableColorWrite: boolean;
  25809. /**
  25810. * Specifies if depth writing should be forced
  25811. */
  25812. forceDepthWrite: boolean;
  25813. /**
  25814. * Specifies the depth function that should be used. 0 means the default engine function
  25815. */
  25816. depthFunction: number;
  25817. /**
  25818. * Specifies if there should be a separate pass for culling
  25819. */
  25820. separateCullingPass: boolean;
  25821. /**
  25822. * Stores the state specifing if fog should be enabled
  25823. */
  25824. private _fogEnabled;
  25825. /**
  25826. * Sets the state for enabling fog
  25827. */
  25828. set fogEnabled(value: boolean);
  25829. /**
  25830. * Gets the value of the fog enabled state
  25831. */
  25832. get fogEnabled(): boolean;
  25833. /**
  25834. * Stores the size of points
  25835. */
  25836. pointSize: number;
  25837. /**
  25838. * Stores the z offset value
  25839. */
  25840. zOffset: number;
  25841. get wireframe(): boolean;
  25842. /**
  25843. * Sets the state of wireframe mode
  25844. */
  25845. set wireframe(value: boolean);
  25846. /**
  25847. * Gets the value specifying if point clouds are enabled
  25848. */
  25849. get pointsCloud(): boolean;
  25850. /**
  25851. * Sets the state of point cloud mode
  25852. */
  25853. set pointsCloud(value: boolean);
  25854. /**
  25855. * Gets the material fill mode
  25856. */
  25857. get fillMode(): number;
  25858. /**
  25859. * Sets the material fill mode
  25860. */
  25861. set fillMode(value: number);
  25862. /**
  25863. * @hidden
  25864. * Stores the effects for the material
  25865. */
  25866. _effect: Nullable<Effect>;
  25867. /**
  25868. * Specifies if uniform buffers should be used
  25869. */
  25870. private _useUBO;
  25871. /**
  25872. * Stores a reference to the scene
  25873. */
  25874. private _scene;
  25875. /**
  25876. * Stores the fill mode state
  25877. */
  25878. private _fillMode;
  25879. /**
  25880. * Specifies if the depth write state should be cached
  25881. */
  25882. private _cachedDepthWriteState;
  25883. /**
  25884. * Specifies if the color write state should be cached
  25885. */
  25886. private _cachedColorWriteState;
  25887. /**
  25888. * Specifies if the depth function state should be cached
  25889. */
  25890. private _cachedDepthFunctionState;
  25891. /**
  25892. * Stores the uniform buffer
  25893. */
  25894. protected _uniformBuffer: UniformBuffer;
  25895. /** @hidden */
  25896. _indexInSceneMaterialArray: number;
  25897. /** @hidden */
  25898. meshMap: Nullable<{
  25899. [id: string]: AbstractMesh | undefined;
  25900. }>;
  25901. /**
  25902. * Creates a material instance
  25903. * @param name defines the name of the material
  25904. * @param scene defines the scene to reference
  25905. * @param doNotAdd specifies if the material should be added to the scene
  25906. */
  25907. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25908. /**
  25909. * Returns a string representation of the current material
  25910. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25911. * @returns a string with material information
  25912. */
  25913. toString(fullDetails?: boolean): string;
  25914. /**
  25915. * Gets the class name of the material
  25916. * @returns a string with the class name of the material
  25917. */
  25918. getClassName(): string;
  25919. /**
  25920. * Specifies if updates for the material been locked
  25921. */
  25922. get isFrozen(): boolean;
  25923. /**
  25924. * Locks updates for the material
  25925. */
  25926. freeze(): void;
  25927. /**
  25928. * Unlocks updates for the material
  25929. */
  25930. unfreeze(): void;
  25931. /**
  25932. * Specifies if the material is ready to be used
  25933. * @param mesh defines the mesh to check
  25934. * @param useInstances specifies if instances should be used
  25935. * @returns a boolean indicating if the material is ready to be used
  25936. */
  25937. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25938. /**
  25939. * Specifies that the submesh is ready to be used
  25940. * @param mesh defines the mesh to check
  25941. * @param subMesh defines which submesh to check
  25942. * @param useInstances specifies that instances should be used
  25943. * @returns a boolean indicating that the submesh is ready or not
  25944. */
  25945. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25946. /**
  25947. * Returns the material effect
  25948. * @returns the effect associated with the material
  25949. */
  25950. getEffect(): Nullable<Effect>;
  25951. /**
  25952. * Returns the current scene
  25953. * @returns a Scene
  25954. */
  25955. getScene(): Scene;
  25956. /**
  25957. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25958. */
  25959. protected _forceAlphaTest: boolean;
  25960. /**
  25961. * The transparency mode of the material.
  25962. */
  25963. protected _transparencyMode: Nullable<number>;
  25964. /**
  25965. * Gets the current transparency mode.
  25966. */
  25967. get transparencyMode(): Nullable<number>;
  25968. /**
  25969. * Sets the transparency mode of the material.
  25970. *
  25971. * | Value | Type | Description |
  25972. * | ----- | ----------------------------------- | ----------- |
  25973. * | 0 | OPAQUE | |
  25974. * | 1 | ALPHATEST | |
  25975. * | 2 | ALPHABLEND | |
  25976. * | 3 | ALPHATESTANDBLEND | |
  25977. *
  25978. */
  25979. set transparencyMode(value: Nullable<number>);
  25980. /**
  25981. * Returns true if alpha blending should be disabled.
  25982. */
  25983. protected get _disableAlphaBlending(): boolean;
  25984. /**
  25985. * Specifies whether or not this material should be rendered in alpha blend mode.
  25986. * @returns a boolean specifying if alpha blending is needed
  25987. */
  25988. needAlphaBlending(): boolean;
  25989. /**
  25990. * Specifies if the mesh will require alpha blending
  25991. * @param mesh defines the mesh to check
  25992. * @returns a boolean specifying if alpha blending is needed for the mesh
  25993. */
  25994. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25995. /**
  25996. * Specifies whether or not this material should be rendered in alpha test mode.
  25997. * @returns a boolean specifying if an alpha test is needed.
  25998. */
  25999. needAlphaTesting(): boolean;
  26000. /**
  26001. * Specifies if material alpha testing should be turned on for the mesh
  26002. * @param mesh defines the mesh to check
  26003. */
  26004. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  26005. /**
  26006. * Gets the texture used for the alpha test
  26007. * @returns the texture to use for alpha testing
  26008. */
  26009. getAlphaTestTexture(): Nullable<BaseTexture>;
  26010. /**
  26011. * Marks the material to indicate that it needs to be re-calculated
  26012. */
  26013. markDirty(): void;
  26014. /** @hidden */
  26015. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  26016. /**
  26017. * Binds the material to the mesh
  26018. * @param world defines the world transformation matrix
  26019. * @param mesh defines the mesh to bind the material to
  26020. */
  26021. bind(world: Matrix, mesh?: Mesh): void;
  26022. /**
  26023. * Binds the submesh to the material
  26024. * @param world defines the world transformation matrix
  26025. * @param mesh defines the mesh containing the submesh
  26026. * @param subMesh defines the submesh to bind the material to
  26027. */
  26028. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26029. /**
  26030. * Binds the world matrix to the material
  26031. * @param world defines the world transformation matrix
  26032. */
  26033. bindOnlyWorldMatrix(world: Matrix): void;
  26034. /**
  26035. * Binds the scene's uniform buffer to the effect.
  26036. * @param effect defines the effect to bind to the scene uniform buffer
  26037. * @param sceneUbo defines the uniform buffer storing scene data
  26038. */
  26039. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26040. /**
  26041. * Binds the view matrix to the effect
  26042. * @param effect defines the effect to bind the view matrix to
  26043. */
  26044. bindView(effect: Effect): void;
  26045. /**
  26046. * Binds the view projection matrix to the effect
  26047. * @param effect defines the effect to bind the view projection matrix to
  26048. */
  26049. bindViewProjection(effect: Effect): void;
  26050. /**
  26051. * Processes to execute after binding the material to a mesh
  26052. * @param mesh defines the rendered mesh
  26053. */
  26054. protected _afterBind(mesh?: Mesh): void;
  26055. /**
  26056. * Unbinds the material from the mesh
  26057. */
  26058. unbind(): void;
  26059. /**
  26060. * Gets the active textures from the material
  26061. * @returns an array of textures
  26062. */
  26063. getActiveTextures(): BaseTexture[];
  26064. /**
  26065. * Specifies if the material uses a texture
  26066. * @param texture defines the texture to check against the material
  26067. * @returns a boolean specifying if the material uses the texture
  26068. */
  26069. hasTexture(texture: BaseTexture): boolean;
  26070. /**
  26071. * Makes a duplicate of the material, and gives it a new name
  26072. * @param name defines the new name for the duplicated material
  26073. * @returns the cloned material
  26074. */
  26075. clone(name: string): Nullable<Material>;
  26076. /**
  26077. * Gets the meshes bound to the material
  26078. * @returns an array of meshes bound to the material
  26079. */
  26080. getBindedMeshes(): AbstractMesh[];
  26081. /**
  26082. * Force shader compilation
  26083. * @param mesh defines the mesh associated with this material
  26084. * @param onCompiled defines a function to execute once the material is compiled
  26085. * @param options defines the options to configure the compilation
  26086. * @param onError defines a function to execute if the material fails compiling
  26087. */
  26088. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26089. /**
  26090. * Force shader compilation
  26091. * @param mesh defines the mesh that will use this material
  26092. * @param options defines additional options for compiling the shaders
  26093. * @returns a promise that resolves when the compilation completes
  26094. */
  26095. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26096. private static readonly _AllDirtyCallBack;
  26097. private static readonly _ImageProcessingDirtyCallBack;
  26098. private static readonly _TextureDirtyCallBack;
  26099. private static readonly _FresnelDirtyCallBack;
  26100. private static readonly _MiscDirtyCallBack;
  26101. private static readonly _LightsDirtyCallBack;
  26102. private static readonly _AttributeDirtyCallBack;
  26103. private static _FresnelAndMiscDirtyCallBack;
  26104. private static _TextureAndMiscDirtyCallBack;
  26105. private static readonly _DirtyCallbackArray;
  26106. private static readonly _RunDirtyCallBacks;
  26107. /**
  26108. * Marks a define in the material to indicate that it needs to be re-computed
  26109. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26110. */
  26111. markAsDirty(flag: number): void;
  26112. /**
  26113. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26114. * @param func defines a function which checks material defines against the submeshes
  26115. */
  26116. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26117. /**
  26118. * Indicates that the scene should check if the rendering now needs a prepass
  26119. */
  26120. protected _markScenePrePassDirty(): void;
  26121. /**
  26122. * Indicates that we need to re-calculated for all submeshes
  26123. */
  26124. protected _markAllSubMeshesAsAllDirty(): void;
  26125. /**
  26126. * Indicates that image processing needs to be re-calculated for all submeshes
  26127. */
  26128. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26129. /**
  26130. * Indicates that textures need to be re-calculated for all submeshes
  26131. */
  26132. protected _markAllSubMeshesAsTexturesDirty(): void;
  26133. /**
  26134. * Indicates that fresnel needs to be re-calculated for all submeshes
  26135. */
  26136. protected _markAllSubMeshesAsFresnelDirty(): void;
  26137. /**
  26138. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26139. */
  26140. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26141. /**
  26142. * Indicates that lights need to be re-calculated for all submeshes
  26143. */
  26144. protected _markAllSubMeshesAsLightsDirty(): void;
  26145. /**
  26146. * Indicates that attributes need to be re-calculated for all submeshes
  26147. */
  26148. protected _markAllSubMeshesAsAttributesDirty(): void;
  26149. /**
  26150. * Indicates that misc needs to be re-calculated for all submeshes
  26151. */
  26152. protected _markAllSubMeshesAsMiscDirty(): void;
  26153. /**
  26154. * Indicates that textures and misc need to be re-calculated for all submeshes
  26155. */
  26156. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26157. /**
  26158. * Sets the required values to the prepass renderer.
  26159. * @param prePassRenderer defines the prepass renderer to setup.
  26160. * @returns true if the pre pass is needed.
  26161. */
  26162. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26163. /**
  26164. * Disposes the material
  26165. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26166. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26167. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26168. */
  26169. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26170. /** @hidden */
  26171. private releaseVertexArrayObject;
  26172. /**
  26173. * Serializes this material
  26174. * @returns the serialized material object
  26175. */
  26176. serialize(): any;
  26177. /**
  26178. * Creates a material from parsed material data
  26179. * @param parsedMaterial defines parsed material data
  26180. * @param scene defines the hosting scene
  26181. * @param rootUrl defines the root URL to use to load textures
  26182. * @returns a new material
  26183. */
  26184. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26185. }
  26186. }
  26187. declare module "babylonjs/Materials/multiMaterial" {
  26188. import { Nullable } from "babylonjs/types";
  26189. import { Scene } from "babylonjs/scene";
  26190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26191. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26193. import { Material } from "babylonjs/Materials/material";
  26194. /**
  26195. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26196. * separate meshes. This can be use to improve performances.
  26197. * @see https://doc.babylonjs.com/how_to/multi_materials
  26198. */
  26199. export class MultiMaterial extends Material {
  26200. private _subMaterials;
  26201. /**
  26202. * Gets or Sets the list of Materials used within the multi material.
  26203. * They need to be ordered according to the submeshes order in the associated mesh
  26204. */
  26205. get subMaterials(): Nullable<Material>[];
  26206. set subMaterials(value: Nullable<Material>[]);
  26207. /**
  26208. * Function used to align with Node.getChildren()
  26209. * @returns the list of Materials used within the multi material
  26210. */
  26211. getChildren(): Nullable<Material>[];
  26212. /**
  26213. * Instantiates a new Multi Material
  26214. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26215. * separate meshes. This can be use to improve performances.
  26216. * @see https://doc.babylonjs.com/how_to/multi_materials
  26217. * @param name Define the name in the scene
  26218. * @param scene Define the scene the material belongs to
  26219. */
  26220. constructor(name: string, scene: Scene);
  26221. private _hookArray;
  26222. /**
  26223. * Get one of the submaterial by its index in the submaterials array
  26224. * @param index The index to look the sub material at
  26225. * @returns The Material if the index has been defined
  26226. */
  26227. getSubMaterial(index: number): Nullable<Material>;
  26228. /**
  26229. * Get the list of active textures for the whole sub materials list.
  26230. * @returns All the textures that will be used during the rendering
  26231. */
  26232. getActiveTextures(): BaseTexture[];
  26233. /**
  26234. * Gets the current class name of the material e.g. "MultiMaterial"
  26235. * Mainly use in serialization.
  26236. * @returns the class name
  26237. */
  26238. getClassName(): string;
  26239. /**
  26240. * Checks if the material is ready to render the requested sub mesh
  26241. * @param mesh Define the mesh the submesh belongs to
  26242. * @param subMesh Define the sub mesh to look readyness for
  26243. * @param useInstances Define whether or not the material is used with instances
  26244. * @returns true if ready, otherwise false
  26245. */
  26246. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26247. /**
  26248. * Clones the current material and its related sub materials
  26249. * @param name Define the name of the newly cloned material
  26250. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26251. * @returns the cloned material
  26252. */
  26253. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26254. /**
  26255. * Serializes the materials into a JSON representation.
  26256. * @returns the JSON representation
  26257. */
  26258. serialize(): any;
  26259. /**
  26260. * Dispose the material and release its associated resources
  26261. * @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)
  26262. * @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)
  26263. * @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)
  26264. */
  26265. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26266. /**
  26267. * Creates a MultiMaterial from parsed MultiMaterial data.
  26268. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26269. * @param scene defines the hosting scene
  26270. * @returns a new MultiMaterial
  26271. */
  26272. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26273. }
  26274. }
  26275. declare module "babylonjs/Meshes/subMesh" {
  26276. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26277. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26278. import { Engine } from "babylonjs/Engines/engine";
  26279. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26280. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26281. import { Effect } from "babylonjs/Materials/effect";
  26282. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26283. import { Plane } from "babylonjs/Maths/math.plane";
  26284. import { Collider } from "babylonjs/Collisions/collider";
  26285. import { Material } from "babylonjs/Materials/material";
  26286. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26288. import { Mesh } from "babylonjs/Meshes/mesh";
  26289. import { Ray } from "babylonjs/Culling/ray";
  26290. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26291. /**
  26292. * Defines a subdivision inside a mesh
  26293. */
  26294. export class SubMesh implements ICullable {
  26295. /** the material index to use */
  26296. materialIndex: number;
  26297. /** vertex index start */
  26298. verticesStart: number;
  26299. /** vertices count */
  26300. verticesCount: number;
  26301. /** index start */
  26302. indexStart: number;
  26303. /** indices count */
  26304. indexCount: number;
  26305. /** @hidden */
  26306. _materialDefines: Nullable<MaterialDefines>;
  26307. /** @hidden */
  26308. _materialEffect: Nullable<Effect>;
  26309. /** @hidden */
  26310. _effectOverride: Nullable<Effect>;
  26311. /**
  26312. * Gets material defines used by the effect associated to the sub mesh
  26313. */
  26314. get materialDefines(): Nullable<MaterialDefines>;
  26315. /**
  26316. * Sets material defines used by the effect associated to the sub mesh
  26317. */
  26318. set materialDefines(defines: Nullable<MaterialDefines>);
  26319. /**
  26320. * Gets associated effect
  26321. */
  26322. get effect(): Nullable<Effect>;
  26323. /**
  26324. * Sets associated effect (effect used to render this submesh)
  26325. * @param effect defines the effect to associate with
  26326. * @param defines defines the set of defines used to compile this effect
  26327. */
  26328. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26329. /** @hidden */
  26330. _linesIndexCount: number;
  26331. private _mesh;
  26332. private _renderingMesh;
  26333. private _boundingInfo;
  26334. private _linesIndexBuffer;
  26335. /** @hidden */
  26336. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26337. /** @hidden */
  26338. _trianglePlanes: Plane[];
  26339. /** @hidden */
  26340. _lastColliderTransformMatrix: Nullable<Matrix>;
  26341. /** @hidden */
  26342. _renderId: number;
  26343. /** @hidden */
  26344. _alphaIndex: number;
  26345. /** @hidden */
  26346. _distanceToCamera: number;
  26347. /** @hidden */
  26348. _id: number;
  26349. private _currentMaterial;
  26350. /**
  26351. * Add a new submesh to a mesh
  26352. * @param materialIndex defines the material index to use
  26353. * @param verticesStart defines vertex index start
  26354. * @param verticesCount defines vertices count
  26355. * @param indexStart defines index start
  26356. * @param indexCount defines indices count
  26357. * @param mesh defines the parent mesh
  26358. * @param renderingMesh defines an optional rendering mesh
  26359. * @param createBoundingBox defines if bounding box should be created for this submesh
  26360. * @returns the new submesh
  26361. */
  26362. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26363. /**
  26364. * Creates a new submesh
  26365. * @param materialIndex defines the material index to use
  26366. * @param verticesStart defines vertex index start
  26367. * @param verticesCount defines vertices count
  26368. * @param indexStart defines index start
  26369. * @param indexCount defines indices count
  26370. * @param mesh defines the parent mesh
  26371. * @param renderingMesh defines an optional rendering mesh
  26372. * @param createBoundingBox defines if bounding box should be created for this submesh
  26373. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26374. */
  26375. constructor(
  26376. /** the material index to use */
  26377. materialIndex: number,
  26378. /** vertex index start */
  26379. verticesStart: number,
  26380. /** vertices count */
  26381. verticesCount: number,
  26382. /** index start */
  26383. indexStart: number,
  26384. /** indices count */
  26385. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26386. /**
  26387. * Returns true if this submesh covers the entire parent mesh
  26388. * @ignorenaming
  26389. */
  26390. get IsGlobal(): boolean;
  26391. /**
  26392. * Returns the submesh BoudingInfo object
  26393. * @returns current bounding info (or mesh's one if the submesh is global)
  26394. */
  26395. getBoundingInfo(): BoundingInfo;
  26396. /**
  26397. * Sets the submesh BoundingInfo
  26398. * @param boundingInfo defines the new bounding info to use
  26399. * @returns the SubMesh
  26400. */
  26401. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26402. /**
  26403. * Returns the mesh of the current submesh
  26404. * @return the parent mesh
  26405. */
  26406. getMesh(): AbstractMesh;
  26407. /**
  26408. * Returns the rendering mesh of the submesh
  26409. * @returns the rendering mesh (could be different from parent mesh)
  26410. */
  26411. getRenderingMesh(): Mesh;
  26412. /**
  26413. * Returns the replacement mesh of the submesh
  26414. * @returns the replacement mesh (could be different from parent mesh)
  26415. */
  26416. getReplacementMesh(): Nullable<AbstractMesh>;
  26417. /**
  26418. * Returns the effective mesh of the submesh
  26419. * @returns the effective mesh (could be different from parent mesh)
  26420. */
  26421. getEffectiveMesh(): AbstractMesh;
  26422. /**
  26423. * Returns the submesh material
  26424. * @returns null or the current material
  26425. */
  26426. getMaterial(): Nullable<Material>;
  26427. private _IsMultiMaterial;
  26428. /**
  26429. * Sets a new updated BoundingInfo object to the submesh
  26430. * @param data defines an optional position array to use to determine the bounding info
  26431. * @returns the SubMesh
  26432. */
  26433. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26434. /** @hidden */
  26435. _checkCollision(collider: Collider): boolean;
  26436. /**
  26437. * Updates the submesh BoundingInfo
  26438. * @param world defines the world matrix to use to update the bounding info
  26439. * @returns the submesh
  26440. */
  26441. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26442. /**
  26443. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26444. * @param frustumPlanes defines the frustum planes
  26445. * @returns true if the submesh is intersecting with the frustum
  26446. */
  26447. isInFrustum(frustumPlanes: Plane[]): boolean;
  26448. /**
  26449. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26450. * @param frustumPlanes defines the frustum planes
  26451. * @returns true if the submesh is inside the frustum
  26452. */
  26453. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26454. /**
  26455. * Renders the submesh
  26456. * @param enableAlphaMode defines if alpha needs to be used
  26457. * @returns the submesh
  26458. */
  26459. render(enableAlphaMode: boolean): SubMesh;
  26460. /**
  26461. * @hidden
  26462. */
  26463. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26464. /**
  26465. * Checks if the submesh intersects with a ray
  26466. * @param ray defines the ray to test
  26467. * @returns true is the passed ray intersects the submesh bounding box
  26468. */
  26469. canIntersects(ray: Ray): boolean;
  26470. /**
  26471. * Intersects current submesh with a ray
  26472. * @param ray defines the ray to test
  26473. * @param positions defines mesh's positions array
  26474. * @param indices defines mesh's indices array
  26475. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26476. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26477. * @returns intersection info or null if no intersection
  26478. */
  26479. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26480. /** @hidden */
  26481. private _intersectLines;
  26482. /** @hidden */
  26483. private _intersectUnIndexedLines;
  26484. /** @hidden */
  26485. private _intersectTriangles;
  26486. /** @hidden */
  26487. private _intersectUnIndexedTriangles;
  26488. /** @hidden */
  26489. _rebuild(): void;
  26490. /**
  26491. * Creates a new submesh from the passed mesh
  26492. * @param newMesh defines the new hosting mesh
  26493. * @param newRenderingMesh defines an optional rendering mesh
  26494. * @returns the new submesh
  26495. */
  26496. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26497. /**
  26498. * Release associated resources
  26499. */
  26500. dispose(): void;
  26501. /**
  26502. * Gets the class name
  26503. * @returns the string "SubMesh".
  26504. */
  26505. getClassName(): string;
  26506. /**
  26507. * Creates a new submesh from indices data
  26508. * @param materialIndex the index of the main mesh material
  26509. * @param startIndex the index where to start the copy in the mesh indices array
  26510. * @param indexCount the number of indices to copy then from the startIndex
  26511. * @param mesh the main mesh to create the submesh from
  26512. * @param renderingMesh the optional rendering mesh
  26513. * @returns a new submesh
  26514. */
  26515. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26516. }
  26517. }
  26518. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26519. /**
  26520. * Class used to represent data loading progression
  26521. */
  26522. export class SceneLoaderFlags {
  26523. private static _ForceFullSceneLoadingForIncremental;
  26524. private static _ShowLoadingScreen;
  26525. private static _CleanBoneMatrixWeights;
  26526. private static _loggingLevel;
  26527. /**
  26528. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26529. */
  26530. static get ForceFullSceneLoadingForIncremental(): boolean;
  26531. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26532. /**
  26533. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26534. */
  26535. static get ShowLoadingScreen(): boolean;
  26536. static set ShowLoadingScreen(value: boolean);
  26537. /**
  26538. * Defines the current logging level (while loading the scene)
  26539. * @ignorenaming
  26540. */
  26541. static get loggingLevel(): number;
  26542. static set loggingLevel(value: number);
  26543. /**
  26544. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26545. */
  26546. static get CleanBoneMatrixWeights(): boolean;
  26547. static set CleanBoneMatrixWeights(value: boolean);
  26548. }
  26549. }
  26550. declare module "babylonjs/Meshes/geometry" {
  26551. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26552. import { Scene } from "babylonjs/scene";
  26553. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26554. import { Engine } from "babylonjs/Engines/engine";
  26555. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26556. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26557. import { Effect } from "babylonjs/Materials/effect";
  26558. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26559. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26560. import { Mesh } from "babylonjs/Meshes/mesh";
  26561. /**
  26562. * Class used to store geometry data (vertex buffers + index buffer)
  26563. */
  26564. export class Geometry implements IGetSetVerticesData {
  26565. /**
  26566. * Gets or sets the ID of the geometry
  26567. */
  26568. id: string;
  26569. /**
  26570. * Gets or sets the unique ID of the geometry
  26571. */
  26572. uniqueId: number;
  26573. /**
  26574. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26575. */
  26576. delayLoadState: number;
  26577. /**
  26578. * Gets the file containing the data to load when running in delay load state
  26579. */
  26580. delayLoadingFile: Nullable<string>;
  26581. /**
  26582. * Callback called when the geometry is updated
  26583. */
  26584. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26585. private _scene;
  26586. private _engine;
  26587. private _meshes;
  26588. private _totalVertices;
  26589. /** @hidden */
  26590. _indices: IndicesArray;
  26591. /** @hidden */
  26592. _vertexBuffers: {
  26593. [key: string]: VertexBuffer;
  26594. };
  26595. private _isDisposed;
  26596. private _extend;
  26597. private _boundingBias;
  26598. /** @hidden */
  26599. _delayInfo: Array<string>;
  26600. private _indexBuffer;
  26601. private _indexBufferIsUpdatable;
  26602. /** @hidden */
  26603. _boundingInfo: Nullable<BoundingInfo>;
  26604. /** @hidden */
  26605. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26606. /** @hidden */
  26607. _softwareSkinningFrameId: number;
  26608. private _vertexArrayObjects;
  26609. private _updatable;
  26610. /** @hidden */
  26611. _positions: Nullable<Vector3[]>;
  26612. /**
  26613. * 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
  26614. */
  26615. get boundingBias(): Vector2;
  26616. /**
  26617. * 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
  26618. */
  26619. set boundingBias(value: Vector2);
  26620. /**
  26621. * Static function used to attach a new empty geometry to a mesh
  26622. * @param mesh defines the mesh to attach the geometry to
  26623. * @returns the new Geometry
  26624. */
  26625. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26626. /** Get the list of meshes using this geometry */
  26627. get meshes(): Mesh[];
  26628. /**
  26629. * 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
  26630. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26631. */
  26632. useBoundingInfoFromGeometry: boolean;
  26633. /**
  26634. * Creates a new geometry
  26635. * @param id defines the unique ID
  26636. * @param scene defines the hosting scene
  26637. * @param vertexData defines the VertexData used to get geometry data
  26638. * @param updatable defines if geometry must be updatable (false by default)
  26639. * @param mesh defines the mesh that will be associated with the geometry
  26640. */
  26641. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26642. /**
  26643. * Gets the current extend of the geometry
  26644. */
  26645. get extend(): {
  26646. minimum: Vector3;
  26647. maximum: Vector3;
  26648. };
  26649. /**
  26650. * Gets the hosting scene
  26651. * @returns the hosting Scene
  26652. */
  26653. getScene(): Scene;
  26654. /**
  26655. * Gets the hosting engine
  26656. * @returns the hosting Engine
  26657. */
  26658. getEngine(): Engine;
  26659. /**
  26660. * Defines if the geometry is ready to use
  26661. * @returns true if the geometry is ready to be used
  26662. */
  26663. isReady(): boolean;
  26664. /**
  26665. * Gets a value indicating that the geometry should not be serialized
  26666. */
  26667. get doNotSerialize(): boolean;
  26668. /** @hidden */
  26669. _rebuild(): void;
  26670. /**
  26671. * Affects all geometry data in one call
  26672. * @param vertexData defines the geometry data
  26673. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26674. */
  26675. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26676. /**
  26677. * Set specific vertex data
  26678. * @param kind defines the data kind (Position, normal, etc...)
  26679. * @param data defines the vertex data to use
  26680. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26681. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26682. */
  26683. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26684. /**
  26685. * Removes a specific vertex data
  26686. * @param kind defines the data kind (Position, normal, etc...)
  26687. */
  26688. removeVerticesData(kind: string): void;
  26689. /**
  26690. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26691. * @param buffer defines the vertex buffer to use
  26692. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26693. */
  26694. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26695. /**
  26696. * Update a specific vertex buffer
  26697. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26698. * It will do nothing if the buffer is not updatable
  26699. * @param kind defines the data kind (Position, normal, etc...)
  26700. * @param data defines the data to use
  26701. * @param offset defines the offset in the target buffer where to store the data
  26702. * @param useBytes set to true if the offset is in bytes
  26703. */
  26704. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26705. /**
  26706. * Update a specific vertex buffer
  26707. * This function will create a new buffer if the current one is not updatable
  26708. * @param kind defines the data kind (Position, normal, etc...)
  26709. * @param data defines the data to use
  26710. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26711. */
  26712. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26713. private _updateBoundingInfo;
  26714. /** @hidden */
  26715. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26716. /**
  26717. * Gets total number of vertices
  26718. * @returns the total number of vertices
  26719. */
  26720. getTotalVertices(): number;
  26721. /**
  26722. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26723. * @param kind defines the data kind (Position, normal, etc...)
  26724. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26725. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26726. * @returns a float array containing vertex data
  26727. */
  26728. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26729. /**
  26730. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26731. * @param kind defines the data kind (Position, normal, etc...)
  26732. * @returns true if the vertex buffer with the specified kind is updatable
  26733. */
  26734. isVertexBufferUpdatable(kind: string): boolean;
  26735. /**
  26736. * Gets a specific vertex buffer
  26737. * @param kind defines the data kind (Position, normal, etc...)
  26738. * @returns a VertexBuffer
  26739. */
  26740. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26741. /**
  26742. * Returns all vertex buffers
  26743. * @return an object holding all vertex buffers indexed by kind
  26744. */
  26745. getVertexBuffers(): Nullable<{
  26746. [key: string]: VertexBuffer;
  26747. }>;
  26748. /**
  26749. * Gets a boolean indicating if specific vertex buffer is present
  26750. * @param kind defines the data kind (Position, normal, etc...)
  26751. * @returns true if data is present
  26752. */
  26753. isVerticesDataPresent(kind: string): boolean;
  26754. /**
  26755. * Gets a list of all attached data kinds (Position, normal, etc...)
  26756. * @returns a list of string containing all kinds
  26757. */
  26758. getVerticesDataKinds(): string[];
  26759. /**
  26760. * Update index buffer
  26761. * @param indices defines the indices to store in the index buffer
  26762. * @param offset defines the offset in the target buffer where to store the data
  26763. * @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)
  26764. */
  26765. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26766. /**
  26767. * Creates a new index buffer
  26768. * @param indices defines the indices to store in the index buffer
  26769. * @param totalVertices defines the total number of vertices (could be null)
  26770. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26771. */
  26772. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26773. /**
  26774. * Return the total number of indices
  26775. * @returns the total number of indices
  26776. */
  26777. getTotalIndices(): number;
  26778. /**
  26779. * Gets the index buffer array
  26780. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26781. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26782. * @returns the index buffer array
  26783. */
  26784. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26785. /**
  26786. * Gets the index buffer
  26787. * @return the index buffer
  26788. */
  26789. getIndexBuffer(): Nullable<DataBuffer>;
  26790. /** @hidden */
  26791. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26792. /**
  26793. * Release the associated resources for a specific mesh
  26794. * @param mesh defines the source mesh
  26795. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26796. */
  26797. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26798. /**
  26799. * Apply current geometry to a given mesh
  26800. * @param mesh defines the mesh to apply geometry to
  26801. */
  26802. applyToMesh(mesh: Mesh): void;
  26803. private _updateExtend;
  26804. private _applyToMesh;
  26805. private notifyUpdate;
  26806. /**
  26807. * Load the geometry if it was flagged as delay loaded
  26808. * @param scene defines the hosting scene
  26809. * @param onLoaded defines a callback called when the geometry is loaded
  26810. */
  26811. load(scene: Scene, onLoaded?: () => void): void;
  26812. private _queueLoad;
  26813. /**
  26814. * Invert the geometry to move from a right handed system to a left handed one.
  26815. */
  26816. toLeftHanded(): void;
  26817. /** @hidden */
  26818. _resetPointsArrayCache(): void;
  26819. /** @hidden */
  26820. _generatePointsArray(): boolean;
  26821. /**
  26822. * Gets a value indicating if the geometry is disposed
  26823. * @returns true if the geometry was disposed
  26824. */
  26825. isDisposed(): boolean;
  26826. private _disposeVertexArrayObjects;
  26827. /**
  26828. * Free all associated resources
  26829. */
  26830. dispose(): void;
  26831. /**
  26832. * Clone the current geometry into a new geometry
  26833. * @param id defines the unique ID of the new geometry
  26834. * @returns a new geometry object
  26835. */
  26836. copy(id: string): Geometry;
  26837. /**
  26838. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26839. * @return a JSON representation of the current geometry data (without the vertices data)
  26840. */
  26841. serialize(): any;
  26842. private toNumberArray;
  26843. /**
  26844. * Serialize all vertices data into a JSON oject
  26845. * @returns a JSON representation of the current geometry data
  26846. */
  26847. serializeVerticeData(): any;
  26848. /**
  26849. * Extracts a clone of a mesh geometry
  26850. * @param mesh defines the source mesh
  26851. * @param id defines the unique ID of the new geometry object
  26852. * @returns the new geometry object
  26853. */
  26854. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26855. /**
  26856. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26857. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26858. * Be aware Math.random() could cause collisions, but:
  26859. * "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"
  26860. * @returns a string containing a new GUID
  26861. */
  26862. static RandomId(): string;
  26863. /** @hidden */
  26864. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26865. private static _CleanMatricesWeights;
  26866. /**
  26867. * Create a new geometry from persisted data (Using .babylon file format)
  26868. * @param parsedVertexData defines the persisted data
  26869. * @param scene defines the hosting scene
  26870. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26871. * @returns the new geometry object
  26872. */
  26873. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26874. }
  26875. }
  26876. declare module "babylonjs/Meshes/mesh.vertexData" {
  26877. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26878. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26879. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26880. import { Geometry } from "babylonjs/Meshes/geometry";
  26881. import { Mesh } from "babylonjs/Meshes/mesh";
  26882. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  26883. /**
  26884. * Define an interface for all classes that will get and set the data on vertices
  26885. */
  26886. export interface IGetSetVerticesData {
  26887. /**
  26888. * Gets a boolean indicating if specific vertex data is present
  26889. * @param kind defines the vertex data kind to use
  26890. * @returns true is data kind is present
  26891. */
  26892. isVerticesDataPresent(kind: string): boolean;
  26893. /**
  26894. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26895. * @param kind defines the data kind (Position, normal, etc...)
  26896. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26897. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26898. * @returns a float array containing vertex data
  26899. */
  26900. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26901. /**
  26902. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26903. * @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.
  26904. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26905. * @returns the indices array or an empty array if the mesh has no geometry
  26906. */
  26907. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26908. /**
  26909. * Set specific vertex data
  26910. * @param kind defines the data kind (Position, normal, etc...)
  26911. * @param data defines the vertex data to use
  26912. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26913. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26914. */
  26915. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26916. /**
  26917. * Update a specific associated vertex buffer
  26918. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26919. * - VertexBuffer.PositionKind
  26920. * - VertexBuffer.UVKind
  26921. * - VertexBuffer.UV2Kind
  26922. * - VertexBuffer.UV3Kind
  26923. * - VertexBuffer.UV4Kind
  26924. * - VertexBuffer.UV5Kind
  26925. * - VertexBuffer.UV6Kind
  26926. * - VertexBuffer.ColorKind
  26927. * - VertexBuffer.MatricesIndicesKind
  26928. * - VertexBuffer.MatricesIndicesExtraKind
  26929. * - VertexBuffer.MatricesWeightsKind
  26930. * - VertexBuffer.MatricesWeightsExtraKind
  26931. * @param data defines the data source
  26932. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26933. * @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)
  26934. */
  26935. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26936. /**
  26937. * Creates a new index buffer
  26938. * @param indices defines the indices to store in the index buffer
  26939. * @param totalVertices defines the total number of vertices (could be null)
  26940. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26941. */
  26942. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26943. }
  26944. /**
  26945. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26946. */
  26947. export class VertexData {
  26948. /**
  26949. * Mesh side orientation : usually the external or front surface
  26950. */
  26951. static readonly FRONTSIDE: number;
  26952. /**
  26953. * Mesh side orientation : usually the internal or back surface
  26954. */
  26955. static readonly BACKSIDE: number;
  26956. /**
  26957. * Mesh side orientation : both internal and external or front and back surfaces
  26958. */
  26959. static readonly DOUBLESIDE: number;
  26960. /**
  26961. * Mesh side orientation : by default, `FRONTSIDE`
  26962. */
  26963. static readonly DEFAULTSIDE: number;
  26964. /**
  26965. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26966. */
  26967. positions: Nullable<FloatArray>;
  26968. /**
  26969. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26970. */
  26971. normals: Nullable<FloatArray>;
  26972. /**
  26973. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26974. */
  26975. tangents: Nullable<FloatArray>;
  26976. /**
  26977. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26978. */
  26979. uvs: Nullable<FloatArray>;
  26980. /**
  26981. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26982. */
  26983. uvs2: Nullable<FloatArray>;
  26984. /**
  26985. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26986. */
  26987. uvs3: Nullable<FloatArray>;
  26988. /**
  26989. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26990. */
  26991. uvs4: Nullable<FloatArray>;
  26992. /**
  26993. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26994. */
  26995. uvs5: Nullable<FloatArray>;
  26996. /**
  26997. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26998. */
  26999. uvs6: Nullable<FloatArray>;
  27000. /**
  27001. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27002. */
  27003. colors: Nullable<FloatArray>;
  27004. /**
  27005. * 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).
  27006. */
  27007. matricesIndices: Nullable<FloatArray>;
  27008. /**
  27009. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27010. */
  27011. matricesWeights: Nullable<FloatArray>;
  27012. /**
  27013. * An array extending the number of possible indices
  27014. */
  27015. matricesIndicesExtra: Nullable<FloatArray>;
  27016. /**
  27017. * An array extending the number of possible weights when the number of indices is extended
  27018. */
  27019. matricesWeightsExtra: Nullable<FloatArray>;
  27020. /**
  27021. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27022. */
  27023. indices: Nullable<IndicesArray>;
  27024. /**
  27025. * Uses the passed data array to set the set the values for the specified kind of data
  27026. * @param data a linear array of floating numbers
  27027. * @param kind the type of data that is being set, eg positions, colors etc
  27028. */
  27029. set(data: FloatArray, kind: string): void;
  27030. /**
  27031. * Associates the vertexData to the passed Mesh.
  27032. * Sets it as updatable or not (default `false`)
  27033. * @param mesh the mesh the vertexData is applied to
  27034. * @param updatable when used and having the value true allows new data to update the vertexData
  27035. * @returns the VertexData
  27036. */
  27037. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27038. /**
  27039. * Associates the vertexData to the passed Geometry.
  27040. * Sets it as updatable or not (default `false`)
  27041. * @param geometry the geometry the vertexData is applied to
  27042. * @param updatable when used and having the value true allows new data to update the vertexData
  27043. * @returns VertexData
  27044. */
  27045. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27046. /**
  27047. * Updates the associated mesh
  27048. * @param mesh the mesh to be updated
  27049. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27050. * @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
  27051. * @returns VertexData
  27052. */
  27053. updateMesh(mesh: Mesh): VertexData;
  27054. /**
  27055. * Updates the associated geometry
  27056. * @param geometry the geometry to be updated
  27057. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27058. * @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
  27059. * @returns VertexData.
  27060. */
  27061. updateGeometry(geometry: Geometry): VertexData;
  27062. private _applyTo;
  27063. private _update;
  27064. /**
  27065. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27066. * @param matrix the transforming matrix
  27067. * @returns the VertexData
  27068. */
  27069. transform(matrix: Matrix): VertexData;
  27070. /**
  27071. * Merges the passed VertexData into the current one
  27072. * @param other the VertexData to be merged into the current one
  27073. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27074. * @returns the modified VertexData
  27075. */
  27076. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27077. private _mergeElement;
  27078. private _validate;
  27079. /**
  27080. * Serializes the VertexData
  27081. * @returns a serialized object
  27082. */
  27083. serialize(): any;
  27084. /**
  27085. * Extracts the vertexData from a mesh
  27086. * @param mesh the mesh from which to extract the VertexData
  27087. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27088. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27089. * @returns the object VertexData associated to the passed mesh
  27090. */
  27091. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27092. /**
  27093. * Extracts the vertexData from the geometry
  27094. * @param geometry the geometry from which to extract the VertexData
  27095. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27096. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27097. * @returns the object VertexData associated to the passed mesh
  27098. */
  27099. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27100. private static _ExtractFrom;
  27101. /**
  27102. * Creates the VertexData for a Ribbon
  27103. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27104. * * pathArray array of paths, each of which an array of successive Vector3
  27105. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27106. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27107. * * 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
  27108. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27109. * * 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)
  27110. * * 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)
  27111. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27112. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27113. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27114. * @returns the VertexData of the ribbon
  27115. */
  27116. static CreateRibbon(options: {
  27117. pathArray: Vector3[][];
  27118. closeArray?: boolean;
  27119. closePath?: boolean;
  27120. offset?: number;
  27121. sideOrientation?: number;
  27122. frontUVs?: Vector4;
  27123. backUVs?: Vector4;
  27124. invertUV?: boolean;
  27125. uvs?: Vector2[];
  27126. colors?: Color4[];
  27127. }): VertexData;
  27128. /**
  27129. * Creates the VertexData for a box
  27130. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27131. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27132. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27133. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27134. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27135. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27136. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27137. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27138. * * 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)
  27139. * * 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)
  27140. * @returns the VertexData of the box
  27141. */
  27142. static CreateBox(options: {
  27143. size?: number;
  27144. width?: number;
  27145. height?: number;
  27146. depth?: number;
  27147. faceUV?: Vector4[];
  27148. faceColors?: Color4[];
  27149. sideOrientation?: number;
  27150. frontUVs?: Vector4;
  27151. backUVs?: Vector4;
  27152. }): VertexData;
  27153. /**
  27154. * Creates the VertexData for a tiled box
  27155. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27156. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27157. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27158. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27160. * @returns the VertexData of the box
  27161. */
  27162. static CreateTiledBox(options: {
  27163. pattern?: number;
  27164. width?: number;
  27165. height?: number;
  27166. depth?: number;
  27167. tileSize?: number;
  27168. tileWidth?: number;
  27169. tileHeight?: number;
  27170. alignHorizontal?: number;
  27171. alignVertical?: number;
  27172. faceUV?: Vector4[];
  27173. faceColors?: Color4[];
  27174. sideOrientation?: number;
  27175. }): VertexData;
  27176. /**
  27177. * Creates the VertexData for a tiled plane
  27178. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27179. * * pattern a limited pattern arrangement depending on the number
  27180. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27181. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27182. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27183. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27184. * * 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)
  27185. * * 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)
  27186. * @returns the VertexData of the tiled plane
  27187. */
  27188. static CreateTiledPlane(options: {
  27189. pattern?: number;
  27190. tileSize?: number;
  27191. tileWidth?: number;
  27192. tileHeight?: number;
  27193. size?: number;
  27194. width?: number;
  27195. height?: number;
  27196. alignHorizontal?: number;
  27197. alignVertical?: number;
  27198. sideOrientation?: number;
  27199. frontUVs?: Vector4;
  27200. backUVs?: Vector4;
  27201. }): VertexData;
  27202. /**
  27203. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27204. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27205. * * segments sets the number of horizontal strips optional, default 32
  27206. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27207. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27208. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27209. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27210. * * 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
  27211. * * 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
  27212. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27213. * * 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)
  27214. * * 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)
  27215. * @returns the VertexData of the ellipsoid
  27216. */
  27217. static CreateSphere(options: {
  27218. segments?: number;
  27219. diameter?: number;
  27220. diameterX?: number;
  27221. diameterY?: number;
  27222. diameterZ?: number;
  27223. arc?: number;
  27224. slice?: number;
  27225. sideOrientation?: number;
  27226. frontUVs?: Vector4;
  27227. backUVs?: Vector4;
  27228. }): VertexData;
  27229. /**
  27230. * Creates the VertexData for a cylinder, cone or prism
  27231. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27232. * * height sets the height (y direction) of the cylinder, optional, default 2
  27233. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27234. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27235. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27236. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27237. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27238. * * 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
  27239. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27240. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27241. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27242. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27244. * * 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)
  27245. * * 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)
  27246. * @returns the VertexData of the cylinder, cone or prism
  27247. */
  27248. static CreateCylinder(options: {
  27249. height?: number;
  27250. diameterTop?: number;
  27251. diameterBottom?: number;
  27252. diameter?: number;
  27253. tessellation?: number;
  27254. subdivisions?: number;
  27255. arc?: number;
  27256. faceColors?: Color4[];
  27257. faceUV?: Vector4[];
  27258. hasRings?: boolean;
  27259. enclose?: boolean;
  27260. sideOrientation?: number;
  27261. frontUVs?: Vector4;
  27262. backUVs?: Vector4;
  27263. }): VertexData;
  27264. /**
  27265. * Creates the VertexData for a torus
  27266. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27267. * * diameter the diameter of the torus, optional default 1
  27268. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27269. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27270. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27271. * * 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)
  27272. * * 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)
  27273. * @returns the VertexData of the torus
  27274. */
  27275. static CreateTorus(options: {
  27276. diameter?: number;
  27277. thickness?: number;
  27278. tessellation?: number;
  27279. sideOrientation?: number;
  27280. frontUVs?: Vector4;
  27281. backUVs?: Vector4;
  27282. }): VertexData;
  27283. /**
  27284. * Creates the VertexData of the LineSystem
  27285. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27286. * - lines an array of lines, each line being an array of successive Vector3
  27287. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27288. * @returns the VertexData of the LineSystem
  27289. */
  27290. static CreateLineSystem(options: {
  27291. lines: Vector3[][];
  27292. colors?: Nullable<Color4[][]>;
  27293. }): VertexData;
  27294. /**
  27295. * Create the VertexData for a DashedLines
  27296. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27297. * - points an array successive Vector3
  27298. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27299. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27300. * - dashNb the intended total number of dashes, optional, default 200
  27301. * @returns the VertexData for the DashedLines
  27302. */
  27303. static CreateDashedLines(options: {
  27304. points: Vector3[];
  27305. dashSize?: number;
  27306. gapSize?: number;
  27307. dashNb?: number;
  27308. }): VertexData;
  27309. /**
  27310. * Creates the VertexData for a Ground
  27311. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27312. * - width the width (x direction) of the ground, optional, default 1
  27313. * - height the height (z direction) of the ground, optional, default 1
  27314. * - subdivisions the number of subdivisions per side, optional, default 1
  27315. * @returns the VertexData of the Ground
  27316. */
  27317. static CreateGround(options: {
  27318. width?: number;
  27319. height?: number;
  27320. subdivisions?: number;
  27321. subdivisionsX?: number;
  27322. subdivisionsY?: number;
  27323. }): VertexData;
  27324. /**
  27325. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27326. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27327. * * xmin the ground minimum X coordinate, optional, default -1
  27328. * * zmin the ground minimum Z coordinate, optional, default -1
  27329. * * xmax the ground maximum X coordinate, optional, default 1
  27330. * * zmax the ground maximum Z coordinate, optional, default 1
  27331. * * 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}
  27332. * * 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}
  27333. * @returns the VertexData of the TiledGround
  27334. */
  27335. static CreateTiledGround(options: {
  27336. xmin: number;
  27337. zmin: number;
  27338. xmax: number;
  27339. zmax: number;
  27340. subdivisions?: {
  27341. w: number;
  27342. h: number;
  27343. };
  27344. precision?: {
  27345. w: number;
  27346. h: number;
  27347. };
  27348. }): VertexData;
  27349. /**
  27350. * Creates the VertexData of the Ground designed from a heightmap
  27351. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27352. * * width the width (x direction) of the ground
  27353. * * height the height (z direction) of the ground
  27354. * * subdivisions the number of subdivisions per side
  27355. * * minHeight the minimum altitude on the ground, optional, default 0
  27356. * * maxHeight the maximum altitude on the ground, optional default 1
  27357. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27358. * * buffer the array holding the image color data
  27359. * * bufferWidth the width of image
  27360. * * bufferHeight the height of image
  27361. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27362. * @returns the VertexData of the Ground designed from a heightmap
  27363. */
  27364. static CreateGroundFromHeightMap(options: {
  27365. width: number;
  27366. height: number;
  27367. subdivisions: number;
  27368. minHeight: number;
  27369. maxHeight: number;
  27370. colorFilter: Color3;
  27371. buffer: Uint8Array;
  27372. bufferWidth: number;
  27373. bufferHeight: number;
  27374. alphaFilter: number;
  27375. }): VertexData;
  27376. /**
  27377. * Creates the VertexData for a Plane
  27378. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27379. * * size sets the width and height of the plane to the value of size, optional default 1
  27380. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27381. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27382. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27383. * * 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)
  27384. * * 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)
  27385. * @returns the VertexData of the box
  27386. */
  27387. static CreatePlane(options: {
  27388. size?: number;
  27389. width?: number;
  27390. height?: number;
  27391. sideOrientation?: number;
  27392. frontUVs?: Vector4;
  27393. backUVs?: Vector4;
  27394. }): VertexData;
  27395. /**
  27396. * Creates the VertexData of the Disc or regular Polygon
  27397. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27398. * * radius the radius of the disc, optional default 0.5
  27399. * * tessellation the number of polygon sides, optional, default 64
  27400. * * 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
  27401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27402. * * 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)
  27403. * * 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)
  27404. * @returns the VertexData of the box
  27405. */
  27406. static CreateDisc(options: {
  27407. radius?: number;
  27408. tessellation?: number;
  27409. arc?: number;
  27410. sideOrientation?: number;
  27411. frontUVs?: Vector4;
  27412. backUVs?: Vector4;
  27413. }): VertexData;
  27414. /**
  27415. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27416. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27417. * @param polygon a mesh built from polygonTriangulation.build()
  27418. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27419. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27420. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27421. * @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)
  27422. * @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)
  27423. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27424. * @returns the VertexData of the Polygon
  27425. */
  27426. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27427. /**
  27428. * Creates the VertexData of the IcoSphere
  27429. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27430. * * radius the radius of the IcoSphere, optional default 1
  27431. * * radiusX allows stretching in the x direction, optional, default radius
  27432. * * radiusY allows stretching in the y direction, optional, default radius
  27433. * * radiusZ allows stretching in the z direction, optional, default radius
  27434. * * flat when true creates a flat shaded mesh, optional, default true
  27435. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27436. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27437. * * 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)
  27438. * * 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)
  27439. * @returns the VertexData of the IcoSphere
  27440. */
  27441. static CreateIcoSphere(options: {
  27442. radius?: number;
  27443. radiusX?: number;
  27444. radiusY?: number;
  27445. radiusZ?: number;
  27446. flat?: boolean;
  27447. subdivisions?: number;
  27448. sideOrientation?: number;
  27449. frontUVs?: Vector4;
  27450. backUVs?: Vector4;
  27451. }): VertexData;
  27452. /**
  27453. * Creates the VertexData for a Polyhedron
  27454. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27455. * * type provided types are:
  27456. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27457. * * 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)
  27458. * * size the size of the IcoSphere, optional default 1
  27459. * * sizeX allows stretching in the x direction, optional, default size
  27460. * * sizeY allows stretching in the y direction, optional, default size
  27461. * * sizeZ allows stretching in the z direction, optional, default size
  27462. * * 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
  27463. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27464. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27465. * * flat when true creates a flat shaded mesh, optional, default true
  27466. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27468. * * 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)
  27469. * * 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)
  27470. * @returns the VertexData of the Polyhedron
  27471. */
  27472. static CreatePolyhedron(options: {
  27473. type?: number;
  27474. size?: number;
  27475. sizeX?: number;
  27476. sizeY?: number;
  27477. sizeZ?: number;
  27478. custom?: any;
  27479. faceUV?: Vector4[];
  27480. faceColors?: Color4[];
  27481. flat?: boolean;
  27482. sideOrientation?: number;
  27483. frontUVs?: Vector4;
  27484. backUVs?: Vector4;
  27485. }): VertexData;
  27486. /**
  27487. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  27488. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  27489. * @returns the VertexData of the Capsule
  27490. */
  27491. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  27492. /**
  27493. * Creates the VertexData for a TorusKnot
  27494. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27495. * * radius the radius of the torus knot, optional, default 2
  27496. * * tube the thickness of the tube, optional, default 0.5
  27497. * * radialSegments the number of sides on each tube segments, optional, default 32
  27498. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27499. * * p the number of windings around the z axis, optional, default 2
  27500. * * q the number of windings around the x axis, optional, default 3
  27501. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27502. * * 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)
  27503. * * 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)
  27504. * @returns the VertexData of the Torus Knot
  27505. */
  27506. static CreateTorusKnot(options: {
  27507. radius?: number;
  27508. tube?: number;
  27509. radialSegments?: number;
  27510. tubularSegments?: number;
  27511. p?: number;
  27512. q?: number;
  27513. sideOrientation?: number;
  27514. frontUVs?: Vector4;
  27515. backUVs?: Vector4;
  27516. }): VertexData;
  27517. /**
  27518. * Compute normals for given positions and indices
  27519. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27520. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27521. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27522. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27523. * * facetNormals : optional array of facet normals (vector3)
  27524. * * facetPositions : optional array of facet positions (vector3)
  27525. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27526. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27527. * * bInfo : optional bounding info, required for facetPartitioning computation
  27528. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27529. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27530. * * useRightHandedSystem: optional boolean to for right handed system computation
  27531. * * depthSort : optional boolean to enable the facet depth sort computation
  27532. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27533. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27534. */
  27535. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27536. facetNormals?: any;
  27537. facetPositions?: any;
  27538. facetPartitioning?: any;
  27539. ratio?: number;
  27540. bInfo?: any;
  27541. bbSize?: Vector3;
  27542. subDiv?: any;
  27543. useRightHandedSystem?: boolean;
  27544. depthSort?: boolean;
  27545. distanceTo?: Vector3;
  27546. depthSortedFacets?: any;
  27547. }): void;
  27548. /** @hidden */
  27549. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27550. /**
  27551. * Applies VertexData created from the imported parameters to the geometry
  27552. * @param parsedVertexData the parsed data from an imported file
  27553. * @param geometry the geometry to apply the VertexData to
  27554. */
  27555. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27556. }
  27557. }
  27558. declare module "babylonjs/Morph/morphTarget" {
  27559. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27560. import { Observable } from "babylonjs/Misc/observable";
  27561. import { Nullable, FloatArray } from "babylonjs/types";
  27562. import { Scene } from "babylonjs/scene";
  27563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27564. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27565. /**
  27566. * Defines a target to use with MorphTargetManager
  27567. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27568. */
  27569. export class MorphTarget implements IAnimatable {
  27570. /** defines the name of the target */
  27571. name: string;
  27572. /**
  27573. * Gets or sets the list of animations
  27574. */
  27575. animations: import("babylonjs/Animations/animation").Animation[];
  27576. private _scene;
  27577. private _positions;
  27578. private _normals;
  27579. private _tangents;
  27580. private _uvs;
  27581. private _influence;
  27582. private _uniqueId;
  27583. /**
  27584. * Observable raised when the influence changes
  27585. */
  27586. onInfluenceChanged: Observable<boolean>;
  27587. /** @hidden */
  27588. _onDataLayoutChanged: Observable<void>;
  27589. /**
  27590. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27591. */
  27592. get influence(): number;
  27593. set influence(influence: number);
  27594. /**
  27595. * Gets or sets the id of the morph Target
  27596. */
  27597. id: string;
  27598. private _animationPropertiesOverride;
  27599. /**
  27600. * Gets or sets the animation properties override
  27601. */
  27602. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27603. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27604. /**
  27605. * Creates a new MorphTarget
  27606. * @param name defines the name of the target
  27607. * @param influence defines the influence to use
  27608. * @param scene defines the scene the morphtarget belongs to
  27609. */
  27610. constructor(
  27611. /** defines the name of the target */
  27612. name: string, influence?: number, scene?: Nullable<Scene>);
  27613. /**
  27614. * Gets the unique ID of this manager
  27615. */
  27616. get uniqueId(): number;
  27617. /**
  27618. * Gets a boolean defining if the target contains position data
  27619. */
  27620. get hasPositions(): boolean;
  27621. /**
  27622. * Gets a boolean defining if the target contains normal data
  27623. */
  27624. get hasNormals(): boolean;
  27625. /**
  27626. * Gets a boolean defining if the target contains tangent data
  27627. */
  27628. get hasTangents(): boolean;
  27629. /**
  27630. * Gets a boolean defining if the target contains texture coordinates data
  27631. */
  27632. get hasUVs(): boolean;
  27633. /**
  27634. * Affects position data to this target
  27635. * @param data defines the position data to use
  27636. */
  27637. setPositions(data: Nullable<FloatArray>): void;
  27638. /**
  27639. * Gets the position data stored in this target
  27640. * @returns a FloatArray containing the position data (or null if not present)
  27641. */
  27642. getPositions(): Nullable<FloatArray>;
  27643. /**
  27644. * Affects normal data to this target
  27645. * @param data defines the normal data to use
  27646. */
  27647. setNormals(data: Nullable<FloatArray>): void;
  27648. /**
  27649. * Gets the normal data stored in this target
  27650. * @returns a FloatArray containing the normal data (or null if not present)
  27651. */
  27652. getNormals(): Nullable<FloatArray>;
  27653. /**
  27654. * Affects tangent data to this target
  27655. * @param data defines the tangent data to use
  27656. */
  27657. setTangents(data: Nullable<FloatArray>): void;
  27658. /**
  27659. * Gets the tangent data stored in this target
  27660. * @returns a FloatArray containing the tangent data (or null if not present)
  27661. */
  27662. getTangents(): Nullable<FloatArray>;
  27663. /**
  27664. * Affects texture coordinates data to this target
  27665. * @param data defines the texture coordinates data to use
  27666. */
  27667. setUVs(data: Nullable<FloatArray>): void;
  27668. /**
  27669. * Gets the texture coordinates data stored in this target
  27670. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27671. */
  27672. getUVs(): Nullable<FloatArray>;
  27673. /**
  27674. * Clone the current target
  27675. * @returns a new MorphTarget
  27676. */
  27677. clone(): MorphTarget;
  27678. /**
  27679. * Serializes the current target into a Serialization object
  27680. * @returns the serialized object
  27681. */
  27682. serialize(): any;
  27683. /**
  27684. * Returns the string "MorphTarget"
  27685. * @returns "MorphTarget"
  27686. */
  27687. getClassName(): string;
  27688. /**
  27689. * Creates a new target from serialized data
  27690. * @param serializationObject defines the serialized data to use
  27691. * @returns a new MorphTarget
  27692. */
  27693. static Parse(serializationObject: any): MorphTarget;
  27694. /**
  27695. * Creates a MorphTarget from mesh data
  27696. * @param mesh defines the source mesh
  27697. * @param name defines the name to use for the new target
  27698. * @param influence defines the influence to attach to the target
  27699. * @returns a new MorphTarget
  27700. */
  27701. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27702. }
  27703. }
  27704. declare module "babylonjs/Morph/morphTargetManager" {
  27705. import { Nullable } from "babylonjs/types";
  27706. import { Scene } from "babylonjs/scene";
  27707. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27708. /**
  27709. * This class is used to deform meshes using morphing between different targets
  27710. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27711. */
  27712. export class MorphTargetManager {
  27713. private _targets;
  27714. private _targetInfluenceChangedObservers;
  27715. private _targetDataLayoutChangedObservers;
  27716. private _activeTargets;
  27717. private _scene;
  27718. private _influences;
  27719. private _supportsNormals;
  27720. private _supportsTangents;
  27721. private _supportsUVs;
  27722. private _vertexCount;
  27723. private _uniqueId;
  27724. private _tempInfluences;
  27725. /**
  27726. * Gets or sets a boolean indicating if normals must be morphed
  27727. */
  27728. enableNormalMorphing: boolean;
  27729. /**
  27730. * Gets or sets a boolean indicating if tangents must be morphed
  27731. */
  27732. enableTangentMorphing: boolean;
  27733. /**
  27734. * Gets or sets a boolean indicating if UV must be morphed
  27735. */
  27736. enableUVMorphing: boolean;
  27737. /**
  27738. * Creates a new MorphTargetManager
  27739. * @param scene defines the current scene
  27740. */
  27741. constructor(scene?: Nullable<Scene>);
  27742. /**
  27743. * Gets the unique ID of this manager
  27744. */
  27745. get uniqueId(): number;
  27746. /**
  27747. * Gets the number of vertices handled by this manager
  27748. */
  27749. get vertexCount(): number;
  27750. /**
  27751. * Gets a boolean indicating if this manager supports morphing of normals
  27752. */
  27753. get supportsNormals(): boolean;
  27754. /**
  27755. * Gets a boolean indicating if this manager supports morphing of tangents
  27756. */
  27757. get supportsTangents(): boolean;
  27758. /**
  27759. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27760. */
  27761. get supportsUVs(): boolean;
  27762. /**
  27763. * Gets the number of targets stored in this manager
  27764. */
  27765. get numTargets(): number;
  27766. /**
  27767. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27768. */
  27769. get numInfluencers(): number;
  27770. /**
  27771. * Gets the list of influences (one per target)
  27772. */
  27773. get influences(): Float32Array;
  27774. /**
  27775. * Gets the active target at specified index. An active target is a target with an influence > 0
  27776. * @param index defines the index to check
  27777. * @returns the requested target
  27778. */
  27779. getActiveTarget(index: number): MorphTarget;
  27780. /**
  27781. * Gets the target at specified index
  27782. * @param index defines the index to check
  27783. * @returns the requested target
  27784. */
  27785. getTarget(index: number): MorphTarget;
  27786. /**
  27787. * Add a new target to this manager
  27788. * @param target defines the target to add
  27789. */
  27790. addTarget(target: MorphTarget): void;
  27791. /**
  27792. * Removes a target from the manager
  27793. * @param target defines the target to remove
  27794. */
  27795. removeTarget(target: MorphTarget): void;
  27796. /**
  27797. * Clone the current manager
  27798. * @returns a new MorphTargetManager
  27799. */
  27800. clone(): MorphTargetManager;
  27801. /**
  27802. * Serializes the current manager into a Serialization object
  27803. * @returns the serialized object
  27804. */
  27805. serialize(): any;
  27806. private _syncActiveTargets;
  27807. /**
  27808. * Syncrhonize the targets with all the meshes using this morph target manager
  27809. */
  27810. synchronize(): void;
  27811. /**
  27812. * Creates a new MorphTargetManager from serialized data
  27813. * @param serializationObject defines the serialized data
  27814. * @param scene defines the hosting scene
  27815. * @returns the new MorphTargetManager
  27816. */
  27817. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27818. }
  27819. }
  27820. declare module "babylonjs/Meshes/meshLODLevel" {
  27821. import { Mesh } from "babylonjs/Meshes/mesh";
  27822. import { Nullable } from "babylonjs/types";
  27823. /**
  27824. * Class used to represent a specific level of detail of a mesh
  27825. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27826. */
  27827. export class MeshLODLevel {
  27828. /** Defines the distance where this level should start being displayed */
  27829. distance: number;
  27830. /** Defines the mesh to use to render this level */
  27831. mesh: Nullable<Mesh>;
  27832. /**
  27833. * Creates a new LOD level
  27834. * @param distance defines the distance where this level should star being displayed
  27835. * @param mesh defines the mesh to use to render this level
  27836. */
  27837. constructor(
  27838. /** Defines the distance where this level should start being displayed */
  27839. distance: number,
  27840. /** Defines the mesh to use to render this level */
  27841. mesh: Nullable<Mesh>);
  27842. }
  27843. }
  27844. declare module "babylonjs/Misc/canvasGenerator" {
  27845. /**
  27846. * Helper class used to generate a canvas to manipulate images
  27847. */
  27848. export class CanvasGenerator {
  27849. /**
  27850. * Create a new canvas (or offscreen canvas depending on the context)
  27851. * @param width defines the expected width
  27852. * @param height defines the expected height
  27853. * @return a new canvas or offscreen canvas
  27854. */
  27855. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27856. }
  27857. }
  27858. declare module "babylonjs/Meshes/groundMesh" {
  27859. import { Scene } from "babylonjs/scene";
  27860. import { Vector3 } from "babylonjs/Maths/math.vector";
  27861. import { Mesh } from "babylonjs/Meshes/mesh";
  27862. /**
  27863. * Mesh representing the gorund
  27864. */
  27865. export class GroundMesh extends Mesh {
  27866. /** If octree should be generated */
  27867. generateOctree: boolean;
  27868. private _heightQuads;
  27869. /** @hidden */
  27870. _subdivisionsX: number;
  27871. /** @hidden */
  27872. _subdivisionsY: number;
  27873. /** @hidden */
  27874. _width: number;
  27875. /** @hidden */
  27876. _height: number;
  27877. /** @hidden */
  27878. _minX: number;
  27879. /** @hidden */
  27880. _maxX: number;
  27881. /** @hidden */
  27882. _minZ: number;
  27883. /** @hidden */
  27884. _maxZ: number;
  27885. constructor(name: string, scene: Scene);
  27886. /**
  27887. * "GroundMesh"
  27888. * @returns "GroundMesh"
  27889. */
  27890. getClassName(): string;
  27891. /**
  27892. * The minimum of x and y subdivisions
  27893. */
  27894. get subdivisions(): number;
  27895. /**
  27896. * X subdivisions
  27897. */
  27898. get subdivisionsX(): number;
  27899. /**
  27900. * Y subdivisions
  27901. */
  27902. get subdivisionsY(): number;
  27903. /**
  27904. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27905. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27906. * @param chunksCount the number of subdivisions for x and y
  27907. * @param octreeBlocksSize (Default: 32)
  27908. */
  27909. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27910. /**
  27911. * Returns a height (y) value in the Worl system :
  27912. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27913. * @param x x coordinate
  27914. * @param z z coordinate
  27915. * @returns the ground y position if (x, z) are outside the ground surface.
  27916. */
  27917. getHeightAtCoordinates(x: number, z: number): number;
  27918. /**
  27919. * Returns a normalized vector (Vector3) orthogonal to the ground
  27920. * at the ground coordinates (x, z) expressed in the World system.
  27921. * @param x x coordinate
  27922. * @param z z coordinate
  27923. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27924. */
  27925. getNormalAtCoordinates(x: number, z: number): Vector3;
  27926. /**
  27927. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27928. * at the ground coordinates (x, z) expressed in the World system.
  27929. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27930. * @param x x coordinate
  27931. * @param z z coordinate
  27932. * @param ref vector to store the result
  27933. * @returns the GroundMesh.
  27934. */
  27935. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27936. /**
  27937. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27938. * if the ground has been updated.
  27939. * This can be used in the render loop.
  27940. * @returns the GroundMesh.
  27941. */
  27942. updateCoordinateHeights(): GroundMesh;
  27943. private _getFacetAt;
  27944. private _initHeightQuads;
  27945. private _computeHeightQuads;
  27946. /**
  27947. * Serializes this ground mesh
  27948. * @param serializationObject object to write serialization to
  27949. */
  27950. serialize(serializationObject: any): void;
  27951. /**
  27952. * Parses a serialized ground mesh
  27953. * @param parsedMesh the serialized mesh
  27954. * @param scene the scene to create the ground mesh in
  27955. * @returns the created ground mesh
  27956. */
  27957. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27958. }
  27959. }
  27960. declare module "babylonjs/Physics/physicsJoint" {
  27961. import { Vector3 } from "babylonjs/Maths/math.vector";
  27962. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27963. /**
  27964. * Interface for Physics-Joint data
  27965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27966. */
  27967. export interface PhysicsJointData {
  27968. /**
  27969. * The main pivot of the joint
  27970. */
  27971. mainPivot?: Vector3;
  27972. /**
  27973. * The connected pivot of the joint
  27974. */
  27975. connectedPivot?: Vector3;
  27976. /**
  27977. * The main axis of the joint
  27978. */
  27979. mainAxis?: Vector3;
  27980. /**
  27981. * The connected axis of the joint
  27982. */
  27983. connectedAxis?: Vector3;
  27984. /**
  27985. * The collision of the joint
  27986. */
  27987. collision?: boolean;
  27988. /**
  27989. * Native Oimo/Cannon/Energy data
  27990. */
  27991. nativeParams?: any;
  27992. }
  27993. /**
  27994. * This is a holder class for the physics joint created by the physics plugin
  27995. * It holds a set of functions to control the underlying joint
  27996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27997. */
  27998. export class PhysicsJoint {
  27999. /**
  28000. * The type of the physics joint
  28001. */
  28002. type: number;
  28003. /**
  28004. * The data for the physics joint
  28005. */
  28006. jointData: PhysicsJointData;
  28007. private _physicsJoint;
  28008. protected _physicsPlugin: IPhysicsEnginePlugin;
  28009. /**
  28010. * Initializes the physics joint
  28011. * @param type The type of the physics joint
  28012. * @param jointData The data for the physics joint
  28013. */
  28014. constructor(
  28015. /**
  28016. * The type of the physics joint
  28017. */
  28018. type: number,
  28019. /**
  28020. * The data for the physics joint
  28021. */
  28022. jointData: PhysicsJointData);
  28023. /**
  28024. * Gets the physics joint
  28025. */
  28026. get physicsJoint(): any;
  28027. /**
  28028. * Sets the physics joint
  28029. */
  28030. set physicsJoint(newJoint: any);
  28031. /**
  28032. * Sets the physics plugin
  28033. */
  28034. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  28035. /**
  28036. * Execute a function that is physics-plugin specific.
  28037. * @param {Function} func the function that will be executed.
  28038. * It accepts two parameters: the physics world and the physics joint
  28039. */
  28040. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  28041. /**
  28042. * Distance-Joint type
  28043. */
  28044. static DistanceJoint: number;
  28045. /**
  28046. * Hinge-Joint type
  28047. */
  28048. static HingeJoint: number;
  28049. /**
  28050. * Ball-and-Socket joint type
  28051. */
  28052. static BallAndSocketJoint: number;
  28053. /**
  28054. * Wheel-Joint type
  28055. */
  28056. static WheelJoint: number;
  28057. /**
  28058. * Slider-Joint type
  28059. */
  28060. static SliderJoint: number;
  28061. /**
  28062. * Prismatic-Joint type
  28063. */
  28064. static PrismaticJoint: number;
  28065. /**
  28066. * Universal-Joint type
  28067. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  28068. */
  28069. static UniversalJoint: number;
  28070. /**
  28071. * Hinge-Joint 2 type
  28072. */
  28073. static Hinge2Joint: number;
  28074. /**
  28075. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28076. */
  28077. static PointToPointJoint: number;
  28078. /**
  28079. * Spring-Joint type
  28080. */
  28081. static SpringJoint: number;
  28082. /**
  28083. * Lock-Joint type
  28084. */
  28085. static LockJoint: number;
  28086. }
  28087. /**
  28088. * A class representing a physics distance joint
  28089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28090. */
  28091. export class DistanceJoint extends PhysicsJoint {
  28092. /**
  28093. *
  28094. * @param jointData The data for the Distance-Joint
  28095. */
  28096. constructor(jointData: DistanceJointData);
  28097. /**
  28098. * Update the predefined distance.
  28099. * @param maxDistance The maximum preferred distance
  28100. * @param minDistance The minimum preferred distance
  28101. */
  28102. updateDistance(maxDistance: number, minDistance?: number): void;
  28103. }
  28104. /**
  28105. * Represents a Motor-Enabled Joint
  28106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28107. */
  28108. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28109. /**
  28110. * Initializes the Motor-Enabled Joint
  28111. * @param type The type of the joint
  28112. * @param jointData The physica joint data for the joint
  28113. */
  28114. constructor(type: number, jointData: PhysicsJointData);
  28115. /**
  28116. * Set the motor values.
  28117. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28118. * @param force the force to apply
  28119. * @param maxForce max force for this motor.
  28120. */
  28121. setMotor(force?: number, maxForce?: number): void;
  28122. /**
  28123. * Set the motor's limits.
  28124. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28125. * @param upperLimit The upper limit of the motor
  28126. * @param lowerLimit The lower limit of the motor
  28127. */
  28128. setLimit(upperLimit: number, lowerLimit?: number): void;
  28129. }
  28130. /**
  28131. * This class represents a single physics Hinge-Joint
  28132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28133. */
  28134. export class HingeJoint extends MotorEnabledJoint {
  28135. /**
  28136. * Initializes the Hinge-Joint
  28137. * @param jointData The joint data for the Hinge-Joint
  28138. */
  28139. constructor(jointData: PhysicsJointData);
  28140. /**
  28141. * Set the motor values.
  28142. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28143. * @param {number} force the force to apply
  28144. * @param {number} maxForce max force for this motor.
  28145. */
  28146. setMotor(force?: number, maxForce?: number): void;
  28147. /**
  28148. * Set the motor's limits.
  28149. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28150. * @param upperLimit The upper limit of the motor
  28151. * @param lowerLimit The lower limit of the motor
  28152. */
  28153. setLimit(upperLimit: number, lowerLimit?: number): void;
  28154. }
  28155. /**
  28156. * This class represents a dual hinge physics joint (same as wheel joint)
  28157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28158. */
  28159. export class Hinge2Joint extends MotorEnabledJoint {
  28160. /**
  28161. * Initializes the Hinge2-Joint
  28162. * @param jointData The joint data for the Hinge2-Joint
  28163. */
  28164. constructor(jointData: PhysicsJointData);
  28165. /**
  28166. * Set the motor values.
  28167. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28168. * @param {number} targetSpeed the speed the motor is to reach
  28169. * @param {number} maxForce max force for this motor.
  28170. * @param {motorIndex} the motor's index, 0 or 1.
  28171. */
  28172. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28173. /**
  28174. * Set the motor limits.
  28175. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28176. * @param {number} upperLimit the upper limit
  28177. * @param {number} lowerLimit lower limit
  28178. * @param {motorIndex} the motor's index, 0 or 1.
  28179. */
  28180. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28181. }
  28182. /**
  28183. * Interface for a motor enabled joint
  28184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28185. */
  28186. export interface IMotorEnabledJoint {
  28187. /**
  28188. * Physics joint
  28189. */
  28190. physicsJoint: any;
  28191. /**
  28192. * Sets the motor of the motor-enabled joint
  28193. * @param force The force of the motor
  28194. * @param maxForce The maximum force of the motor
  28195. * @param motorIndex The index of the motor
  28196. */
  28197. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28198. /**
  28199. * Sets the limit of the motor
  28200. * @param upperLimit The upper limit of the motor
  28201. * @param lowerLimit The lower limit of the motor
  28202. * @param motorIndex The index of the motor
  28203. */
  28204. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28205. }
  28206. /**
  28207. * Joint data for a Distance-Joint
  28208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28209. */
  28210. export interface DistanceJointData extends PhysicsJointData {
  28211. /**
  28212. * Max distance the 2 joint objects can be apart
  28213. */
  28214. maxDistance: number;
  28215. }
  28216. /**
  28217. * Joint data from a spring joint
  28218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28219. */
  28220. export interface SpringJointData extends PhysicsJointData {
  28221. /**
  28222. * Length of the spring
  28223. */
  28224. length: number;
  28225. /**
  28226. * Stiffness of the spring
  28227. */
  28228. stiffness: number;
  28229. /**
  28230. * Damping of the spring
  28231. */
  28232. damping: number;
  28233. /** this callback will be called when applying the force to the impostors. */
  28234. forceApplicationCallback: () => void;
  28235. }
  28236. }
  28237. declare module "babylonjs/Physics/physicsRaycastResult" {
  28238. import { Vector3 } from "babylonjs/Maths/math.vector";
  28239. /**
  28240. * Holds the data for the raycast result
  28241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28242. */
  28243. export class PhysicsRaycastResult {
  28244. private _hasHit;
  28245. private _hitDistance;
  28246. private _hitNormalWorld;
  28247. private _hitPointWorld;
  28248. private _rayFromWorld;
  28249. private _rayToWorld;
  28250. /**
  28251. * Gets if there was a hit
  28252. */
  28253. get hasHit(): boolean;
  28254. /**
  28255. * Gets the distance from the hit
  28256. */
  28257. get hitDistance(): number;
  28258. /**
  28259. * Gets the hit normal/direction in the world
  28260. */
  28261. get hitNormalWorld(): Vector3;
  28262. /**
  28263. * Gets the hit point in the world
  28264. */
  28265. get hitPointWorld(): Vector3;
  28266. /**
  28267. * Gets the ray "start point" of the ray in the world
  28268. */
  28269. get rayFromWorld(): Vector3;
  28270. /**
  28271. * Gets the ray "end point" of the ray in the world
  28272. */
  28273. get rayToWorld(): Vector3;
  28274. /**
  28275. * Sets the hit data (normal & point in world space)
  28276. * @param hitNormalWorld defines the normal in world space
  28277. * @param hitPointWorld defines the point in world space
  28278. */
  28279. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28280. /**
  28281. * Sets the distance from the start point to the hit point
  28282. * @param distance
  28283. */
  28284. setHitDistance(distance: number): void;
  28285. /**
  28286. * Calculates the distance manually
  28287. */
  28288. calculateHitDistance(): void;
  28289. /**
  28290. * Resets all the values to default
  28291. * @param from The from point on world space
  28292. * @param to The to point on world space
  28293. */
  28294. reset(from?: Vector3, to?: Vector3): void;
  28295. }
  28296. /**
  28297. * Interface for the size containing width and height
  28298. */
  28299. interface IXYZ {
  28300. /**
  28301. * X
  28302. */
  28303. x: number;
  28304. /**
  28305. * Y
  28306. */
  28307. y: number;
  28308. /**
  28309. * Z
  28310. */
  28311. z: number;
  28312. }
  28313. }
  28314. declare module "babylonjs/Physics/IPhysicsEngine" {
  28315. import { Nullable } from "babylonjs/types";
  28316. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28318. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28319. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28320. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28321. /**
  28322. * Interface used to describe a physics joint
  28323. */
  28324. export interface PhysicsImpostorJoint {
  28325. /** Defines the main impostor to which the joint is linked */
  28326. mainImpostor: PhysicsImpostor;
  28327. /** Defines the impostor that is connected to the main impostor using this joint */
  28328. connectedImpostor: PhysicsImpostor;
  28329. /** Defines the joint itself */
  28330. joint: PhysicsJoint;
  28331. }
  28332. /** @hidden */
  28333. export interface IPhysicsEnginePlugin {
  28334. world: any;
  28335. name: string;
  28336. setGravity(gravity: Vector3): void;
  28337. setTimeStep(timeStep: number): void;
  28338. getTimeStep(): number;
  28339. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28340. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28341. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28342. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28343. removePhysicsBody(impostor: PhysicsImpostor): void;
  28344. generateJoint(joint: PhysicsImpostorJoint): void;
  28345. removeJoint(joint: PhysicsImpostorJoint): void;
  28346. isSupported(): boolean;
  28347. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28348. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28349. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28350. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28351. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28352. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28353. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28354. getBodyMass(impostor: PhysicsImpostor): number;
  28355. getBodyFriction(impostor: PhysicsImpostor): number;
  28356. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28357. getBodyRestitution(impostor: PhysicsImpostor): number;
  28358. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28359. getBodyPressure?(impostor: PhysicsImpostor): number;
  28360. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28361. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28362. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28363. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28364. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28365. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28366. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28367. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28368. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28369. sleepBody(impostor: PhysicsImpostor): void;
  28370. wakeUpBody(impostor: PhysicsImpostor): void;
  28371. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28372. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28373. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28374. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28375. getRadius(impostor: PhysicsImpostor): number;
  28376. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28377. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28378. dispose(): void;
  28379. }
  28380. /**
  28381. * Interface used to define a physics engine
  28382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28383. */
  28384. export interface IPhysicsEngine {
  28385. /**
  28386. * Gets the gravity vector used by the simulation
  28387. */
  28388. gravity: Vector3;
  28389. /**
  28390. * Sets the gravity vector used by the simulation
  28391. * @param gravity defines the gravity vector to use
  28392. */
  28393. setGravity(gravity: Vector3): void;
  28394. /**
  28395. * Set the time step of the physics engine.
  28396. * Default is 1/60.
  28397. * To slow it down, enter 1/600 for example.
  28398. * To speed it up, 1/30
  28399. * @param newTimeStep the new timestep to apply to this world.
  28400. */
  28401. setTimeStep(newTimeStep: number): void;
  28402. /**
  28403. * Get the time step of the physics engine.
  28404. * @returns the current time step
  28405. */
  28406. getTimeStep(): number;
  28407. /**
  28408. * Set the sub time step of the physics engine.
  28409. * Default is 0 meaning there is no sub steps
  28410. * To increase physics resolution precision, set a small value (like 1 ms)
  28411. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28412. */
  28413. setSubTimeStep(subTimeStep: number): void;
  28414. /**
  28415. * Get the sub time step of the physics engine.
  28416. * @returns the current sub time step
  28417. */
  28418. getSubTimeStep(): number;
  28419. /**
  28420. * Release all resources
  28421. */
  28422. dispose(): void;
  28423. /**
  28424. * Gets the name of the current physics plugin
  28425. * @returns the name of the plugin
  28426. */
  28427. getPhysicsPluginName(): string;
  28428. /**
  28429. * Adding a new impostor for the impostor tracking.
  28430. * This will be done by the impostor itself.
  28431. * @param impostor the impostor to add
  28432. */
  28433. addImpostor(impostor: PhysicsImpostor): void;
  28434. /**
  28435. * Remove an impostor from the engine.
  28436. * This impostor and its mesh will not longer be updated by the physics engine.
  28437. * @param impostor the impostor to remove
  28438. */
  28439. removeImpostor(impostor: PhysicsImpostor): void;
  28440. /**
  28441. * Add a joint to the physics engine
  28442. * @param mainImpostor defines the main impostor to which the joint is added.
  28443. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28444. * @param joint defines the joint that will connect both impostors.
  28445. */
  28446. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28447. /**
  28448. * Removes a joint from the simulation
  28449. * @param mainImpostor defines the impostor used with the joint
  28450. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28451. * @param joint defines the joint to remove
  28452. */
  28453. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28454. /**
  28455. * Gets the current plugin used to run the simulation
  28456. * @returns current plugin
  28457. */
  28458. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28459. /**
  28460. * Gets the list of physic impostors
  28461. * @returns an array of PhysicsImpostor
  28462. */
  28463. getImpostors(): Array<PhysicsImpostor>;
  28464. /**
  28465. * Gets the impostor for a physics enabled object
  28466. * @param object defines the object impersonated by the impostor
  28467. * @returns the PhysicsImpostor or null if not found
  28468. */
  28469. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28470. /**
  28471. * Gets the impostor for a physics body object
  28472. * @param body defines physics body used by the impostor
  28473. * @returns the PhysicsImpostor or null if not found
  28474. */
  28475. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28476. /**
  28477. * Does a raycast in the physics world
  28478. * @param from when should the ray start?
  28479. * @param to when should the ray end?
  28480. * @returns PhysicsRaycastResult
  28481. */
  28482. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28483. /**
  28484. * Called by the scene. No need to call it.
  28485. * @param delta defines the timespam between frames
  28486. */
  28487. _step(delta: number): void;
  28488. }
  28489. }
  28490. declare module "babylonjs/Physics/physicsImpostor" {
  28491. import { Nullable, IndicesArray } from "babylonjs/types";
  28492. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28493. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28495. import { Scene } from "babylonjs/scene";
  28496. import { Bone } from "babylonjs/Bones/bone";
  28497. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28498. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28499. import { Space } from "babylonjs/Maths/math.axis";
  28500. /**
  28501. * The interface for the physics imposter parameters
  28502. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28503. */
  28504. export interface PhysicsImpostorParameters {
  28505. /**
  28506. * The mass of the physics imposter
  28507. */
  28508. mass: number;
  28509. /**
  28510. * The friction of the physics imposter
  28511. */
  28512. friction?: number;
  28513. /**
  28514. * The coefficient of restitution of the physics imposter
  28515. */
  28516. restitution?: number;
  28517. /**
  28518. * The native options of the physics imposter
  28519. */
  28520. nativeOptions?: any;
  28521. /**
  28522. * Specifies if the parent should be ignored
  28523. */
  28524. ignoreParent?: boolean;
  28525. /**
  28526. * Specifies if bi-directional transformations should be disabled
  28527. */
  28528. disableBidirectionalTransformation?: boolean;
  28529. /**
  28530. * The pressure inside the physics imposter, soft object only
  28531. */
  28532. pressure?: number;
  28533. /**
  28534. * The stiffness the physics imposter, soft object only
  28535. */
  28536. stiffness?: number;
  28537. /**
  28538. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28539. */
  28540. velocityIterations?: number;
  28541. /**
  28542. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28543. */
  28544. positionIterations?: number;
  28545. /**
  28546. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28547. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28548. * Add to fix multiple points
  28549. */
  28550. fixedPoints?: number;
  28551. /**
  28552. * The collision margin around a soft object
  28553. */
  28554. margin?: number;
  28555. /**
  28556. * The collision margin around a soft object
  28557. */
  28558. damping?: number;
  28559. /**
  28560. * The path for a rope based on an extrusion
  28561. */
  28562. path?: any;
  28563. /**
  28564. * The shape of an extrusion used for a rope based on an extrusion
  28565. */
  28566. shape?: any;
  28567. }
  28568. /**
  28569. * Interface for a physics-enabled object
  28570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28571. */
  28572. export interface IPhysicsEnabledObject {
  28573. /**
  28574. * The position of the physics-enabled object
  28575. */
  28576. position: Vector3;
  28577. /**
  28578. * The rotation of the physics-enabled object
  28579. */
  28580. rotationQuaternion: Nullable<Quaternion>;
  28581. /**
  28582. * The scale of the physics-enabled object
  28583. */
  28584. scaling: Vector3;
  28585. /**
  28586. * The rotation of the physics-enabled object
  28587. */
  28588. rotation?: Vector3;
  28589. /**
  28590. * The parent of the physics-enabled object
  28591. */
  28592. parent?: any;
  28593. /**
  28594. * The bounding info of the physics-enabled object
  28595. * @returns The bounding info of the physics-enabled object
  28596. */
  28597. getBoundingInfo(): BoundingInfo;
  28598. /**
  28599. * Computes the world matrix
  28600. * @param force Specifies if the world matrix should be computed by force
  28601. * @returns A world matrix
  28602. */
  28603. computeWorldMatrix(force: boolean): Matrix;
  28604. /**
  28605. * Gets the world matrix
  28606. * @returns A world matrix
  28607. */
  28608. getWorldMatrix?(): Matrix;
  28609. /**
  28610. * Gets the child meshes
  28611. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28612. * @returns An array of abstract meshes
  28613. */
  28614. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28615. /**
  28616. * Gets the vertex data
  28617. * @param kind The type of vertex data
  28618. * @returns A nullable array of numbers, or a float32 array
  28619. */
  28620. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28621. /**
  28622. * Gets the indices from the mesh
  28623. * @returns A nullable array of index arrays
  28624. */
  28625. getIndices?(): Nullable<IndicesArray>;
  28626. /**
  28627. * Gets the scene from the mesh
  28628. * @returns the indices array or null
  28629. */
  28630. getScene?(): Scene;
  28631. /**
  28632. * Gets the absolute position from the mesh
  28633. * @returns the absolute position
  28634. */
  28635. getAbsolutePosition(): Vector3;
  28636. /**
  28637. * Gets the absolute pivot point from the mesh
  28638. * @returns the absolute pivot point
  28639. */
  28640. getAbsolutePivotPoint(): Vector3;
  28641. /**
  28642. * Rotates the mesh
  28643. * @param axis The axis of rotation
  28644. * @param amount The amount of rotation
  28645. * @param space The space of the rotation
  28646. * @returns The rotation transform node
  28647. */
  28648. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28649. /**
  28650. * Translates the mesh
  28651. * @param axis The axis of translation
  28652. * @param distance The distance of translation
  28653. * @param space The space of the translation
  28654. * @returns The transform node
  28655. */
  28656. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28657. /**
  28658. * Sets the absolute position of the mesh
  28659. * @param absolutePosition The absolute position of the mesh
  28660. * @returns The transform node
  28661. */
  28662. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28663. /**
  28664. * Gets the class name of the mesh
  28665. * @returns The class name
  28666. */
  28667. getClassName(): string;
  28668. }
  28669. /**
  28670. * Represents a physics imposter
  28671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28672. */
  28673. export class PhysicsImpostor {
  28674. /**
  28675. * The physics-enabled object used as the physics imposter
  28676. */
  28677. object: IPhysicsEnabledObject;
  28678. /**
  28679. * The type of the physics imposter
  28680. */
  28681. type: number;
  28682. private _options;
  28683. private _scene?;
  28684. /**
  28685. * The default object size of the imposter
  28686. */
  28687. static DEFAULT_OBJECT_SIZE: Vector3;
  28688. /**
  28689. * The identity quaternion of the imposter
  28690. */
  28691. static IDENTITY_QUATERNION: Quaternion;
  28692. /** @hidden */
  28693. _pluginData: any;
  28694. private _physicsEngine;
  28695. private _physicsBody;
  28696. private _bodyUpdateRequired;
  28697. private _onBeforePhysicsStepCallbacks;
  28698. private _onAfterPhysicsStepCallbacks;
  28699. /** @hidden */
  28700. _onPhysicsCollideCallbacks: Array<{
  28701. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28702. otherImpostors: Array<PhysicsImpostor>;
  28703. }>;
  28704. private _deltaPosition;
  28705. private _deltaRotation;
  28706. private _deltaRotationConjugated;
  28707. /** @hidden */
  28708. _isFromLine: boolean;
  28709. private _parent;
  28710. private _isDisposed;
  28711. private static _tmpVecs;
  28712. private static _tmpQuat;
  28713. /**
  28714. * Specifies if the physics imposter is disposed
  28715. */
  28716. get isDisposed(): boolean;
  28717. /**
  28718. * Gets the mass of the physics imposter
  28719. */
  28720. get mass(): number;
  28721. set mass(value: number);
  28722. /**
  28723. * Gets the coefficient of friction
  28724. */
  28725. get friction(): number;
  28726. /**
  28727. * Sets the coefficient of friction
  28728. */
  28729. set friction(value: number);
  28730. /**
  28731. * Gets the coefficient of restitution
  28732. */
  28733. get restitution(): number;
  28734. /**
  28735. * Sets the coefficient of restitution
  28736. */
  28737. set restitution(value: number);
  28738. /**
  28739. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28740. */
  28741. get pressure(): number;
  28742. /**
  28743. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28744. */
  28745. set pressure(value: number);
  28746. /**
  28747. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28748. */
  28749. get stiffness(): number;
  28750. /**
  28751. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28752. */
  28753. set stiffness(value: number);
  28754. /**
  28755. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28756. */
  28757. get velocityIterations(): number;
  28758. /**
  28759. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28760. */
  28761. set velocityIterations(value: number);
  28762. /**
  28763. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28764. */
  28765. get positionIterations(): number;
  28766. /**
  28767. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28768. */
  28769. set positionIterations(value: number);
  28770. /**
  28771. * The unique id of the physics imposter
  28772. * set by the physics engine when adding this impostor to the array
  28773. */
  28774. uniqueId: number;
  28775. /**
  28776. * @hidden
  28777. */
  28778. soft: boolean;
  28779. /**
  28780. * @hidden
  28781. */
  28782. segments: number;
  28783. private _joints;
  28784. /**
  28785. * Initializes the physics imposter
  28786. * @param object The physics-enabled object used as the physics imposter
  28787. * @param type The type of the physics imposter
  28788. * @param _options The options for the physics imposter
  28789. * @param _scene The Babylon scene
  28790. */
  28791. constructor(
  28792. /**
  28793. * The physics-enabled object used as the physics imposter
  28794. */
  28795. object: IPhysicsEnabledObject,
  28796. /**
  28797. * The type of the physics imposter
  28798. */
  28799. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28800. /**
  28801. * This function will completly initialize this impostor.
  28802. * It will create a new body - but only if this mesh has no parent.
  28803. * If it has, this impostor will not be used other than to define the impostor
  28804. * of the child mesh.
  28805. * @hidden
  28806. */
  28807. _init(): void;
  28808. private _getPhysicsParent;
  28809. /**
  28810. * Should a new body be generated.
  28811. * @returns boolean specifying if body initialization is required
  28812. */
  28813. isBodyInitRequired(): boolean;
  28814. /**
  28815. * Sets the updated scaling
  28816. * @param updated Specifies if the scaling is updated
  28817. */
  28818. setScalingUpdated(): void;
  28819. /**
  28820. * Force a regeneration of this or the parent's impostor's body.
  28821. * Use under cautious - This will remove all joints already implemented.
  28822. */
  28823. forceUpdate(): void;
  28824. /**
  28825. * Gets the body that holds this impostor. Either its own, or its parent.
  28826. */
  28827. get physicsBody(): any;
  28828. /**
  28829. * Get the parent of the physics imposter
  28830. * @returns Physics imposter or null
  28831. */
  28832. get parent(): Nullable<PhysicsImpostor>;
  28833. /**
  28834. * Sets the parent of the physics imposter
  28835. */
  28836. set parent(value: Nullable<PhysicsImpostor>);
  28837. /**
  28838. * Set the physics body. Used mainly by the physics engine/plugin
  28839. */
  28840. set physicsBody(physicsBody: any);
  28841. /**
  28842. * Resets the update flags
  28843. */
  28844. resetUpdateFlags(): void;
  28845. /**
  28846. * Gets the object extend size
  28847. * @returns the object extend size
  28848. */
  28849. getObjectExtendSize(): Vector3;
  28850. /**
  28851. * Gets the object center
  28852. * @returns The object center
  28853. */
  28854. getObjectCenter(): Vector3;
  28855. /**
  28856. * Get a specific parameter from the options parameters
  28857. * @param paramName The object parameter name
  28858. * @returns The object parameter
  28859. */
  28860. getParam(paramName: string): any;
  28861. /**
  28862. * Sets a specific parameter in the options given to the physics plugin
  28863. * @param paramName The parameter name
  28864. * @param value The value of the parameter
  28865. */
  28866. setParam(paramName: string, value: number): void;
  28867. /**
  28868. * Specifically change the body's mass option. Won't recreate the physics body object
  28869. * @param mass The mass of the physics imposter
  28870. */
  28871. setMass(mass: number): void;
  28872. /**
  28873. * Gets the linear velocity
  28874. * @returns linear velocity or null
  28875. */
  28876. getLinearVelocity(): Nullable<Vector3>;
  28877. /**
  28878. * Sets the linear velocity
  28879. * @param velocity linear velocity or null
  28880. */
  28881. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28882. /**
  28883. * Gets the angular velocity
  28884. * @returns angular velocity or null
  28885. */
  28886. getAngularVelocity(): Nullable<Vector3>;
  28887. /**
  28888. * Sets the angular velocity
  28889. * @param velocity The velocity or null
  28890. */
  28891. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28892. /**
  28893. * Execute a function with the physics plugin native code
  28894. * Provide a function the will have two variables - the world object and the physics body object
  28895. * @param func The function to execute with the physics plugin native code
  28896. */
  28897. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28898. /**
  28899. * Register a function that will be executed before the physics world is stepping forward
  28900. * @param func The function to execute before the physics world is stepped forward
  28901. */
  28902. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28903. /**
  28904. * Unregister a function that will be executed before the physics world is stepping forward
  28905. * @param func The function to execute before the physics world is stepped forward
  28906. */
  28907. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28908. /**
  28909. * Register a function that will be executed after the physics step
  28910. * @param func The function to execute after physics step
  28911. */
  28912. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28913. /**
  28914. * Unregisters a function that will be executed after the physics step
  28915. * @param func The function to execute after physics step
  28916. */
  28917. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28918. /**
  28919. * register a function that will be executed when this impostor collides against a different body
  28920. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28921. * @param func Callback that is executed on collision
  28922. */
  28923. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28924. /**
  28925. * Unregisters the physics imposter on contact
  28926. * @param collideAgainst The physics object to collide against
  28927. * @param func Callback to execute on collision
  28928. */
  28929. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28930. private _tmpQuat;
  28931. private _tmpQuat2;
  28932. /**
  28933. * Get the parent rotation
  28934. * @returns The parent rotation
  28935. */
  28936. getParentsRotation(): Quaternion;
  28937. /**
  28938. * this function is executed by the physics engine.
  28939. */
  28940. beforeStep: () => void;
  28941. /**
  28942. * this function is executed by the physics engine
  28943. */
  28944. afterStep: () => void;
  28945. /**
  28946. * Legacy collision detection event support
  28947. */
  28948. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28949. /**
  28950. * event and body object due to cannon's event-based architecture.
  28951. */
  28952. onCollide: (e: {
  28953. body: any;
  28954. }) => void;
  28955. /**
  28956. * Apply a force
  28957. * @param force The force to apply
  28958. * @param contactPoint The contact point for the force
  28959. * @returns The physics imposter
  28960. */
  28961. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28962. /**
  28963. * Apply an impulse
  28964. * @param force The impulse force
  28965. * @param contactPoint The contact point for the impulse force
  28966. * @returns The physics imposter
  28967. */
  28968. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28969. /**
  28970. * A help function to create a joint
  28971. * @param otherImpostor A physics imposter used to create a joint
  28972. * @param jointType The type of joint
  28973. * @param jointData The data for the joint
  28974. * @returns The physics imposter
  28975. */
  28976. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28977. /**
  28978. * Add a joint to this impostor with a different impostor
  28979. * @param otherImpostor A physics imposter used to add a joint
  28980. * @param joint The joint to add
  28981. * @returns The physics imposter
  28982. */
  28983. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28984. /**
  28985. * Add an anchor to a cloth impostor
  28986. * @param otherImpostor rigid impostor to anchor to
  28987. * @param width ratio across width from 0 to 1
  28988. * @param height ratio up height from 0 to 1
  28989. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28990. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28991. * @returns impostor the soft imposter
  28992. */
  28993. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28994. /**
  28995. * Add a hook to a rope impostor
  28996. * @param otherImpostor rigid impostor to anchor to
  28997. * @param length ratio across rope from 0 to 1
  28998. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28999. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  29000. * @returns impostor the rope imposter
  29001. */
  29002. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29003. /**
  29004. * Will keep this body still, in a sleep mode.
  29005. * @returns the physics imposter
  29006. */
  29007. sleep(): PhysicsImpostor;
  29008. /**
  29009. * Wake the body up.
  29010. * @returns The physics imposter
  29011. */
  29012. wakeUp(): PhysicsImpostor;
  29013. /**
  29014. * Clones the physics imposter
  29015. * @param newObject The physics imposter clones to this physics-enabled object
  29016. * @returns A nullable physics imposter
  29017. */
  29018. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29019. /**
  29020. * Disposes the physics imposter
  29021. */
  29022. dispose(): void;
  29023. /**
  29024. * Sets the delta position
  29025. * @param position The delta position amount
  29026. */
  29027. setDeltaPosition(position: Vector3): void;
  29028. /**
  29029. * Sets the delta rotation
  29030. * @param rotation The delta rotation amount
  29031. */
  29032. setDeltaRotation(rotation: Quaternion): void;
  29033. /**
  29034. * Gets the box size of the physics imposter and stores the result in the input parameter
  29035. * @param result Stores the box size
  29036. * @returns The physics imposter
  29037. */
  29038. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  29039. /**
  29040. * Gets the radius of the physics imposter
  29041. * @returns Radius of the physics imposter
  29042. */
  29043. getRadius(): number;
  29044. /**
  29045. * Sync a bone with this impostor
  29046. * @param bone The bone to sync to the impostor.
  29047. * @param boneMesh The mesh that the bone is influencing.
  29048. * @param jointPivot The pivot of the joint / bone in local space.
  29049. * @param distToJoint Optional distance from the impostor to the joint.
  29050. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29051. */
  29052. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  29053. /**
  29054. * Sync impostor to a bone
  29055. * @param bone The bone that the impostor will be synced to.
  29056. * @param boneMesh The mesh that the bone is influencing.
  29057. * @param jointPivot The pivot of the joint / bone in local space.
  29058. * @param distToJoint Optional distance from the impostor to the joint.
  29059. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29060. * @param boneAxis Optional vector3 axis the bone is aligned with
  29061. */
  29062. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  29063. /**
  29064. * No-Imposter type
  29065. */
  29066. static NoImpostor: number;
  29067. /**
  29068. * Sphere-Imposter type
  29069. */
  29070. static SphereImpostor: number;
  29071. /**
  29072. * Box-Imposter type
  29073. */
  29074. static BoxImpostor: number;
  29075. /**
  29076. * Plane-Imposter type
  29077. */
  29078. static PlaneImpostor: number;
  29079. /**
  29080. * Mesh-imposter type
  29081. */
  29082. static MeshImpostor: number;
  29083. /**
  29084. * Capsule-Impostor type (Ammo.js plugin only)
  29085. */
  29086. static CapsuleImpostor: number;
  29087. /**
  29088. * Cylinder-Imposter type
  29089. */
  29090. static CylinderImpostor: number;
  29091. /**
  29092. * Particle-Imposter type
  29093. */
  29094. static ParticleImpostor: number;
  29095. /**
  29096. * Heightmap-Imposter type
  29097. */
  29098. static HeightmapImpostor: number;
  29099. /**
  29100. * ConvexHull-Impostor type (Ammo.js plugin only)
  29101. */
  29102. static ConvexHullImpostor: number;
  29103. /**
  29104. * Custom-Imposter type (Ammo.js plugin only)
  29105. */
  29106. static CustomImpostor: number;
  29107. /**
  29108. * Rope-Imposter type
  29109. */
  29110. static RopeImpostor: number;
  29111. /**
  29112. * Cloth-Imposter type
  29113. */
  29114. static ClothImpostor: number;
  29115. /**
  29116. * Softbody-Imposter type
  29117. */
  29118. static SoftbodyImpostor: number;
  29119. }
  29120. }
  29121. declare module "babylonjs/Meshes/mesh" {
  29122. import { Observable } from "babylonjs/Misc/observable";
  29123. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29124. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29125. import { Camera } from "babylonjs/Cameras/camera";
  29126. import { Scene } from "babylonjs/scene";
  29127. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29128. import { Color4 } from "babylonjs/Maths/math.color";
  29129. import { Engine } from "babylonjs/Engines/engine";
  29130. import { Node } from "babylonjs/node";
  29131. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29132. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29133. import { Buffer } from "babylonjs/Meshes/buffer";
  29134. import { Geometry } from "babylonjs/Meshes/geometry";
  29135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29136. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29137. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29138. import { Effect } from "babylonjs/Materials/effect";
  29139. import { Material } from "babylonjs/Materials/material";
  29140. import { Skeleton } from "babylonjs/Bones/skeleton";
  29141. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29142. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29143. import { Path3D } from "babylonjs/Maths/math.path";
  29144. import { Plane } from "babylonjs/Maths/math.plane";
  29145. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29146. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  29147. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29148. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29149. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29150. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29151. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29152. /**
  29153. * @hidden
  29154. **/
  29155. export class _CreationDataStorage {
  29156. closePath?: boolean;
  29157. closeArray?: boolean;
  29158. idx: number[];
  29159. dashSize: number;
  29160. gapSize: number;
  29161. path3D: Path3D;
  29162. pathArray: Vector3[][];
  29163. arc: number;
  29164. radius: number;
  29165. cap: number;
  29166. tessellation: number;
  29167. }
  29168. /**
  29169. * @hidden
  29170. **/
  29171. class _InstanceDataStorage {
  29172. visibleInstances: any;
  29173. batchCache: _InstancesBatch;
  29174. instancesBufferSize: number;
  29175. instancesBuffer: Nullable<Buffer>;
  29176. instancesData: Float32Array;
  29177. overridenInstanceCount: number;
  29178. isFrozen: boolean;
  29179. previousBatch: Nullable<_InstancesBatch>;
  29180. hardwareInstancedRendering: boolean;
  29181. sideOrientation: number;
  29182. manualUpdate: boolean;
  29183. previousRenderId: number;
  29184. }
  29185. /**
  29186. * @hidden
  29187. **/
  29188. export class _InstancesBatch {
  29189. mustReturn: boolean;
  29190. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29191. renderSelf: boolean[];
  29192. hardwareInstancedRendering: boolean[];
  29193. }
  29194. /**
  29195. * @hidden
  29196. **/
  29197. class _ThinInstanceDataStorage {
  29198. instancesCount: number;
  29199. matrixBuffer: Nullable<Buffer>;
  29200. matrixBufferSize: number;
  29201. matrixData: Nullable<Float32Array>;
  29202. boundingVectors: Array<Vector3>;
  29203. worldMatrices: Nullable<Matrix[]>;
  29204. }
  29205. /**
  29206. * Class used to represent renderable models
  29207. */
  29208. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29209. /**
  29210. * Mesh side orientation : usually the external or front surface
  29211. */
  29212. static readonly FRONTSIDE: number;
  29213. /**
  29214. * Mesh side orientation : usually the internal or back surface
  29215. */
  29216. static readonly BACKSIDE: number;
  29217. /**
  29218. * Mesh side orientation : both internal and external or front and back surfaces
  29219. */
  29220. static readonly DOUBLESIDE: number;
  29221. /**
  29222. * Mesh side orientation : by default, `FRONTSIDE`
  29223. */
  29224. static readonly DEFAULTSIDE: number;
  29225. /**
  29226. * Mesh cap setting : no cap
  29227. */
  29228. static readonly NO_CAP: number;
  29229. /**
  29230. * Mesh cap setting : one cap at the beginning of the mesh
  29231. */
  29232. static readonly CAP_START: number;
  29233. /**
  29234. * Mesh cap setting : one cap at the end of the mesh
  29235. */
  29236. static readonly CAP_END: number;
  29237. /**
  29238. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29239. */
  29240. static readonly CAP_ALL: number;
  29241. /**
  29242. * Mesh pattern setting : no flip or rotate
  29243. */
  29244. static readonly NO_FLIP: number;
  29245. /**
  29246. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29247. */
  29248. static readonly FLIP_TILE: number;
  29249. /**
  29250. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29251. */
  29252. static readonly ROTATE_TILE: number;
  29253. /**
  29254. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29255. */
  29256. static readonly FLIP_ROW: number;
  29257. /**
  29258. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29259. */
  29260. static readonly ROTATE_ROW: number;
  29261. /**
  29262. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29263. */
  29264. static readonly FLIP_N_ROTATE_TILE: number;
  29265. /**
  29266. * Mesh pattern setting : rotate pattern and rotate
  29267. */
  29268. static readonly FLIP_N_ROTATE_ROW: number;
  29269. /**
  29270. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29271. */
  29272. static readonly CENTER: number;
  29273. /**
  29274. * Mesh tile positioning : part tiles on left
  29275. */
  29276. static readonly LEFT: number;
  29277. /**
  29278. * Mesh tile positioning : part tiles on right
  29279. */
  29280. static readonly RIGHT: number;
  29281. /**
  29282. * Mesh tile positioning : part tiles on top
  29283. */
  29284. static readonly TOP: number;
  29285. /**
  29286. * Mesh tile positioning : part tiles on bottom
  29287. */
  29288. static readonly BOTTOM: number;
  29289. /**
  29290. * Gets the default side orientation.
  29291. * @param orientation the orientation to value to attempt to get
  29292. * @returns the default orientation
  29293. * @hidden
  29294. */
  29295. static _GetDefaultSideOrientation(orientation?: number): number;
  29296. private _internalMeshDataInfo;
  29297. get computeBonesUsingShaders(): boolean;
  29298. set computeBonesUsingShaders(value: boolean);
  29299. /**
  29300. * An event triggered before rendering the mesh
  29301. */
  29302. get onBeforeRenderObservable(): Observable<Mesh>;
  29303. /**
  29304. * An event triggered before binding the mesh
  29305. */
  29306. get onBeforeBindObservable(): Observable<Mesh>;
  29307. /**
  29308. * An event triggered after rendering the mesh
  29309. */
  29310. get onAfterRenderObservable(): Observable<Mesh>;
  29311. /**
  29312. * An event triggered before drawing the mesh
  29313. */
  29314. get onBeforeDrawObservable(): Observable<Mesh>;
  29315. private _onBeforeDrawObserver;
  29316. /**
  29317. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29318. */
  29319. set onBeforeDraw(callback: () => void);
  29320. get hasInstances(): boolean;
  29321. get hasThinInstances(): boolean;
  29322. /**
  29323. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29324. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29325. */
  29326. delayLoadState: number;
  29327. /**
  29328. * Gets the list of instances created from this mesh
  29329. * it is not supposed to be modified manually.
  29330. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29331. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29332. */
  29333. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29334. /**
  29335. * Gets the file containing delay loading data for this mesh
  29336. */
  29337. delayLoadingFile: string;
  29338. /** @hidden */
  29339. _binaryInfo: any;
  29340. /**
  29341. * User defined function used to change how LOD level selection is done
  29342. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29343. */
  29344. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29345. /**
  29346. * Gets or sets the morph target manager
  29347. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29348. */
  29349. get morphTargetManager(): Nullable<MorphTargetManager>;
  29350. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29351. /** @hidden */
  29352. _creationDataStorage: Nullable<_CreationDataStorage>;
  29353. /** @hidden */
  29354. _geometry: Nullable<Geometry>;
  29355. /** @hidden */
  29356. _delayInfo: Array<string>;
  29357. /** @hidden */
  29358. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29359. /** @hidden */
  29360. _instanceDataStorage: _InstanceDataStorage;
  29361. /** @hidden */
  29362. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29363. private _effectiveMaterial;
  29364. /** @hidden */
  29365. _shouldGenerateFlatShading: boolean;
  29366. /** @hidden */
  29367. _originalBuilderSideOrientation: number;
  29368. /**
  29369. * Use this property to change the original side orientation defined at construction time
  29370. */
  29371. overrideMaterialSideOrientation: Nullable<number>;
  29372. /**
  29373. * Gets the source mesh (the one used to clone this one from)
  29374. */
  29375. get source(): Nullable<Mesh>;
  29376. /**
  29377. * Gets the list of clones of this mesh
  29378. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29379. * Note that useClonedMeshMap=true is the default setting
  29380. */
  29381. get cloneMeshMap(): Nullable<{
  29382. [id: string]: Mesh | undefined;
  29383. }>;
  29384. /**
  29385. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29386. */
  29387. get isUnIndexed(): boolean;
  29388. set isUnIndexed(value: boolean);
  29389. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29390. get worldMatrixInstancedBuffer(): Float32Array;
  29391. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29392. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29393. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29394. /**
  29395. * @constructor
  29396. * @param name The value used by scene.getMeshByName() to do a lookup.
  29397. * @param scene The scene to add this mesh to.
  29398. * @param parent The parent of this mesh, if it has one
  29399. * @param source An optional Mesh from which geometry is shared, cloned.
  29400. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29401. * When false, achieved by calling a clone(), also passing False.
  29402. * This will make creation of children, recursive.
  29403. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29404. */
  29405. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29406. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29407. doNotInstantiate: boolean;
  29408. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29409. /**
  29410. * Gets the class name
  29411. * @returns the string "Mesh".
  29412. */
  29413. getClassName(): string;
  29414. /** @hidden */
  29415. get _isMesh(): boolean;
  29416. /**
  29417. * Returns a description of this mesh
  29418. * @param fullDetails define if full details about this mesh must be used
  29419. * @returns a descriptive string representing this mesh
  29420. */
  29421. toString(fullDetails?: boolean): string;
  29422. /** @hidden */
  29423. _unBindEffect(): void;
  29424. /**
  29425. * Gets a boolean indicating if this mesh has LOD
  29426. */
  29427. get hasLODLevels(): boolean;
  29428. /**
  29429. * Gets the list of MeshLODLevel associated with the current mesh
  29430. * @returns an array of MeshLODLevel
  29431. */
  29432. getLODLevels(): MeshLODLevel[];
  29433. private _sortLODLevels;
  29434. /**
  29435. * Add a mesh as LOD level triggered at the given distance.
  29436. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29437. * @param distance The distance from the center of the object to show this level
  29438. * @param mesh The mesh to be added as LOD level (can be null)
  29439. * @return This mesh (for chaining)
  29440. */
  29441. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29442. /**
  29443. * Returns the LOD level mesh at the passed distance or null if not found.
  29444. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29445. * @param distance The distance from the center of the object to show this level
  29446. * @returns a Mesh or `null`
  29447. */
  29448. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29449. /**
  29450. * Remove a mesh from the LOD array
  29451. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29452. * @param mesh defines the mesh to be removed
  29453. * @return This mesh (for chaining)
  29454. */
  29455. removeLODLevel(mesh: Mesh): Mesh;
  29456. /**
  29457. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29458. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29459. * @param camera defines the camera to use to compute distance
  29460. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29461. * @return This mesh (for chaining)
  29462. */
  29463. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29464. /**
  29465. * Gets the mesh internal Geometry object
  29466. */
  29467. get geometry(): Nullable<Geometry>;
  29468. /**
  29469. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29470. * @returns the total number of vertices
  29471. */
  29472. getTotalVertices(): number;
  29473. /**
  29474. * Returns the content of an associated vertex buffer
  29475. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29476. * - VertexBuffer.PositionKind
  29477. * - VertexBuffer.UVKind
  29478. * - VertexBuffer.UV2Kind
  29479. * - VertexBuffer.UV3Kind
  29480. * - VertexBuffer.UV4Kind
  29481. * - VertexBuffer.UV5Kind
  29482. * - VertexBuffer.UV6Kind
  29483. * - VertexBuffer.ColorKind
  29484. * - VertexBuffer.MatricesIndicesKind
  29485. * - VertexBuffer.MatricesIndicesExtraKind
  29486. * - VertexBuffer.MatricesWeightsKind
  29487. * - VertexBuffer.MatricesWeightsExtraKind
  29488. * @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
  29489. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29490. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29491. */
  29492. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29493. /**
  29494. * Returns the mesh VertexBuffer object from the requested `kind`
  29495. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29496. * - VertexBuffer.PositionKind
  29497. * - VertexBuffer.NormalKind
  29498. * - VertexBuffer.UVKind
  29499. * - VertexBuffer.UV2Kind
  29500. * - VertexBuffer.UV3Kind
  29501. * - VertexBuffer.UV4Kind
  29502. * - VertexBuffer.UV5Kind
  29503. * - VertexBuffer.UV6Kind
  29504. * - VertexBuffer.ColorKind
  29505. * - VertexBuffer.MatricesIndicesKind
  29506. * - VertexBuffer.MatricesIndicesExtraKind
  29507. * - VertexBuffer.MatricesWeightsKind
  29508. * - VertexBuffer.MatricesWeightsExtraKind
  29509. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29510. */
  29511. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29512. /**
  29513. * Tests if a specific vertex buffer is associated with this mesh
  29514. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29515. * - VertexBuffer.PositionKind
  29516. * - VertexBuffer.NormalKind
  29517. * - VertexBuffer.UVKind
  29518. * - VertexBuffer.UV2Kind
  29519. * - VertexBuffer.UV3Kind
  29520. * - VertexBuffer.UV4Kind
  29521. * - VertexBuffer.UV5Kind
  29522. * - VertexBuffer.UV6Kind
  29523. * - VertexBuffer.ColorKind
  29524. * - VertexBuffer.MatricesIndicesKind
  29525. * - VertexBuffer.MatricesIndicesExtraKind
  29526. * - VertexBuffer.MatricesWeightsKind
  29527. * - VertexBuffer.MatricesWeightsExtraKind
  29528. * @returns a boolean
  29529. */
  29530. isVerticesDataPresent(kind: string): boolean;
  29531. /**
  29532. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29533. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29534. * - VertexBuffer.PositionKind
  29535. * - VertexBuffer.UVKind
  29536. * - VertexBuffer.UV2Kind
  29537. * - VertexBuffer.UV3Kind
  29538. * - VertexBuffer.UV4Kind
  29539. * - VertexBuffer.UV5Kind
  29540. * - VertexBuffer.UV6Kind
  29541. * - VertexBuffer.ColorKind
  29542. * - VertexBuffer.MatricesIndicesKind
  29543. * - VertexBuffer.MatricesIndicesExtraKind
  29544. * - VertexBuffer.MatricesWeightsKind
  29545. * - VertexBuffer.MatricesWeightsExtraKind
  29546. * @returns a boolean
  29547. */
  29548. isVertexBufferUpdatable(kind: string): boolean;
  29549. /**
  29550. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29551. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29552. * - VertexBuffer.PositionKind
  29553. * - VertexBuffer.NormalKind
  29554. * - VertexBuffer.UVKind
  29555. * - VertexBuffer.UV2Kind
  29556. * - VertexBuffer.UV3Kind
  29557. * - VertexBuffer.UV4Kind
  29558. * - VertexBuffer.UV5Kind
  29559. * - VertexBuffer.UV6Kind
  29560. * - VertexBuffer.ColorKind
  29561. * - VertexBuffer.MatricesIndicesKind
  29562. * - VertexBuffer.MatricesIndicesExtraKind
  29563. * - VertexBuffer.MatricesWeightsKind
  29564. * - VertexBuffer.MatricesWeightsExtraKind
  29565. * @returns an array of strings
  29566. */
  29567. getVerticesDataKinds(): string[];
  29568. /**
  29569. * Returns a positive integer : the total number of indices in this mesh geometry.
  29570. * @returns the numner of indices or zero if the mesh has no geometry.
  29571. */
  29572. getTotalIndices(): number;
  29573. /**
  29574. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29575. * @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.
  29576. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29577. * @returns the indices array or an empty array if the mesh has no geometry
  29578. */
  29579. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29580. get isBlocked(): boolean;
  29581. /**
  29582. * Determine if the current mesh is ready to be rendered
  29583. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29584. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29585. * @returns true if all associated assets are ready (material, textures, shaders)
  29586. */
  29587. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29588. /**
  29589. * 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.
  29590. */
  29591. get areNormalsFrozen(): boolean;
  29592. /**
  29593. * 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.
  29594. * @returns the current mesh
  29595. */
  29596. freezeNormals(): Mesh;
  29597. /**
  29598. * 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
  29599. * @returns the current mesh
  29600. */
  29601. unfreezeNormals(): Mesh;
  29602. /**
  29603. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29604. */
  29605. set overridenInstanceCount(count: number);
  29606. /** @hidden */
  29607. _preActivate(): Mesh;
  29608. /** @hidden */
  29609. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29610. /** @hidden */
  29611. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29612. protected _afterComputeWorldMatrix(): void;
  29613. /** @hidden */
  29614. _postActivate(): void;
  29615. /**
  29616. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29617. * This means the mesh underlying bounding box and sphere are recomputed.
  29618. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29619. * @returns the current mesh
  29620. */
  29621. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29622. /** @hidden */
  29623. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29624. /**
  29625. * This function will subdivide the mesh into multiple submeshes
  29626. * @param count defines the expected number of submeshes
  29627. */
  29628. subdivide(count: number): void;
  29629. /**
  29630. * Copy a FloatArray into a specific associated vertex buffer
  29631. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29632. * - VertexBuffer.PositionKind
  29633. * - VertexBuffer.UVKind
  29634. * - VertexBuffer.UV2Kind
  29635. * - VertexBuffer.UV3Kind
  29636. * - VertexBuffer.UV4Kind
  29637. * - VertexBuffer.UV5Kind
  29638. * - VertexBuffer.UV6Kind
  29639. * - VertexBuffer.ColorKind
  29640. * - VertexBuffer.MatricesIndicesKind
  29641. * - VertexBuffer.MatricesIndicesExtraKind
  29642. * - VertexBuffer.MatricesWeightsKind
  29643. * - VertexBuffer.MatricesWeightsExtraKind
  29644. * @param data defines the data source
  29645. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29646. * @param stride defines the data stride size (can be null)
  29647. * @returns the current mesh
  29648. */
  29649. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29650. /**
  29651. * Delete a vertex buffer associated with this mesh
  29652. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29653. * - VertexBuffer.PositionKind
  29654. * - VertexBuffer.UVKind
  29655. * - VertexBuffer.UV2Kind
  29656. * - VertexBuffer.UV3Kind
  29657. * - VertexBuffer.UV4Kind
  29658. * - VertexBuffer.UV5Kind
  29659. * - VertexBuffer.UV6Kind
  29660. * - VertexBuffer.ColorKind
  29661. * - VertexBuffer.MatricesIndicesKind
  29662. * - VertexBuffer.MatricesIndicesExtraKind
  29663. * - VertexBuffer.MatricesWeightsKind
  29664. * - VertexBuffer.MatricesWeightsExtraKind
  29665. */
  29666. removeVerticesData(kind: string): void;
  29667. /**
  29668. * Flags an associated vertex buffer as updatable
  29669. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29670. * - VertexBuffer.PositionKind
  29671. * - VertexBuffer.UVKind
  29672. * - VertexBuffer.UV2Kind
  29673. * - VertexBuffer.UV3Kind
  29674. * - VertexBuffer.UV4Kind
  29675. * - VertexBuffer.UV5Kind
  29676. * - VertexBuffer.UV6Kind
  29677. * - VertexBuffer.ColorKind
  29678. * - VertexBuffer.MatricesIndicesKind
  29679. * - VertexBuffer.MatricesIndicesExtraKind
  29680. * - VertexBuffer.MatricesWeightsKind
  29681. * - VertexBuffer.MatricesWeightsExtraKind
  29682. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29683. */
  29684. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29685. /**
  29686. * Sets the mesh global Vertex Buffer
  29687. * @param buffer defines the buffer to use
  29688. * @returns the current mesh
  29689. */
  29690. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29691. /**
  29692. * Update a specific associated vertex buffer
  29693. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29694. * - VertexBuffer.PositionKind
  29695. * - VertexBuffer.UVKind
  29696. * - VertexBuffer.UV2Kind
  29697. * - VertexBuffer.UV3Kind
  29698. * - VertexBuffer.UV4Kind
  29699. * - VertexBuffer.UV5Kind
  29700. * - VertexBuffer.UV6Kind
  29701. * - VertexBuffer.ColorKind
  29702. * - VertexBuffer.MatricesIndicesKind
  29703. * - VertexBuffer.MatricesIndicesExtraKind
  29704. * - VertexBuffer.MatricesWeightsKind
  29705. * - VertexBuffer.MatricesWeightsExtraKind
  29706. * @param data defines the data source
  29707. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29708. * @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)
  29709. * @returns the current mesh
  29710. */
  29711. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29712. /**
  29713. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29714. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29715. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29716. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29717. * @returns the current mesh
  29718. */
  29719. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29720. /**
  29721. * Creates a un-shared specific occurence of the geometry for the mesh.
  29722. * @returns the current mesh
  29723. */
  29724. makeGeometryUnique(): Mesh;
  29725. /**
  29726. * Set the index buffer of this mesh
  29727. * @param indices defines the source data
  29728. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29729. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29730. * @returns the current mesh
  29731. */
  29732. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29733. /**
  29734. * Update the current index buffer
  29735. * @param indices defines the source data
  29736. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29737. * @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)
  29738. * @returns the current mesh
  29739. */
  29740. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29741. /**
  29742. * Invert the geometry to move from a right handed system to a left handed one.
  29743. * @returns the current mesh
  29744. */
  29745. toLeftHanded(): Mesh;
  29746. /** @hidden */
  29747. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29748. /** @hidden */
  29749. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29750. /**
  29751. * Registers for this mesh a javascript function called just before the rendering process
  29752. * @param func defines the function to call before rendering this mesh
  29753. * @returns the current mesh
  29754. */
  29755. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29756. /**
  29757. * Disposes a previously registered javascript function called before the rendering
  29758. * @param func defines the function to remove
  29759. * @returns the current mesh
  29760. */
  29761. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29762. /**
  29763. * Registers for this mesh a javascript function called just after the rendering is complete
  29764. * @param func defines the function to call after rendering this mesh
  29765. * @returns the current mesh
  29766. */
  29767. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29768. /**
  29769. * Disposes a previously registered javascript function called after the rendering.
  29770. * @param func defines the function to remove
  29771. * @returns the current mesh
  29772. */
  29773. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29774. /** @hidden */
  29775. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29776. /** @hidden */
  29777. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29778. /** @hidden */
  29779. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29780. /** @hidden */
  29781. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29782. /** @hidden */
  29783. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29784. /** @hidden */
  29785. _rebuild(): void;
  29786. /** @hidden */
  29787. _freeze(): void;
  29788. /** @hidden */
  29789. _unFreeze(): void;
  29790. /**
  29791. * 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
  29792. * @param subMesh defines the subMesh to render
  29793. * @param enableAlphaMode defines if alpha mode can be changed
  29794. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29795. * @returns the current mesh
  29796. */
  29797. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29798. private _onBeforeDraw;
  29799. /**
  29800. * Renormalize the mesh and patch it up if there are no weights
  29801. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29802. * However in the case of zero weights then we set just a single influence to 1.
  29803. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29804. */
  29805. cleanMatrixWeights(): void;
  29806. private normalizeSkinFourWeights;
  29807. private normalizeSkinWeightsAndExtra;
  29808. /**
  29809. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29810. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29811. * the user know there was an issue with importing the mesh
  29812. * @returns a validation object with skinned, valid and report string
  29813. */
  29814. validateSkinning(): {
  29815. skinned: boolean;
  29816. valid: boolean;
  29817. report: string;
  29818. };
  29819. /** @hidden */
  29820. _checkDelayState(): Mesh;
  29821. private _queueLoad;
  29822. /**
  29823. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29824. * A mesh is in the frustum if its bounding box intersects the frustum
  29825. * @param frustumPlanes defines the frustum to test
  29826. * @returns true if the mesh is in the frustum planes
  29827. */
  29828. isInFrustum(frustumPlanes: Plane[]): boolean;
  29829. /**
  29830. * Sets the mesh material by the material or multiMaterial `id` property
  29831. * @param id is a string identifying the material or the multiMaterial
  29832. * @returns the current mesh
  29833. */
  29834. setMaterialByID(id: string): Mesh;
  29835. /**
  29836. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29837. * @returns an array of IAnimatable
  29838. */
  29839. getAnimatables(): IAnimatable[];
  29840. /**
  29841. * Modifies the mesh geometry according to the passed transformation matrix.
  29842. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29843. * The mesh normals are modified using the same transformation.
  29844. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29845. * @param transform defines the transform matrix to use
  29846. * @see https://doc.babylonjs.com/resources/baking_transformations
  29847. * @returns the current mesh
  29848. */
  29849. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29850. /**
  29851. * Modifies the mesh geometry according to its own current World Matrix.
  29852. * The mesh World Matrix is then reset.
  29853. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29854. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29855. * @see https://doc.babylonjs.com/resources/baking_transformations
  29856. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29857. * @returns the current mesh
  29858. */
  29859. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29860. /** @hidden */
  29861. get _positions(): Nullable<Vector3[]>;
  29862. /** @hidden */
  29863. _resetPointsArrayCache(): Mesh;
  29864. /** @hidden */
  29865. _generatePointsArray(): boolean;
  29866. /**
  29867. * Returns a new Mesh object generated from the current mesh properties.
  29868. * This method must not get confused with createInstance()
  29869. * @param name is a string, the name given to the new mesh
  29870. * @param newParent can be any Node object (default `null`)
  29871. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29872. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29873. * @returns a new mesh
  29874. */
  29875. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29876. /**
  29877. * Releases resources associated with this mesh.
  29878. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29879. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29880. */
  29881. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29882. /** @hidden */
  29883. _disposeInstanceSpecificData(): void;
  29884. /** @hidden */
  29885. _disposeThinInstanceSpecificData(): void;
  29886. /**
  29887. * Modifies the mesh geometry according to a displacement map.
  29888. * 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.
  29889. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29890. * @param url is a string, the URL from the image file is to be downloaded.
  29891. * @param minHeight is the lower limit of the displacement.
  29892. * @param maxHeight is the upper limit of the displacement.
  29893. * @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.
  29894. * @param uvOffset is an optional vector2 used to offset UV.
  29895. * @param uvScale is an optional vector2 used to scale UV.
  29896. * @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.
  29897. * @returns the Mesh.
  29898. */
  29899. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29900. /**
  29901. * Modifies the mesh geometry according to a displacementMap buffer.
  29902. * 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.
  29903. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29904. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29905. * @param heightMapWidth is the width of the buffer image.
  29906. * @param heightMapHeight is the height of the buffer image.
  29907. * @param minHeight is the lower limit of the displacement.
  29908. * @param maxHeight is the upper limit of the displacement.
  29909. * @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.
  29910. * @param uvOffset is an optional vector2 used to offset UV.
  29911. * @param uvScale is an optional vector2 used to scale UV.
  29912. * @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.
  29913. * @returns the Mesh.
  29914. */
  29915. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29916. /**
  29917. * Modify the mesh to get a flat shading rendering.
  29918. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29919. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29920. * @returns current mesh
  29921. */
  29922. convertToFlatShadedMesh(): Mesh;
  29923. /**
  29924. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29925. * In other words, more vertices, no more indices and a single bigger VBO.
  29926. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29927. * @returns current mesh
  29928. */
  29929. convertToUnIndexedMesh(): Mesh;
  29930. /**
  29931. * Inverses facet orientations.
  29932. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29933. * @param flipNormals will also inverts the normals
  29934. * @returns current mesh
  29935. */
  29936. flipFaces(flipNormals?: boolean): Mesh;
  29937. /**
  29938. * Increase the number of facets and hence vertices in a mesh
  29939. * Vertex normals are interpolated from existing vertex normals
  29940. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29941. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29942. */
  29943. increaseVertices(numberPerEdge: number): void;
  29944. /**
  29945. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29946. * This will undo any application of covertToFlatShadedMesh
  29947. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29948. */
  29949. forceSharedVertices(): void;
  29950. /** @hidden */
  29951. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29952. /** @hidden */
  29953. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29954. /**
  29955. * Creates a new InstancedMesh object from the mesh model.
  29956. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29957. * @param name defines the name of the new instance
  29958. * @returns a new InstancedMesh
  29959. */
  29960. createInstance(name: string): InstancedMesh;
  29961. /**
  29962. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29963. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29964. * @returns the current mesh
  29965. */
  29966. synchronizeInstances(): Mesh;
  29967. /**
  29968. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29969. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29970. * This should be used together with the simplification to avoid disappearing triangles.
  29971. * @param successCallback an optional success callback to be called after the optimization finished.
  29972. * @returns the current mesh
  29973. */
  29974. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29975. /**
  29976. * Serialize current mesh
  29977. * @param serializationObject defines the object which will receive the serialization data
  29978. */
  29979. serialize(serializationObject: any): void;
  29980. /** @hidden */
  29981. _syncGeometryWithMorphTargetManager(): void;
  29982. /** @hidden */
  29983. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29984. /**
  29985. * Returns a new Mesh object parsed from the source provided.
  29986. * @param parsedMesh is the source
  29987. * @param scene defines the hosting scene
  29988. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29989. * @returns a new Mesh
  29990. */
  29991. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29992. /**
  29993. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29995. * @param name defines the name of the mesh to create
  29996. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29997. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29998. * @param closePath creates a seam between the first and the last points of each path of the path array
  29999. * @param offset is taken in account only if the `pathArray` is containing a single path
  30000. * @param scene defines the hosting scene
  30001. * @param updatable defines if the mesh must be flagged as updatable
  30002. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30003. * @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)
  30004. * @returns a new Mesh
  30005. */
  30006. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30007. /**
  30008. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  30009. * @param name defines the name of the mesh to create
  30010. * @param radius sets the radius size (float) of the polygon (default 0.5)
  30011. * @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
  30012. * @param scene defines the hosting scene
  30013. * @param updatable defines if the mesh must be flagged as updatable
  30014. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30015. * @returns a new Mesh
  30016. */
  30017. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30018. /**
  30019. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  30020. * @param name defines the name of the mesh to create
  30021. * @param size sets the size (float) of each box side (default 1)
  30022. * @param scene defines the hosting scene
  30023. * @param updatable defines if the mesh must be flagged as updatable
  30024. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30025. * @returns a new Mesh
  30026. */
  30027. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30028. /**
  30029. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  30030. * @param name defines the name of the mesh to create
  30031. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30032. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30033. * @param scene defines the hosting scene
  30034. * @param updatable defines if the mesh must be flagged as updatable
  30035. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30036. * @returns a new Mesh
  30037. */
  30038. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30039. /**
  30040. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  30041. * @param name defines the name of the mesh to create
  30042. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30043. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30044. * @param scene defines the hosting scene
  30045. * @returns a new Mesh
  30046. */
  30047. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  30048. /**
  30049. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  30050. * @param name defines the name of the mesh to create
  30051. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  30052. * @param diameterTop set the top cap diameter (floats, default 1)
  30053. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  30054. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  30055. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  30056. * @param scene defines the hosting scene
  30057. * @param updatable defines if the mesh must be flagged as updatable
  30058. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30059. * @returns a new Mesh
  30060. */
  30061. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  30062. /**
  30063. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  30064. * @param name defines the name of the mesh to create
  30065. * @param diameter sets the diameter size (float) of the torus (default 1)
  30066. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  30067. * @param tessellation sets the number of torus sides (postive integer, default 16)
  30068. * @param scene defines the hosting scene
  30069. * @param updatable defines if the mesh must be flagged as updatable
  30070. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30071. * @returns a new Mesh
  30072. */
  30073. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30074. /**
  30075. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30076. * @param name defines the name of the mesh to create
  30077. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30078. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30079. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30080. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30081. * @param p the number of windings on X axis (positive integers, default 2)
  30082. * @param q the number of windings on Y axis (positive integers, default 3)
  30083. * @param scene defines the hosting scene
  30084. * @param updatable defines if the mesh must be flagged as updatable
  30085. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30086. * @returns a new Mesh
  30087. */
  30088. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30089. /**
  30090. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30091. * @param name defines the name of the mesh to create
  30092. * @param points is an array successive Vector3
  30093. * @param scene defines the hosting scene
  30094. * @param updatable defines if the mesh must be flagged as updatable
  30095. * @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).
  30096. * @returns a new Mesh
  30097. */
  30098. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30099. /**
  30100. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30101. * @param name defines the name of the mesh to create
  30102. * @param points is an array successive Vector3
  30103. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30104. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30105. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30106. * @param scene defines the hosting scene
  30107. * @param updatable defines if the mesh must be flagged as updatable
  30108. * @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)
  30109. * @returns a new Mesh
  30110. */
  30111. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30112. /**
  30113. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30114. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30115. * 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.
  30116. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30117. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30118. * Remember you can only change the shape positions, not their number when updating a polygon.
  30119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30120. * @param name defines the name of the mesh to create
  30121. * @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
  30122. * @param scene defines the hosting scene
  30123. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30124. * @param updatable defines if the mesh must be flagged as updatable
  30125. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30126. * @param earcutInjection can be used to inject your own earcut reference
  30127. * @returns a new Mesh
  30128. */
  30129. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30130. /**
  30131. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30132. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30133. * @param name defines the name of the mesh to create
  30134. * @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
  30135. * @param depth defines the height of extrusion
  30136. * @param scene defines the hosting scene
  30137. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30138. * @param updatable defines if the mesh must be flagged as updatable
  30139. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30140. * @param earcutInjection can be used to inject your own earcut reference
  30141. * @returns a new Mesh
  30142. */
  30143. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30144. /**
  30145. * Creates an extruded shape mesh.
  30146. * 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
  30147. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30148. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30149. * @param name defines the name of the mesh to create
  30150. * @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
  30151. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30152. * @param scale is the value to scale the shape
  30153. * @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
  30154. * @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
  30155. * @param scene defines the hosting scene
  30156. * @param updatable defines if the mesh must be flagged as updatable
  30157. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30158. * @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)
  30159. * @returns a new Mesh
  30160. */
  30161. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30162. /**
  30163. * Creates an custom extruded shape mesh.
  30164. * The custom extrusion is a parametric shape.
  30165. * It has no predefined shape. Its final shape will depend on the input parameters.
  30166. * Please consider using the same method from the MeshBuilder class instead
  30167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30168. * @param name defines the name of the mesh to create
  30169. * @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
  30170. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30171. * @param scaleFunction is a custom Javascript function called on each path point
  30172. * @param rotationFunction is a custom Javascript function called on each path point
  30173. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30174. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30175. * @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
  30176. * @param scene defines the hosting scene
  30177. * @param updatable defines if the mesh must be flagged as updatable
  30178. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30179. * @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)
  30180. * @returns a new Mesh
  30181. */
  30182. 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;
  30183. /**
  30184. * Creates lathe mesh.
  30185. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30186. * Please consider using the same method from the MeshBuilder class instead
  30187. * @param name defines the name of the mesh to create
  30188. * @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
  30189. * @param radius is the radius value of the lathe
  30190. * @param tessellation is the side number of the lathe.
  30191. * @param scene defines the hosting scene
  30192. * @param updatable defines if the mesh must be flagged as updatable
  30193. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30194. * @returns a new Mesh
  30195. */
  30196. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30197. /**
  30198. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30199. * @param name defines the name of the mesh to create
  30200. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30201. * @param scene defines the hosting scene
  30202. * @param updatable defines if the mesh must be flagged as updatable
  30203. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30204. * @returns a new Mesh
  30205. */
  30206. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30207. /**
  30208. * Creates a ground mesh.
  30209. * Please consider using the same method from the MeshBuilder class instead
  30210. * @param name defines the name of the mesh to create
  30211. * @param width set the width of the ground
  30212. * @param height set the height of the ground
  30213. * @param subdivisions sets the number of subdivisions per side
  30214. * @param scene defines the hosting scene
  30215. * @param updatable defines if the mesh must be flagged as updatable
  30216. * @returns a new Mesh
  30217. */
  30218. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30219. /**
  30220. * Creates a tiled ground mesh.
  30221. * Please consider using the same method from the MeshBuilder class instead
  30222. * @param name defines the name of the mesh to create
  30223. * @param xmin set the ground minimum X coordinate
  30224. * @param zmin set the ground minimum Y coordinate
  30225. * @param xmax set the ground maximum X coordinate
  30226. * @param zmax set the ground maximum Z coordinate
  30227. * @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
  30228. * @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
  30229. * @param scene defines the hosting scene
  30230. * @param updatable defines if the mesh must be flagged as updatable
  30231. * @returns a new Mesh
  30232. */
  30233. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30234. w: number;
  30235. h: number;
  30236. }, precision: {
  30237. w: number;
  30238. h: number;
  30239. }, scene: Scene, updatable?: boolean): Mesh;
  30240. /**
  30241. * Creates a ground mesh from a height map.
  30242. * Please consider using the same method from the MeshBuilder class instead
  30243. * @see https://doc.babylonjs.com/babylon101/height_map
  30244. * @param name defines the name of the mesh to create
  30245. * @param url sets the URL of the height map image resource
  30246. * @param width set the ground width size
  30247. * @param height set the ground height size
  30248. * @param subdivisions sets the number of subdivision per side
  30249. * @param minHeight is the minimum altitude on the ground
  30250. * @param maxHeight is the maximum altitude on the ground
  30251. * @param scene defines the hosting scene
  30252. * @param updatable defines if the mesh must be flagged as updatable
  30253. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30254. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30255. * @returns a new Mesh
  30256. */
  30257. 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;
  30258. /**
  30259. * Creates a tube mesh.
  30260. * The tube is a parametric shape.
  30261. * It has no predefined shape. Its final shape will depend on the input parameters.
  30262. * Please consider using the same method from the MeshBuilder class instead
  30263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30264. * @param name defines the name of the mesh to create
  30265. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30266. * @param radius sets the tube radius size
  30267. * @param tessellation is the number of sides on the tubular surface
  30268. * @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
  30269. * @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
  30270. * @param scene defines the hosting scene
  30271. * @param updatable defines if the mesh must be flagged as updatable
  30272. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30273. * @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)
  30274. * @returns a new Mesh
  30275. */
  30276. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30277. (i: number, distance: number): number;
  30278. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30279. /**
  30280. * Creates a polyhedron mesh.
  30281. * Please consider using the same method from the MeshBuilder class instead.
  30282. * * 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
  30283. * * The parameter `size` (positive float, default 1) sets the polygon size
  30284. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30285. * * 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`
  30286. * * 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
  30287. * * 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)`)
  30288. * * 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
  30289. * * 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
  30290. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30293. * @param name defines the name of the mesh to create
  30294. * @param options defines the options used to create the mesh
  30295. * @param scene defines the hosting scene
  30296. * @returns a new Mesh
  30297. */
  30298. static CreatePolyhedron(name: string, options: {
  30299. type?: number;
  30300. size?: number;
  30301. sizeX?: number;
  30302. sizeY?: number;
  30303. sizeZ?: number;
  30304. custom?: any;
  30305. faceUV?: Vector4[];
  30306. faceColors?: Color4[];
  30307. updatable?: boolean;
  30308. sideOrientation?: number;
  30309. }, scene: Scene): Mesh;
  30310. /**
  30311. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30312. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30313. * * 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`)
  30314. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30315. * * 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
  30316. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30319. * @param name defines the name of the mesh
  30320. * @param options defines the options used to create the mesh
  30321. * @param scene defines the hosting scene
  30322. * @returns a new Mesh
  30323. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30324. */
  30325. static CreateIcoSphere(name: string, options: {
  30326. radius?: number;
  30327. flat?: boolean;
  30328. subdivisions?: number;
  30329. sideOrientation?: number;
  30330. updatable?: boolean;
  30331. }, scene: Scene): Mesh;
  30332. /**
  30333. * Creates a decal mesh.
  30334. * Please consider using the same method from the MeshBuilder class instead.
  30335. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30336. * @param name defines the name of the mesh
  30337. * @param sourceMesh defines the mesh receiving the decal
  30338. * @param position sets the position of the decal in world coordinates
  30339. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30340. * @param size sets the decal scaling
  30341. * @param angle sets the angle to rotate the decal
  30342. * @returns a new Mesh
  30343. */
  30344. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30345. /** Creates a Capsule Mesh
  30346. * @param name defines the name of the mesh.
  30347. * @param options the constructors options used to shape the mesh.
  30348. * @param scene defines the scene the mesh is scoped to.
  30349. * @returns the capsule mesh
  30350. * @see https://doc.babylonjs.com/how_to/capsule_shape
  30351. */
  30352. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  30353. /**
  30354. * Prepare internal position array for software CPU skinning
  30355. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30356. */
  30357. setPositionsForCPUSkinning(): Float32Array;
  30358. /**
  30359. * Prepare internal normal array for software CPU skinning
  30360. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30361. */
  30362. setNormalsForCPUSkinning(): Float32Array;
  30363. /**
  30364. * Updates the vertex buffer by applying transformation from the bones
  30365. * @param skeleton defines the skeleton to apply to current mesh
  30366. * @returns the current mesh
  30367. */
  30368. applySkeleton(skeleton: Skeleton): Mesh;
  30369. /**
  30370. * 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
  30371. * @param meshes defines the list of meshes to scan
  30372. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30373. */
  30374. static MinMax(meshes: AbstractMesh[]): {
  30375. min: Vector3;
  30376. max: Vector3;
  30377. };
  30378. /**
  30379. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30380. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30381. * @returns a vector3
  30382. */
  30383. static Center(meshesOrMinMaxVector: {
  30384. min: Vector3;
  30385. max: Vector3;
  30386. } | AbstractMesh[]): Vector3;
  30387. /**
  30388. * Merge the array of meshes into a single mesh for performance reasons.
  30389. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30390. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30391. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30392. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30393. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30394. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30395. * @returns a new mesh
  30396. */
  30397. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30398. /** @hidden */
  30399. addInstance(instance: InstancedMesh): void;
  30400. /** @hidden */
  30401. removeInstance(instance: InstancedMesh): void;
  30402. }
  30403. }
  30404. declare module "babylonjs/Cameras/camera" {
  30405. import { SmartArray } from "babylonjs/Misc/smartArray";
  30406. import { Observable } from "babylonjs/Misc/observable";
  30407. import { Nullable } from "babylonjs/types";
  30408. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30409. import { Scene } from "babylonjs/scene";
  30410. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30411. import { Node } from "babylonjs/node";
  30412. import { Mesh } from "babylonjs/Meshes/mesh";
  30413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30414. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30415. import { Viewport } from "babylonjs/Maths/math.viewport";
  30416. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30417. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30418. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30419. import { Ray } from "babylonjs/Culling/ray";
  30420. /**
  30421. * This is the base class of all the camera used in the application.
  30422. * @see https://doc.babylonjs.com/features/cameras
  30423. */
  30424. export class Camera extends Node {
  30425. /** @hidden */
  30426. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30427. /**
  30428. * This is the default projection mode used by the cameras.
  30429. * It helps recreating a feeling of perspective and better appreciate depth.
  30430. * This is the best way to simulate real life cameras.
  30431. */
  30432. static readonly PERSPECTIVE_CAMERA: number;
  30433. /**
  30434. * This helps creating camera with an orthographic mode.
  30435. * 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.
  30436. */
  30437. static readonly ORTHOGRAPHIC_CAMERA: number;
  30438. /**
  30439. * This is the default FOV mode for perspective cameras.
  30440. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30441. */
  30442. static readonly FOVMODE_VERTICAL_FIXED: number;
  30443. /**
  30444. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30445. */
  30446. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30447. /**
  30448. * This specifies ther is no need for a camera rig.
  30449. * Basically only one eye is rendered corresponding to the camera.
  30450. */
  30451. static readonly RIG_MODE_NONE: number;
  30452. /**
  30453. * Simulates a camera Rig with one blue eye and one red eye.
  30454. * This can be use with 3d blue and red glasses.
  30455. */
  30456. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30457. /**
  30458. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30459. */
  30460. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30461. /**
  30462. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30463. */
  30464. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30465. /**
  30466. * Defines that both eyes of the camera will be rendered over under each other.
  30467. */
  30468. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30469. /**
  30470. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30471. */
  30472. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30473. /**
  30474. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30475. */
  30476. static readonly RIG_MODE_VR: number;
  30477. /**
  30478. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30479. */
  30480. static readonly RIG_MODE_WEBVR: number;
  30481. /**
  30482. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30483. */
  30484. static readonly RIG_MODE_CUSTOM: number;
  30485. /**
  30486. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30487. */
  30488. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30489. /**
  30490. * Define the input manager associated with the camera.
  30491. */
  30492. inputs: CameraInputsManager<Camera>;
  30493. /** @hidden */
  30494. _position: Vector3;
  30495. /**
  30496. * Define the current local position of the camera in the scene
  30497. */
  30498. get position(): Vector3;
  30499. set position(newPosition: Vector3);
  30500. protected _upVector: Vector3;
  30501. /**
  30502. * The vector the camera should consider as up.
  30503. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30504. */
  30505. set upVector(vec: Vector3);
  30506. get upVector(): Vector3;
  30507. /**
  30508. * Define the current limit on the left side for an orthographic camera
  30509. * In scene unit
  30510. */
  30511. orthoLeft: Nullable<number>;
  30512. /**
  30513. * Define the current limit on the right side for an orthographic camera
  30514. * In scene unit
  30515. */
  30516. orthoRight: Nullable<number>;
  30517. /**
  30518. * Define the current limit on the bottom side for an orthographic camera
  30519. * In scene unit
  30520. */
  30521. orthoBottom: Nullable<number>;
  30522. /**
  30523. * Define the current limit on the top side for an orthographic camera
  30524. * In scene unit
  30525. */
  30526. orthoTop: Nullable<number>;
  30527. /**
  30528. * Field Of View is set in Radians. (default is 0.8)
  30529. */
  30530. fov: number;
  30531. /**
  30532. * Define the minimum distance the camera can see from.
  30533. * This is important to note that the depth buffer are not infinite and the closer it starts
  30534. * the more your scene might encounter depth fighting issue.
  30535. */
  30536. minZ: number;
  30537. /**
  30538. * Define the maximum distance the camera can see to.
  30539. * This is important to note that the depth buffer are not infinite and the further it end
  30540. * the more your scene might encounter depth fighting issue.
  30541. */
  30542. maxZ: number;
  30543. /**
  30544. * Define the default inertia of the camera.
  30545. * This helps giving a smooth feeling to the camera movement.
  30546. */
  30547. inertia: number;
  30548. /**
  30549. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30550. */
  30551. mode: number;
  30552. /**
  30553. * Define whether the camera is intermediate.
  30554. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30555. */
  30556. isIntermediate: boolean;
  30557. /**
  30558. * Define the viewport of the camera.
  30559. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30560. */
  30561. viewport: Viewport;
  30562. /**
  30563. * Restricts the camera to viewing objects with the same layerMask.
  30564. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30565. */
  30566. layerMask: number;
  30567. /**
  30568. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30569. */
  30570. fovMode: number;
  30571. /**
  30572. * Rig mode of the camera.
  30573. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30574. * This is normally controlled byt the camera themselves as internal use.
  30575. */
  30576. cameraRigMode: number;
  30577. /**
  30578. * Defines the distance between both "eyes" in case of a RIG
  30579. */
  30580. interaxialDistance: number;
  30581. /**
  30582. * Defines if stereoscopic rendering is done side by side or over under.
  30583. */
  30584. isStereoscopicSideBySide: boolean;
  30585. /**
  30586. * 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
  30587. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30588. * else in the scene. (Eg. security camera)
  30589. *
  30590. * 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)
  30591. */
  30592. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30593. /**
  30594. * When set, the camera will render to this render target instead of the default canvas
  30595. *
  30596. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30597. */
  30598. outputRenderTarget: Nullable<RenderTargetTexture>;
  30599. /**
  30600. * Observable triggered when the camera view matrix has changed.
  30601. */
  30602. onViewMatrixChangedObservable: Observable<Camera>;
  30603. /**
  30604. * Observable triggered when the camera Projection matrix has changed.
  30605. */
  30606. onProjectionMatrixChangedObservable: Observable<Camera>;
  30607. /**
  30608. * Observable triggered when the inputs have been processed.
  30609. */
  30610. onAfterCheckInputsObservable: Observable<Camera>;
  30611. /**
  30612. * Observable triggered when reset has been called and applied to the camera.
  30613. */
  30614. onRestoreStateObservable: Observable<Camera>;
  30615. /**
  30616. * Is this camera a part of a rig system?
  30617. */
  30618. isRigCamera: boolean;
  30619. /**
  30620. * If isRigCamera set to true this will be set with the parent camera.
  30621. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30622. */
  30623. rigParent?: Camera;
  30624. /** @hidden */
  30625. _cameraRigParams: any;
  30626. /** @hidden */
  30627. _rigCameras: Camera[];
  30628. /** @hidden */
  30629. _rigPostProcess: Nullable<PostProcess>;
  30630. protected _webvrViewMatrix: Matrix;
  30631. /** @hidden */
  30632. _skipRendering: boolean;
  30633. /** @hidden */
  30634. _projectionMatrix: Matrix;
  30635. /** @hidden */
  30636. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30637. /** @hidden */
  30638. _activeMeshes: SmartArray<AbstractMesh>;
  30639. protected _globalPosition: Vector3;
  30640. /** @hidden */
  30641. _computedViewMatrix: Matrix;
  30642. private _doNotComputeProjectionMatrix;
  30643. private _transformMatrix;
  30644. private _frustumPlanes;
  30645. private _refreshFrustumPlanes;
  30646. private _storedFov;
  30647. private _stateStored;
  30648. /**
  30649. * Instantiates a new camera object.
  30650. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30651. * @see https://doc.babylonjs.com/features/cameras
  30652. * @param name Defines the name of the camera in the scene
  30653. * @param position Defines the position of the camera
  30654. * @param scene Defines the scene the camera belongs too
  30655. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30656. */
  30657. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30658. /**
  30659. * Store current camera state (fov, position, etc..)
  30660. * @returns the camera
  30661. */
  30662. storeState(): Camera;
  30663. /**
  30664. * Restores the camera state values if it has been stored. You must call storeState() first
  30665. */
  30666. protected _restoreStateValues(): boolean;
  30667. /**
  30668. * Restored camera state. You must call storeState() first.
  30669. * @returns true if restored and false otherwise
  30670. */
  30671. restoreState(): boolean;
  30672. /**
  30673. * Gets the class name of the camera.
  30674. * @returns the class name
  30675. */
  30676. getClassName(): string;
  30677. /** @hidden */
  30678. readonly _isCamera: boolean;
  30679. /**
  30680. * Gets a string representation of the camera useful for debug purpose.
  30681. * @param fullDetails Defines that a more verboe level of logging is required
  30682. * @returns the string representation
  30683. */
  30684. toString(fullDetails?: boolean): string;
  30685. /**
  30686. * Gets the current world space position of the camera.
  30687. */
  30688. get globalPosition(): Vector3;
  30689. /**
  30690. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30691. * @returns the active meshe list
  30692. */
  30693. getActiveMeshes(): SmartArray<AbstractMesh>;
  30694. /**
  30695. * Check whether a mesh is part of the current active mesh list of the camera
  30696. * @param mesh Defines the mesh to check
  30697. * @returns true if active, false otherwise
  30698. */
  30699. isActiveMesh(mesh: Mesh): boolean;
  30700. /**
  30701. * Is this camera ready to be used/rendered
  30702. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30703. * @return true if the camera is ready
  30704. */
  30705. isReady(completeCheck?: boolean): boolean;
  30706. /** @hidden */
  30707. _initCache(): void;
  30708. /** @hidden */
  30709. _updateCache(ignoreParentClass?: boolean): void;
  30710. /** @hidden */
  30711. _isSynchronized(): boolean;
  30712. /** @hidden */
  30713. _isSynchronizedViewMatrix(): boolean;
  30714. /** @hidden */
  30715. _isSynchronizedProjectionMatrix(): boolean;
  30716. /**
  30717. * Attach the input controls to a specific dom element to get the input from.
  30718. * @param element Defines the element the controls should be listened from
  30719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30720. */
  30721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30722. /**
  30723. * Detach the current controls from the specified dom element.
  30724. * @param element Defines the element to stop listening the inputs from
  30725. */
  30726. detachControl(element: HTMLElement): void;
  30727. /**
  30728. * Update the camera state according to the different inputs gathered during the frame.
  30729. */
  30730. update(): void;
  30731. /** @hidden */
  30732. _checkInputs(): void;
  30733. /** @hidden */
  30734. get rigCameras(): Camera[];
  30735. /**
  30736. * Gets the post process used by the rig cameras
  30737. */
  30738. get rigPostProcess(): Nullable<PostProcess>;
  30739. /**
  30740. * Internal, gets the first post proces.
  30741. * @returns the first post process to be run on this camera.
  30742. */
  30743. _getFirstPostProcess(): Nullable<PostProcess>;
  30744. private _cascadePostProcessesToRigCams;
  30745. /**
  30746. * Attach a post process to the camera.
  30747. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30748. * @param postProcess The post process to attach to the camera
  30749. * @param insertAt The position of the post process in case several of them are in use in the scene
  30750. * @returns the position the post process has been inserted at
  30751. */
  30752. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30753. /**
  30754. * Detach a post process to the camera.
  30755. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30756. * @param postProcess The post process to detach from the camera
  30757. */
  30758. detachPostProcess(postProcess: PostProcess): void;
  30759. /**
  30760. * Gets the current world matrix of the camera
  30761. */
  30762. getWorldMatrix(): Matrix;
  30763. /** @hidden */
  30764. _getViewMatrix(): Matrix;
  30765. /**
  30766. * Gets the current view matrix of the camera.
  30767. * @param force forces the camera to recompute the matrix without looking at the cached state
  30768. * @returns the view matrix
  30769. */
  30770. getViewMatrix(force?: boolean): Matrix;
  30771. /**
  30772. * Freeze the projection matrix.
  30773. * It will prevent the cache check of the camera projection compute and can speed up perf
  30774. * if no parameter of the camera are meant to change
  30775. * @param projection Defines manually a projection if necessary
  30776. */
  30777. freezeProjectionMatrix(projection?: Matrix): void;
  30778. /**
  30779. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30780. */
  30781. unfreezeProjectionMatrix(): void;
  30782. /**
  30783. * Gets the current projection matrix of the camera.
  30784. * @param force forces the camera to recompute the matrix without looking at the cached state
  30785. * @returns the projection matrix
  30786. */
  30787. getProjectionMatrix(force?: boolean): Matrix;
  30788. /**
  30789. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30790. * @returns a Matrix
  30791. */
  30792. getTransformationMatrix(): Matrix;
  30793. private _updateFrustumPlanes;
  30794. /**
  30795. * Checks if a cullable object (mesh...) is in the camera frustum
  30796. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30797. * @param target The object to check
  30798. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30799. * @returns true if the object is in frustum otherwise false
  30800. */
  30801. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30802. /**
  30803. * Checks if a cullable object (mesh...) is in the camera frustum
  30804. * Unlike isInFrustum this cheks the full bounding box
  30805. * @param target The object to check
  30806. * @returns true if the object is in frustum otherwise false
  30807. */
  30808. isCompletelyInFrustum(target: ICullable): boolean;
  30809. /**
  30810. * Gets a ray in the forward direction from the camera.
  30811. * @param length Defines the length of the ray to create
  30812. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30813. * @param origin Defines the start point of the ray which defaults to the camera position
  30814. * @returns the forward ray
  30815. */
  30816. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30817. /**
  30818. * Gets a ray in the forward direction from the camera.
  30819. * @param refRay the ray to (re)use when setting the values
  30820. * @param length Defines the length of the ray to create
  30821. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30822. * @param origin Defines the start point of the ray which defaults to the camera position
  30823. * @returns the forward ray
  30824. */
  30825. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30826. /**
  30827. * Releases resources associated with this node.
  30828. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30829. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30830. */
  30831. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30832. /** @hidden */
  30833. _isLeftCamera: boolean;
  30834. /**
  30835. * Gets the left camera of a rig setup in case of Rigged Camera
  30836. */
  30837. get isLeftCamera(): boolean;
  30838. /** @hidden */
  30839. _isRightCamera: boolean;
  30840. /**
  30841. * Gets the right camera of a rig setup in case of Rigged Camera
  30842. */
  30843. get isRightCamera(): boolean;
  30844. /**
  30845. * Gets the left camera of a rig setup in case of Rigged Camera
  30846. */
  30847. get leftCamera(): Nullable<FreeCamera>;
  30848. /**
  30849. * Gets the right camera of a rig setup in case of Rigged Camera
  30850. */
  30851. get rightCamera(): Nullable<FreeCamera>;
  30852. /**
  30853. * Gets the left camera target of a rig setup in case of Rigged Camera
  30854. * @returns the target position
  30855. */
  30856. getLeftTarget(): Nullable<Vector3>;
  30857. /**
  30858. * Gets the right camera target of a rig setup in case of Rigged Camera
  30859. * @returns the target position
  30860. */
  30861. getRightTarget(): Nullable<Vector3>;
  30862. /**
  30863. * @hidden
  30864. */
  30865. setCameraRigMode(mode: number, rigParams: any): void;
  30866. /** @hidden */
  30867. static _setStereoscopicRigMode(camera: Camera): void;
  30868. /** @hidden */
  30869. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30870. /** @hidden */
  30871. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30872. /** @hidden */
  30873. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30874. /** @hidden */
  30875. _getVRProjectionMatrix(): Matrix;
  30876. protected _updateCameraRotationMatrix(): void;
  30877. protected _updateWebVRCameraRotationMatrix(): void;
  30878. /**
  30879. * This function MUST be overwritten by the different WebVR cameras available.
  30880. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30881. * @hidden
  30882. */
  30883. _getWebVRProjectionMatrix(): Matrix;
  30884. /**
  30885. * This function MUST be overwritten by the different WebVR cameras available.
  30886. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30887. * @hidden
  30888. */
  30889. _getWebVRViewMatrix(): Matrix;
  30890. /** @hidden */
  30891. setCameraRigParameter(name: string, value: any): void;
  30892. /**
  30893. * needs to be overridden by children so sub has required properties to be copied
  30894. * @hidden
  30895. */
  30896. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30897. /**
  30898. * May need to be overridden by children
  30899. * @hidden
  30900. */
  30901. _updateRigCameras(): void;
  30902. /** @hidden */
  30903. _setupInputs(): void;
  30904. /**
  30905. * Serialiaze the camera setup to a json represention
  30906. * @returns the JSON representation
  30907. */
  30908. serialize(): any;
  30909. /**
  30910. * Clones the current camera.
  30911. * @param name The cloned camera name
  30912. * @returns the cloned camera
  30913. */
  30914. clone(name: string): Camera;
  30915. /**
  30916. * Gets the direction of the camera relative to a given local axis.
  30917. * @param localAxis Defines the reference axis to provide a relative direction.
  30918. * @return the direction
  30919. */
  30920. getDirection(localAxis: Vector3): Vector3;
  30921. /**
  30922. * Returns the current camera absolute rotation
  30923. */
  30924. get absoluteRotation(): Quaternion;
  30925. /**
  30926. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30927. * @param localAxis Defines the reference axis to provide a relative direction.
  30928. * @param result Defines the vector to store the result in
  30929. */
  30930. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30931. /**
  30932. * Gets a camera constructor for a given camera type
  30933. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30934. * @param name The name of the camera the result will be able to instantiate
  30935. * @param scene The scene the result will construct the camera in
  30936. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30937. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30938. * @returns a factory method to construc the camera
  30939. */
  30940. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30941. /**
  30942. * Compute the world matrix of the camera.
  30943. * @returns the camera world matrix
  30944. */
  30945. computeWorldMatrix(): Matrix;
  30946. /**
  30947. * Parse a JSON and creates the camera from the parsed information
  30948. * @param parsedCamera The JSON to parse
  30949. * @param scene The scene to instantiate the camera in
  30950. * @returns the newly constructed camera
  30951. */
  30952. static Parse(parsedCamera: any, scene: Scene): Camera;
  30953. }
  30954. }
  30955. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30956. import { Nullable } from "babylonjs/types";
  30957. import { Scene } from "babylonjs/scene";
  30958. import { Vector4 } from "babylonjs/Maths/math.vector";
  30959. import { Mesh } from "babylonjs/Meshes/mesh";
  30960. /**
  30961. * Class containing static functions to help procedurally build meshes
  30962. */
  30963. export class DiscBuilder {
  30964. /**
  30965. * Creates a plane polygonal mesh. By default, this is a disc
  30966. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30967. * * 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
  30968. * * 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
  30969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30972. * @param name defines the name of the mesh
  30973. * @param options defines the options used to create the mesh
  30974. * @param scene defines the hosting scene
  30975. * @returns the plane polygonal mesh
  30976. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30977. */
  30978. static CreateDisc(name: string, options: {
  30979. radius?: number;
  30980. tessellation?: number;
  30981. arc?: number;
  30982. updatable?: boolean;
  30983. sideOrientation?: number;
  30984. frontUVs?: Vector4;
  30985. backUVs?: Vector4;
  30986. }, scene?: Nullable<Scene>): Mesh;
  30987. }
  30988. }
  30989. declare module "babylonjs/Materials/fresnelParameters" {
  30990. import { DeepImmutable } from "babylonjs/types";
  30991. import { Color3 } from "babylonjs/Maths/math.color";
  30992. /**
  30993. * Options to be used when creating a FresnelParameters.
  30994. */
  30995. export type IFresnelParametersCreationOptions = {
  30996. /**
  30997. * Define the color used on edges (grazing angle)
  30998. */
  30999. leftColor?: Color3;
  31000. /**
  31001. * Define the color used on center
  31002. */
  31003. rightColor?: Color3;
  31004. /**
  31005. * Define bias applied to computed fresnel term
  31006. */
  31007. bias?: number;
  31008. /**
  31009. * Defined the power exponent applied to fresnel term
  31010. */
  31011. power?: number;
  31012. /**
  31013. * Define if the fresnel effect is enable or not.
  31014. */
  31015. isEnabled?: boolean;
  31016. };
  31017. /**
  31018. * Serialized format for FresnelParameters.
  31019. */
  31020. export type IFresnelParametersSerialized = {
  31021. /**
  31022. * Define the color used on edges (grazing angle) [as an array]
  31023. */
  31024. leftColor: number[];
  31025. /**
  31026. * Define the color used on center [as an array]
  31027. */
  31028. rightColor: number[];
  31029. /**
  31030. * Define bias applied to computed fresnel term
  31031. */
  31032. bias: number;
  31033. /**
  31034. * Defined the power exponent applied to fresnel term
  31035. */
  31036. power?: number;
  31037. /**
  31038. * Define if the fresnel effect is enable or not.
  31039. */
  31040. isEnabled: boolean;
  31041. };
  31042. /**
  31043. * This represents all the required information to add a fresnel effect on a material:
  31044. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31045. */
  31046. export class FresnelParameters {
  31047. private _isEnabled;
  31048. /**
  31049. * Define if the fresnel effect is enable or not.
  31050. */
  31051. get isEnabled(): boolean;
  31052. set isEnabled(value: boolean);
  31053. /**
  31054. * Define the color used on edges (grazing angle)
  31055. */
  31056. leftColor: Color3;
  31057. /**
  31058. * Define the color used on center
  31059. */
  31060. rightColor: Color3;
  31061. /**
  31062. * Define bias applied to computed fresnel term
  31063. */
  31064. bias: number;
  31065. /**
  31066. * Defined the power exponent applied to fresnel term
  31067. */
  31068. power: number;
  31069. /**
  31070. * Creates a new FresnelParameters object.
  31071. *
  31072. * @param options provide your own settings to optionally to override defaults
  31073. */
  31074. constructor(options?: IFresnelParametersCreationOptions);
  31075. /**
  31076. * Clones the current fresnel and its valuues
  31077. * @returns a clone fresnel configuration
  31078. */
  31079. clone(): FresnelParameters;
  31080. /**
  31081. * Determines equality between FresnelParameters objects
  31082. * @param otherFresnelParameters defines the second operand
  31083. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31084. */
  31085. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31086. /**
  31087. * Serializes the current fresnel parameters to a JSON representation.
  31088. * @return the JSON serialization
  31089. */
  31090. serialize(): IFresnelParametersSerialized;
  31091. /**
  31092. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31093. * @param parsedFresnelParameters Define the JSON representation
  31094. * @returns the parsed parameters
  31095. */
  31096. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31097. }
  31098. }
  31099. declare module "babylonjs/Materials/materialFlags" {
  31100. /**
  31101. * This groups all the flags used to control the materials channel.
  31102. */
  31103. export class MaterialFlags {
  31104. private static _DiffuseTextureEnabled;
  31105. /**
  31106. * Are diffuse textures enabled in the application.
  31107. */
  31108. static get DiffuseTextureEnabled(): boolean;
  31109. static set DiffuseTextureEnabled(value: boolean);
  31110. private static _DetailTextureEnabled;
  31111. /**
  31112. * Are detail textures enabled in the application.
  31113. */
  31114. static get DetailTextureEnabled(): boolean;
  31115. static set DetailTextureEnabled(value: boolean);
  31116. private static _AmbientTextureEnabled;
  31117. /**
  31118. * Are ambient textures enabled in the application.
  31119. */
  31120. static get AmbientTextureEnabled(): boolean;
  31121. static set AmbientTextureEnabled(value: boolean);
  31122. private static _OpacityTextureEnabled;
  31123. /**
  31124. * Are opacity textures enabled in the application.
  31125. */
  31126. static get OpacityTextureEnabled(): boolean;
  31127. static set OpacityTextureEnabled(value: boolean);
  31128. private static _ReflectionTextureEnabled;
  31129. /**
  31130. * Are reflection textures enabled in the application.
  31131. */
  31132. static get ReflectionTextureEnabled(): boolean;
  31133. static set ReflectionTextureEnabled(value: boolean);
  31134. private static _EmissiveTextureEnabled;
  31135. /**
  31136. * Are emissive textures enabled in the application.
  31137. */
  31138. static get EmissiveTextureEnabled(): boolean;
  31139. static set EmissiveTextureEnabled(value: boolean);
  31140. private static _SpecularTextureEnabled;
  31141. /**
  31142. * Are specular textures enabled in the application.
  31143. */
  31144. static get SpecularTextureEnabled(): boolean;
  31145. static set SpecularTextureEnabled(value: boolean);
  31146. private static _BumpTextureEnabled;
  31147. /**
  31148. * Are bump textures enabled in the application.
  31149. */
  31150. static get BumpTextureEnabled(): boolean;
  31151. static set BumpTextureEnabled(value: boolean);
  31152. private static _LightmapTextureEnabled;
  31153. /**
  31154. * Are lightmap textures enabled in the application.
  31155. */
  31156. static get LightmapTextureEnabled(): boolean;
  31157. static set LightmapTextureEnabled(value: boolean);
  31158. private static _RefractionTextureEnabled;
  31159. /**
  31160. * Are refraction textures enabled in the application.
  31161. */
  31162. static get RefractionTextureEnabled(): boolean;
  31163. static set RefractionTextureEnabled(value: boolean);
  31164. private static _ColorGradingTextureEnabled;
  31165. /**
  31166. * Are color grading textures enabled in the application.
  31167. */
  31168. static get ColorGradingTextureEnabled(): boolean;
  31169. static set ColorGradingTextureEnabled(value: boolean);
  31170. private static _FresnelEnabled;
  31171. /**
  31172. * Are fresnels enabled in the application.
  31173. */
  31174. static get FresnelEnabled(): boolean;
  31175. static set FresnelEnabled(value: boolean);
  31176. private static _ClearCoatTextureEnabled;
  31177. /**
  31178. * Are clear coat textures enabled in the application.
  31179. */
  31180. static get ClearCoatTextureEnabled(): boolean;
  31181. static set ClearCoatTextureEnabled(value: boolean);
  31182. private static _ClearCoatBumpTextureEnabled;
  31183. /**
  31184. * Are clear coat bump textures enabled in the application.
  31185. */
  31186. static get ClearCoatBumpTextureEnabled(): boolean;
  31187. static set ClearCoatBumpTextureEnabled(value: boolean);
  31188. private static _ClearCoatTintTextureEnabled;
  31189. /**
  31190. * Are clear coat tint textures enabled in the application.
  31191. */
  31192. static get ClearCoatTintTextureEnabled(): boolean;
  31193. static set ClearCoatTintTextureEnabled(value: boolean);
  31194. private static _SheenTextureEnabled;
  31195. /**
  31196. * Are sheen textures enabled in the application.
  31197. */
  31198. static get SheenTextureEnabled(): boolean;
  31199. static set SheenTextureEnabled(value: boolean);
  31200. private static _AnisotropicTextureEnabled;
  31201. /**
  31202. * Are anisotropic textures enabled in the application.
  31203. */
  31204. static get AnisotropicTextureEnabled(): boolean;
  31205. static set AnisotropicTextureEnabled(value: boolean);
  31206. private static _ThicknessTextureEnabled;
  31207. /**
  31208. * Are thickness textures enabled in the application.
  31209. */
  31210. static get ThicknessTextureEnabled(): boolean;
  31211. static set ThicknessTextureEnabled(value: boolean);
  31212. }
  31213. }
  31214. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31215. /** @hidden */
  31216. export var defaultFragmentDeclaration: {
  31217. name: string;
  31218. shader: string;
  31219. };
  31220. }
  31221. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31222. /** @hidden */
  31223. export var defaultUboDeclaration: {
  31224. name: string;
  31225. shader: string;
  31226. };
  31227. }
  31228. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31229. /** @hidden */
  31230. export var prePassDeclaration: {
  31231. name: string;
  31232. shader: string;
  31233. };
  31234. }
  31235. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31236. /** @hidden */
  31237. export var lightFragmentDeclaration: {
  31238. name: string;
  31239. shader: string;
  31240. };
  31241. }
  31242. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31243. /** @hidden */
  31244. export var lightUboDeclaration: {
  31245. name: string;
  31246. shader: string;
  31247. };
  31248. }
  31249. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31250. /** @hidden */
  31251. export var lightsFragmentFunctions: {
  31252. name: string;
  31253. shader: string;
  31254. };
  31255. }
  31256. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31257. /** @hidden */
  31258. export var shadowsFragmentFunctions: {
  31259. name: string;
  31260. shader: string;
  31261. };
  31262. }
  31263. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31264. /** @hidden */
  31265. export var fresnelFunction: {
  31266. name: string;
  31267. shader: string;
  31268. };
  31269. }
  31270. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31271. /** @hidden */
  31272. export var bumpFragmentMainFunctions: {
  31273. name: string;
  31274. shader: string;
  31275. };
  31276. }
  31277. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31278. /** @hidden */
  31279. export var bumpFragmentFunctions: {
  31280. name: string;
  31281. shader: string;
  31282. };
  31283. }
  31284. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31285. /** @hidden */
  31286. export var logDepthDeclaration: {
  31287. name: string;
  31288. shader: string;
  31289. };
  31290. }
  31291. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31292. /** @hidden */
  31293. export var bumpFragment: {
  31294. name: string;
  31295. shader: string;
  31296. };
  31297. }
  31298. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31299. /** @hidden */
  31300. export var depthPrePass: {
  31301. name: string;
  31302. shader: string;
  31303. };
  31304. }
  31305. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31306. /** @hidden */
  31307. export var lightFragment: {
  31308. name: string;
  31309. shader: string;
  31310. };
  31311. }
  31312. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31313. /** @hidden */
  31314. export var logDepthFragment: {
  31315. name: string;
  31316. shader: string;
  31317. };
  31318. }
  31319. declare module "babylonjs/Shaders/default.fragment" {
  31320. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31321. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31322. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31323. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31324. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31325. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31326. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31327. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31328. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31329. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31330. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31331. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31332. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31333. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31334. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31335. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31336. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31337. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31338. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31339. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31340. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31341. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31342. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31343. /** @hidden */
  31344. export var defaultPixelShader: {
  31345. name: string;
  31346. shader: string;
  31347. };
  31348. }
  31349. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31350. /** @hidden */
  31351. export var defaultVertexDeclaration: {
  31352. name: string;
  31353. shader: string;
  31354. };
  31355. }
  31356. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31357. /** @hidden */
  31358. export var bumpVertexDeclaration: {
  31359. name: string;
  31360. shader: string;
  31361. };
  31362. }
  31363. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31364. /** @hidden */
  31365. export var bumpVertex: {
  31366. name: string;
  31367. shader: string;
  31368. };
  31369. }
  31370. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31371. /** @hidden */
  31372. export var fogVertex: {
  31373. name: string;
  31374. shader: string;
  31375. };
  31376. }
  31377. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31378. /** @hidden */
  31379. export var shadowsVertex: {
  31380. name: string;
  31381. shader: string;
  31382. };
  31383. }
  31384. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31385. /** @hidden */
  31386. export var pointCloudVertex: {
  31387. name: string;
  31388. shader: string;
  31389. };
  31390. }
  31391. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31392. /** @hidden */
  31393. export var logDepthVertex: {
  31394. name: string;
  31395. shader: string;
  31396. };
  31397. }
  31398. declare module "babylonjs/Shaders/default.vertex" {
  31399. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31400. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31401. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31402. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31403. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31404. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31405. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31406. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31407. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31408. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31409. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31410. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31411. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31412. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31413. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31414. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31415. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31416. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31417. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31418. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31419. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31420. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31421. /** @hidden */
  31422. export var defaultVertexShader: {
  31423. name: string;
  31424. shader: string;
  31425. };
  31426. }
  31427. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31428. import { Nullable } from "babylonjs/types";
  31429. import { Scene } from "babylonjs/scene";
  31430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31431. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31432. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31433. /**
  31434. * @hidden
  31435. */
  31436. export interface IMaterialDetailMapDefines {
  31437. DETAIL: boolean;
  31438. DETAILDIRECTUV: number;
  31439. DETAIL_NORMALBLENDMETHOD: number;
  31440. /** @hidden */
  31441. _areTexturesDirty: boolean;
  31442. }
  31443. /**
  31444. * Define the code related to the detail map parameters of a material
  31445. *
  31446. * Inspired from:
  31447. * 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
  31448. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31449. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31450. */
  31451. export class DetailMapConfiguration {
  31452. private _texture;
  31453. /**
  31454. * The detail texture of the material.
  31455. */
  31456. texture: Nullable<BaseTexture>;
  31457. /**
  31458. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31459. * Bigger values mean stronger blending
  31460. */
  31461. diffuseBlendLevel: number;
  31462. /**
  31463. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31464. * Bigger values mean stronger blending. Only used with PBR materials
  31465. */
  31466. roughnessBlendLevel: number;
  31467. /**
  31468. * Defines how strong the bump effect from the detail map is
  31469. * Bigger values mean stronger effect
  31470. */
  31471. bumpLevel: number;
  31472. private _normalBlendMethod;
  31473. /**
  31474. * The method used to blend the bump and detail normals together
  31475. */
  31476. normalBlendMethod: number;
  31477. private _isEnabled;
  31478. /**
  31479. * Enable or disable the detail map on this material
  31480. */
  31481. isEnabled: boolean;
  31482. /** @hidden */
  31483. private _internalMarkAllSubMeshesAsTexturesDirty;
  31484. /** @hidden */
  31485. _markAllSubMeshesAsTexturesDirty(): void;
  31486. /**
  31487. * Instantiate a new detail map
  31488. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31489. */
  31490. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31491. /**
  31492. * Gets whether the submesh is ready to be used or not.
  31493. * @param defines the list of "defines" to update.
  31494. * @param scene defines the scene the material belongs to.
  31495. * @returns - boolean indicating that the submesh is ready or not.
  31496. */
  31497. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31498. /**
  31499. * Update the defines for detail map usage
  31500. * @param defines the list of "defines" to update.
  31501. * @param scene defines the scene the material belongs to.
  31502. */
  31503. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31504. /**
  31505. * Binds the material data.
  31506. * @param uniformBuffer defines the Uniform buffer to fill in.
  31507. * @param scene defines the scene the material belongs to.
  31508. * @param isFrozen defines whether the material is frozen or not.
  31509. */
  31510. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31511. /**
  31512. * Checks to see if a texture is used in the material.
  31513. * @param texture - Base texture to use.
  31514. * @returns - Boolean specifying if a texture is used in the material.
  31515. */
  31516. hasTexture(texture: BaseTexture): boolean;
  31517. /**
  31518. * Returns an array of the actively used textures.
  31519. * @param activeTextures Array of BaseTextures
  31520. */
  31521. getActiveTextures(activeTextures: BaseTexture[]): void;
  31522. /**
  31523. * Returns the animatable textures.
  31524. * @param animatables Array of animatable textures.
  31525. */
  31526. getAnimatables(animatables: IAnimatable[]): void;
  31527. /**
  31528. * Disposes the resources of the material.
  31529. * @param forceDisposeTextures - Forces the disposal of all textures.
  31530. */
  31531. dispose(forceDisposeTextures?: boolean): void;
  31532. /**
  31533. * Get the current class name useful for serialization or dynamic coding.
  31534. * @returns "DetailMap"
  31535. */
  31536. getClassName(): string;
  31537. /**
  31538. * Add the required uniforms to the current list.
  31539. * @param uniforms defines the current uniform list.
  31540. */
  31541. static AddUniforms(uniforms: string[]): void;
  31542. /**
  31543. * Add the required samplers to the current list.
  31544. * @param samplers defines the current sampler list.
  31545. */
  31546. static AddSamplers(samplers: string[]): void;
  31547. /**
  31548. * Add the required uniforms to the current buffer.
  31549. * @param uniformBuffer defines the current uniform buffer.
  31550. */
  31551. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31552. /**
  31553. * Makes a duplicate of the current instance into another one.
  31554. * @param detailMap define the instance where to copy the info
  31555. */
  31556. copyTo(detailMap: DetailMapConfiguration): void;
  31557. /**
  31558. * Serializes this detail map instance
  31559. * @returns - An object with the serialized instance.
  31560. */
  31561. serialize(): any;
  31562. /**
  31563. * Parses a detail map setting from a serialized object.
  31564. * @param source - Serialized object.
  31565. * @param scene Defines the scene we are parsing for
  31566. * @param rootUrl Defines the rootUrl to load from
  31567. */
  31568. parse(source: any, scene: Scene, rootUrl: string): void;
  31569. }
  31570. }
  31571. declare module "babylonjs/Materials/standardMaterial" {
  31572. import { SmartArray } from "babylonjs/Misc/smartArray";
  31573. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31574. import { Nullable } from "babylonjs/types";
  31575. import { Scene } from "babylonjs/scene";
  31576. import { Matrix } from "babylonjs/Maths/math.vector";
  31577. import { Color3 } from "babylonjs/Maths/math.color";
  31578. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31580. import { Mesh } from "babylonjs/Meshes/mesh";
  31581. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31582. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31583. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31584. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31585. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31587. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31588. import "babylonjs/Shaders/default.fragment";
  31589. import "babylonjs/Shaders/default.vertex";
  31590. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31591. /** @hidden */
  31592. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31593. MAINUV1: boolean;
  31594. MAINUV2: boolean;
  31595. DIFFUSE: boolean;
  31596. DIFFUSEDIRECTUV: number;
  31597. DETAIL: boolean;
  31598. DETAILDIRECTUV: number;
  31599. DETAIL_NORMALBLENDMETHOD: number;
  31600. AMBIENT: boolean;
  31601. AMBIENTDIRECTUV: number;
  31602. OPACITY: boolean;
  31603. OPACITYDIRECTUV: number;
  31604. OPACITYRGB: boolean;
  31605. REFLECTION: boolean;
  31606. EMISSIVE: boolean;
  31607. EMISSIVEDIRECTUV: number;
  31608. SPECULAR: boolean;
  31609. SPECULARDIRECTUV: number;
  31610. BUMP: boolean;
  31611. BUMPDIRECTUV: number;
  31612. PARALLAX: boolean;
  31613. PARALLAXOCCLUSION: boolean;
  31614. SPECULAROVERALPHA: boolean;
  31615. CLIPPLANE: boolean;
  31616. CLIPPLANE2: boolean;
  31617. CLIPPLANE3: boolean;
  31618. CLIPPLANE4: boolean;
  31619. CLIPPLANE5: boolean;
  31620. CLIPPLANE6: boolean;
  31621. ALPHATEST: boolean;
  31622. DEPTHPREPASS: boolean;
  31623. ALPHAFROMDIFFUSE: boolean;
  31624. POINTSIZE: boolean;
  31625. FOG: boolean;
  31626. SPECULARTERM: boolean;
  31627. DIFFUSEFRESNEL: boolean;
  31628. OPACITYFRESNEL: boolean;
  31629. REFLECTIONFRESNEL: boolean;
  31630. REFRACTIONFRESNEL: boolean;
  31631. EMISSIVEFRESNEL: boolean;
  31632. FRESNEL: boolean;
  31633. NORMAL: boolean;
  31634. UV1: boolean;
  31635. UV2: boolean;
  31636. VERTEXCOLOR: boolean;
  31637. VERTEXALPHA: boolean;
  31638. NUM_BONE_INFLUENCERS: number;
  31639. BonesPerMesh: number;
  31640. BONETEXTURE: boolean;
  31641. INSTANCES: boolean;
  31642. THIN_INSTANCES: boolean;
  31643. GLOSSINESS: boolean;
  31644. ROUGHNESS: boolean;
  31645. EMISSIVEASILLUMINATION: boolean;
  31646. LINKEMISSIVEWITHDIFFUSE: boolean;
  31647. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31648. LIGHTMAP: boolean;
  31649. LIGHTMAPDIRECTUV: number;
  31650. OBJECTSPACE_NORMALMAP: boolean;
  31651. USELIGHTMAPASSHADOWMAP: boolean;
  31652. REFLECTIONMAP_3D: boolean;
  31653. REFLECTIONMAP_SPHERICAL: boolean;
  31654. REFLECTIONMAP_PLANAR: boolean;
  31655. REFLECTIONMAP_CUBIC: boolean;
  31656. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31657. REFLECTIONMAP_PROJECTION: boolean;
  31658. REFLECTIONMAP_SKYBOX: boolean;
  31659. REFLECTIONMAP_EXPLICIT: boolean;
  31660. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31661. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31662. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31663. INVERTCUBICMAP: boolean;
  31664. LOGARITHMICDEPTH: boolean;
  31665. REFRACTION: boolean;
  31666. REFRACTIONMAP_3D: boolean;
  31667. REFLECTIONOVERALPHA: boolean;
  31668. TWOSIDEDLIGHTING: boolean;
  31669. SHADOWFLOAT: boolean;
  31670. MORPHTARGETS: boolean;
  31671. MORPHTARGETS_NORMAL: boolean;
  31672. MORPHTARGETS_TANGENT: boolean;
  31673. MORPHTARGETS_UV: boolean;
  31674. NUM_MORPH_INFLUENCERS: number;
  31675. NONUNIFORMSCALING: boolean;
  31676. PREMULTIPLYALPHA: boolean;
  31677. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31678. ALPHABLEND: boolean;
  31679. PREPASS: boolean;
  31680. PREPASS_IRRADIANCE: boolean;
  31681. PREPASS_IRRADIANCE_INDEX: number;
  31682. PREPASS_ALBEDO: boolean;
  31683. PREPASS_ALBEDO_INDEX: number;
  31684. PREPASS_DEPTHNORMAL: boolean;
  31685. PREPASS_DEPTHNORMAL_INDEX: number;
  31686. SCENE_MRT_COUNT: number;
  31687. RGBDLIGHTMAP: boolean;
  31688. RGBDREFLECTION: boolean;
  31689. RGBDREFRACTION: boolean;
  31690. IMAGEPROCESSING: boolean;
  31691. VIGNETTE: boolean;
  31692. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31693. VIGNETTEBLENDMODEOPAQUE: boolean;
  31694. TONEMAPPING: boolean;
  31695. TONEMAPPING_ACES: boolean;
  31696. CONTRAST: boolean;
  31697. COLORCURVES: boolean;
  31698. COLORGRADING: boolean;
  31699. COLORGRADING3D: boolean;
  31700. SAMPLER3DGREENDEPTH: boolean;
  31701. SAMPLER3DBGRMAP: boolean;
  31702. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31703. MULTIVIEW: boolean;
  31704. /**
  31705. * If the reflection texture on this material is in linear color space
  31706. * @hidden
  31707. */
  31708. IS_REFLECTION_LINEAR: boolean;
  31709. /**
  31710. * If the refraction texture on this material is in linear color space
  31711. * @hidden
  31712. */
  31713. IS_REFRACTION_LINEAR: boolean;
  31714. EXPOSURE: boolean;
  31715. constructor();
  31716. setReflectionMode(modeToEnable: string): void;
  31717. }
  31718. /**
  31719. * This is the default material used in Babylon. It is the best trade off between quality
  31720. * and performances.
  31721. * @see https://doc.babylonjs.com/babylon101/materials
  31722. */
  31723. export class StandardMaterial extends PushMaterial {
  31724. private _diffuseTexture;
  31725. /**
  31726. * The basic texture of the material as viewed under a light.
  31727. */
  31728. diffuseTexture: Nullable<BaseTexture>;
  31729. private _ambientTexture;
  31730. /**
  31731. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31732. */
  31733. ambientTexture: Nullable<BaseTexture>;
  31734. private _opacityTexture;
  31735. /**
  31736. * Define the transparency of the material from a texture.
  31737. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31738. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31739. */
  31740. opacityTexture: Nullable<BaseTexture>;
  31741. private _reflectionTexture;
  31742. /**
  31743. * Define the texture used to display the reflection.
  31744. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31745. */
  31746. reflectionTexture: Nullable<BaseTexture>;
  31747. private _emissiveTexture;
  31748. /**
  31749. * Define texture of the material as if self lit.
  31750. * This will be mixed in the final result even in the absence of light.
  31751. */
  31752. emissiveTexture: Nullable<BaseTexture>;
  31753. private _specularTexture;
  31754. /**
  31755. * Define how the color and intensity of the highlight given by the light in the material.
  31756. */
  31757. specularTexture: Nullable<BaseTexture>;
  31758. private _bumpTexture;
  31759. /**
  31760. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31761. * 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.
  31762. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31763. */
  31764. bumpTexture: Nullable<BaseTexture>;
  31765. private _lightmapTexture;
  31766. /**
  31767. * Complex lighting can be computationally expensive to compute at runtime.
  31768. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31769. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31770. */
  31771. lightmapTexture: Nullable<BaseTexture>;
  31772. private _refractionTexture;
  31773. /**
  31774. * Define the texture used to display the refraction.
  31775. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31776. */
  31777. refractionTexture: Nullable<BaseTexture>;
  31778. /**
  31779. * The color of the material lit by the environmental background lighting.
  31780. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31781. */
  31782. ambientColor: Color3;
  31783. /**
  31784. * The basic color of the material as viewed under a light.
  31785. */
  31786. diffuseColor: Color3;
  31787. /**
  31788. * Define how the color and intensity of the highlight given by the light in the material.
  31789. */
  31790. specularColor: Color3;
  31791. /**
  31792. * Define the color of the material as if self lit.
  31793. * This will be mixed in the final result even in the absence of light.
  31794. */
  31795. emissiveColor: Color3;
  31796. /**
  31797. * Defines how sharp are the highlights in the material.
  31798. * The bigger the value the sharper giving a more glossy feeling to the result.
  31799. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31800. */
  31801. specularPower: number;
  31802. private _useAlphaFromDiffuseTexture;
  31803. /**
  31804. * Does the transparency come from the diffuse texture alpha channel.
  31805. */
  31806. useAlphaFromDiffuseTexture: boolean;
  31807. private _useEmissiveAsIllumination;
  31808. /**
  31809. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31810. */
  31811. useEmissiveAsIllumination: boolean;
  31812. private _linkEmissiveWithDiffuse;
  31813. /**
  31814. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31815. * the emissive level when the final color is close to one.
  31816. */
  31817. linkEmissiveWithDiffuse: boolean;
  31818. private _useSpecularOverAlpha;
  31819. /**
  31820. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31821. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31822. */
  31823. useSpecularOverAlpha: boolean;
  31824. private _useReflectionOverAlpha;
  31825. /**
  31826. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31827. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31828. */
  31829. useReflectionOverAlpha: boolean;
  31830. private _disableLighting;
  31831. /**
  31832. * Does lights from the scene impacts this material.
  31833. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31834. */
  31835. disableLighting: boolean;
  31836. private _useObjectSpaceNormalMap;
  31837. /**
  31838. * Allows using an object space normal map (instead of tangent space).
  31839. */
  31840. useObjectSpaceNormalMap: boolean;
  31841. private _useParallax;
  31842. /**
  31843. * Is parallax enabled or not.
  31844. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31845. */
  31846. useParallax: boolean;
  31847. private _useParallaxOcclusion;
  31848. /**
  31849. * Is parallax occlusion enabled or not.
  31850. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31851. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31852. */
  31853. useParallaxOcclusion: boolean;
  31854. /**
  31855. * 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.
  31856. */
  31857. parallaxScaleBias: number;
  31858. private _roughness;
  31859. /**
  31860. * Helps to define how blurry the reflections should appears in the material.
  31861. */
  31862. roughness: number;
  31863. /**
  31864. * In case of refraction, define the value of the index of refraction.
  31865. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31866. */
  31867. indexOfRefraction: number;
  31868. /**
  31869. * Invert the refraction texture alongside the y axis.
  31870. * It can be useful with procedural textures or probe for instance.
  31871. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31872. */
  31873. invertRefractionY: boolean;
  31874. /**
  31875. * Defines the alpha limits in alpha test mode.
  31876. */
  31877. alphaCutOff: number;
  31878. private _useLightmapAsShadowmap;
  31879. /**
  31880. * In case of light mapping, define whether the map contains light or shadow informations.
  31881. */
  31882. useLightmapAsShadowmap: boolean;
  31883. private _diffuseFresnelParameters;
  31884. /**
  31885. * Define the diffuse fresnel parameters of the material.
  31886. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31887. */
  31888. diffuseFresnelParameters: FresnelParameters;
  31889. private _opacityFresnelParameters;
  31890. /**
  31891. * Define the opacity fresnel parameters of the material.
  31892. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31893. */
  31894. opacityFresnelParameters: FresnelParameters;
  31895. private _reflectionFresnelParameters;
  31896. /**
  31897. * Define the reflection fresnel parameters of the material.
  31898. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31899. */
  31900. reflectionFresnelParameters: FresnelParameters;
  31901. private _refractionFresnelParameters;
  31902. /**
  31903. * Define the refraction fresnel parameters of the material.
  31904. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31905. */
  31906. refractionFresnelParameters: FresnelParameters;
  31907. private _emissiveFresnelParameters;
  31908. /**
  31909. * Define the emissive fresnel parameters of the material.
  31910. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31911. */
  31912. emissiveFresnelParameters: FresnelParameters;
  31913. private _useReflectionFresnelFromSpecular;
  31914. /**
  31915. * If true automatically deducts the fresnels values from the material specularity.
  31916. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31917. */
  31918. useReflectionFresnelFromSpecular: boolean;
  31919. private _useGlossinessFromSpecularMapAlpha;
  31920. /**
  31921. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31922. */
  31923. useGlossinessFromSpecularMapAlpha: boolean;
  31924. private _maxSimultaneousLights;
  31925. /**
  31926. * Defines the maximum number of lights that can be used in the material
  31927. */
  31928. maxSimultaneousLights: number;
  31929. private _invertNormalMapX;
  31930. /**
  31931. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31932. */
  31933. invertNormalMapX: boolean;
  31934. private _invertNormalMapY;
  31935. /**
  31936. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31937. */
  31938. invertNormalMapY: boolean;
  31939. private _twoSidedLighting;
  31940. /**
  31941. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31942. */
  31943. twoSidedLighting: boolean;
  31944. /**
  31945. * Default configuration related to image processing available in the standard Material.
  31946. */
  31947. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31948. /**
  31949. * Gets the image processing configuration used either in this material.
  31950. */
  31951. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31952. /**
  31953. * Sets the Default image processing configuration used either in the this material.
  31954. *
  31955. * If sets to null, the scene one is in use.
  31956. */
  31957. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31958. /**
  31959. * Keep track of the image processing observer to allow dispose and replace.
  31960. */
  31961. private _imageProcessingObserver;
  31962. /**
  31963. * Attaches a new image processing configuration to the Standard Material.
  31964. * @param configuration
  31965. */
  31966. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31967. /**
  31968. * Gets wether the color curves effect is enabled.
  31969. */
  31970. get cameraColorCurvesEnabled(): boolean;
  31971. /**
  31972. * Sets wether the color curves effect is enabled.
  31973. */
  31974. set cameraColorCurvesEnabled(value: boolean);
  31975. /**
  31976. * Gets wether the color grading effect is enabled.
  31977. */
  31978. get cameraColorGradingEnabled(): boolean;
  31979. /**
  31980. * Gets wether the color grading effect is enabled.
  31981. */
  31982. set cameraColorGradingEnabled(value: boolean);
  31983. /**
  31984. * Gets wether tonemapping is enabled or not.
  31985. */
  31986. get cameraToneMappingEnabled(): boolean;
  31987. /**
  31988. * Sets wether tonemapping is enabled or not
  31989. */
  31990. set cameraToneMappingEnabled(value: boolean);
  31991. /**
  31992. * The camera exposure used on this material.
  31993. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31994. * This corresponds to a photographic exposure.
  31995. */
  31996. get cameraExposure(): number;
  31997. /**
  31998. * The camera exposure used on this material.
  31999. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32000. * This corresponds to a photographic exposure.
  32001. */
  32002. set cameraExposure(value: number);
  32003. /**
  32004. * Gets The camera contrast used on this material.
  32005. */
  32006. get cameraContrast(): number;
  32007. /**
  32008. * Sets The camera contrast used on this material.
  32009. */
  32010. set cameraContrast(value: number);
  32011. /**
  32012. * Gets the Color Grading 2D Lookup Texture.
  32013. */
  32014. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  32015. /**
  32016. * Sets the Color Grading 2D Lookup Texture.
  32017. */
  32018. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  32019. /**
  32020. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32021. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32022. * 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;
  32023. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32024. */
  32025. get cameraColorCurves(): Nullable<ColorCurves>;
  32026. /**
  32027. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32028. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32029. * 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;
  32030. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32031. */
  32032. set cameraColorCurves(value: Nullable<ColorCurves>);
  32033. /**
  32034. * Can this material render to several textures at once
  32035. */
  32036. get canRenderToMRT(): boolean;
  32037. /**
  32038. * Defines the detail map parameters for the material.
  32039. */
  32040. readonly detailMap: DetailMapConfiguration;
  32041. protected _renderTargets: SmartArray<RenderTargetTexture>;
  32042. protected _worldViewProjectionMatrix: Matrix;
  32043. protected _globalAmbientColor: Color3;
  32044. protected _useLogarithmicDepth: boolean;
  32045. protected _rebuildInParallel: boolean;
  32046. /**
  32047. * Instantiates a new standard material.
  32048. * This is the default material used in Babylon. It is the best trade off between quality
  32049. * and performances.
  32050. * @see https://doc.babylonjs.com/babylon101/materials
  32051. * @param name Define the name of the material in the scene
  32052. * @param scene Define the scene the material belong to
  32053. */
  32054. constructor(name: string, scene: Scene);
  32055. /**
  32056. * Gets a boolean indicating that current material needs to register RTT
  32057. */
  32058. get hasRenderTargetTextures(): boolean;
  32059. /**
  32060. * Gets the current class name of the material e.g. "StandardMaterial"
  32061. * Mainly use in serialization.
  32062. * @returns the class name
  32063. */
  32064. getClassName(): string;
  32065. /**
  32066. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  32067. * You can try switching to logarithmic depth.
  32068. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  32069. */
  32070. get useLogarithmicDepth(): boolean;
  32071. set useLogarithmicDepth(value: boolean);
  32072. /**
  32073. * Specifies if the material will require alpha blending
  32074. * @returns a boolean specifying if alpha blending is needed
  32075. */
  32076. needAlphaBlending(): boolean;
  32077. /**
  32078. * Specifies if this material should be rendered in alpha test mode
  32079. * @returns a boolean specifying if an alpha test is needed.
  32080. */
  32081. needAlphaTesting(): boolean;
  32082. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  32083. /**
  32084. * Get the texture used for alpha test purpose.
  32085. * @returns the diffuse texture in case of the standard material.
  32086. */
  32087. getAlphaTestTexture(): Nullable<BaseTexture>;
  32088. /**
  32089. * Get if the submesh is ready to be used and all its information available.
  32090. * Child classes can use it to update shaders
  32091. * @param mesh defines the mesh to check
  32092. * @param subMesh defines which submesh to check
  32093. * @param useInstances specifies that instances should be used
  32094. * @returns a boolean indicating that the submesh is ready or not
  32095. */
  32096. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32097. /**
  32098. * Builds the material UBO layouts.
  32099. * Used internally during the effect preparation.
  32100. */
  32101. buildUniformLayout(): void;
  32102. /**
  32103. * Unbinds the material from the mesh
  32104. */
  32105. unbind(): void;
  32106. /**
  32107. * Binds the submesh to this material by preparing the effect and shader to draw
  32108. * @param world defines the world transformation matrix
  32109. * @param mesh defines the mesh containing the submesh
  32110. * @param subMesh defines the submesh to bind the material to
  32111. */
  32112. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32113. /**
  32114. * Get the list of animatables in the material.
  32115. * @returns the list of animatables object used in the material
  32116. */
  32117. getAnimatables(): IAnimatable[];
  32118. /**
  32119. * Gets the active textures from the material
  32120. * @returns an array of textures
  32121. */
  32122. getActiveTextures(): BaseTexture[];
  32123. /**
  32124. * Specifies if the material uses a texture
  32125. * @param texture defines the texture to check against the material
  32126. * @returns a boolean specifying if the material uses the texture
  32127. */
  32128. hasTexture(texture: BaseTexture): boolean;
  32129. /**
  32130. * Disposes the material
  32131. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32132. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32133. */
  32134. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32135. /**
  32136. * Makes a duplicate of the material, and gives it a new name
  32137. * @param name defines the new name for the duplicated material
  32138. * @returns the cloned material
  32139. */
  32140. clone(name: string): StandardMaterial;
  32141. /**
  32142. * Serializes this material in a JSON representation
  32143. * @returns the serialized material object
  32144. */
  32145. serialize(): any;
  32146. /**
  32147. * Creates a standard material from parsed material data
  32148. * @param source defines the JSON representation of the material
  32149. * @param scene defines the hosting scene
  32150. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32151. * @returns a new standard material
  32152. */
  32153. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32154. /**
  32155. * Are diffuse textures enabled in the application.
  32156. */
  32157. static get DiffuseTextureEnabled(): boolean;
  32158. static set DiffuseTextureEnabled(value: boolean);
  32159. /**
  32160. * Are detail textures enabled in the application.
  32161. */
  32162. static get DetailTextureEnabled(): boolean;
  32163. static set DetailTextureEnabled(value: boolean);
  32164. /**
  32165. * Are ambient textures enabled in the application.
  32166. */
  32167. static get AmbientTextureEnabled(): boolean;
  32168. static set AmbientTextureEnabled(value: boolean);
  32169. /**
  32170. * Are opacity textures enabled in the application.
  32171. */
  32172. static get OpacityTextureEnabled(): boolean;
  32173. static set OpacityTextureEnabled(value: boolean);
  32174. /**
  32175. * Are reflection textures enabled in the application.
  32176. */
  32177. static get ReflectionTextureEnabled(): boolean;
  32178. static set ReflectionTextureEnabled(value: boolean);
  32179. /**
  32180. * Are emissive textures enabled in the application.
  32181. */
  32182. static get EmissiveTextureEnabled(): boolean;
  32183. static set EmissiveTextureEnabled(value: boolean);
  32184. /**
  32185. * Are specular textures enabled in the application.
  32186. */
  32187. static get SpecularTextureEnabled(): boolean;
  32188. static set SpecularTextureEnabled(value: boolean);
  32189. /**
  32190. * Are bump textures enabled in the application.
  32191. */
  32192. static get BumpTextureEnabled(): boolean;
  32193. static set BumpTextureEnabled(value: boolean);
  32194. /**
  32195. * Are lightmap textures enabled in the application.
  32196. */
  32197. static get LightmapTextureEnabled(): boolean;
  32198. static set LightmapTextureEnabled(value: boolean);
  32199. /**
  32200. * Are refraction textures enabled in the application.
  32201. */
  32202. static get RefractionTextureEnabled(): boolean;
  32203. static set RefractionTextureEnabled(value: boolean);
  32204. /**
  32205. * Are color grading textures enabled in the application.
  32206. */
  32207. static get ColorGradingTextureEnabled(): boolean;
  32208. static set ColorGradingTextureEnabled(value: boolean);
  32209. /**
  32210. * Are fresnels enabled in the application.
  32211. */
  32212. static get FresnelEnabled(): boolean;
  32213. static set FresnelEnabled(value: boolean);
  32214. }
  32215. }
  32216. declare module "babylonjs/Particles/solidParticleSystem" {
  32217. import { Nullable } from "babylonjs/types";
  32218. import { Mesh } from "babylonjs/Meshes/mesh";
  32219. import { Scene, IDisposable } from "babylonjs/scene";
  32220. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32221. import { Material } from "babylonjs/Materials/material";
  32222. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32223. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32224. /**
  32225. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32226. *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.
  32227. * The SPS is also a particle system. It provides some methods to manage the particles.
  32228. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32229. *
  32230. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32231. */
  32232. export class SolidParticleSystem implements IDisposable {
  32233. /**
  32234. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32235. * Example : var p = SPS.particles[i];
  32236. */
  32237. particles: SolidParticle[];
  32238. /**
  32239. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32240. */
  32241. nbParticles: number;
  32242. /**
  32243. * If the particles must ever face the camera (default false). Useful for planar particles.
  32244. */
  32245. billboard: boolean;
  32246. /**
  32247. * Recompute normals when adding a shape
  32248. */
  32249. recomputeNormals: boolean;
  32250. /**
  32251. * This a counter ofr your own usage. It's not set by any SPS functions.
  32252. */
  32253. counter: number;
  32254. /**
  32255. * The SPS name. This name is also given to the underlying mesh.
  32256. */
  32257. name: string;
  32258. /**
  32259. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32260. */
  32261. mesh: Mesh;
  32262. /**
  32263. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32264. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32265. */
  32266. vars: any;
  32267. /**
  32268. * This array is populated when the SPS is set as 'pickable'.
  32269. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32270. * Each element of this array is an object `{idx: int, faceId: int}`.
  32271. * `idx` is the picked particle index in the `SPS.particles` array
  32272. * `faceId` is the picked face index counted within this particle.
  32273. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32274. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32275. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32276. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32277. */
  32278. pickedParticles: {
  32279. idx: number;
  32280. faceId: number;
  32281. }[];
  32282. /**
  32283. * This array is populated when the SPS is set as 'pickable'
  32284. * Each key of this array is a submesh index.
  32285. * Each element of this array is a second array defined like this :
  32286. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32287. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32288. * `idx` is the picked particle index in the `SPS.particles` array
  32289. * `faceId` is the picked face index counted within this particle.
  32290. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32291. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32292. */
  32293. pickedBySubMesh: {
  32294. idx: number;
  32295. faceId: number;
  32296. }[][];
  32297. /**
  32298. * This array is populated when `enableDepthSort` is set to true.
  32299. * Each element of this array is an instance of the class DepthSortedParticle.
  32300. */
  32301. depthSortedParticles: DepthSortedParticle[];
  32302. /**
  32303. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32304. * @hidden
  32305. */
  32306. _bSphereOnly: boolean;
  32307. /**
  32308. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32309. * @hidden
  32310. */
  32311. _bSphereRadiusFactor: number;
  32312. private _scene;
  32313. private _positions;
  32314. private _indices;
  32315. private _normals;
  32316. private _colors;
  32317. private _uvs;
  32318. private _indices32;
  32319. private _positions32;
  32320. private _normals32;
  32321. private _fixedNormal32;
  32322. private _colors32;
  32323. private _uvs32;
  32324. private _index;
  32325. private _updatable;
  32326. private _pickable;
  32327. private _isVisibilityBoxLocked;
  32328. private _alwaysVisible;
  32329. private _depthSort;
  32330. private _expandable;
  32331. private _shapeCounter;
  32332. private _copy;
  32333. private _color;
  32334. private _computeParticleColor;
  32335. private _computeParticleTexture;
  32336. private _computeParticleRotation;
  32337. private _computeParticleVertex;
  32338. private _computeBoundingBox;
  32339. private _depthSortParticles;
  32340. private _camera;
  32341. private _mustUnrotateFixedNormals;
  32342. private _particlesIntersect;
  32343. private _needs32Bits;
  32344. private _isNotBuilt;
  32345. private _lastParticleId;
  32346. private _idxOfId;
  32347. private _multimaterialEnabled;
  32348. private _useModelMaterial;
  32349. private _indicesByMaterial;
  32350. private _materialIndexes;
  32351. private _depthSortFunction;
  32352. private _materialSortFunction;
  32353. private _materials;
  32354. private _multimaterial;
  32355. private _materialIndexesById;
  32356. private _defaultMaterial;
  32357. private _autoUpdateSubMeshes;
  32358. private _tmpVertex;
  32359. /**
  32360. * Creates a SPS (Solid Particle System) object.
  32361. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32362. * @param scene (Scene) is the scene in which the SPS is added.
  32363. * @param options defines the options of the sps e.g.
  32364. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32365. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32366. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32367. * * 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.
  32368. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32369. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32370. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32371. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32372. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32373. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32374. */
  32375. constructor(name: string, scene: Scene, options?: {
  32376. updatable?: boolean;
  32377. isPickable?: boolean;
  32378. enableDepthSort?: boolean;
  32379. particleIntersection?: boolean;
  32380. boundingSphereOnly?: boolean;
  32381. bSphereRadiusFactor?: number;
  32382. expandable?: boolean;
  32383. useModelMaterial?: boolean;
  32384. enableMultiMaterial?: boolean;
  32385. });
  32386. /**
  32387. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32388. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32389. * @returns the created mesh
  32390. */
  32391. buildMesh(): Mesh;
  32392. /**
  32393. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32394. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32395. * Thus the particles generated from `digest()` have their property `position` set yet.
  32396. * @param mesh ( Mesh ) is the mesh to be digested
  32397. * @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
  32398. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32399. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32400. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32401. * @returns the current SPS
  32402. */
  32403. digest(mesh: Mesh, options?: {
  32404. facetNb?: number;
  32405. number?: number;
  32406. delta?: number;
  32407. storage?: [];
  32408. }): SolidParticleSystem;
  32409. /**
  32410. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32411. * @hidden
  32412. */
  32413. private _unrotateFixedNormals;
  32414. /**
  32415. * Resets the temporary working copy particle
  32416. * @hidden
  32417. */
  32418. private _resetCopy;
  32419. /**
  32420. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32421. * @param p the current index in the positions array to be updated
  32422. * @param ind the current index in the indices array
  32423. * @param shape a Vector3 array, the shape geometry
  32424. * @param positions the positions array to be updated
  32425. * @param meshInd the shape indices array
  32426. * @param indices the indices array to be updated
  32427. * @param meshUV the shape uv array
  32428. * @param uvs the uv array to be updated
  32429. * @param meshCol the shape color array
  32430. * @param colors the color array to be updated
  32431. * @param meshNor the shape normals array
  32432. * @param normals the normals array to be updated
  32433. * @param idx the particle index
  32434. * @param idxInShape the particle index in its shape
  32435. * @param options the addShape() method passed options
  32436. * @model the particle model
  32437. * @hidden
  32438. */
  32439. private _meshBuilder;
  32440. /**
  32441. * Returns a shape Vector3 array from positions float array
  32442. * @param positions float array
  32443. * @returns a vector3 array
  32444. * @hidden
  32445. */
  32446. private _posToShape;
  32447. /**
  32448. * Returns a shapeUV array from a float uvs (array deep copy)
  32449. * @param uvs as a float array
  32450. * @returns a shapeUV array
  32451. * @hidden
  32452. */
  32453. private _uvsToShapeUV;
  32454. /**
  32455. * Adds a new particle object in the particles array
  32456. * @param idx particle index in particles array
  32457. * @param id particle id
  32458. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32459. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32460. * @param model particle ModelShape object
  32461. * @param shapeId model shape identifier
  32462. * @param idxInShape index of the particle in the current model
  32463. * @param bInfo model bounding info object
  32464. * @param storage target storage array, if any
  32465. * @hidden
  32466. */
  32467. private _addParticle;
  32468. /**
  32469. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32470. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32471. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32472. * @param nb (positive integer) the number of particles to be created from this model
  32473. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32474. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32475. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32476. * @returns the number of shapes in the system
  32477. */
  32478. addShape(mesh: Mesh, nb: number, options?: {
  32479. positionFunction?: any;
  32480. vertexFunction?: any;
  32481. storage?: [];
  32482. }): number;
  32483. /**
  32484. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32485. * @hidden
  32486. */
  32487. private _rebuildParticle;
  32488. /**
  32489. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32490. * @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.
  32491. * @returns the SPS.
  32492. */
  32493. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32494. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32495. * Returns an array with the removed particles.
  32496. * 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.
  32497. * The SPS can't be empty so at least one particle needs to remain in place.
  32498. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32499. * @param start index of the first particle to remove
  32500. * @param end index of the last particle to remove (included)
  32501. * @returns an array populated with the removed particles
  32502. */
  32503. removeParticles(start: number, end: number): SolidParticle[];
  32504. /**
  32505. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32506. * @param solidParticleArray an array populated with Solid Particles objects
  32507. * @returns the SPS
  32508. */
  32509. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32510. /**
  32511. * Creates a new particle and modifies the SPS mesh geometry :
  32512. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32513. * - calls _addParticle() to populate the particle array
  32514. * factorized code from addShape() and insertParticlesFromArray()
  32515. * @param idx particle index in the particles array
  32516. * @param i particle index in its shape
  32517. * @param modelShape particle ModelShape object
  32518. * @param shape shape vertex array
  32519. * @param meshInd shape indices array
  32520. * @param meshUV shape uv array
  32521. * @param meshCol shape color array
  32522. * @param meshNor shape normals array
  32523. * @param bbInfo shape bounding info
  32524. * @param storage target particle storage
  32525. * @options addShape() passed options
  32526. * @hidden
  32527. */
  32528. private _insertNewParticle;
  32529. /**
  32530. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32531. * This method calls `updateParticle()` for each particle of the SPS.
  32532. * For an animated SPS, it is usually called within the render loop.
  32533. * 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.
  32534. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32535. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32536. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32537. * @returns the SPS.
  32538. */
  32539. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32540. /**
  32541. * Disposes the SPS.
  32542. */
  32543. dispose(): void;
  32544. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32545. * idx is the particle index in the SPS
  32546. * faceId is the picked face index counted within this particle.
  32547. * Returns null if the pickInfo can't identify a picked particle.
  32548. * @param pickingInfo (PickingInfo object)
  32549. * @returns {idx: number, faceId: number} or null
  32550. */
  32551. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32552. idx: number;
  32553. faceId: number;
  32554. }>;
  32555. /**
  32556. * Returns a SolidParticle object from its identifier : particle.id
  32557. * @param id (integer) the particle Id
  32558. * @returns the searched particle or null if not found in the SPS.
  32559. */
  32560. getParticleById(id: number): Nullable<SolidParticle>;
  32561. /**
  32562. * Returns a new array populated with the particles having the passed shapeId.
  32563. * @param shapeId (integer) the shape identifier
  32564. * @returns a new solid particle array
  32565. */
  32566. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32567. /**
  32568. * Populates the passed array "ref" with the particles having the passed shapeId.
  32569. * @param shapeId the shape identifier
  32570. * @returns the SPS
  32571. * @param ref
  32572. */
  32573. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32574. /**
  32575. * Computes the required SubMeshes according the materials assigned to the particles.
  32576. * @returns the solid particle system.
  32577. * Does nothing if called before the SPS mesh is built.
  32578. */
  32579. computeSubMeshes(): SolidParticleSystem;
  32580. /**
  32581. * Sorts the solid particles by material when MultiMaterial is enabled.
  32582. * Updates the indices32 array.
  32583. * Updates the indicesByMaterial array.
  32584. * Updates the mesh indices array.
  32585. * @returns the SPS
  32586. * @hidden
  32587. */
  32588. private _sortParticlesByMaterial;
  32589. /**
  32590. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32591. * @hidden
  32592. */
  32593. private _setMaterialIndexesById;
  32594. /**
  32595. * Returns an array with unique values of Materials from the passed array
  32596. * @param array the material array to be checked and filtered
  32597. * @hidden
  32598. */
  32599. private _filterUniqueMaterialId;
  32600. /**
  32601. * Sets a new Standard Material as _defaultMaterial if not already set.
  32602. * @hidden
  32603. */
  32604. private _setDefaultMaterial;
  32605. /**
  32606. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32607. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32608. * @returns the SPS.
  32609. */
  32610. refreshVisibleSize(): SolidParticleSystem;
  32611. /**
  32612. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32613. * @param size the size (float) of the visibility box
  32614. * note : this doesn't lock the SPS mesh bounding box.
  32615. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32616. */
  32617. setVisibilityBox(size: number): void;
  32618. /**
  32619. * Gets whether the SPS as always visible or not
  32620. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32621. */
  32622. get isAlwaysVisible(): boolean;
  32623. /**
  32624. * Sets the SPS as always visible or not
  32625. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32626. */
  32627. set isAlwaysVisible(val: boolean);
  32628. /**
  32629. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32630. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32631. */
  32632. set isVisibilityBoxLocked(val: boolean);
  32633. /**
  32634. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32635. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32636. */
  32637. get isVisibilityBoxLocked(): boolean;
  32638. /**
  32639. * Tells to `setParticles()` to compute the particle rotations or not.
  32640. * Default value : true. The SPS is faster when it's set to false.
  32641. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32642. */
  32643. set computeParticleRotation(val: boolean);
  32644. /**
  32645. * Tells to `setParticles()` to compute the particle colors or not.
  32646. * Default value : true. The SPS is faster when it's set to false.
  32647. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32648. */
  32649. set computeParticleColor(val: boolean);
  32650. set computeParticleTexture(val: boolean);
  32651. /**
  32652. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32653. * Default value : false. The SPS is faster when it's set to false.
  32654. * Note : the particle custom vertex positions aren't stored values.
  32655. */
  32656. set computeParticleVertex(val: boolean);
  32657. /**
  32658. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32659. */
  32660. set computeBoundingBox(val: boolean);
  32661. /**
  32662. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32663. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32664. * Default : `true`
  32665. */
  32666. set depthSortParticles(val: boolean);
  32667. /**
  32668. * Gets if `setParticles()` computes the particle rotations or not.
  32669. * Default value : true. The SPS is faster when it's set to false.
  32670. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32671. */
  32672. get computeParticleRotation(): boolean;
  32673. /**
  32674. * Gets if `setParticles()` computes the particle colors or not.
  32675. * Default value : true. The SPS is faster when it's set to false.
  32676. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32677. */
  32678. get computeParticleColor(): boolean;
  32679. /**
  32680. * Gets if `setParticles()` computes the particle textures or not.
  32681. * Default value : true. The SPS is faster when it's set to false.
  32682. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32683. */
  32684. get computeParticleTexture(): boolean;
  32685. /**
  32686. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32687. * Default value : false. The SPS is faster when it's set to false.
  32688. * Note : the particle custom vertex positions aren't stored values.
  32689. */
  32690. get computeParticleVertex(): boolean;
  32691. /**
  32692. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32693. */
  32694. get computeBoundingBox(): boolean;
  32695. /**
  32696. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32697. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32698. * Default : `true`
  32699. */
  32700. get depthSortParticles(): boolean;
  32701. /**
  32702. * Gets if the SPS is created as expandable at construction time.
  32703. * Default : `false`
  32704. */
  32705. get expandable(): boolean;
  32706. /**
  32707. * Gets if the SPS supports the Multi Materials
  32708. */
  32709. get multimaterialEnabled(): boolean;
  32710. /**
  32711. * Gets if the SPS uses the model materials for its own multimaterial.
  32712. */
  32713. get useModelMaterial(): boolean;
  32714. /**
  32715. * The SPS used material array.
  32716. */
  32717. get materials(): Material[];
  32718. /**
  32719. * Sets the SPS MultiMaterial from the passed materials.
  32720. * Note : the passed array is internally copied and not used then by reference.
  32721. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32722. */
  32723. setMultiMaterial(materials: Material[]): void;
  32724. /**
  32725. * The SPS computed multimaterial object
  32726. */
  32727. get multimaterial(): MultiMaterial;
  32728. set multimaterial(mm: MultiMaterial);
  32729. /**
  32730. * If the subMeshes must be updated on the next call to setParticles()
  32731. */
  32732. get autoUpdateSubMeshes(): boolean;
  32733. set autoUpdateSubMeshes(val: boolean);
  32734. /**
  32735. * This function does nothing. It may be overwritten to set all the particle first values.
  32736. * The SPS doesn't call this function, you may have to call it by your own.
  32737. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32738. */
  32739. initParticles(): void;
  32740. /**
  32741. * This function does nothing. It may be overwritten to recycle a particle.
  32742. * The SPS doesn't call this function, you may have to call it by your own.
  32743. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32744. * @param particle The particle to recycle
  32745. * @returns the recycled particle
  32746. */
  32747. recycleParticle(particle: SolidParticle): SolidParticle;
  32748. /**
  32749. * Updates a particle : this function should be overwritten by the user.
  32750. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32751. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32752. * @example : just set a particle position or velocity and recycle conditions
  32753. * @param particle The particle to update
  32754. * @returns the updated particle
  32755. */
  32756. updateParticle(particle: SolidParticle): SolidParticle;
  32757. /**
  32758. * Updates a vertex of a particle : it can be overwritten by the user.
  32759. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32760. * @param particle the current particle
  32761. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32762. * @param pt the index of the current vertex in the particle shape
  32763. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32764. * @example : just set a vertex particle position or color
  32765. * @returns the sps
  32766. */
  32767. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32768. /**
  32769. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32770. * This does nothing and may be overwritten by the user.
  32771. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32772. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32773. * @param update the boolean update value actually passed to setParticles()
  32774. */
  32775. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32776. /**
  32777. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32778. * This will be passed three parameters.
  32779. * This does nothing and may be overwritten by the user.
  32780. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32781. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32782. * @param update the boolean update value actually passed to setParticles()
  32783. */
  32784. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32785. }
  32786. }
  32787. declare module "babylonjs/Particles/solidParticle" {
  32788. import { Nullable } from "babylonjs/types";
  32789. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32790. import { Color4 } from "babylonjs/Maths/math.color";
  32791. import { Mesh } from "babylonjs/Meshes/mesh";
  32792. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32793. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32794. import { Plane } from "babylonjs/Maths/math.plane";
  32795. import { Material } from "babylonjs/Materials/material";
  32796. /**
  32797. * Represents one particle of a solid particle system.
  32798. */
  32799. export class SolidParticle {
  32800. /**
  32801. * particle global index
  32802. */
  32803. idx: number;
  32804. /**
  32805. * particle identifier
  32806. */
  32807. id: number;
  32808. /**
  32809. * The color of the particle
  32810. */
  32811. color: Nullable<Color4>;
  32812. /**
  32813. * The world space position of the particle.
  32814. */
  32815. position: Vector3;
  32816. /**
  32817. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32818. */
  32819. rotation: Vector3;
  32820. /**
  32821. * The world space rotation quaternion of the particle.
  32822. */
  32823. rotationQuaternion: Nullable<Quaternion>;
  32824. /**
  32825. * The scaling of the particle.
  32826. */
  32827. scaling: Vector3;
  32828. /**
  32829. * The uvs of the particle.
  32830. */
  32831. uvs: Vector4;
  32832. /**
  32833. * The current speed of the particle.
  32834. */
  32835. velocity: Vector3;
  32836. /**
  32837. * The pivot point in the particle local space.
  32838. */
  32839. pivot: Vector3;
  32840. /**
  32841. * Must the particle be translated from its pivot point in its local space ?
  32842. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32843. * Default : false
  32844. */
  32845. translateFromPivot: boolean;
  32846. /**
  32847. * Is the particle active or not ?
  32848. */
  32849. alive: boolean;
  32850. /**
  32851. * Is the particle visible or not ?
  32852. */
  32853. isVisible: boolean;
  32854. /**
  32855. * Index of this particle in the global "positions" array (Internal use)
  32856. * @hidden
  32857. */
  32858. _pos: number;
  32859. /**
  32860. * @hidden Index of this particle in the global "indices" array (Internal use)
  32861. */
  32862. _ind: number;
  32863. /**
  32864. * @hidden ModelShape of this particle (Internal use)
  32865. */
  32866. _model: ModelShape;
  32867. /**
  32868. * ModelShape id of this particle
  32869. */
  32870. shapeId: number;
  32871. /**
  32872. * Index of the particle in its shape id
  32873. */
  32874. idxInShape: number;
  32875. /**
  32876. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32877. */
  32878. _modelBoundingInfo: BoundingInfo;
  32879. /**
  32880. * @hidden Particle BoundingInfo object (Internal use)
  32881. */
  32882. _boundingInfo: BoundingInfo;
  32883. /**
  32884. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32885. */
  32886. _sps: SolidParticleSystem;
  32887. /**
  32888. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32889. */
  32890. _stillInvisible: boolean;
  32891. /**
  32892. * @hidden Last computed particle rotation matrix
  32893. */
  32894. _rotationMatrix: number[];
  32895. /**
  32896. * Parent particle Id, if any.
  32897. * Default null.
  32898. */
  32899. parentId: Nullable<number>;
  32900. /**
  32901. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32902. */
  32903. materialIndex: Nullable<number>;
  32904. /**
  32905. * Custom object or properties.
  32906. */
  32907. props: Nullable<any>;
  32908. /**
  32909. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32910. * The possible values are :
  32911. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32912. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32913. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32914. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32915. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32916. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32917. * */
  32918. cullingStrategy: number;
  32919. /**
  32920. * @hidden Internal global position in the SPS.
  32921. */
  32922. _globalPosition: Vector3;
  32923. /**
  32924. * Creates a Solid Particle object.
  32925. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32926. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32927. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32928. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32929. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32930. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32931. * @param shapeId (integer) is the model shape identifier in the SPS.
  32932. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32933. * @param sps defines the sps it is associated to
  32934. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32935. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32936. */
  32937. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32938. /**
  32939. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32940. * @param target the particle target
  32941. * @returns the current particle
  32942. */
  32943. copyToRef(target: SolidParticle): SolidParticle;
  32944. /**
  32945. * Legacy support, changed scale to scaling
  32946. */
  32947. get scale(): Vector3;
  32948. /**
  32949. * Legacy support, changed scale to scaling
  32950. */
  32951. set scale(scale: Vector3);
  32952. /**
  32953. * Legacy support, changed quaternion to rotationQuaternion
  32954. */
  32955. get quaternion(): Nullable<Quaternion>;
  32956. /**
  32957. * Legacy support, changed quaternion to rotationQuaternion
  32958. */
  32959. set quaternion(q: Nullable<Quaternion>);
  32960. /**
  32961. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32962. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32963. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32964. * @returns true if it intersects
  32965. */
  32966. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32967. /**
  32968. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32969. * A particle is in the frustum if its bounding box intersects the frustum
  32970. * @param frustumPlanes defines the frustum to test
  32971. * @returns true if the particle is in the frustum planes
  32972. */
  32973. isInFrustum(frustumPlanes: Plane[]): boolean;
  32974. /**
  32975. * get the rotation matrix of the particle
  32976. * @hidden
  32977. */
  32978. getRotationMatrix(m: Matrix): void;
  32979. }
  32980. /**
  32981. * Represents the shape of the model used by one particle of a solid particle system.
  32982. * SPS internal tool, don't use it manually.
  32983. */
  32984. export class ModelShape {
  32985. /**
  32986. * The shape id
  32987. * @hidden
  32988. */
  32989. shapeID: number;
  32990. /**
  32991. * flat array of model positions (internal use)
  32992. * @hidden
  32993. */
  32994. _shape: Vector3[];
  32995. /**
  32996. * flat array of model UVs (internal use)
  32997. * @hidden
  32998. */
  32999. _shapeUV: number[];
  33000. /**
  33001. * color array of the model
  33002. * @hidden
  33003. */
  33004. _shapeColors: number[];
  33005. /**
  33006. * indices array of the model
  33007. * @hidden
  33008. */
  33009. _indices: number[];
  33010. /**
  33011. * normals array of the model
  33012. * @hidden
  33013. */
  33014. _normals: number[];
  33015. /**
  33016. * length of the shape in the model indices array (internal use)
  33017. * @hidden
  33018. */
  33019. _indicesLength: number;
  33020. /**
  33021. * Custom position function (internal use)
  33022. * @hidden
  33023. */
  33024. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33025. /**
  33026. * Custom vertex function (internal use)
  33027. * @hidden
  33028. */
  33029. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33030. /**
  33031. * Model material (internal use)
  33032. * @hidden
  33033. */
  33034. _material: Nullable<Material>;
  33035. /**
  33036. * 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.
  33037. * SPS internal tool, don't use it manually.
  33038. * @hidden
  33039. */
  33040. 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>);
  33041. }
  33042. /**
  33043. * Represents a Depth Sorted Particle in the solid particle system.
  33044. * @hidden
  33045. */
  33046. export class DepthSortedParticle {
  33047. /**
  33048. * Particle index
  33049. */
  33050. idx: number;
  33051. /**
  33052. * Index of the particle in the "indices" array
  33053. */
  33054. ind: number;
  33055. /**
  33056. * Length of the particle shape in the "indices" array
  33057. */
  33058. indicesLength: number;
  33059. /**
  33060. * Squared distance from the particle to the camera
  33061. */
  33062. sqDistance: number;
  33063. /**
  33064. * Material index when used with MultiMaterials
  33065. */
  33066. materialIndex: number;
  33067. /**
  33068. * Creates a new sorted particle
  33069. * @param materialIndex
  33070. */
  33071. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  33072. }
  33073. /**
  33074. * Represents a solid particle vertex
  33075. */
  33076. export class SolidParticleVertex {
  33077. /**
  33078. * Vertex position
  33079. */
  33080. position: Vector3;
  33081. /**
  33082. * Vertex color
  33083. */
  33084. color: Color4;
  33085. /**
  33086. * Vertex UV
  33087. */
  33088. uv: Vector2;
  33089. /**
  33090. * Creates a new solid particle vertex
  33091. */
  33092. constructor();
  33093. /** Vertex x coordinate */
  33094. get x(): number;
  33095. set x(val: number);
  33096. /** Vertex y coordinate */
  33097. get y(): number;
  33098. set y(val: number);
  33099. /** Vertex z coordinate */
  33100. get z(): number;
  33101. set z(val: number);
  33102. }
  33103. }
  33104. declare module "babylonjs/Collisions/meshCollisionData" {
  33105. import { Collider } from "babylonjs/Collisions/collider";
  33106. import { Vector3 } from "babylonjs/Maths/math.vector";
  33107. import { Nullable } from "babylonjs/types";
  33108. import { Observer } from "babylonjs/Misc/observable";
  33109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33110. /**
  33111. * @hidden
  33112. */
  33113. export class _MeshCollisionData {
  33114. _checkCollisions: boolean;
  33115. _collisionMask: number;
  33116. _collisionGroup: number;
  33117. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33118. _collider: Nullable<Collider>;
  33119. _oldPositionForCollisions: Vector3;
  33120. _diffPositionForCollisions: Vector3;
  33121. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33122. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33123. _collisionResponse: boolean;
  33124. }
  33125. }
  33126. declare module "babylonjs/Meshes/abstractMesh" {
  33127. import { Observable } from "babylonjs/Misc/observable";
  33128. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33129. import { Camera } from "babylonjs/Cameras/camera";
  33130. import { Scene, IDisposable } from "babylonjs/scene";
  33131. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33132. import { Node } from "babylonjs/node";
  33133. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33134. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33135. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33136. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33137. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33138. import { Material } from "babylonjs/Materials/material";
  33139. import { Light } from "babylonjs/Lights/light";
  33140. import { Skeleton } from "babylonjs/Bones/skeleton";
  33141. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33142. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33143. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33144. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33145. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33146. import { Plane } from "babylonjs/Maths/math.plane";
  33147. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33148. import { Ray } from "babylonjs/Culling/ray";
  33149. import { Collider } from "babylonjs/Collisions/collider";
  33150. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33151. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33152. /** @hidden */
  33153. class _FacetDataStorage {
  33154. facetPositions: Vector3[];
  33155. facetNormals: Vector3[];
  33156. facetPartitioning: number[][];
  33157. facetNb: number;
  33158. partitioningSubdivisions: number;
  33159. partitioningBBoxRatio: number;
  33160. facetDataEnabled: boolean;
  33161. facetParameters: any;
  33162. bbSize: Vector3;
  33163. subDiv: {
  33164. max: number;
  33165. X: number;
  33166. Y: number;
  33167. Z: number;
  33168. };
  33169. facetDepthSort: boolean;
  33170. facetDepthSortEnabled: boolean;
  33171. depthSortedIndices: IndicesArray;
  33172. depthSortedFacets: {
  33173. ind: number;
  33174. sqDistance: number;
  33175. }[];
  33176. facetDepthSortFunction: (f1: {
  33177. ind: number;
  33178. sqDistance: number;
  33179. }, f2: {
  33180. ind: number;
  33181. sqDistance: number;
  33182. }) => number;
  33183. facetDepthSortFrom: Vector3;
  33184. facetDepthSortOrigin: Vector3;
  33185. invertedMatrix: Matrix;
  33186. }
  33187. /**
  33188. * @hidden
  33189. **/
  33190. class _InternalAbstractMeshDataInfo {
  33191. _hasVertexAlpha: boolean;
  33192. _useVertexColors: boolean;
  33193. _numBoneInfluencers: number;
  33194. _applyFog: boolean;
  33195. _receiveShadows: boolean;
  33196. _facetData: _FacetDataStorage;
  33197. _visibility: number;
  33198. _skeleton: Nullable<Skeleton>;
  33199. _layerMask: number;
  33200. _computeBonesUsingShaders: boolean;
  33201. _isActive: boolean;
  33202. _onlyForInstances: boolean;
  33203. _isActiveIntermediate: boolean;
  33204. _onlyForInstancesIntermediate: boolean;
  33205. _actAsRegularMesh: boolean;
  33206. }
  33207. /**
  33208. * Class used to store all common mesh properties
  33209. */
  33210. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33211. /** No occlusion */
  33212. static OCCLUSION_TYPE_NONE: number;
  33213. /** Occlusion set to optimisitic */
  33214. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33215. /** Occlusion set to strict */
  33216. static OCCLUSION_TYPE_STRICT: number;
  33217. /** Use an accurante occlusion algorithm */
  33218. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33219. /** Use a conservative occlusion algorithm */
  33220. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33221. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33222. * Test order :
  33223. * Is the bounding sphere outside the frustum ?
  33224. * If not, are the bounding box vertices outside the frustum ?
  33225. * It not, then the cullable object is in the frustum.
  33226. */
  33227. static readonly CULLINGSTRATEGY_STANDARD: number;
  33228. /** Culling strategy : Bounding Sphere Only.
  33229. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33230. * It's also less accurate than the standard because some not visible objects can still be selected.
  33231. * Test : is the bounding sphere outside the frustum ?
  33232. * If not, then the cullable object is in the frustum.
  33233. */
  33234. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33235. /** Culling strategy : Optimistic Inclusion.
  33236. * This in an inclusion test first, then the standard exclusion test.
  33237. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33238. * 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.
  33239. * Anyway, it's as accurate as the standard strategy.
  33240. * Test :
  33241. * Is the cullable object bounding sphere center in the frustum ?
  33242. * If not, apply the default culling strategy.
  33243. */
  33244. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33245. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33246. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33247. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33248. * 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.
  33249. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33250. * Test :
  33251. * Is the cullable object bounding sphere center in the frustum ?
  33252. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33253. */
  33254. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33255. /**
  33256. * No billboard
  33257. */
  33258. static get BILLBOARDMODE_NONE(): number;
  33259. /** Billboard on X axis */
  33260. static get BILLBOARDMODE_X(): number;
  33261. /** Billboard on Y axis */
  33262. static get BILLBOARDMODE_Y(): number;
  33263. /** Billboard on Z axis */
  33264. static get BILLBOARDMODE_Z(): number;
  33265. /** Billboard on all axes */
  33266. static get BILLBOARDMODE_ALL(): number;
  33267. /** Billboard on using position instead of orientation */
  33268. static get BILLBOARDMODE_USE_POSITION(): number;
  33269. /** @hidden */
  33270. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33271. /**
  33272. * The culling strategy to use to check whether the mesh must be rendered or not.
  33273. * This value can be changed at any time and will be used on the next render mesh selection.
  33274. * The possible values are :
  33275. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33276. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33277. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33278. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33279. * Please read each static variable documentation to get details about the culling process.
  33280. * */
  33281. cullingStrategy: number;
  33282. /**
  33283. * Gets the number of facets in the mesh
  33284. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33285. */
  33286. get facetNb(): number;
  33287. /**
  33288. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33289. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33290. */
  33291. get partitioningSubdivisions(): number;
  33292. set partitioningSubdivisions(nb: number);
  33293. /**
  33294. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33295. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33296. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33297. */
  33298. get partitioningBBoxRatio(): number;
  33299. set partitioningBBoxRatio(ratio: number);
  33300. /**
  33301. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33302. * Works only for updatable meshes.
  33303. * Doesn't work with multi-materials
  33304. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33305. */
  33306. get mustDepthSortFacets(): boolean;
  33307. set mustDepthSortFacets(sort: boolean);
  33308. /**
  33309. * The location (Vector3) where the facet depth sort must be computed from.
  33310. * By default, the active camera position.
  33311. * Used only when facet depth sort is enabled
  33312. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33313. */
  33314. get facetDepthSortFrom(): Vector3;
  33315. set facetDepthSortFrom(location: Vector3);
  33316. /**
  33317. * gets a boolean indicating if facetData is enabled
  33318. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33319. */
  33320. get isFacetDataEnabled(): boolean;
  33321. /** @hidden */
  33322. _updateNonUniformScalingState(value: boolean): boolean;
  33323. /**
  33324. * An event triggered when this mesh collides with another one
  33325. */
  33326. onCollideObservable: Observable<AbstractMesh>;
  33327. /** Set a function to call when this mesh collides with another one */
  33328. set onCollide(callback: () => void);
  33329. /**
  33330. * An event triggered when the collision's position changes
  33331. */
  33332. onCollisionPositionChangeObservable: Observable<Vector3>;
  33333. /** Set a function to call when the collision's position changes */
  33334. set onCollisionPositionChange(callback: () => void);
  33335. /**
  33336. * An event triggered when material is changed
  33337. */
  33338. onMaterialChangedObservable: Observable<AbstractMesh>;
  33339. /**
  33340. * Gets or sets the orientation for POV movement & rotation
  33341. */
  33342. definedFacingForward: boolean;
  33343. /** @hidden */
  33344. _occlusionQuery: Nullable<WebGLQuery>;
  33345. /** @hidden */
  33346. _renderingGroup: Nullable<RenderingGroup>;
  33347. /**
  33348. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33349. */
  33350. get visibility(): number;
  33351. /**
  33352. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33353. */
  33354. set visibility(value: number);
  33355. /** Gets or sets the alpha index used to sort transparent meshes
  33356. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33357. */
  33358. alphaIndex: number;
  33359. /**
  33360. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33361. */
  33362. isVisible: boolean;
  33363. /**
  33364. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33365. */
  33366. isPickable: boolean;
  33367. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33368. showSubMeshesBoundingBox: boolean;
  33369. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33370. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33371. */
  33372. isBlocker: boolean;
  33373. /**
  33374. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33375. */
  33376. enablePointerMoveEvents: boolean;
  33377. private _renderingGroupId;
  33378. /**
  33379. * Specifies the rendering group id for this mesh (0 by default)
  33380. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33381. */
  33382. get renderingGroupId(): number;
  33383. set renderingGroupId(value: number);
  33384. private _material;
  33385. /** Gets or sets current material */
  33386. get material(): Nullable<Material>;
  33387. set material(value: Nullable<Material>);
  33388. /**
  33389. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33390. * @see https://doc.babylonjs.com/babylon101/shadows
  33391. */
  33392. get receiveShadows(): boolean;
  33393. set receiveShadows(value: boolean);
  33394. /** Defines color to use when rendering outline */
  33395. outlineColor: Color3;
  33396. /** Define width to use when rendering outline */
  33397. outlineWidth: number;
  33398. /** Defines color to use when rendering overlay */
  33399. overlayColor: Color3;
  33400. /** Defines alpha to use when rendering overlay */
  33401. overlayAlpha: number;
  33402. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33403. get hasVertexAlpha(): boolean;
  33404. set hasVertexAlpha(value: boolean);
  33405. /** 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) */
  33406. get useVertexColors(): boolean;
  33407. set useVertexColors(value: boolean);
  33408. /**
  33409. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33410. */
  33411. get computeBonesUsingShaders(): boolean;
  33412. set computeBonesUsingShaders(value: boolean);
  33413. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33414. get numBoneInfluencers(): number;
  33415. set numBoneInfluencers(value: number);
  33416. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33417. get applyFog(): boolean;
  33418. set applyFog(value: boolean);
  33419. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33420. useOctreeForRenderingSelection: boolean;
  33421. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33422. useOctreeForPicking: boolean;
  33423. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33424. useOctreeForCollisions: boolean;
  33425. /**
  33426. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33427. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33428. */
  33429. get layerMask(): number;
  33430. set layerMask(value: number);
  33431. /**
  33432. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33433. */
  33434. alwaysSelectAsActiveMesh: boolean;
  33435. /**
  33436. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33437. */
  33438. doNotSyncBoundingInfo: boolean;
  33439. /**
  33440. * Gets or sets the current action manager
  33441. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33442. */
  33443. actionManager: Nullable<AbstractActionManager>;
  33444. private _meshCollisionData;
  33445. /**
  33446. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33447. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33448. */
  33449. ellipsoid: Vector3;
  33450. /**
  33451. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33452. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33453. */
  33454. ellipsoidOffset: Vector3;
  33455. /**
  33456. * Gets or sets a collision mask used to mask collisions (default is -1).
  33457. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33458. */
  33459. get collisionMask(): number;
  33460. set collisionMask(mask: number);
  33461. /**
  33462. * Gets or sets a collision response flag (default is true).
  33463. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33464. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33465. * to respond to the collision.
  33466. */
  33467. get collisionResponse(): boolean;
  33468. set collisionResponse(response: boolean);
  33469. /**
  33470. * Gets or sets the current collision group mask (-1 by default).
  33471. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33472. */
  33473. get collisionGroup(): number;
  33474. set collisionGroup(mask: number);
  33475. /**
  33476. * Gets or sets current surrounding meshes (null by default).
  33477. *
  33478. * By default collision detection is tested against every mesh in the scene.
  33479. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33480. * meshes will be tested for the collision.
  33481. *
  33482. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33483. */
  33484. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33485. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33486. /**
  33487. * Defines edge width used when edgesRenderer is enabled
  33488. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33489. */
  33490. edgesWidth: number;
  33491. /**
  33492. * Defines edge color used when edgesRenderer is enabled
  33493. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33494. */
  33495. edgesColor: Color4;
  33496. /** @hidden */
  33497. _edgesRenderer: Nullable<IEdgesRenderer>;
  33498. /** @hidden */
  33499. _masterMesh: Nullable<AbstractMesh>;
  33500. /** @hidden */
  33501. _boundingInfo: Nullable<BoundingInfo>;
  33502. /** @hidden */
  33503. _renderId: number;
  33504. /**
  33505. * Gets or sets the list of subMeshes
  33506. * @see https://doc.babylonjs.com/how_to/multi_materials
  33507. */
  33508. subMeshes: SubMesh[];
  33509. /** @hidden */
  33510. _intersectionsInProgress: AbstractMesh[];
  33511. /** @hidden */
  33512. _unIndexed: boolean;
  33513. /** @hidden */
  33514. _lightSources: Light[];
  33515. /** Gets the list of lights affecting that mesh */
  33516. get lightSources(): Light[];
  33517. /** @hidden */
  33518. get _positions(): Nullable<Vector3[]>;
  33519. /** @hidden */
  33520. _waitingData: {
  33521. lods: Nullable<any>;
  33522. actions: Nullable<any>;
  33523. freezeWorldMatrix: Nullable<boolean>;
  33524. };
  33525. /** @hidden */
  33526. _bonesTransformMatrices: Nullable<Float32Array>;
  33527. /** @hidden */
  33528. _transformMatrixTexture: Nullable<RawTexture>;
  33529. /**
  33530. * Gets or sets a skeleton to apply skining transformations
  33531. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33532. */
  33533. set skeleton(value: Nullable<Skeleton>);
  33534. get skeleton(): Nullable<Skeleton>;
  33535. /**
  33536. * An event triggered when the mesh is rebuilt.
  33537. */
  33538. onRebuildObservable: Observable<AbstractMesh>;
  33539. /**
  33540. * Creates a new AbstractMesh
  33541. * @param name defines the name of the mesh
  33542. * @param scene defines the hosting scene
  33543. */
  33544. constructor(name: string, scene?: Nullable<Scene>);
  33545. /**
  33546. * Returns the string "AbstractMesh"
  33547. * @returns "AbstractMesh"
  33548. */
  33549. getClassName(): string;
  33550. /**
  33551. * Gets a string representation of the current mesh
  33552. * @param fullDetails defines a boolean indicating if full details must be included
  33553. * @returns a string representation of the current mesh
  33554. */
  33555. toString(fullDetails?: boolean): string;
  33556. /**
  33557. * @hidden
  33558. */
  33559. protected _getEffectiveParent(): Nullable<Node>;
  33560. /** @hidden */
  33561. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33562. /** @hidden */
  33563. _rebuild(): void;
  33564. /** @hidden */
  33565. _resyncLightSources(): void;
  33566. /** @hidden */
  33567. _resyncLightSource(light: Light): void;
  33568. /** @hidden */
  33569. _unBindEffect(): void;
  33570. /** @hidden */
  33571. _removeLightSource(light: Light, dispose: boolean): void;
  33572. private _markSubMeshesAsDirty;
  33573. /** @hidden */
  33574. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33575. /** @hidden */
  33576. _markSubMeshesAsAttributesDirty(): void;
  33577. /** @hidden */
  33578. _markSubMeshesAsMiscDirty(): void;
  33579. /**
  33580. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33581. */
  33582. get scaling(): Vector3;
  33583. set scaling(newScaling: Vector3);
  33584. /**
  33585. * Returns true if the mesh is blocked. Implemented by child classes
  33586. */
  33587. get isBlocked(): boolean;
  33588. /**
  33589. * Returns the mesh itself by default. Implemented by child classes
  33590. * @param camera defines the camera to use to pick the right LOD level
  33591. * @returns the currentAbstractMesh
  33592. */
  33593. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33594. /**
  33595. * Returns 0 by default. Implemented by child classes
  33596. * @returns an integer
  33597. */
  33598. getTotalVertices(): number;
  33599. /**
  33600. * Returns a positive integer : the total number of indices in this mesh geometry.
  33601. * @returns the numner of indices or zero if the mesh has no geometry.
  33602. */
  33603. getTotalIndices(): number;
  33604. /**
  33605. * Returns null by default. Implemented by child classes
  33606. * @returns null
  33607. */
  33608. getIndices(): Nullable<IndicesArray>;
  33609. /**
  33610. * Returns the array of the requested vertex data kind. Implemented by child classes
  33611. * @param kind defines the vertex data kind to use
  33612. * @returns null
  33613. */
  33614. getVerticesData(kind: string): Nullable<FloatArray>;
  33615. /**
  33616. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33617. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33618. * Note that a new underlying VertexBuffer object is created each call.
  33619. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33620. * @param kind defines vertex data kind:
  33621. * * VertexBuffer.PositionKind
  33622. * * VertexBuffer.UVKind
  33623. * * VertexBuffer.UV2Kind
  33624. * * VertexBuffer.UV3Kind
  33625. * * VertexBuffer.UV4Kind
  33626. * * VertexBuffer.UV5Kind
  33627. * * VertexBuffer.UV6Kind
  33628. * * VertexBuffer.ColorKind
  33629. * * VertexBuffer.MatricesIndicesKind
  33630. * * VertexBuffer.MatricesIndicesExtraKind
  33631. * * VertexBuffer.MatricesWeightsKind
  33632. * * VertexBuffer.MatricesWeightsExtraKind
  33633. * @param data defines the data source
  33634. * @param updatable defines if the data must be flagged as updatable (or static)
  33635. * @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
  33636. * @returns the current mesh
  33637. */
  33638. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33639. /**
  33640. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33641. * If the mesh has no geometry, it is simply returned as it is.
  33642. * @param kind defines vertex data kind:
  33643. * * VertexBuffer.PositionKind
  33644. * * VertexBuffer.UVKind
  33645. * * VertexBuffer.UV2Kind
  33646. * * VertexBuffer.UV3Kind
  33647. * * VertexBuffer.UV4Kind
  33648. * * VertexBuffer.UV5Kind
  33649. * * VertexBuffer.UV6Kind
  33650. * * VertexBuffer.ColorKind
  33651. * * VertexBuffer.MatricesIndicesKind
  33652. * * VertexBuffer.MatricesIndicesExtraKind
  33653. * * VertexBuffer.MatricesWeightsKind
  33654. * * VertexBuffer.MatricesWeightsExtraKind
  33655. * @param data defines the data source
  33656. * @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
  33657. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33658. * @returns the current mesh
  33659. */
  33660. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33661. /**
  33662. * Sets the mesh indices,
  33663. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33664. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33665. * @param totalVertices Defines the total number of vertices
  33666. * @returns the current mesh
  33667. */
  33668. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33669. /**
  33670. * Gets a boolean indicating if specific vertex data is present
  33671. * @param kind defines the vertex data kind to use
  33672. * @returns true is data kind is present
  33673. */
  33674. isVerticesDataPresent(kind: string): boolean;
  33675. /**
  33676. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33677. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33678. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33679. * @returns a BoundingInfo
  33680. */
  33681. getBoundingInfo(): BoundingInfo;
  33682. /**
  33683. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33684. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33685. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33686. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33687. * @returns the current mesh
  33688. */
  33689. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33690. /**
  33691. * Overwrite the current bounding info
  33692. * @param boundingInfo defines the new bounding info
  33693. * @returns the current mesh
  33694. */
  33695. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33696. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33697. get useBones(): boolean;
  33698. /** @hidden */
  33699. _preActivate(): void;
  33700. /** @hidden */
  33701. _preActivateForIntermediateRendering(renderId: number): void;
  33702. /** @hidden */
  33703. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33704. /** @hidden */
  33705. _postActivate(): void;
  33706. /** @hidden */
  33707. _freeze(): void;
  33708. /** @hidden */
  33709. _unFreeze(): void;
  33710. /**
  33711. * Gets the current world matrix
  33712. * @returns a Matrix
  33713. */
  33714. getWorldMatrix(): Matrix;
  33715. /** @hidden */
  33716. _getWorldMatrixDeterminant(): number;
  33717. /**
  33718. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33719. */
  33720. get isAnInstance(): boolean;
  33721. /**
  33722. * Gets a boolean indicating if this mesh has instances
  33723. */
  33724. get hasInstances(): boolean;
  33725. /**
  33726. * Gets a boolean indicating if this mesh has thin instances
  33727. */
  33728. get hasThinInstances(): boolean;
  33729. /**
  33730. * Perform relative position change from the point of view of behind the front of the mesh.
  33731. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33732. * Supports definition of mesh facing forward or backward
  33733. * @param amountRight defines the distance on the right axis
  33734. * @param amountUp defines the distance on the up axis
  33735. * @param amountForward defines the distance on the forward axis
  33736. * @returns the current mesh
  33737. */
  33738. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33739. /**
  33740. * Calculate relative position change from the point of view of behind the front of the mesh.
  33741. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33742. * Supports definition of mesh facing forward or backward
  33743. * @param amountRight defines the distance on the right axis
  33744. * @param amountUp defines the distance on the up axis
  33745. * @param amountForward defines the distance on the forward axis
  33746. * @returns the new displacement vector
  33747. */
  33748. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33749. /**
  33750. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33751. * Supports definition of mesh facing forward or backward
  33752. * @param flipBack defines the flip
  33753. * @param twirlClockwise defines the twirl
  33754. * @param tiltRight defines the tilt
  33755. * @returns the current mesh
  33756. */
  33757. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33758. /**
  33759. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33760. * Supports definition of mesh facing forward or backward.
  33761. * @param flipBack defines the flip
  33762. * @param twirlClockwise defines the twirl
  33763. * @param tiltRight defines the tilt
  33764. * @returns the new rotation vector
  33765. */
  33766. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33767. /**
  33768. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33769. * This means the mesh underlying bounding box and sphere are recomputed.
  33770. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33771. * @returns the current mesh
  33772. */
  33773. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33774. /** @hidden */
  33775. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33776. /** @hidden */
  33777. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33778. /** @hidden */
  33779. _updateBoundingInfo(): AbstractMesh;
  33780. /** @hidden */
  33781. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33782. /** @hidden */
  33783. protected _afterComputeWorldMatrix(): void;
  33784. /** @hidden */
  33785. get _effectiveMesh(): AbstractMesh;
  33786. /**
  33787. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33788. * A mesh is in the frustum if its bounding box intersects the frustum
  33789. * @param frustumPlanes defines the frustum to test
  33790. * @returns true if the mesh is in the frustum planes
  33791. */
  33792. isInFrustum(frustumPlanes: Plane[]): boolean;
  33793. /**
  33794. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33795. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33796. * @param frustumPlanes defines the frustum to test
  33797. * @returns true if the mesh is completely in the frustum planes
  33798. */
  33799. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33800. /**
  33801. * True if the mesh intersects another mesh or a SolidParticle object
  33802. * @param mesh defines a target mesh or SolidParticle to test
  33803. * @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)
  33804. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33805. * @returns true if there is an intersection
  33806. */
  33807. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33808. /**
  33809. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33810. * @param point defines the point to test
  33811. * @returns true if there is an intersection
  33812. */
  33813. intersectsPoint(point: Vector3): boolean;
  33814. /**
  33815. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33816. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33817. */
  33818. get checkCollisions(): boolean;
  33819. set checkCollisions(collisionEnabled: boolean);
  33820. /**
  33821. * Gets Collider object used to compute collisions (not physics)
  33822. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33823. */
  33824. get collider(): Nullable<Collider>;
  33825. /**
  33826. * Move the mesh using collision engine
  33827. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33828. * @param displacement defines the requested displacement vector
  33829. * @returns the current mesh
  33830. */
  33831. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33832. private _onCollisionPositionChange;
  33833. /** @hidden */
  33834. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33835. /** @hidden */
  33836. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33837. /** @hidden */
  33838. _checkCollision(collider: Collider): AbstractMesh;
  33839. /** @hidden */
  33840. _generatePointsArray(): boolean;
  33841. /**
  33842. * Checks if the passed Ray intersects with the mesh
  33843. * @param ray defines the ray to use
  33844. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33845. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33846. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33847. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33848. * @returns the picking info
  33849. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33850. */
  33851. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33852. /**
  33853. * Clones the current mesh
  33854. * @param name defines the mesh name
  33855. * @param newParent defines the new mesh parent
  33856. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33857. * @returns the new mesh
  33858. */
  33859. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33860. /**
  33861. * Disposes all the submeshes of the current meshnp
  33862. * @returns the current mesh
  33863. */
  33864. releaseSubMeshes(): AbstractMesh;
  33865. /**
  33866. * Releases resources associated with this abstract mesh.
  33867. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33868. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33869. */
  33870. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33871. /**
  33872. * Adds the passed mesh as a child to the current mesh
  33873. * @param mesh defines the child mesh
  33874. * @returns the current mesh
  33875. */
  33876. addChild(mesh: AbstractMesh): AbstractMesh;
  33877. /**
  33878. * Removes the passed mesh from the current mesh children list
  33879. * @param mesh defines the child mesh
  33880. * @returns the current mesh
  33881. */
  33882. removeChild(mesh: AbstractMesh): AbstractMesh;
  33883. /** @hidden */
  33884. private _initFacetData;
  33885. /**
  33886. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33887. * This method can be called within the render loop.
  33888. * 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
  33889. * @returns the current mesh
  33890. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33891. */
  33892. updateFacetData(): AbstractMesh;
  33893. /**
  33894. * Returns the facetLocalNormals array.
  33895. * The normals are expressed in the mesh local spac
  33896. * @returns an array of Vector3
  33897. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33898. */
  33899. getFacetLocalNormals(): Vector3[];
  33900. /**
  33901. * Returns the facetLocalPositions array.
  33902. * The facet positions are expressed in the mesh local space
  33903. * @returns an array of Vector3
  33904. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33905. */
  33906. getFacetLocalPositions(): Vector3[];
  33907. /**
  33908. * Returns the facetLocalPartioning array
  33909. * @returns an array of array of numbers
  33910. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33911. */
  33912. getFacetLocalPartitioning(): number[][];
  33913. /**
  33914. * Returns the i-th facet position in the world system.
  33915. * This method allocates a new Vector3 per call
  33916. * @param i defines the facet index
  33917. * @returns a new Vector3
  33918. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33919. */
  33920. getFacetPosition(i: number): Vector3;
  33921. /**
  33922. * Sets the reference Vector3 with the i-th facet position in the world system
  33923. * @param i defines the facet index
  33924. * @param ref defines the target vector
  33925. * @returns the current mesh
  33926. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33927. */
  33928. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33929. /**
  33930. * Returns the i-th facet normal in the world system.
  33931. * This method allocates a new Vector3 per call
  33932. * @param i defines the facet index
  33933. * @returns a new Vector3
  33934. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33935. */
  33936. getFacetNormal(i: number): Vector3;
  33937. /**
  33938. * Sets the reference Vector3 with the i-th facet normal in the world system
  33939. * @param i defines the facet index
  33940. * @param ref defines the target vector
  33941. * @returns the current mesh
  33942. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33943. */
  33944. getFacetNormalToRef(i: number, ref: Vector3): this;
  33945. /**
  33946. * 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)
  33947. * @param x defines x coordinate
  33948. * @param y defines y coordinate
  33949. * @param z defines z coordinate
  33950. * @returns the array of facet indexes
  33951. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33952. */
  33953. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33954. /**
  33955. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33956. * @param projected sets as the (x,y,z) world projection on the facet
  33957. * @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
  33958. * @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
  33959. * @param x defines x coordinate
  33960. * @param y defines y coordinate
  33961. * @param z defines z coordinate
  33962. * @returns the face index if found (or null instead)
  33963. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33964. */
  33965. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33966. /**
  33967. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33968. * @param projected sets as the (x,y,z) local projection on the facet
  33969. * @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
  33970. * @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
  33971. * @param x defines x coordinate
  33972. * @param y defines y coordinate
  33973. * @param z defines z coordinate
  33974. * @returns the face index if found (or null instead)
  33975. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33976. */
  33977. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33978. /**
  33979. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33980. * @returns the parameters
  33981. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33982. */
  33983. getFacetDataParameters(): any;
  33984. /**
  33985. * Disables the feature FacetData and frees the related memory
  33986. * @returns the current mesh
  33987. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33988. */
  33989. disableFacetData(): AbstractMesh;
  33990. /**
  33991. * Updates the AbstractMesh indices array
  33992. * @param indices defines the data source
  33993. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33994. * @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)
  33995. * @returns the current mesh
  33996. */
  33997. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33998. /**
  33999. * Creates new normals data for the mesh
  34000. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  34001. * @returns the current mesh
  34002. */
  34003. createNormals(updatable: boolean): AbstractMesh;
  34004. /**
  34005. * Align the mesh with a normal
  34006. * @param normal defines the normal to use
  34007. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  34008. * @returns the current mesh
  34009. */
  34010. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  34011. /** @hidden */
  34012. _checkOcclusionQuery(): boolean;
  34013. /**
  34014. * Disables the mesh edge rendering mode
  34015. * @returns the currentAbstractMesh
  34016. */
  34017. disableEdgesRendering(): AbstractMesh;
  34018. /**
  34019. * Enables the edge rendering mode on the mesh.
  34020. * This mode makes the mesh edges visible
  34021. * @param epsilon defines the maximal distance between two angles to detect a face
  34022. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34023. * @returns the currentAbstractMesh
  34024. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34025. */
  34026. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34027. /**
  34028. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  34029. * @returns an array of particle systems in the scene that use the mesh as an emitter
  34030. */
  34031. getConnectedParticleSystems(): IParticleSystem[];
  34032. }
  34033. }
  34034. declare module "babylonjs/Actions/actionEvent" {
  34035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34036. import { Nullable } from "babylonjs/types";
  34037. import { Sprite } from "babylonjs/Sprites/sprite";
  34038. import { Scene } from "babylonjs/scene";
  34039. import { Vector2 } from "babylonjs/Maths/math.vector";
  34040. /**
  34041. * Interface used to define ActionEvent
  34042. */
  34043. export interface IActionEvent {
  34044. /** The mesh or sprite that triggered the action */
  34045. source: any;
  34046. /** The X mouse cursor position at the time of the event */
  34047. pointerX: number;
  34048. /** The Y mouse cursor position at the time of the event */
  34049. pointerY: number;
  34050. /** The mesh that is currently pointed at (can be null) */
  34051. meshUnderPointer: Nullable<AbstractMesh>;
  34052. /** the original (browser) event that triggered the ActionEvent */
  34053. sourceEvent?: any;
  34054. /** additional data for the event */
  34055. additionalData?: any;
  34056. }
  34057. /**
  34058. * ActionEvent is the event being sent when an action is triggered.
  34059. */
  34060. export class ActionEvent implements IActionEvent {
  34061. /** The mesh or sprite that triggered the action */
  34062. source: any;
  34063. /** The X mouse cursor position at the time of the event */
  34064. pointerX: number;
  34065. /** The Y mouse cursor position at the time of the event */
  34066. pointerY: number;
  34067. /** The mesh that is currently pointed at (can be null) */
  34068. meshUnderPointer: Nullable<AbstractMesh>;
  34069. /** the original (browser) event that triggered the ActionEvent */
  34070. sourceEvent?: any;
  34071. /** additional data for the event */
  34072. additionalData?: any;
  34073. /**
  34074. * Creates a new ActionEvent
  34075. * @param source The mesh or sprite that triggered the action
  34076. * @param pointerX The X mouse cursor position at the time of the event
  34077. * @param pointerY The Y mouse cursor position at the time of the event
  34078. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  34079. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  34080. * @param additionalData additional data for the event
  34081. */
  34082. constructor(
  34083. /** The mesh or sprite that triggered the action */
  34084. source: any,
  34085. /** The X mouse cursor position at the time of the event */
  34086. pointerX: number,
  34087. /** The Y mouse cursor position at the time of the event */
  34088. pointerY: number,
  34089. /** The mesh that is currently pointed at (can be null) */
  34090. meshUnderPointer: Nullable<AbstractMesh>,
  34091. /** the original (browser) event that triggered the ActionEvent */
  34092. sourceEvent?: any,
  34093. /** additional data for the event */
  34094. additionalData?: any);
  34095. /**
  34096. * Helper function to auto-create an ActionEvent from a source mesh.
  34097. * @param source The source mesh that triggered the event
  34098. * @param evt The original (browser) event
  34099. * @param additionalData additional data for the event
  34100. * @returns the new ActionEvent
  34101. */
  34102. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34103. /**
  34104. * Helper function to auto-create an ActionEvent from a source sprite
  34105. * @param source The source sprite that triggered the event
  34106. * @param scene Scene associated with the sprite
  34107. * @param evt The original (browser) event
  34108. * @param additionalData additional data for the event
  34109. * @returns the new ActionEvent
  34110. */
  34111. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34112. /**
  34113. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34114. * @param scene the scene where the event occurred
  34115. * @param evt The original (browser) event
  34116. * @returns the new ActionEvent
  34117. */
  34118. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34119. /**
  34120. * Helper function to auto-create an ActionEvent from a primitive
  34121. * @param prim defines the target primitive
  34122. * @param pointerPos defines the pointer position
  34123. * @param evt The original (browser) event
  34124. * @param additionalData additional data for the event
  34125. * @returns the new ActionEvent
  34126. */
  34127. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34128. }
  34129. }
  34130. declare module "babylonjs/Actions/abstractActionManager" {
  34131. import { IDisposable } from "babylonjs/scene";
  34132. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34133. import { IAction } from "babylonjs/Actions/action";
  34134. import { Nullable } from "babylonjs/types";
  34135. /**
  34136. * Abstract class used to decouple action Manager from scene and meshes.
  34137. * Do not instantiate.
  34138. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34139. */
  34140. export abstract class AbstractActionManager implements IDisposable {
  34141. /** Gets the list of active triggers */
  34142. static Triggers: {
  34143. [key: string]: number;
  34144. };
  34145. /** Gets the cursor to use when hovering items */
  34146. hoverCursor: string;
  34147. /** Gets the list of actions */
  34148. actions: IAction[];
  34149. /**
  34150. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34151. */
  34152. isRecursive: boolean;
  34153. /**
  34154. * Releases all associated resources
  34155. */
  34156. abstract dispose(): void;
  34157. /**
  34158. * Does this action manager has pointer triggers
  34159. */
  34160. abstract get hasPointerTriggers(): boolean;
  34161. /**
  34162. * Does this action manager has pick triggers
  34163. */
  34164. abstract get hasPickTriggers(): boolean;
  34165. /**
  34166. * Process a specific trigger
  34167. * @param trigger defines the trigger to process
  34168. * @param evt defines the event details to be processed
  34169. */
  34170. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34171. /**
  34172. * Does this action manager handles actions of any of the given triggers
  34173. * @param triggers defines the triggers to be tested
  34174. * @return a boolean indicating whether one (or more) of the triggers is handled
  34175. */
  34176. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34177. /**
  34178. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34179. * speed.
  34180. * @param triggerA defines the trigger to be tested
  34181. * @param triggerB defines the trigger to be tested
  34182. * @return a boolean indicating whether one (or more) of the triggers is handled
  34183. */
  34184. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34185. /**
  34186. * Does this action manager handles actions of a given trigger
  34187. * @param trigger defines the trigger to be tested
  34188. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34189. * @return whether the trigger is handled
  34190. */
  34191. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34192. /**
  34193. * Serialize this manager to a JSON object
  34194. * @param name defines the property name to store this manager
  34195. * @returns a JSON representation of this manager
  34196. */
  34197. abstract serialize(name: string): any;
  34198. /**
  34199. * Registers an action to this action manager
  34200. * @param action defines the action to be registered
  34201. * @return the action amended (prepared) after registration
  34202. */
  34203. abstract registerAction(action: IAction): Nullable<IAction>;
  34204. /**
  34205. * Unregisters an action to this action manager
  34206. * @param action defines the action to be unregistered
  34207. * @return a boolean indicating whether the action has been unregistered
  34208. */
  34209. abstract unregisterAction(action: IAction): Boolean;
  34210. /**
  34211. * Does exist one action manager with at least one trigger
  34212. **/
  34213. static get HasTriggers(): boolean;
  34214. /**
  34215. * Does exist one action manager with at least one pick trigger
  34216. **/
  34217. static get HasPickTriggers(): boolean;
  34218. /**
  34219. * Does exist one action manager that handles actions of a given trigger
  34220. * @param trigger defines the trigger to be tested
  34221. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34222. **/
  34223. static HasSpecificTrigger(trigger: number): boolean;
  34224. }
  34225. }
  34226. declare module "babylonjs/node" {
  34227. import { Scene } from "babylonjs/scene";
  34228. import { Nullable } from "babylonjs/types";
  34229. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34230. import { Engine } from "babylonjs/Engines/engine";
  34231. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34232. import { Observable } from "babylonjs/Misc/observable";
  34233. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34234. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34235. import { Animatable } from "babylonjs/Animations/animatable";
  34236. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34237. import { Animation } from "babylonjs/Animations/animation";
  34238. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34240. /**
  34241. * Defines how a node can be built from a string name.
  34242. */
  34243. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34244. /**
  34245. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34246. */
  34247. export class Node implements IBehaviorAware<Node> {
  34248. /** @hidden */
  34249. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34250. private static _NodeConstructors;
  34251. /**
  34252. * Add a new node constructor
  34253. * @param type defines the type name of the node to construct
  34254. * @param constructorFunc defines the constructor function
  34255. */
  34256. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34257. /**
  34258. * Returns a node constructor based on type name
  34259. * @param type defines the type name
  34260. * @param name defines the new node name
  34261. * @param scene defines the hosting scene
  34262. * @param options defines optional options to transmit to constructors
  34263. * @returns the new constructor or null
  34264. */
  34265. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34266. /**
  34267. * Gets or sets the name of the node
  34268. */
  34269. name: string;
  34270. /**
  34271. * Gets or sets the id of the node
  34272. */
  34273. id: string;
  34274. /**
  34275. * Gets or sets the unique id of the node
  34276. */
  34277. uniqueId: number;
  34278. /**
  34279. * Gets or sets a string used to store user defined state for the node
  34280. */
  34281. state: string;
  34282. /**
  34283. * Gets or sets an object used to store user defined information for the node
  34284. */
  34285. metadata: any;
  34286. /**
  34287. * For internal use only. Please do not use.
  34288. */
  34289. reservedDataStore: any;
  34290. /**
  34291. * List of inspectable custom properties (used by the Inspector)
  34292. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34293. */
  34294. inspectableCustomProperties: IInspectable[];
  34295. private _doNotSerialize;
  34296. /**
  34297. * Gets or sets a boolean used to define if the node must be serialized
  34298. */
  34299. get doNotSerialize(): boolean;
  34300. set doNotSerialize(value: boolean);
  34301. /** @hidden */
  34302. _isDisposed: boolean;
  34303. /**
  34304. * Gets a list of Animations associated with the node
  34305. */
  34306. animations: import("babylonjs/Animations/animation").Animation[];
  34307. protected _ranges: {
  34308. [name: string]: Nullable<AnimationRange>;
  34309. };
  34310. /**
  34311. * Callback raised when the node is ready to be used
  34312. */
  34313. onReady: Nullable<(node: Node) => void>;
  34314. private _isEnabled;
  34315. private _isParentEnabled;
  34316. private _isReady;
  34317. /** @hidden */
  34318. _currentRenderId: number;
  34319. private _parentUpdateId;
  34320. /** @hidden */
  34321. _childUpdateId: number;
  34322. /** @hidden */
  34323. _waitingParentId: Nullable<string>;
  34324. /** @hidden */
  34325. _scene: Scene;
  34326. /** @hidden */
  34327. _cache: any;
  34328. private _parentNode;
  34329. private _children;
  34330. /** @hidden */
  34331. _worldMatrix: Matrix;
  34332. /** @hidden */
  34333. _worldMatrixDeterminant: number;
  34334. /** @hidden */
  34335. _worldMatrixDeterminantIsDirty: boolean;
  34336. /** @hidden */
  34337. private _sceneRootNodesIndex;
  34338. /**
  34339. * Gets a boolean indicating if the node has been disposed
  34340. * @returns true if the node was disposed
  34341. */
  34342. isDisposed(): boolean;
  34343. /**
  34344. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34345. * @see https://doc.babylonjs.com/how_to/parenting
  34346. */
  34347. set parent(parent: Nullable<Node>);
  34348. get parent(): Nullable<Node>;
  34349. /** @hidden */
  34350. _addToSceneRootNodes(): void;
  34351. /** @hidden */
  34352. _removeFromSceneRootNodes(): void;
  34353. private _animationPropertiesOverride;
  34354. /**
  34355. * Gets or sets the animation properties override
  34356. */
  34357. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34358. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34359. /**
  34360. * Gets a string identifying the name of the class
  34361. * @returns "Node" string
  34362. */
  34363. getClassName(): string;
  34364. /** @hidden */
  34365. readonly _isNode: boolean;
  34366. /**
  34367. * An event triggered when the mesh is disposed
  34368. */
  34369. onDisposeObservable: Observable<Node>;
  34370. private _onDisposeObserver;
  34371. /**
  34372. * Sets a callback that will be raised when the node will be disposed
  34373. */
  34374. set onDispose(callback: () => void);
  34375. /**
  34376. * Creates a new Node
  34377. * @param name the name and id to be given to this node
  34378. * @param scene the scene this node will be added to
  34379. */
  34380. constructor(name: string, scene?: Nullable<Scene>);
  34381. /**
  34382. * Gets the scene of the node
  34383. * @returns a scene
  34384. */
  34385. getScene(): Scene;
  34386. /**
  34387. * Gets the engine of the node
  34388. * @returns a Engine
  34389. */
  34390. getEngine(): Engine;
  34391. private _behaviors;
  34392. /**
  34393. * Attach a behavior to the node
  34394. * @see https://doc.babylonjs.com/features/behaviour
  34395. * @param behavior defines the behavior to attach
  34396. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34397. * @returns the current Node
  34398. */
  34399. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34400. /**
  34401. * Remove an attached behavior
  34402. * @see https://doc.babylonjs.com/features/behaviour
  34403. * @param behavior defines the behavior to attach
  34404. * @returns the current Node
  34405. */
  34406. removeBehavior(behavior: Behavior<Node>): Node;
  34407. /**
  34408. * Gets the list of attached behaviors
  34409. * @see https://doc.babylonjs.com/features/behaviour
  34410. */
  34411. get behaviors(): Behavior<Node>[];
  34412. /**
  34413. * Gets an attached behavior by name
  34414. * @param name defines the name of the behavior to look for
  34415. * @see https://doc.babylonjs.com/features/behaviour
  34416. * @returns null if behavior was not found else the requested behavior
  34417. */
  34418. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34419. /**
  34420. * Returns the latest update of the World matrix
  34421. * @returns a Matrix
  34422. */
  34423. getWorldMatrix(): Matrix;
  34424. /** @hidden */
  34425. _getWorldMatrixDeterminant(): number;
  34426. /**
  34427. * Returns directly the latest state of the mesh World matrix.
  34428. * A Matrix is returned.
  34429. */
  34430. get worldMatrixFromCache(): Matrix;
  34431. /** @hidden */
  34432. _initCache(): void;
  34433. /** @hidden */
  34434. updateCache(force?: boolean): void;
  34435. /** @hidden */
  34436. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34437. /** @hidden */
  34438. _updateCache(ignoreParentClass?: boolean): void;
  34439. /** @hidden */
  34440. _isSynchronized(): boolean;
  34441. /** @hidden */
  34442. _markSyncedWithParent(): void;
  34443. /** @hidden */
  34444. isSynchronizedWithParent(): boolean;
  34445. /** @hidden */
  34446. isSynchronized(): boolean;
  34447. /**
  34448. * Is this node ready to be used/rendered
  34449. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34450. * @return true if the node is ready
  34451. */
  34452. isReady(completeCheck?: boolean): boolean;
  34453. /**
  34454. * Is this node enabled?
  34455. * 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
  34456. * @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
  34457. * @return whether this node (and its parent) is enabled
  34458. */
  34459. isEnabled(checkAncestors?: boolean): boolean;
  34460. /** @hidden */
  34461. protected _syncParentEnabledState(): void;
  34462. /**
  34463. * Set the enabled state of this node
  34464. * @param value defines the new enabled state
  34465. */
  34466. setEnabled(value: boolean): void;
  34467. /**
  34468. * Is this node a descendant of the given node?
  34469. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34470. * @param ancestor defines the parent node to inspect
  34471. * @returns a boolean indicating if this node is a descendant of the given node
  34472. */
  34473. isDescendantOf(ancestor: Node): boolean;
  34474. /** @hidden */
  34475. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34476. /**
  34477. * Will return all nodes that have this node as ascendant
  34478. * @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
  34479. * @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
  34480. * @return all children nodes of all types
  34481. */
  34482. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34483. /**
  34484. * Get all child-meshes of this node
  34485. * @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)
  34486. * @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
  34487. * @returns an array of AbstractMesh
  34488. */
  34489. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34490. /**
  34491. * Get all direct children of this node
  34492. * @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
  34493. * @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)
  34494. * @returns an array of Node
  34495. */
  34496. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34497. /** @hidden */
  34498. _setReady(state: boolean): void;
  34499. /**
  34500. * Get an animation by name
  34501. * @param name defines the name of the animation to look for
  34502. * @returns null if not found else the requested animation
  34503. */
  34504. getAnimationByName(name: string): Nullable<Animation>;
  34505. /**
  34506. * Creates an animation range for this node
  34507. * @param name defines the name of the range
  34508. * @param from defines the starting key
  34509. * @param to defines the end key
  34510. */
  34511. createAnimationRange(name: string, from: number, to: number): void;
  34512. /**
  34513. * Delete a specific animation range
  34514. * @param name defines the name of the range to delete
  34515. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34516. */
  34517. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34518. /**
  34519. * Get an animation range by name
  34520. * @param name defines the name of the animation range to look for
  34521. * @returns null if not found else the requested animation range
  34522. */
  34523. getAnimationRange(name: string): Nullable<AnimationRange>;
  34524. /**
  34525. * Gets the list of all animation ranges defined on this node
  34526. * @returns an array
  34527. */
  34528. getAnimationRanges(): Nullable<AnimationRange>[];
  34529. /**
  34530. * Will start the animation sequence
  34531. * @param name defines the range frames for animation sequence
  34532. * @param loop defines if the animation should loop (false by default)
  34533. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34534. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34535. * @returns the object created for this animation. If range does not exist, it will return null
  34536. */
  34537. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34538. /**
  34539. * Serialize animation ranges into a JSON compatible object
  34540. * @returns serialization object
  34541. */
  34542. serializeAnimationRanges(): any;
  34543. /**
  34544. * Computes the world matrix of the node
  34545. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34546. * @returns the world matrix
  34547. */
  34548. computeWorldMatrix(force?: boolean): Matrix;
  34549. /**
  34550. * Releases resources associated with this node.
  34551. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34552. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34553. */
  34554. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34555. /**
  34556. * Parse animation range data from a serialization object and store them into a given node
  34557. * @param node defines where to store the animation ranges
  34558. * @param parsedNode defines the serialization object to read data from
  34559. * @param scene defines the hosting scene
  34560. */
  34561. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34562. /**
  34563. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34564. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34565. * @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
  34566. * @returns the new bounding vectors
  34567. */
  34568. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34569. min: Vector3;
  34570. max: Vector3;
  34571. };
  34572. }
  34573. }
  34574. declare module "babylonjs/Animations/animation" {
  34575. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34576. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34577. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34578. import { Nullable } from "babylonjs/types";
  34579. import { Scene } from "babylonjs/scene";
  34580. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34581. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34582. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34583. import { Node } from "babylonjs/node";
  34584. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34585. import { Size } from "babylonjs/Maths/math.size";
  34586. import { Animatable } from "babylonjs/Animations/animatable";
  34587. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34588. /**
  34589. * @hidden
  34590. */
  34591. export class _IAnimationState {
  34592. key: number;
  34593. repeatCount: number;
  34594. workValue?: any;
  34595. loopMode?: number;
  34596. offsetValue?: any;
  34597. highLimitValue?: any;
  34598. }
  34599. /**
  34600. * Class used to store any kind of animation
  34601. */
  34602. export class Animation {
  34603. /**Name of the animation */
  34604. name: string;
  34605. /**Property to animate */
  34606. targetProperty: string;
  34607. /**The frames per second of the animation */
  34608. framePerSecond: number;
  34609. /**The data type of the animation */
  34610. dataType: number;
  34611. /**The loop mode of the animation */
  34612. loopMode?: number | undefined;
  34613. /**Specifies if blending should be enabled */
  34614. enableBlending?: boolean | undefined;
  34615. /**
  34616. * Use matrix interpolation instead of using direct key value when animating matrices
  34617. */
  34618. static AllowMatricesInterpolation: boolean;
  34619. /**
  34620. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34621. */
  34622. static AllowMatrixDecomposeForInterpolation: boolean;
  34623. /** Define the Url to load snippets */
  34624. static SnippetUrl: string;
  34625. /** Snippet ID if the animation was created from the snippet server */
  34626. snippetId: string;
  34627. /**
  34628. * Stores the key frames of the animation
  34629. */
  34630. private _keys;
  34631. /**
  34632. * Stores the easing function of the animation
  34633. */
  34634. private _easingFunction;
  34635. /**
  34636. * @hidden Internal use only
  34637. */
  34638. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34639. /**
  34640. * The set of event that will be linked to this animation
  34641. */
  34642. private _events;
  34643. /**
  34644. * Stores an array of target property paths
  34645. */
  34646. targetPropertyPath: string[];
  34647. /**
  34648. * Stores the blending speed of the animation
  34649. */
  34650. blendingSpeed: number;
  34651. /**
  34652. * Stores the animation ranges for the animation
  34653. */
  34654. private _ranges;
  34655. /**
  34656. * @hidden Internal use
  34657. */
  34658. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34659. /**
  34660. * Sets up an animation
  34661. * @param property The property to animate
  34662. * @param animationType The animation type to apply
  34663. * @param framePerSecond The frames per second of the animation
  34664. * @param easingFunction The easing function used in the animation
  34665. * @returns The created animation
  34666. */
  34667. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34668. /**
  34669. * Create and start an animation on a node
  34670. * @param name defines the name of the global animation that will be run on all nodes
  34671. * @param node defines the root node where the animation will take place
  34672. * @param targetProperty defines property to animate
  34673. * @param framePerSecond defines the number of frame per second yo use
  34674. * @param totalFrame defines the number of frames in total
  34675. * @param from defines the initial value
  34676. * @param to defines the final value
  34677. * @param loopMode defines which loop mode you want to use (off by default)
  34678. * @param easingFunction defines the easing function to use (linear by default)
  34679. * @param onAnimationEnd defines the callback to call when animation end
  34680. * @returns the animatable created for this animation
  34681. */
  34682. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34683. /**
  34684. * Create and start an animation on a node and its descendants
  34685. * @param name defines the name of the global animation that will be run on all nodes
  34686. * @param node defines the root node where the animation will take place
  34687. * @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
  34688. * @param targetProperty defines property to animate
  34689. * @param framePerSecond defines the number of frame per second to use
  34690. * @param totalFrame defines the number of frames in total
  34691. * @param from defines the initial value
  34692. * @param to defines the final value
  34693. * @param loopMode defines which loop mode you want to use (off by default)
  34694. * @param easingFunction defines the easing function to use (linear by default)
  34695. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34696. * @returns the list of animatables created for all nodes
  34697. * @example https://www.babylonjs-playground.com/#MH0VLI
  34698. */
  34699. 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[]>;
  34700. /**
  34701. * Creates a new animation, merges it with the existing animations and starts it
  34702. * @param name Name of the animation
  34703. * @param node Node which contains the scene that begins the animations
  34704. * @param targetProperty Specifies which property to animate
  34705. * @param framePerSecond The frames per second of the animation
  34706. * @param totalFrame The total number of frames
  34707. * @param from The frame at the beginning of the animation
  34708. * @param to The frame at the end of the animation
  34709. * @param loopMode Specifies the loop mode of the animation
  34710. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34711. * @param onAnimationEnd Callback to run once the animation is complete
  34712. * @returns Nullable animation
  34713. */
  34714. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34715. /**
  34716. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34717. * @param sourceAnimation defines the Animation containing keyframes to convert
  34718. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34719. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34720. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34721. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34722. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34723. */
  34724. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34725. /**
  34726. * Transition property of an host to the target Value
  34727. * @param property The property to transition
  34728. * @param targetValue The target Value of the property
  34729. * @param host The object where the property to animate belongs
  34730. * @param scene Scene used to run the animation
  34731. * @param frameRate Framerate (in frame/s) to use
  34732. * @param transition The transition type we want to use
  34733. * @param duration The duration of the animation, in milliseconds
  34734. * @param onAnimationEnd Callback trigger at the end of the animation
  34735. * @returns Nullable animation
  34736. */
  34737. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34738. /**
  34739. * Return the array of runtime animations currently using this animation
  34740. */
  34741. get runtimeAnimations(): RuntimeAnimation[];
  34742. /**
  34743. * Specifies if any of the runtime animations are currently running
  34744. */
  34745. get hasRunningRuntimeAnimations(): boolean;
  34746. /**
  34747. * Initializes the animation
  34748. * @param name Name of the animation
  34749. * @param targetProperty Property to animate
  34750. * @param framePerSecond The frames per second of the animation
  34751. * @param dataType The data type of the animation
  34752. * @param loopMode The loop mode of the animation
  34753. * @param enableBlending Specifies if blending should be enabled
  34754. */
  34755. constructor(
  34756. /**Name of the animation */
  34757. name: string,
  34758. /**Property to animate */
  34759. targetProperty: string,
  34760. /**The frames per second of the animation */
  34761. framePerSecond: number,
  34762. /**The data type of the animation */
  34763. dataType: number,
  34764. /**The loop mode of the animation */
  34765. loopMode?: number | undefined,
  34766. /**Specifies if blending should be enabled */
  34767. enableBlending?: boolean | undefined);
  34768. /**
  34769. * Converts the animation to a string
  34770. * @param fullDetails support for multiple levels of logging within scene loading
  34771. * @returns String form of the animation
  34772. */
  34773. toString(fullDetails?: boolean): string;
  34774. /**
  34775. * Add an event to this animation
  34776. * @param event Event to add
  34777. */
  34778. addEvent(event: AnimationEvent): void;
  34779. /**
  34780. * Remove all events found at the given frame
  34781. * @param frame The frame to remove events from
  34782. */
  34783. removeEvents(frame: number): void;
  34784. /**
  34785. * Retrieves all the events from the animation
  34786. * @returns Events from the animation
  34787. */
  34788. getEvents(): AnimationEvent[];
  34789. /**
  34790. * Creates an animation range
  34791. * @param name Name of the animation range
  34792. * @param from Starting frame of the animation range
  34793. * @param to Ending frame of the animation
  34794. */
  34795. createRange(name: string, from: number, to: number): void;
  34796. /**
  34797. * Deletes an animation range by name
  34798. * @param name Name of the animation range to delete
  34799. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34800. */
  34801. deleteRange(name: string, deleteFrames?: boolean): void;
  34802. /**
  34803. * Gets the animation range by name, or null if not defined
  34804. * @param name Name of the animation range
  34805. * @returns Nullable animation range
  34806. */
  34807. getRange(name: string): Nullable<AnimationRange>;
  34808. /**
  34809. * Gets the key frames from the animation
  34810. * @returns The key frames of the animation
  34811. */
  34812. getKeys(): Array<IAnimationKey>;
  34813. /**
  34814. * Gets the highest frame rate of the animation
  34815. * @returns Highest frame rate of the animation
  34816. */
  34817. getHighestFrame(): number;
  34818. /**
  34819. * Gets the easing function of the animation
  34820. * @returns Easing function of the animation
  34821. */
  34822. getEasingFunction(): IEasingFunction;
  34823. /**
  34824. * Sets the easing function of the animation
  34825. * @param easingFunction A custom mathematical formula for animation
  34826. */
  34827. setEasingFunction(easingFunction: EasingFunction): void;
  34828. /**
  34829. * Interpolates a scalar linearly
  34830. * @param startValue Start value of the animation curve
  34831. * @param endValue End value of the animation curve
  34832. * @param gradient Scalar amount to interpolate
  34833. * @returns Interpolated scalar value
  34834. */
  34835. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34836. /**
  34837. * Interpolates a scalar cubically
  34838. * @param startValue Start value of the animation curve
  34839. * @param outTangent End tangent of the animation
  34840. * @param endValue End value of the animation curve
  34841. * @param inTangent Start tangent of the animation curve
  34842. * @param gradient Scalar amount to interpolate
  34843. * @returns Interpolated scalar value
  34844. */
  34845. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34846. /**
  34847. * Interpolates a quaternion using a spherical linear interpolation
  34848. * @param startValue Start value of the animation curve
  34849. * @param endValue End value of the animation curve
  34850. * @param gradient Scalar amount to interpolate
  34851. * @returns Interpolated quaternion value
  34852. */
  34853. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34854. /**
  34855. * Interpolates a quaternion cubically
  34856. * @param startValue Start value of the animation curve
  34857. * @param outTangent End tangent of the animation curve
  34858. * @param endValue End value of the animation curve
  34859. * @param inTangent Start tangent of the animation curve
  34860. * @param gradient Scalar amount to interpolate
  34861. * @returns Interpolated quaternion value
  34862. */
  34863. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34864. /**
  34865. * Interpolates a Vector3 linearl
  34866. * @param startValue Start value of the animation curve
  34867. * @param endValue End value of the animation curve
  34868. * @param gradient Scalar amount to interpolate
  34869. * @returns Interpolated scalar value
  34870. */
  34871. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34872. /**
  34873. * Interpolates a Vector3 cubically
  34874. * @param startValue Start value of the animation curve
  34875. * @param outTangent End tangent of the animation
  34876. * @param endValue End value of the animation curve
  34877. * @param inTangent Start tangent of the animation curve
  34878. * @param gradient Scalar amount to interpolate
  34879. * @returns InterpolatedVector3 value
  34880. */
  34881. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34882. /**
  34883. * Interpolates a Vector2 linearly
  34884. * @param startValue Start value of the animation curve
  34885. * @param endValue End value of the animation curve
  34886. * @param gradient Scalar amount to interpolate
  34887. * @returns Interpolated Vector2 value
  34888. */
  34889. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34890. /**
  34891. * Interpolates a Vector2 cubically
  34892. * @param startValue Start value of the animation curve
  34893. * @param outTangent End tangent of the animation
  34894. * @param endValue End value of the animation curve
  34895. * @param inTangent Start tangent of the animation curve
  34896. * @param gradient Scalar amount to interpolate
  34897. * @returns Interpolated Vector2 value
  34898. */
  34899. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34900. /**
  34901. * Interpolates a size linearly
  34902. * @param startValue Start value of the animation curve
  34903. * @param endValue End value of the animation curve
  34904. * @param gradient Scalar amount to interpolate
  34905. * @returns Interpolated Size value
  34906. */
  34907. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34908. /**
  34909. * Interpolates a Color3 linearly
  34910. * @param startValue Start value of the animation curve
  34911. * @param endValue End value of the animation curve
  34912. * @param gradient Scalar amount to interpolate
  34913. * @returns Interpolated Color3 value
  34914. */
  34915. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34916. /**
  34917. * Interpolates a Color4 linearly
  34918. * @param startValue Start value of the animation curve
  34919. * @param endValue End value of the animation curve
  34920. * @param gradient Scalar amount to interpolate
  34921. * @returns Interpolated Color3 value
  34922. */
  34923. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34924. /**
  34925. * @hidden Internal use only
  34926. */
  34927. _getKeyValue(value: any): any;
  34928. /**
  34929. * @hidden Internal use only
  34930. */
  34931. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34932. /**
  34933. * Defines the function to use to interpolate matrices
  34934. * @param startValue defines the start matrix
  34935. * @param endValue defines the end matrix
  34936. * @param gradient defines the gradient between both matrices
  34937. * @param result defines an optional target matrix where to store the interpolation
  34938. * @returns the interpolated matrix
  34939. */
  34940. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34941. /**
  34942. * Makes a copy of the animation
  34943. * @returns Cloned animation
  34944. */
  34945. clone(): Animation;
  34946. /**
  34947. * Sets the key frames of the animation
  34948. * @param values The animation key frames to set
  34949. */
  34950. setKeys(values: Array<IAnimationKey>): void;
  34951. /**
  34952. * Serializes the animation to an object
  34953. * @returns Serialized object
  34954. */
  34955. serialize(): any;
  34956. /**
  34957. * Float animation type
  34958. */
  34959. static readonly ANIMATIONTYPE_FLOAT: number;
  34960. /**
  34961. * Vector3 animation type
  34962. */
  34963. static readonly ANIMATIONTYPE_VECTOR3: number;
  34964. /**
  34965. * Quaternion animation type
  34966. */
  34967. static readonly ANIMATIONTYPE_QUATERNION: number;
  34968. /**
  34969. * Matrix animation type
  34970. */
  34971. static readonly ANIMATIONTYPE_MATRIX: number;
  34972. /**
  34973. * Color3 animation type
  34974. */
  34975. static readonly ANIMATIONTYPE_COLOR3: number;
  34976. /**
  34977. * Color3 animation type
  34978. */
  34979. static readonly ANIMATIONTYPE_COLOR4: number;
  34980. /**
  34981. * Vector2 animation type
  34982. */
  34983. static readonly ANIMATIONTYPE_VECTOR2: number;
  34984. /**
  34985. * Size animation type
  34986. */
  34987. static readonly ANIMATIONTYPE_SIZE: number;
  34988. /**
  34989. * Relative Loop Mode
  34990. */
  34991. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34992. /**
  34993. * Cycle Loop Mode
  34994. */
  34995. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34996. /**
  34997. * Constant Loop Mode
  34998. */
  34999. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  35000. /** @hidden */
  35001. static _UniversalLerp(left: any, right: any, amount: number): any;
  35002. /**
  35003. * Parses an animation object and creates an animation
  35004. * @param parsedAnimation Parsed animation object
  35005. * @returns Animation object
  35006. */
  35007. static Parse(parsedAnimation: any): Animation;
  35008. /**
  35009. * Appends the serialized animations from the source animations
  35010. * @param source Source containing the animations
  35011. * @param destination Target to store the animations
  35012. */
  35013. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35014. /**
  35015. * Creates a new animation or an array of animations from a snippet saved in a remote file
  35016. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  35017. * @param url defines the url to load from
  35018. * @returns a promise that will resolve to the new animation or an array of animations
  35019. */
  35020. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  35021. /**
  35022. * Creates an animation or an array of animations from a snippet saved by the Inspector
  35023. * @param snippetId defines the snippet to load
  35024. * @returns a promise that will resolve to the new animation or a new array of animations
  35025. */
  35026. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  35027. }
  35028. }
  35029. declare module "babylonjs/Animations/animatable.interface" {
  35030. import { Nullable } from "babylonjs/types";
  35031. import { Animation } from "babylonjs/Animations/animation";
  35032. /**
  35033. * Interface containing an array of animations
  35034. */
  35035. export interface IAnimatable {
  35036. /**
  35037. * Array of animations
  35038. */
  35039. animations: Nullable<Array<Animation>>;
  35040. }
  35041. }
  35042. declare module "babylonjs/Misc/decorators" {
  35043. import { Nullable } from "babylonjs/types";
  35044. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35045. import { Scene } from "babylonjs/scene";
  35046. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35047. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  35048. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  35049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35050. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35051. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35052. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35053. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35054. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35055. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35056. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35057. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35058. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35059. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35060. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35061. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35062. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35063. /**
  35064. * Decorator used to define property that can be serialized as reference to a camera
  35065. * @param sourceName defines the name of the property to decorate
  35066. */
  35067. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35068. /**
  35069. * Class used to help serialization objects
  35070. */
  35071. export class SerializationHelper {
  35072. /** @hidden */
  35073. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  35074. /** @hidden */
  35075. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  35076. /** @hidden */
  35077. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  35078. /** @hidden */
  35079. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  35080. /**
  35081. * Appends the serialized animations from the source animations
  35082. * @param source Source containing the animations
  35083. * @param destination Target to store the animations
  35084. */
  35085. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35086. /**
  35087. * Static function used to serialized a specific entity
  35088. * @param entity defines the entity to serialize
  35089. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35090. * @returns a JSON compatible object representing the serialization of the entity
  35091. */
  35092. static Serialize<T>(entity: T, serializationObject?: any): any;
  35093. /**
  35094. * Creates a new entity from a serialization data object
  35095. * @param creationFunction defines a function used to instanciated the new entity
  35096. * @param source defines the source serialization data
  35097. * @param scene defines the hosting scene
  35098. * @param rootUrl defines the root url for resources
  35099. * @returns a new entity
  35100. */
  35101. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35102. /**
  35103. * Clones an object
  35104. * @param creationFunction defines the function used to instanciate the new object
  35105. * @param source defines the source object
  35106. * @returns the cloned object
  35107. */
  35108. static Clone<T>(creationFunction: () => T, source: T): T;
  35109. /**
  35110. * Instanciates a new object based on a source one (some data will be shared between both object)
  35111. * @param creationFunction defines the function used to instanciate the new object
  35112. * @param source defines the source object
  35113. * @returns the new object
  35114. */
  35115. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35116. }
  35117. }
  35118. declare module "babylonjs/Materials/Textures/baseTexture" {
  35119. import { Observable } from "babylonjs/Misc/observable";
  35120. import { Nullable } from "babylonjs/types";
  35121. import { Scene } from "babylonjs/scene";
  35122. import { Matrix } from "babylonjs/Maths/math.vector";
  35123. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35124. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35125. import { ISize } from "babylonjs/Maths/math.size";
  35126. import "babylonjs/Misc/fileTools";
  35127. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35128. /**
  35129. * Base class of all the textures in babylon.
  35130. * It groups all the common properties the materials, post process, lights... might need
  35131. * in order to make a correct use of the texture.
  35132. */
  35133. export class BaseTexture implements IAnimatable {
  35134. /**
  35135. * Default anisotropic filtering level for the application.
  35136. * It is set to 4 as a good tradeoff between perf and quality.
  35137. */
  35138. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35139. /**
  35140. * Gets or sets the unique id of the texture
  35141. */
  35142. uniqueId: number;
  35143. /**
  35144. * Define the name of the texture.
  35145. */
  35146. name: string;
  35147. /**
  35148. * Gets or sets an object used to store user defined information.
  35149. */
  35150. metadata: any;
  35151. /**
  35152. * For internal use only. Please do not use.
  35153. */
  35154. reservedDataStore: any;
  35155. private _hasAlpha;
  35156. /**
  35157. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35158. */
  35159. set hasAlpha(value: boolean);
  35160. get hasAlpha(): boolean;
  35161. /**
  35162. * Defines if the alpha value should be determined via the rgb values.
  35163. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35164. */
  35165. getAlphaFromRGB: boolean;
  35166. /**
  35167. * Intensity or strength of the texture.
  35168. * It is commonly used by materials to fine tune the intensity of the texture
  35169. */
  35170. level: number;
  35171. /**
  35172. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35173. * This is part of the texture as textures usually maps to one uv set.
  35174. */
  35175. coordinatesIndex: number;
  35176. protected _coordinatesMode: number;
  35177. /**
  35178. * How a texture is mapped.
  35179. *
  35180. * | Value | Type | Description |
  35181. * | ----- | ----------------------------------- | ----------- |
  35182. * | 0 | EXPLICIT_MODE | |
  35183. * | 1 | SPHERICAL_MODE | |
  35184. * | 2 | PLANAR_MODE | |
  35185. * | 3 | CUBIC_MODE | |
  35186. * | 4 | PROJECTION_MODE | |
  35187. * | 5 | SKYBOX_MODE | |
  35188. * | 6 | INVCUBIC_MODE | |
  35189. * | 7 | EQUIRECTANGULAR_MODE | |
  35190. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35191. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35192. */
  35193. set coordinatesMode(value: number);
  35194. get coordinatesMode(): number;
  35195. private _wrapU;
  35196. /**
  35197. * | Value | Type | Description |
  35198. * | ----- | ------------------ | ----------- |
  35199. * | 0 | CLAMP_ADDRESSMODE | |
  35200. * | 1 | WRAP_ADDRESSMODE | |
  35201. * | 2 | MIRROR_ADDRESSMODE | |
  35202. */
  35203. get wrapU(): number;
  35204. set wrapU(value: number);
  35205. private _wrapV;
  35206. /**
  35207. * | Value | Type | Description |
  35208. * | ----- | ------------------ | ----------- |
  35209. * | 0 | CLAMP_ADDRESSMODE | |
  35210. * | 1 | WRAP_ADDRESSMODE | |
  35211. * | 2 | MIRROR_ADDRESSMODE | |
  35212. */
  35213. get wrapV(): number;
  35214. set wrapV(value: number);
  35215. /**
  35216. * | Value | Type | Description |
  35217. * | ----- | ------------------ | ----------- |
  35218. * | 0 | CLAMP_ADDRESSMODE | |
  35219. * | 1 | WRAP_ADDRESSMODE | |
  35220. * | 2 | MIRROR_ADDRESSMODE | |
  35221. */
  35222. wrapR: number;
  35223. /**
  35224. * With compliant hardware and browser (supporting anisotropic filtering)
  35225. * this defines the level of anisotropic filtering in the texture.
  35226. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35227. */
  35228. anisotropicFilteringLevel: number;
  35229. /**
  35230. * Define if the texture is a cube texture or if false a 2d texture.
  35231. */
  35232. get isCube(): boolean;
  35233. set isCube(value: boolean);
  35234. /**
  35235. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35236. */
  35237. get is3D(): boolean;
  35238. set is3D(value: boolean);
  35239. /**
  35240. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35241. */
  35242. get is2DArray(): boolean;
  35243. set is2DArray(value: boolean);
  35244. private _gammaSpace;
  35245. /**
  35246. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35247. * HDR texture are usually stored in linear space.
  35248. * This only impacts the PBR and Background materials
  35249. */
  35250. get gammaSpace(): boolean;
  35251. set gammaSpace(gamma: boolean);
  35252. /**
  35253. * Gets or sets whether or not the texture contains RGBD data.
  35254. */
  35255. get isRGBD(): boolean;
  35256. set isRGBD(value: boolean);
  35257. /**
  35258. * Is Z inverted in the texture (useful in a cube texture).
  35259. */
  35260. invertZ: boolean;
  35261. /**
  35262. * Are mip maps generated for this texture or not.
  35263. */
  35264. get noMipmap(): boolean;
  35265. /**
  35266. * @hidden
  35267. */
  35268. lodLevelInAlpha: boolean;
  35269. /**
  35270. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35271. */
  35272. get lodGenerationOffset(): number;
  35273. set lodGenerationOffset(value: number);
  35274. /**
  35275. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35276. */
  35277. get lodGenerationScale(): number;
  35278. set lodGenerationScale(value: number);
  35279. /**
  35280. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35281. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35282. * average roughness values.
  35283. */
  35284. get linearSpecularLOD(): boolean;
  35285. set linearSpecularLOD(value: boolean);
  35286. /**
  35287. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35288. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35289. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35290. */
  35291. get irradianceTexture(): Nullable<BaseTexture>;
  35292. set irradianceTexture(value: Nullable<BaseTexture>);
  35293. /**
  35294. * Define if the texture is a render target.
  35295. */
  35296. isRenderTarget: boolean;
  35297. /**
  35298. * Define the unique id of the texture in the scene.
  35299. */
  35300. get uid(): string;
  35301. /** @hidden */
  35302. _prefiltered: boolean;
  35303. /**
  35304. * Return a string representation of the texture.
  35305. * @returns the texture as a string
  35306. */
  35307. toString(): string;
  35308. /**
  35309. * Get the class name of the texture.
  35310. * @returns "BaseTexture"
  35311. */
  35312. getClassName(): string;
  35313. /**
  35314. * Define the list of animation attached to the texture.
  35315. */
  35316. animations: import("babylonjs/Animations/animation").Animation[];
  35317. /**
  35318. * An event triggered when the texture is disposed.
  35319. */
  35320. onDisposeObservable: Observable<BaseTexture>;
  35321. private _onDisposeObserver;
  35322. /**
  35323. * Callback triggered when the texture has been disposed.
  35324. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35325. */
  35326. set onDispose(callback: () => void);
  35327. /**
  35328. * Define the current state of the loading sequence when in delayed load mode.
  35329. */
  35330. delayLoadState: number;
  35331. protected _scene: Nullable<Scene>;
  35332. protected _engine: Nullable<ThinEngine>;
  35333. /** @hidden */
  35334. _texture: Nullable<InternalTexture>;
  35335. private _uid;
  35336. /**
  35337. * Define if the texture is preventinga material to render or not.
  35338. * If not and the texture is not ready, the engine will use a default black texture instead.
  35339. */
  35340. get isBlocking(): boolean;
  35341. /**
  35342. * Instantiates a new BaseTexture.
  35343. * Base class of all the textures in babylon.
  35344. * It groups all the common properties the materials, post process, lights... might need
  35345. * in order to make a correct use of the texture.
  35346. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35347. */
  35348. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35349. /**
  35350. * Get the scene the texture belongs to.
  35351. * @returns the scene or null if undefined
  35352. */
  35353. getScene(): Nullable<Scene>;
  35354. /** @hidden */
  35355. protected _getEngine(): Nullable<ThinEngine>;
  35356. /**
  35357. * Get the texture transform matrix used to offset tile the texture for istance.
  35358. * @returns the transformation matrix
  35359. */
  35360. getTextureMatrix(): Matrix;
  35361. /**
  35362. * Get the texture reflection matrix used to rotate/transform the reflection.
  35363. * @returns the reflection matrix
  35364. */
  35365. getReflectionTextureMatrix(): Matrix;
  35366. /**
  35367. * Get the underlying lower level texture from Babylon.
  35368. * @returns the insternal texture
  35369. */
  35370. getInternalTexture(): Nullable<InternalTexture>;
  35371. /**
  35372. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35373. * @returns true if ready or not blocking
  35374. */
  35375. isReadyOrNotBlocking(): boolean;
  35376. /**
  35377. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35378. * @returns true if fully ready
  35379. */
  35380. isReady(): boolean;
  35381. private _cachedSize;
  35382. /**
  35383. * Get the size of the texture.
  35384. * @returns the texture size.
  35385. */
  35386. getSize(): ISize;
  35387. /**
  35388. * Get the base size of the texture.
  35389. * It can be different from the size if the texture has been resized for POT for instance
  35390. * @returns the base size
  35391. */
  35392. getBaseSize(): ISize;
  35393. /**
  35394. * Update the sampling mode of the texture.
  35395. * Default is Trilinear mode.
  35396. *
  35397. * | Value | Type | Description |
  35398. * | ----- | ------------------ | ----------- |
  35399. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35400. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35401. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35402. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35403. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35404. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35405. * | 7 | NEAREST_LINEAR | |
  35406. * | 8 | NEAREST_NEAREST | |
  35407. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35408. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35409. * | 11 | LINEAR_LINEAR | |
  35410. * | 12 | LINEAR_NEAREST | |
  35411. *
  35412. * > _mag_: magnification filter (close to the viewer)
  35413. * > _min_: minification filter (far from the viewer)
  35414. * > _mip_: filter used between mip map levels
  35415. *@param samplingMode Define the new sampling mode of the texture
  35416. */
  35417. updateSamplingMode(samplingMode: number): void;
  35418. /**
  35419. * Scales the texture if is `canRescale()`
  35420. * @param ratio the resize factor we want to use to rescale
  35421. */
  35422. scale(ratio: number): void;
  35423. /**
  35424. * Get if the texture can rescale.
  35425. */
  35426. get canRescale(): boolean;
  35427. /** @hidden */
  35428. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35429. /** @hidden */
  35430. _rebuild(): void;
  35431. /**
  35432. * Triggers the load sequence in delayed load mode.
  35433. */
  35434. delayLoad(): void;
  35435. /**
  35436. * Clones the texture.
  35437. * @returns the cloned texture
  35438. */
  35439. clone(): Nullable<BaseTexture>;
  35440. /**
  35441. * Get the texture underlying type (INT, FLOAT...)
  35442. */
  35443. get textureType(): number;
  35444. /**
  35445. * Get the texture underlying format (RGB, RGBA...)
  35446. */
  35447. get textureFormat(): number;
  35448. /**
  35449. * Indicates that textures need to be re-calculated for all materials
  35450. */
  35451. protected _markAllSubMeshesAsTexturesDirty(): void;
  35452. /**
  35453. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35454. * This will returns an RGBA array buffer containing either in values (0-255) or
  35455. * float values (0-1) depending of the underlying buffer type.
  35456. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35457. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35458. * @param buffer defines a user defined buffer to fill with data (can be null)
  35459. * @returns The Array buffer containing the pixels data.
  35460. */
  35461. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35462. /**
  35463. * Release and destroy the underlying lower level texture aka internalTexture.
  35464. */
  35465. releaseInternalTexture(): void;
  35466. /** @hidden */
  35467. get _lodTextureHigh(): Nullable<BaseTexture>;
  35468. /** @hidden */
  35469. get _lodTextureMid(): Nullable<BaseTexture>;
  35470. /** @hidden */
  35471. get _lodTextureLow(): Nullable<BaseTexture>;
  35472. /**
  35473. * Dispose the texture and release its associated resources.
  35474. */
  35475. dispose(): void;
  35476. /**
  35477. * Serialize the texture into a JSON representation that can be parsed later on.
  35478. * @returns the JSON representation of the texture
  35479. */
  35480. serialize(): any;
  35481. /**
  35482. * Helper function to be called back once a list of texture contains only ready textures.
  35483. * @param textures Define the list of textures to wait for
  35484. * @param callback Define the callback triggered once the entire list will be ready
  35485. */
  35486. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35487. private static _isScene;
  35488. }
  35489. }
  35490. declare module "babylonjs/Materials/effect" {
  35491. import { Observable } from "babylonjs/Misc/observable";
  35492. import { Nullable } from "babylonjs/types";
  35493. import { IDisposable } from "babylonjs/scene";
  35494. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35495. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35496. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35497. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35498. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35499. import { Engine } from "babylonjs/Engines/engine";
  35500. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35502. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35503. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35504. /**
  35505. * Options to be used when creating an effect.
  35506. */
  35507. export interface IEffectCreationOptions {
  35508. /**
  35509. * Atrributes that will be used in the shader.
  35510. */
  35511. attributes: string[];
  35512. /**
  35513. * Uniform varible names that will be set in the shader.
  35514. */
  35515. uniformsNames: string[];
  35516. /**
  35517. * Uniform buffer variable names that will be set in the shader.
  35518. */
  35519. uniformBuffersNames: string[];
  35520. /**
  35521. * Sampler texture variable names that will be set in the shader.
  35522. */
  35523. samplers: string[];
  35524. /**
  35525. * Define statements that will be set in the shader.
  35526. */
  35527. defines: any;
  35528. /**
  35529. * Possible fallbacks for this effect to improve performance when needed.
  35530. */
  35531. fallbacks: Nullable<IEffectFallbacks>;
  35532. /**
  35533. * Callback that will be called when the shader is compiled.
  35534. */
  35535. onCompiled: Nullable<(effect: Effect) => void>;
  35536. /**
  35537. * Callback that will be called if an error occurs during shader compilation.
  35538. */
  35539. onError: Nullable<(effect: Effect, errors: string) => void>;
  35540. /**
  35541. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35542. */
  35543. indexParameters?: any;
  35544. /**
  35545. * Max number of lights that can be used in the shader.
  35546. */
  35547. maxSimultaneousLights?: number;
  35548. /**
  35549. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35550. */
  35551. transformFeedbackVaryings?: Nullable<string[]>;
  35552. /**
  35553. * 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
  35554. */
  35555. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35556. /**
  35557. * Is this effect rendering to several color attachments ?
  35558. */
  35559. multiTarget?: boolean;
  35560. }
  35561. /**
  35562. * Effect containing vertex and fragment shader that can be executed on an object.
  35563. */
  35564. export class Effect implements IDisposable {
  35565. /**
  35566. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35567. */
  35568. static ShadersRepository: string;
  35569. /**
  35570. * Enable logging of the shader code when a compilation error occurs
  35571. */
  35572. static LogShaderCodeOnCompilationError: boolean;
  35573. /**
  35574. * Name of the effect.
  35575. */
  35576. name: any;
  35577. /**
  35578. * String container all the define statements that should be set on the shader.
  35579. */
  35580. defines: string;
  35581. /**
  35582. * Callback that will be called when the shader is compiled.
  35583. */
  35584. onCompiled: Nullable<(effect: Effect) => void>;
  35585. /**
  35586. * Callback that will be called if an error occurs during shader compilation.
  35587. */
  35588. onError: Nullable<(effect: Effect, errors: string) => void>;
  35589. /**
  35590. * Callback that will be called when effect is bound.
  35591. */
  35592. onBind: Nullable<(effect: Effect) => void>;
  35593. /**
  35594. * Unique ID of the effect.
  35595. */
  35596. uniqueId: number;
  35597. /**
  35598. * Observable that will be called when the shader is compiled.
  35599. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35600. */
  35601. onCompileObservable: Observable<Effect>;
  35602. /**
  35603. * Observable that will be called if an error occurs during shader compilation.
  35604. */
  35605. onErrorObservable: Observable<Effect>;
  35606. /** @hidden */
  35607. _onBindObservable: Nullable<Observable<Effect>>;
  35608. /**
  35609. * @hidden
  35610. * Specifies if the effect was previously ready
  35611. */
  35612. _wasPreviouslyReady: boolean;
  35613. /**
  35614. * Observable that will be called when effect is bound.
  35615. */
  35616. get onBindObservable(): Observable<Effect>;
  35617. /** @hidden */
  35618. _bonesComputationForcedToCPU: boolean;
  35619. /** @hidden */
  35620. _multiTarget: boolean;
  35621. private static _uniqueIdSeed;
  35622. private _engine;
  35623. private _uniformBuffersNames;
  35624. private _uniformBuffersNamesList;
  35625. private _uniformsNames;
  35626. private _samplerList;
  35627. private _samplers;
  35628. private _isReady;
  35629. private _compilationError;
  35630. private _allFallbacksProcessed;
  35631. private _attributesNames;
  35632. private _attributes;
  35633. private _attributeLocationByName;
  35634. private _uniforms;
  35635. /**
  35636. * Key for the effect.
  35637. * @hidden
  35638. */
  35639. _key: string;
  35640. private _indexParameters;
  35641. private _fallbacks;
  35642. private _vertexSourceCode;
  35643. private _fragmentSourceCode;
  35644. private _vertexSourceCodeOverride;
  35645. private _fragmentSourceCodeOverride;
  35646. private _transformFeedbackVaryings;
  35647. /**
  35648. * Compiled shader to webGL program.
  35649. * @hidden
  35650. */
  35651. _pipelineContext: Nullable<IPipelineContext>;
  35652. private _valueCache;
  35653. private static _baseCache;
  35654. /**
  35655. * Instantiates an effect.
  35656. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35657. * @param baseName Name of the effect.
  35658. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35659. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35660. * @param samplers List of sampler variables that will be passed to the shader.
  35661. * @param engine Engine to be used to render the effect
  35662. * @param defines Define statements to be added to the shader.
  35663. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35664. * @param onCompiled Callback that will be called when the shader is compiled.
  35665. * @param onError Callback that will be called if an error occurs during shader compilation.
  35666. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35667. */
  35668. 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);
  35669. private _useFinalCode;
  35670. /**
  35671. * Unique key for this effect
  35672. */
  35673. get key(): string;
  35674. /**
  35675. * If the effect has been compiled and prepared.
  35676. * @returns if the effect is compiled and prepared.
  35677. */
  35678. isReady(): boolean;
  35679. private _isReadyInternal;
  35680. /**
  35681. * The engine the effect was initialized with.
  35682. * @returns the engine.
  35683. */
  35684. getEngine(): Engine;
  35685. /**
  35686. * The pipeline context for this effect
  35687. * @returns the associated pipeline context
  35688. */
  35689. getPipelineContext(): Nullable<IPipelineContext>;
  35690. /**
  35691. * The set of names of attribute variables for the shader.
  35692. * @returns An array of attribute names.
  35693. */
  35694. getAttributesNames(): string[];
  35695. /**
  35696. * Returns the attribute at the given index.
  35697. * @param index The index of the attribute.
  35698. * @returns The location of the attribute.
  35699. */
  35700. getAttributeLocation(index: number): number;
  35701. /**
  35702. * Returns the attribute based on the name of the variable.
  35703. * @param name of the attribute to look up.
  35704. * @returns the attribute location.
  35705. */
  35706. getAttributeLocationByName(name: string): number;
  35707. /**
  35708. * The number of attributes.
  35709. * @returns the numnber of attributes.
  35710. */
  35711. getAttributesCount(): number;
  35712. /**
  35713. * Gets the index of a uniform variable.
  35714. * @param uniformName of the uniform to look up.
  35715. * @returns the index.
  35716. */
  35717. getUniformIndex(uniformName: string): number;
  35718. /**
  35719. * Returns the attribute based on the name of the variable.
  35720. * @param uniformName of the uniform to look up.
  35721. * @returns the location of the uniform.
  35722. */
  35723. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35724. /**
  35725. * Returns an array of sampler variable names
  35726. * @returns The array of sampler variable names.
  35727. */
  35728. getSamplers(): string[];
  35729. /**
  35730. * Returns an array of uniform variable names
  35731. * @returns The array of uniform variable names.
  35732. */
  35733. getUniformNames(): string[];
  35734. /**
  35735. * Returns an array of uniform buffer variable names
  35736. * @returns The array of uniform buffer variable names.
  35737. */
  35738. getUniformBuffersNames(): string[];
  35739. /**
  35740. * Returns the index parameters used to create the effect
  35741. * @returns The index parameters object
  35742. */
  35743. getIndexParameters(): any;
  35744. /**
  35745. * The error from the last compilation.
  35746. * @returns the error string.
  35747. */
  35748. getCompilationError(): string;
  35749. /**
  35750. * Gets a boolean indicating that all fallbacks were used during compilation
  35751. * @returns true if all fallbacks were used
  35752. */
  35753. allFallbacksProcessed(): boolean;
  35754. /**
  35755. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35756. * @param func The callback to be used.
  35757. */
  35758. executeWhenCompiled(func: (effect: Effect) => void): void;
  35759. private _checkIsReady;
  35760. private _loadShader;
  35761. /**
  35762. * Gets the vertex shader source code of this effect
  35763. */
  35764. get vertexSourceCode(): string;
  35765. /**
  35766. * Gets the fragment shader source code of this effect
  35767. */
  35768. get fragmentSourceCode(): string;
  35769. /**
  35770. * Recompiles the webGL program
  35771. * @param vertexSourceCode The source code for the vertex shader.
  35772. * @param fragmentSourceCode The source code for the fragment shader.
  35773. * @param onCompiled Callback called when completed.
  35774. * @param onError Callback called on error.
  35775. * @hidden
  35776. */
  35777. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35778. /**
  35779. * Prepares the effect
  35780. * @hidden
  35781. */
  35782. _prepareEffect(): void;
  35783. private _getShaderCodeAndErrorLine;
  35784. private _processCompilationErrors;
  35785. /**
  35786. * Checks if the effect is supported. (Must be called after compilation)
  35787. */
  35788. get isSupported(): boolean;
  35789. /**
  35790. * Binds a texture to the engine to be used as output of the shader.
  35791. * @param channel Name of the output variable.
  35792. * @param texture Texture to bind.
  35793. * @hidden
  35794. */
  35795. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35796. /**
  35797. * Sets a texture on the engine to be used in the shader.
  35798. * @param channel Name of the sampler variable.
  35799. * @param texture Texture to set.
  35800. */
  35801. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35802. /**
  35803. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35804. * @param channel Name of the sampler variable.
  35805. * @param texture Texture to set.
  35806. */
  35807. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35808. /**
  35809. * Sets an array of textures on the engine to be used in the shader.
  35810. * @param channel Name of the variable.
  35811. * @param textures Textures to set.
  35812. */
  35813. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35814. /**
  35815. * 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)
  35816. * @param channel Name of the sampler variable.
  35817. * @param postProcess Post process to get the input texture from.
  35818. */
  35819. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35820. /**
  35821. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35822. * 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)
  35823. * @param channel Name of the sampler variable.
  35824. * @param postProcess Post process to get the output texture from.
  35825. */
  35826. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35827. /** @hidden */
  35828. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35829. /** @hidden */
  35830. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35831. /** @hidden */
  35832. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35833. /** @hidden */
  35834. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35835. /**
  35836. * Binds a buffer to a uniform.
  35837. * @param buffer Buffer to bind.
  35838. * @param name Name of the uniform variable to bind to.
  35839. */
  35840. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35841. /**
  35842. * Binds block to a uniform.
  35843. * @param blockName Name of the block to bind.
  35844. * @param index Index to bind.
  35845. */
  35846. bindUniformBlock(blockName: string, index: number): void;
  35847. /**
  35848. * Sets an interger value on a uniform variable.
  35849. * @param uniformName Name of the variable.
  35850. * @param value Value to be set.
  35851. * @returns this effect.
  35852. */
  35853. setInt(uniformName: string, value: number): Effect;
  35854. /**
  35855. * Sets an int array on a uniform variable.
  35856. * @param uniformName Name of the variable.
  35857. * @param array array to be set.
  35858. * @returns this effect.
  35859. */
  35860. setIntArray(uniformName: string, array: Int32Array): Effect;
  35861. /**
  35862. * 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)
  35863. * @param uniformName Name of the variable.
  35864. * @param array array to be set.
  35865. * @returns this effect.
  35866. */
  35867. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35868. /**
  35869. * 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)
  35870. * @param uniformName Name of the variable.
  35871. * @param array array to be set.
  35872. * @returns this effect.
  35873. */
  35874. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35875. /**
  35876. * 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)
  35877. * @param uniformName Name of the variable.
  35878. * @param array array to be set.
  35879. * @returns this effect.
  35880. */
  35881. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35882. /**
  35883. * Sets an float array on a uniform variable.
  35884. * @param uniformName Name of the variable.
  35885. * @param array array to be set.
  35886. * @returns this effect.
  35887. */
  35888. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35889. /**
  35890. * 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)
  35891. * @param uniformName Name of the variable.
  35892. * @param array array to be set.
  35893. * @returns this effect.
  35894. */
  35895. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35896. /**
  35897. * 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)
  35898. * @param uniformName Name of the variable.
  35899. * @param array array to be set.
  35900. * @returns this effect.
  35901. */
  35902. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35903. /**
  35904. * 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)
  35905. * @param uniformName Name of the variable.
  35906. * @param array array to be set.
  35907. * @returns this effect.
  35908. */
  35909. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35910. /**
  35911. * Sets an array on a uniform variable.
  35912. * @param uniformName Name of the variable.
  35913. * @param array array to be set.
  35914. * @returns this effect.
  35915. */
  35916. setArray(uniformName: string, array: number[]): Effect;
  35917. /**
  35918. * 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)
  35919. * @param uniformName Name of the variable.
  35920. * @param array array to be set.
  35921. * @returns this effect.
  35922. */
  35923. setArray2(uniformName: string, array: number[]): Effect;
  35924. /**
  35925. * 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)
  35926. * @param uniformName Name of the variable.
  35927. * @param array array to be set.
  35928. * @returns this effect.
  35929. */
  35930. setArray3(uniformName: string, array: number[]): Effect;
  35931. /**
  35932. * 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)
  35933. * @param uniformName Name of the variable.
  35934. * @param array array to be set.
  35935. * @returns this effect.
  35936. */
  35937. setArray4(uniformName: string, array: number[]): Effect;
  35938. /**
  35939. * Sets matrices on a uniform variable.
  35940. * @param uniformName Name of the variable.
  35941. * @param matrices matrices to be set.
  35942. * @returns this effect.
  35943. */
  35944. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35945. /**
  35946. * Sets matrix on a uniform variable.
  35947. * @param uniformName Name of the variable.
  35948. * @param matrix matrix to be set.
  35949. * @returns this effect.
  35950. */
  35951. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35952. /**
  35953. * 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)
  35954. * @param uniformName Name of the variable.
  35955. * @param matrix matrix to be set.
  35956. * @returns this effect.
  35957. */
  35958. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35959. /**
  35960. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35961. * @param uniformName Name of the variable.
  35962. * @param matrix matrix to be set.
  35963. * @returns this effect.
  35964. */
  35965. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35966. /**
  35967. * Sets a float on a uniform variable.
  35968. * @param uniformName Name of the variable.
  35969. * @param value value to be set.
  35970. * @returns this effect.
  35971. */
  35972. setFloat(uniformName: string, value: number): Effect;
  35973. /**
  35974. * Sets a boolean on a uniform variable.
  35975. * @param uniformName Name of the variable.
  35976. * @param bool value to be set.
  35977. * @returns this effect.
  35978. */
  35979. setBool(uniformName: string, bool: boolean): Effect;
  35980. /**
  35981. * Sets a Vector2 on a uniform variable.
  35982. * @param uniformName Name of the variable.
  35983. * @param vector2 vector2 to be set.
  35984. * @returns this effect.
  35985. */
  35986. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35987. /**
  35988. * Sets a float2 on a uniform variable.
  35989. * @param uniformName Name of the variable.
  35990. * @param x First float in float2.
  35991. * @param y Second float in float2.
  35992. * @returns this effect.
  35993. */
  35994. setFloat2(uniformName: string, x: number, y: number): Effect;
  35995. /**
  35996. * Sets a Vector3 on a uniform variable.
  35997. * @param uniformName Name of the variable.
  35998. * @param vector3 Value to be set.
  35999. * @returns this effect.
  36000. */
  36001. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  36002. /**
  36003. * Sets a float3 on a uniform variable.
  36004. * @param uniformName Name of the variable.
  36005. * @param x First float in float3.
  36006. * @param y Second float in float3.
  36007. * @param z Third float in float3.
  36008. * @returns this effect.
  36009. */
  36010. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  36011. /**
  36012. * Sets a Vector4 on a uniform variable.
  36013. * @param uniformName Name of the variable.
  36014. * @param vector4 Value to be set.
  36015. * @returns this effect.
  36016. */
  36017. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  36018. /**
  36019. * Sets a float4 on a uniform variable.
  36020. * @param uniformName Name of the variable.
  36021. * @param x First float in float4.
  36022. * @param y Second float in float4.
  36023. * @param z Third float in float4.
  36024. * @param w Fourth float in float4.
  36025. * @returns this effect.
  36026. */
  36027. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  36028. /**
  36029. * Sets a Color3 on a uniform variable.
  36030. * @param uniformName Name of the variable.
  36031. * @param color3 Value to be set.
  36032. * @returns this effect.
  36033. */
  36034. setColor3(uniformName: string, color3: IColor3Like): Effect;
  36035. /**
  36036. * Sets a Color4 on a uniform variable.
  36037. * @param uniformName Name of the variable.
  36038. * @param color3 Value to be set.
  36039. * @param alpha Alpha value to be set.
  36040. * @returns this effect.
  36041. */
  36042. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  36043. /**
  36044. * Sets a Color4 on a uniform variable
  36045. * @param uniformName defines the name of the variable
  36046. * @param color4 defines the value to be set
  36047. * @returns this effect.
  36048. */
  36049. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  36050. /** Release all associated resources */
  36051. dispose(): void;
  36052. /**
  36053. * This function will add a new shader to the shader store
  36054. * @param name the name of the shader
  36055. * @param pixelShader optional pixel shader content
  36056. * @param vertexShader optional vertex shader content
  36057. */
  36058. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  36059. /**
  36060. * Store of each shader (The can be looked up using effect.key)
  36061. */
  36062. static ShadersStore: {
  36063. [key: string]: string;
  36064. };
  36065. /**
  36066. * Store of each included file for a shader (The can be looked up using effect.key)
  36067. */
  36068. static IncludesShadersStore: {
  36069. [key: string]: string;
  36070. };
  36071. /**
  36072. * Resets the cache of effects.
  36073. */
  36074. static ResetCache(): void;
  36075. }
  36076. }
  36077. declare module "babylonjs/Engines/engineCapabilities" {
  36078. /**
  36079. * Interface used to describe the capabilities of the engine relatively to the current browser
  36080. */
  36081. export interface EngineCapabilities {
  36082. /** Maximum textures units per fragment shader */
  36083. maxTexturesImageUnits: number;
  36084. /** Maximum texture units per vertex shader */
  36085. maxVertexTextureImageUnits: number;
  36086. /** Maximum textures units in the entire pipeline */
  36087. maxCombinedTexturesImageUnits: number;
  36088. /** Maximum texture size */
  36089. maxTextureSize: number;
  36090. /** Maximum texture samples */
  36091. maxSamples?: number;
  36092. /** Maximum cube texture size */
  36093. maxCubemapTextureSize: number;
  36094. /** Maximum render texture size */
  36095. maxRenderTextureSize: number;
  36096. /** Maximum number of vertex attributes */
  36097. maxVertexAttribs: number;
  36098. /** Maximum number of varyings */
  36099. maxVaryingVectors: number;
  36100. /** Maximum number of uniforms per vertex shader */
  36101. maxVertexUniformVectors: number;
  36102. /** Maximum number of uniforms per fragment shader */
  36103. maxFragmentUniformVectors: number;
  36104. /** Defines if standard derivates (dx/dy) are supported */
  36105. standardDerivatives: boolean;
  36106. /** Defines if s3tc texture compression is supported */
  36107. s3tc?: WEBGL_compressed_texture_s3tc;
  36108. /** Defines if pvrtc texture compression is supported */
  36109. pvrtc: any;
  36110. /** Defines if etc1 texture compression is supported */
  36111. etc1: any;
  36112. /** Defines if etc2 texture compression is supported */
  36113. etc2: any;
  36114. /** Defines if astc texture compression is supported */
  36115. astc: any;
  36116. /** Defines if bptc texture compression is supported */
  36117. bptc: any;
  36118. /** Defines if float textures are supported */
  36119. textureFloat: boolean;
  36120. /** Defines if vertex array objects are supported */
  36121. vertexArrayObject: boolean;
  36122. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36123. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36124. /** Gets the maximum level of anisotropy supported */
  36125. maxAnisotropy: number;
  36126. /** Defines if instancing is supported */
  36127. instancedArrays: boolean;
  36128. /** Defines if 32 bits indices are supported */
  36129. uintIndices: boolean;
  36130. /** Defines if high precision shaders are supported */
  36131. highPrecisionShaderSupported: boolean;
  36132. /** Defines if depth reading in the fragment shader is supported */
  36133. fragmentDepthSupported: boolean;
  36134. /** Defines if float texture linear filtering is supported*/
  36135. textureFloatLinearFiltering: boolean;
  36136. /** Defines if rendering to float textures is supported */
  36137. textureFloatRender: boolean;
  36138. /** Defines if half float textures are supported*/
  36139. textureHalfFloat: boolean;
  36140. /** Defines if half float texture linear filtering is supported*/
  36141. textureHalfFloatLinearFiltering: boolean;
  36142. /** Defines if rendering to half float textures is supported */
  36143. textureHalfFloatRender: boolean;
  36144. /** Defines if textureLOD shader command is supported */
  36145. textureLOD: boolean;
  36146. /** Defines if draw buffers extension is supported */
  36147. drawBuffersExtension: boolean;
  36148. /** Defines if depth textures are supported */
  36149. depthTextureExtension: boolean;
  36150. /** Defines if float color buffer are supported */
  36151. colorBufferFloat: boolean;
  36152. /** Gets disjoint timer query extension (null if not supported) */
  36153. timerQuery?: EXT_disjoint_timer_query;
  36154. /** Defines if timestamp can be used with timer query */
  36155. canUseTimestampForTimerQuery: boolean;
  36156. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36157. multiview?: any;
  36158. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36159. oculusMultiview?: any;
  36160. /** Function used to let the system compiles shaders in background */
  36161. parallelShaderCompile?: {
  36162. COMPLETION_STATUS_KHR: number;
  36163. };
  36164. /** Max number of texture samples for MSAA */
  36165. maxMSAASamples: number;
  36166. /** Defines if the blend min max extension is supported */
  36167. blendMinMax: boolean;
  36168. }
  36169. }
  36170. declare module "babylonjs/States/depthCullingState" {
  36171. import { Nullable } from "babylonjs/types";
  36172. /**
  36173. * @hidden
  36174. **/
  36175. export class DepthCullingState {
  36176. private _isDepthTestDirty;
  36177. private _isDepthMaskDirty;
  36178. private _isDepthFuncDirty;
  36179. private _isCullFaceDirty;
  36180. private _isCullDirty;
  36181. private _isZOffsetDirty;
  36182. private _isFrontFaceDirty;
  36183. private _depthTest;
  36184. private _depthMask;
  36185. private _depthFunc;
  36186. private _cull;
  36187. private _cullFace;
  36188. private _zOffset;
  36189. private _frontFace;
  36190. /**
  36191. * Initializes the state.
  36192. */
  36193. constructor();
  36194. get isDirty(): boolean;
  36195. get zOffset(): number;
  36196. set zOffset(value: number);
  36197. get cullFace(): Nullable<number>;
  36198. set cullFace(value: Nullable<number>);
  36199. get cull(): Nullable<boolean>;
  36200. set cull(value: Nullable<boolean>);
  36201. get depthFunc(): Nullable<number>;
  36202. set depthFunc(value: Nullable<number>);
  36203. get depthMask(): boolean;
  36204. set depthMask(value: boolean);
  36205. get depthTest(): boolean;
  36206. set depthTest(value: boolean);
  36207. get frontFace(): Nullable<number>;
  36208. set frontFace(value: Nullable<number>);
  36209. reset(): void;
  36210. apply(gl: WebGLRenderingContext): void;
  36211. }
  36212. }
  36213. declare module "babylonjs/States/stencilState" {
  36214. /**
  36215. * @hidden
  36216. **/
  36217. export class StencilState {
  36218. /** 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 */
  36219. static readonly ALWAYS: number;
  36220. /** Passed to stencilOperation to specify that stencil value must be kept */
  36221. static readonly KEEP: number;
  36222. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36223. static readonly REPLACE: number;
  36224. private _isStencilTestDirty;
  36225. private _isStencilMaskDirty;
  36226. private _isStencilFuncDirty;
  36227. private _isStencilOpDirty;
  36228. private _stencilTest;
  36229. private _stencilMask;
  36230. private _stencilFunc;
  36231. private _stencilFuncRef;
  36232. private _stencilFuncMask;
  36233. private _stencilOpStencilFail;
  36234. private _stencilOpDepthFail;
  36235. private _stencilOpStencilDepthPass;
  36236. get isDirty(): boolean;
  36237. get stencilFunc(): number;
  36238. set stencilFunc(value: number);
  36239. get stencilFuncRef(): number;
  36240. set stencilFuncRef(value: number);
  36241. get stencilFuncMask(): number;
  36242. set stencilFuncMask(value: number);
  36243. get stencilOpStencilFail(): number;
  36244. set stencilOpStencilFail(value: number);
  36245. get stencilOpDepthFail(): number;
  36246. set stencilOpDepthFail(value: number);
  36247. get stencilOpStencilDepthPass(): number;
  36248. set stencilOpStencilDepthPass(value: number);
  36249. get stencilMask(): number;
  36250. set stencilMask(value: number);
  36251. get stencilTest(): boolean;
  36252. set stencilTest(value: boolean);
  36253. constructor();
  36254. reset(): void;
  36255. apply(gl: WebGLRenderingContext): void;
  36256. }
  36257. }
  36258. declare module "babylonjs/States/alphaCullingState" {
  36259. /**
  36260. * @hidden
  36261. **/
  36262. export class AlphaState {
  36263. private _isAlphaBlendDirty;
  36264. private _isBlendFunctionParametersDirty;
  36265. private _isBlendEquationParametersDirty;
  36266. private _isBlendConstantsDirty;
  36267. private _alphaBlend;
  36268. private _blendFunctionParameters;
  36269. private _blendEquationParameters;
  36270. private _blendConstants;
  36271. /**
  36272. * Initializes the state.
  36273. */
  36274. constructor();
  36275. get isDirty(): boolean;
  36276. get alphaBlend(): boolean;
  36277. set alphaBlend(value: boolean);
  36278. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36279. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36280. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36281. reset(): void;
  36282. apply(gl: WebGLRenderingContext): void;
  36283. }
  36284. }
  36285. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36286. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36287. /** @hidden */
  36288. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36289. attributeProcessor(attribute: string): string;
  36290. varyingProcessor(varying: string, isFragment: boolean): string;
  36291. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36292. }
  36293. }
  36294. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36295. /**
  36296. * Interface for attribute information associated with buffer instanciation
  36297. */
  36298. export interface InstancingAttributeInfo {
  36299. /**
  36300. * Name of the GLSL attribute
  36301. * if attribute index is not specified, this is used to retrieve the index from the effect
  36302. */
  36303. attributeName: string;
  36304. /**
  36305. * Index/offset of the attribute in the vertex shader
  36306. * if not specified, this will be computes from the name.
  36307. */
  36308. index?: number;
  36309. /**
  36310. * size of the attribute, 1, 2, 3 or 4
  36311. */
  36312. attributeSize: number;
  36313. /**
  36314. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36315. */
  36316. offset: number;
  36317. /**
  36318. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36319. * default to 1
  36320. */
  36321. divisor?: number;
  36322. /**
  36323. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36324. * default is FLOAT
  36325. */
  36326. attributeType?: number;
  36327. /**
  36328. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36329. */
  36330. normalized?: boolean;
  36331. }
  36332. }
  36333. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36334. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36335. import { Nullable } from "babylonjs/types";
  36336. module "babylonjs/Engines/thinEngine" {
  36337. interface ThinEngine {
  36338. /**
  36339. * Update a video texture
  36340. * @param texture defines the texture to update
  36341. * @param video defines the video element to use
  36342. * @param invertY defines if data must be stored with Y axis inverted
  36343. */
  36344. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36345. }
  36346. }
  36347. }
  36348. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36350. import { Nullable } from "babylonjs/types";
  36351. module "babylonjs/Engines/thinEngine" {
  36352. interface ThinEngine {
  36353. /**
  36354. * Creates a dynamic texture
  36355. * @param width defines the width of the texture
  36356. * @param height defines the height of the texture
  36357. * @param generateMipMaps defines if the engine should generate the mip levels
  36358. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36359. * @returns the dynamic texture inside an InternalTexture
  36360. */
  36361. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36362. /**
  36363. * Update the content of a dynamic texture
  36364. * @param texture defines the texture to update
  36365. * @param canvas defines the canvas containing the source
  36366. * @param invertY defines if data must be stored with Y axis inverted
  36367. * @param premulAlpha defines if alpha is stored as premultiplied
  36368. * @param format defines the format of the data
  36369. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36370. */
  36371. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36372. }
  36373. }
  36374. }
  36375. declare module "babylonjs/Materials/Textures/videoTexture" {
  36376. import { Observable } from "babylonjs/Misc/observable";
  36377. import { Nullable } from "babylonjs/types";
  36378. import { Scene } from "babylonjs/scene";
  36379. import { Texture } from "babylonjs/Materials/Textures/texture";
  36380. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36381. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36382. /**
  36383. * Settings for finer control over video usage
  36384. */
  36385. export interface VideoTextureSettings {
  36386. /**
  36387. * Applies `autoplay` to video, if specified
  36388. */
  36389. autoPlay?: boolean;
  36390. /**
  36391. * Applies `loop` to video, if specified
  36392. */
  36393. loop?: boolean;
  36394. /**
  36395. * Automatically updates internal texture from video at every frame in the render loop
  36396. */
  36397. autoUpdateTexture: boolean;
  36398. /**
  36399. * Image src displayed during the video loading or until the user interacts with the video.
  36400. */
  36401. poster?: string;
  36402. }
  36403. /**
  36404. * If you want to display a video in your scene, this is the special texture for that.
  36405. * This special texture works similar to other textures, with the exception of a few parameters.
  36406. * @see https://doc.babylonjs.com/how_to/video_texture
  36407. */
  36408. export class VideoTexture extends Texture {
  36409. /**
  36410. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36411. */
  36412. readonly autoUpdateTexture: boolean;
  36413. /**
  36414. * The video instance used by the texture internally
  36415. */
  36416. readonly video: HTMLVideoElement;
  36417. private _onUserActionRequestedObservable;
  36418. /**
  36419. * Event triggerd when a dom action is required by the user to play the video.
  36420. * This happens due to recent changes in browser policies preventing video to auto start.
  36421. */
  36422. get onUserActionRequestedObservable(): Observable<Texture>;
  36423. private _generateMipMaps;
  36424. private _stillImageCaptured;
  36425. private _displayingPosterTexture;
  36426. private _settings;
  36427. private _createInternalTextureOnEvent;
  36428. private _frameId;
  36429. private _currentSrc;
  36430. /**
  36431. * Creates a video texture.
  36432. * If you want to display a video in your scene, this is the special texture for that.
  36433. * This special texture works similar to other textures, with the exception of a few parameters.
  36434. * @see https://doc.babylonjs.com/how_to/video_texture
  36435. * @param name optional name, will detect from video source, if not defined
  36436. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36437. * @param scene is obviously the current scene.
  36438. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36439. * @param invertY is false by default but can be used to invert video on Y axis
  36440. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36441. * @param settings allows finer control over video usage
  36442. */
  36443. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36444. private _getName;
  36445. private _getVideo;
  36446. private _createInternalTexture;
  36447. private reset;
  36448. /**
  36449. * @hidden Internal method to initiate `update`.
  36450. */
  36451. _rebuild(): void;
  36452. /**
  36453. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36454. */
  36455. update(): void;
  36456. /**
  36457. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36458. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36459. */
  36460. updateTexture(isVisible: boolean): void;
  36461. protected _updateInternalTexture: () => void;
  36462. /**
  36463. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36464. * @param url New url.
  36465. */
  36466. updateURL(url: string): void;
  36467. /**
  36468. * Clones the texture.
  36469. * @returns the cloned texture
  36470. */
  36471. clone(): VideoTexture;
  36472. /**
  36473. * Dispose the texture and release its associated resources.
  36474. */
  36475. dispose(): void;
  36476. /**
  36477. * Creates a video texture straight from a stream.
  36478. * @param scene Define the scene the texture should be created in
  36479. * @param stream Define the stream the texture should be created from
  36480. * @returns The created video texture as a promise
  36481. */
  36482. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36483. /**
  36484. * Creates a video texture straight from your WebCam video feed.
  36485. * @param scene Define the scene the texture should be created in
  36486. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36487. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36488. * @returns The created video texture as a promise
  36489. */
  36490. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36491. minWidth: number;
  36492. maxWidth: number;
  36493. minHeight: number;
  36494. maxHeight: number;
  36495. deviceId: string;
  36496. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36497. /**
  36498. * Creates a video texture straight from your WebCam video feed.
  36499. * @param scene Define the scene the texture should be created in
  36500. * @param onReady Define a callback to triggered once the texture will be ready
  36501. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36502. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36503. */
  36504. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36505. minWidth: number;
  36506. maxWidth: number;
  36507. minHeight: number;
  36508. maxHeight: number;
  36509. deviceId: string;
  36510. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36511. }
  36512. }
  36513. declare module "babylonjs/Engines/thinEngine" {
  36514. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36515. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36516. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36517. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36518. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36519. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36520. import { Observable } from "babylonjs/Misc/observable";
  36521. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36522. import { StencilState } from "babylonjs/States/stencilState";
  36523. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36524. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36525. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36526. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36527. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36528. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36529. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36530. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36531. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36532. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36533. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36534. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36535. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36536. import { WebRequest } from "babylonjs/Misc/webRequest";
  36537. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36538. /**
  36539. * Defines the interface used by objects working like Scene
  36540. * @hidden
  36541. */
  36542. export interface ISceneLike {
  36543. _addPendingData(data: any): void;
  36544. _removePendingData(data: any): void;
  36545. offlineProvider: IOfflineProvider;
  36546. }
  36547. /**
  36548. * Information about the current host
  36549. */
  36550. export interface HostInformation {
  36551. /**
  36552. * Defines if the current host is a mobile
  36553. */
  36554. isMobile: boolean;
  36555. }
  36556. /** Interface defining initialization parameters for Engine class */
  36557. export interface EngineOptions extends WebGLContextAttributes {
  36558. /**
  36559. * Defines if the engine should no exceed a specified device ratio
  36560. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36561. */
  36562. limitDeviceRatio?: number;
  36563. /**
  36564. * Defines if webvr should be enabled automatically
  36565. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36566. */
  36567. autoEnableWebVR?: boolean;
  36568. /**
  36569. * Defines if webgl2 should be turned off even if supported
  36570. * @see https://doc.babylonjs.com/features/webgl2
  36571. */
  36572. disableWebGL2Support?: boolean;
  36573. /**
  36574. * Defines if webaudio should be initialized as well
  36575. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36576. */
  36577. audioEngine?: boolean;
  36578. /**
  36579. * Defines if animations should run using a deterministic lock step
  36580. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36581. */
  36582. deterministicLockstep?: boolean;
  36583. /** Defines the maximum steps to use with deterministic lock step mode */
  36584. lockstepMaxSteps?: number;
  36585. /** Defines the seconds between each deterministic lock step */
  36586. timeStep?: number;
  36587. /**
  36588. * Defines that engine should ignore context lost events
  36589. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36590. */
  36591. doNotHandleContextLost?: boolean;
  36592. /**
  36593. * Defines that engine should ignore modifying touch action attribute and style
  36594. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36595. */
  36596. doNotHandleTouchAction?: boolean;
  36597. /**
  36598. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36599. */
  36600. useHighPrecisionFloats?: boolean;
  36601. /**
  36602. * Make the canvas XR Compatible for XR sessions
  36603. */
  36604. xrCompatible?: boolean;
  36605. /**
  36606. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36607. */
  36608. useHighPrecisionMatrix?: boolean;
  36609. }
  36610. /**
  36611. * The base engine class (root of all engines)
  36612. */
  36613. export class ThinEngine {
  36614. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36615. static ExceptionList: ({
  36616. key: string;
  36617. capture: string;
  36618. captureConstraint: number;
  36619. targets: string[];
  36620. } | {
  36621. key: string;
  36622. capture: null;
  36623. captureConstraint: null;
  36624. targets: string[];
  36625. })[];
  36626. /** @hidden */
  36627. static _TextureLoaders: IInternalTextureLoader[];
  36628. /**
  36629. * Returns the current npm package of the sdk
  36630. */
  36631. static get NpmPackage(): string;
  36632. /**
  36633. * Returns the current version of the framework
  36634. */
  36635. static get Version(): string;
  36636. /**
  36637. * Returns a string describing the current engine
  36638. */
  36639. get description(): string;
  36640. /**
  36641. * Gets or sets the epsilon value used by collision engine
  36642. */
  36643. static CollisionsEpsilon: number;
  36644. /**
  36645. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36646. */
  36647. static get ShadersRepository(): string;
  36648. static set ShadersRepository(value: string);
  36649. /** @hidden */
  36650. _shaderProcessor: IShaderProcessor;
  36651. /**
  36652. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36653. */
  36654. forcePOTTextures: boolean;
  36655. /**
  36656. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36657. */
  36658. isFullscreen: boolean;
  36659. /**
  36660. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36661. */
  36662. cullBackFaces: boolean;
  36663. /**
  36664. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36665. */
  36666. renderEvenInBackground: boolean;
  36667. /**
  36668. * Gets or sets a boolean indicating that cache can be kept between frames
  36669. */
  36670. preventCacheWipeBetweenFrames: boolean;
  36671. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36672. validateShaderPrograms: boolean;
  36673. /**
  36674. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36675. * This can provide greater z depth for distant objects.
  36676. */
  36677. useReverseDepthBuffer: boolean;
  36678. /**
  36679. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36680. */
  36681. disableUniformBuffers: boolean;
  36682. /** @hidden */
  36683. _uniformBuffers: UniformBuffer[];
  36684. /**
  36685. * Gets a boolean indicating that the engine supports uniform buffers
  36686. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36687. */
  36688. get supportsUniformBuffers(): boolean;
  36689. /** @hidden */
  36690. _gl: WebGLRenderingContext;
  36691. /** @hidden */
  36692. _webGLVersion: number;
  36693. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36694. protected _windowIsBackground: boolean;
  36695. protected _creationOptions: EngineOptions;
  36696. protected _highPrecisionShadersAllowed: boolean;
  36697. /** @hidden */
  36698. get _shouldUseHighPrecisionShader(): boolean;
  36699. /**
  36700. * Gets a boolean indicating that only power of 2 textures are supported
  36701. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36702. */
  36703. get needPOTTextures(): boolean;
  36704. /** @hidden */
  36705. _badOS: boolean;
  36706. /** @hidden */
  36707. _badDesktopOS: boolean;
  36708. private _hardwareScalingLevel;
  36709. /** @hidden */
  36710. _caps: EngineCapabilities;
  36711. private _isStencilEnable;
  36712. private _glVersion;
  36713. private _glRenderer;
  36714. private _glVendor;
  36715. /** @hidden */
  36716. _videoTextureSupported: boolean;
  36717. protected _renderingQueueLaunched: boolean;
  36718. protected _activeRenderLoops: (() => void)[];
  36719. /**
  36720. * Observable signaled when a context lost event is raised
  36721. */
  36722. onContextLostObservable: Observable<ThinEngine>;
  36723. /**
  36724. * Observable signaled when a context restored event is raised
  36725. */
  36726. onContextRestoredObservable: Observable<ThinEngine>;
  36727. private _onContextLost;
  36728. private _onContextRestored;
  36729. protected _contextWasLost: boolean;
  36730. /** @hidden */
  36731. _doNotHandleContextLost: boolean;
  36732. /**
  36733. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36734. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36735. */
  36736. get doNotHandleContextLost(): boolean;
  36737. set doNotHandleContextLost(value: boolean);
  36738. /**
  36739. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36740. */
  36741. disableVertexArrayObjects: boolean;
  36742. /** @hidden */
  36743. protected _colorWrite: boolean;
  36744. /** @hidden */
  36745. protected _colorWriteChanged: boolean;
  36746. /** @hidden */
  36747. protected _depthCullingState: DepthCullingState;
  36748. /** @hidden */
  36749. protected _stencilState: StencilState;
  36750. /** @hidden */
  36751. _alphaState: AlphaState;
  36752. /** @hidden */
  36753. _alphaMode: number;
  36754. /** @hidden */
  36755. _alphaEquation: number;
  36756. /** @hidden */
  36757. _internalTexturesCache: InternalTexture[];
  36758. /** @hidden */
  36759. protected _activeChannel: number;
  36760. private _currentTextureChannel;
  36761. /** @hidden */
  36762. protected _boundTexturesCache: {
  36763. [key: string]: Nullable<InternalTexture>;
  36764. };
  36765. /** @hidden */
  36766. protected _currentEffect: Nullable<Effect>;
  36767. /** @hidden */
  36768. protected _currentProgram: Nullable<WebGLProgram>;
  36769. private _compiledEffects;
  36770. private _vertexAttribArraysEnabled;
  36771. /** @hidden */
  36772. protected _cachedViewport: Nullable<IViewportLike>;
  36773. private _cachedVertexArrayObject;
  36774. /** @hidden */
  36775. protected _cachedVertexBuffers: any;
  36776. /** @hidden */
  36777. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36778. /** @hidden */
  36779. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36780. /** @hidden */
  36781. _currentRenderTarget: Nullable<InternalTexture>;
  36782. private _uintIndicesCurrentlySet;
  36783. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36784. /** @hidden */
  36785. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36786. /** @hidden */
  36787. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36788. private _currentBufferPointers;
  36789. private _currentInstanceLocations;
  36790. private _currentInstanceBuffers;
  36791. private _textureUnits;
  36792. /** @hidden */
  36793. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36794. /** @hidden */
  36795. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36796. /** @hidden */
  36797. _boundRenderFunction: any;
  36798. private _vaoRecordInProgress;
  36799. private _mustWipeVertexAttributes;
  36800. private _emptyTexture;
  36801. private _emptyCubeTexture;
  36802. private _emptyTexture3D;
  36803. private _emptyTexture2DArray;
  36804. /** @hidden */
  36805. _frameHandler: number;
  36806. private _nextFreeTextureSlots;
  36807. private _maxSimultaneousTextures;
  36808. private _activeRequests;
  36809. /** @hidden */
  36810. _transformTextureUrl: Nullable<(url: string) => string>;
  36811. /**
  36812. * Gets information about the current host
  36813. */
  36814. hostInformation: HostInformation;
  36815. protected get _supportsHardwareTextureRescaling(): boolean;
  36816. private _framebufferDimensionsObject;
  36817. /**
  36818. * sets the object from which width and height will be taken from when getting render width and height
  36819. * Will fallback to the gl object
  36820. * @param dimensions the framebuffer width and height that will be used.
  36821. */
  36822. set framebufferDimensionsObject(dimensions: Nullable<{
  36823. framebufferWidth: number;
  36824. framebufferHeight: number;
  36825. }>);
  36826. /**
  36827. * Gets the current viewport
  36828. */
  36829. get currentViewport(): Nullable<IViewportLike>;
  36830. /**
  36831. * Gets the default empty texture
  36832. */
  36833. get emptyTexture(): InternalTexture;
  36834. /**
  36835. * Gets the default empty 3D texture
  36836. */
  36837. get emptyTexture3D(): InternalTexture;
  36838. /**
  36839. * Gets the default empty 2D array texture
  36840. */
  36841. get emptyTexture2DArray(): InternalTexture;
  36842. /**
  36843. * Gets the default empty cube texture
  36844. */
  36845. get emptyCubeTexture(): InternalTexture;
  36846. /**
  36847. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36848. */
  36849. readonly premultipliedAlpha: boolean;
  36850. /**
  36851. * Observable event triggered before each texture is initialized
  36852. */
  36853. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36854. /**
  36855. * Creates a new engine
  36856. * @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
  36857. * @param antialias defines enable antialiasing (default: false)
  36858. * @param options defines further options to be sent to the getContext() function
  36859. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36860. */
  36861. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36862. private _rebuildInternalTextures;
  36863. private _rebuildEffects;
  36864. /**
  36865. * Gets a boolean indicating if all created effects are ready
  36866. * @returns true if all effects are ready
  36867. */
  36868. areAllEffectsReady(): boolean;
  36869. protected _rebuildBuffers(): void;
  36870. protected _initGLContext(): void;
  36871. /**
  36872. * Gets version of the current webGL context
  36873. */
  36874. get webGLVersion(): number;
  36875. /**
  36876. * Gets a string identifying the name of the class
  36877. * @returns "Engine" string
  36878. */
  36879. getClassName(): string;
  36880. /**
  36881. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36882. */
  36883. get isStencilEnable(): boolean;
  36884. /** @hidden */
  36885. _prepareWorkingCanvas(): void;
  36886. /**
  36887. * Reset the texture cache to empty state
  36888. */
  36889. resetTextureCache(): void;
  36890. /**
  36891. * Gets an object containing information about the current webGL context
  36892. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36893. */
  36894. getGlInfo(): {
  36895. vendor: string;
  36896. renderer: string;
  36897. version: string;
  36898. };
  36899. /**
  36900. * Defines the hardware scaling level.
  36901. * By default the hardware scaling level is computed from the window device ratio.
  36902. * 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.
  36903. * @param level defines the level to use
  36904. */
  36905. setHardwareScalingLevel(level: number): void;
  36906. /**
  36907. * Gets the current hardware scaling level.
  36908. * By default the hardware scaling level is computed from the window device ratio.
  36909. * 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.
  36910. * @returns a number indicating the current hardware scaling level
  36911. */
  36912. getHardwareScalingLevel(): number;
  36913. /**
  36914. * Gets the list of loaded textures
  36915. * @returns an array containing all loaded textures
  36916. */
  36917. getLoadedTexturesCache(): InternalTexture[];
  36918. /**
  36919. * Gets the object containing all engine capabilities
  36920. * @returns the EngineCapabilities object
  36921. */
  36922. getCaps(): EngineCapabilities;
  36923. /**
  36924. * stop executing a render loop function and remove it from the execution array
  36925. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36926. */
  36927. stopRenderLoop(renderFunction?: () => void): void;
  36928. /** @hidden */
  36929. _renderLoop(): void;
  36930. /**
  36931. * Gets the HTML canvas attached with the current webGL context
  36932. * @returns a HTML canvas
  36933. */
  36934. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36935. /**
  36936. * Gets host window
  36937. * @returns the host window object
  36938. */
  36939. getHostWindow(): Nullable<Window>;
  36940. /**
  36941. * Gets the current render width
  36942. * @param useScreen defines if screen size must be used (or the current render target if any)
  36943. * @returns a number defining the current render width
  36944. */
  36945. getRenderWidth(useScreen?: boolean): number;
  36946. /**
  36947. * Gets the current render height
  36948. * @param useScreen defines if screen size must be used (or the current render target if any)
  36949. * @returns a number defining the current render height
  36950. */
  36951. getRenderHeight(useScreen?: boolean): number;
  36952. /**
  36953. * Can be used to override the current requestAnimationFrame requester.
  36954. * @hidden
  36955. */
  36956. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36957. /**
  36958. * Register and execute a render loop. The engine can have more than one render function
  36959. * @param renderFunction defines the function to continuously execute
  36960. */
  36961. runRenderLoop(renderFunction: () => void): void;
  36962. /**
  36963. * Clear the current render buffer or the current render target (if any is set up)
  36964. * @param color defines the color to use
  36965. * @param backBuffer defines if the back buffer must be cleared
  36966. * @param depth defines if the depth buffer must be cleared
  36967. * @param stencil defines if the stencil buffer must be cleared
  36968. */
  36969. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36970. private _viewportCached;
  36971. /** @hidden */
  36972. _viewport(x: number, y: number, width: number, height: number): void;
  36973. /**
  36974. * Set the WebGL's viewport
  36975. * @param viewport defines the viewport element to be used
  36976. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36977. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36978. */
  36979. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36980. /**
  36981. * Begin a new frame
  36982. */
  36983. beginFrame(): void;
  36984. /**
  36985. * Enf the current frame
  36986. */
  36987. endFrame(): void;
  36988. /**
  36989. * Resize the view according to the canvas' size
  36990. */
  36991. resize(): void;
  36992. /**
  36993. * Force a specific size of the canvas
  36994. * @param width defines the new canvas' width
  36995. * @param height defines the new canvas' height
  36996. * @returns true if the size was changed
  36997. */
  36998. setSize(width: number, height: number): boolean;
  36999. /**
  37000. * Binds the frame buffer to the specified texture.
  37001. * @param texture The texture to render to or null for the default canvas
  37002. * @param faceIndex The face of the texture to render to in case of cube texture
  37003. * @param requiredWidth The width of the target to render to
  37004. * @param requiredHeight The height of the target to render to
  37005. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  37006. * @param lodLevel defines the lod level to bind to the frame buffer
  37007. * @param layer defines the 2d array index to bind to frame buffer to
  37008. */
  37009. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  37010. /** @hidden */
  37011. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  37012. /**
  37013. * Unbind the current render target texture from the webGL context
  37014. * @param texture defines the render target texture to unbind
  37015. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  37016. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  37017. */
  37018. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  37019. /**
  37020. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  37021. */
  37022. flushFramebuffer(): void;
  37023. /**
  37024. * Unbind the current render target and bind the default framebuffer
  37025. */
  37026. restoreDefaultFramebuffer(): void;
  37027. /** @hidden */
  37028. protected _resetVertexBufferBinding(): void;
  37029. /**
  37030. * Creates a vertex buffer
  37031. * @param data the data for the vertex buffer
  37032. * @returns the new WebGL static buffer
  37033. */
  37034. createVertexBuffer(data: DataArray): DataBuffer;
  37035. private _createVertexBuffer;
  37036. /**
  37037. * Creates a dynamic vertex buffer
  37038. * @param data the data for the dynamic vertex buffer
  37039. * @returns the new WebGL dynamic buffer
  37040. */
  37041. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  37042. protected _resetIndexBufferBinding(): void;
  37043. /**
  37044. * Creates a new index buffer
  37045. * @param indices defines the content of the index buffer
  37046. * @param updatable defines if the index buffer must be updatable
  37047. * @returns a new webGL buffer
  37048. */
  37049. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  37050. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  37051. /**
  37052. * Bind a webGL buffer to the webGL context
  37053. * @param buffer defines the buffer to bind
  37054. */
  37055. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  37056. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  37057. private bindBuffer;
  37058. /**
  37059. * update the bound buffer with the given data
  37060. * @param data defines the data to update
  37061. */
  37062. updateArrayBuffer(data: Float32Array): void;
  37063. private _vertexAttribPointer;
  37064. /** @hidden */
  37065. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  37066. private _bindVertexBuffersAttributes;
  37067. /**
  37068. * Records a vertex array object
  37069. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37070. * @param vertexBuffers defines the list of vertex buffers to store
  37071. * @param indexBuffer defines the index buffer to store
  37072. * @param effect defines the effect to store
  37073. * @returns the new vertex array object
  37074. */
  37075. recordVertexArrayObject(vertexBuffers: {
  37076. [key: string]: VertexBuffer;
  37077. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  37078. /**
  37079. * Bind a specific vertex array object
  37080. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37081. * @param vertexArrayObject defines the vertex array object to bind
  37082. * @param indexBuffer defines the index buffer to bind
  37083. */
  37084. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  37085. /**
  37086. * Bind webGl buffers directly to the webGL context
  37087. * @param vertexBuffer defines the vertex buffer to bind
  37088. * @param indexBuffer defines the index buffer to bind
  37089. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37090. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37091. * @param effect defines the effect associated with the vertex buffer
  37092. */
  37093. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37094. private _unbindVertexArrayObject;
  37095. /**
  37096. * Bind a list of vertex buffers to the webGL context
  37097. * @param vertexBuffers defines the list of vertex buffers to bind
  37098. * @param indexBuffer defines the index buffer to bind
  37099. * @param effect defines the effect associated with the vertex buffers
  37100. */
  37101. bindBuffers(vertexBuffers: {
  37102. [key: string]: Nullable<VertexBuffer>;
  37103. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37104. /**
  37105. * Unbind all instance attributes
  37106. */
  37107. unbindInstanceAttributes(): void;
  37108. /**
  37109. * Release and free the memory of a vertex array object
  37110. * @param vao defines the vertex array object to delete
  37111. */
  37112. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37113. /** @hidden */
  37114. _releaseBuffer(buffer: DataBuffer): boolean;
  37115. protected _deleteBuffer(buffer: DataBuffer): void;
  37116. /**
  37117. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37118. * @param instancesBuffer defines the webGL buffer to update and bind
  37119. * @param data defines the data to store in the buffer
  37120. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37121. */
  37122. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37123. /**
  37124. * Bind the content of a webGL buffer used with instantiation
  37125. * @param instancesBuffer defines the webGL buffer to bind
  37126. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37127. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37128. */
  37129. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37130. /**
  37131. * Disable the instance attribute corresponding to the name in parameter
  37132. * @param name defines the name of the attribute to disable
  37133. */
  37134. disableInstanceAttributeByName(name: string): void;
  37135. /**
  37136. * Disable the instance attribute corresponding to the location in parameter
  37137. * @param attributeLocation defines the attribute location of the attribute to disable
  37138. */
  37139. disableInstanceAttribute(attributeLocation: number): void;
  37140. /**
  37141. * Disable the attribute corresponding to the location in parameter
  37142. * @param attributeLocation defines the attribute location of the attribute to disable
  37143. */
  37144. disableAttributeByIndex(attributeLocation: number): void;
  37145. /**
  37146. * Send a draw order
  37147. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37148. * @param indexStart defines the starting index
  37149. * @param indexCount defines the number of index to draw
  37150. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37151. */
  37152. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37153. /**
  37154. * Draw a list of points
  37155. * @param verticesStart defines the index of first vertex to draw
  37156. * @param verticesCount defines the count of vertices to draw
  37157. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37158. */
  37159. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37160. /**
  37161. * Draw a list of unindexed primitives
  37162. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37163. * @param verticesStart defines the index of first vertex to draw
  37164. * @param verticesCount defines the count of vertices to draw
  37165. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37166. */
  37167. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37168. /**
  37169. * Draw a list of indexed primitives
  37170. * @param fillMode defines the primitive to use
  37171. * @param indexStart defines the starting index
  37172. * @param indexCount defines the number of index to draw
  37173. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37174. */
  37175. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37176. /**
  37177. * Draw a list of unindexed primitives
  37178. * @param fillMode defines the primitive to use
  37179. * @param verticesStart defines the index of first vertex to draw
  37180. * @param verticesCount defines the count of vertices to draw
  37181. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37182. */
  37183. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37184. private _drawMode;
  37185. /** @hidden */
  37186. protected _reportDrawCall(): void;
  37187. /** @hidden */
  37188. _releaseEffect(effect: Effect): void;
  37189. /** @hidden */
  37190. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37191. /**
  37192. * Create a new effect (used to store vertex/fragment shaders)
  37193. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37194. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37195. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37196. * @param samplers defines an array of string used to represent textures
  37197. * @param defines defines the string containing the defines to use to compile the shaders
  37198. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37199. * @param onCompiled defines a function to call when the effect creation is successful
  37200. * @param onError defines a function to call when the effect creation has failed
  37201. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37202. * @returns the new Effect
  37203. */
  37204. 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;
  37205. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37206. private _compileShader;
  37207. private _compileRawShader;
  37208. /** @hidden */
  37209. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37210. /**
  37211. * Directly creates a webGL program
  37212. * @param pipelineContext defines the pipeline context to attach to
  37213. * @param vertexCode defines the vertex shader code to use
  37214. * @param fragmentCode defines the fragment shader code to use
  37215. * @param context defines the webGL context to use (if not set, the current one will be used)
  37216. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37217. * @returns the new webGL program
  37218. */
  37219. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37220. /**
  37221. * Creates a webGL program
  37222. * @param pipelineContext defines the pipeline context to attach to
  37223. * @param vertexCode defines the vertex shader code to use
  37224. * @param fragmentCode defines the fragment shader code to use
  37225. * @param defines defines the string containing the defines to use to compile the shaders
  37226. * @param context defines the webGL context to use (if not set, the current one will be used)
  37227. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37228. * @returns the new webGL program
  37229. */
  37230. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37231. /**
  37232. * Creates a new pipeline context
  37233. * @returns the new pipeline
  37234. */
  37235. createPipelineContext(): IPipelineContext;
  37236. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37237. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37238. /** @hidden */
  37239. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37240. /** @hidden */
  37241. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37242. /** @hidden */
  37243. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37244. /**
  37245. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37246. * @param pipelineContext defines the pipeline context to use
  37247. * @param uniformsNames defines the list of uniform names
  37248. * @returns an array of webGL uniform locations
  37249. */
  37250. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37251. /**
  37252. * Gets the lsit of active attributes for a given webGL program
  37253. * @param pipelineContext defines the pipeline context to use
  37254. * @param attributesNames defines the list of attribute names to get
  37255. * @returns an array of indices indicating the offset of each attribute
  37256. */
  37257. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37258. /**
  37259. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37260. * @param effect defines the effect to activate
  37261. */
  37262. enableEffect(effect: Nullable<Effect>): void;
  37263. /**
  37264. * Set the value of an uniform to a number (int)
  37265. * @param uniform defines the webGL uniform location where to store the value
  37266. * @param value defines the int number to store
  37267. * @returns true if the value was set
  37268. */
  37269. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37270. /**
  37271. * Set the value of an uniform to an array of int32
  37272. * @param uniform defines the webGL uniform location where to store the value
  37273. * @param array defines the array of int32 to store
  37274. * @returns true if the value was set
  37275. */
  37276. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37277. /**
  37278. * Set the value of an uniform to an array of int32 (stored as vec2)
  37279. * @param uniform defines the webGL uniform location where to store the value
  37280. * @param array defines the array of int32 to store
  37281. * @returns true if the value was set
  37282. */
  37283. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37284. /**
  37285. * Set the value of an uniform to an array of int32 (stored as vec3)
  37286. * @param uniform defines the webGL uniform location where to store the value
  37287. * @param array defines the array of int32 to store
  37288. * @returns true if the value was set
  37289. */
  37290. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37291. /**
  37292. * Set the value of an uniform to an array of int32 (stored as vec4)
  37293. * @param uniform defines the webGL uniform location where to store the value
  37294. * @param array defines the array of int32 to store
  37295. * @returns true if the value was set
  37296. */
  37297. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37298. /**
  37299. * Set the value of an uniform to an array of number
  37300. * @param uniform defines the webGL uniform location where to store the value
  37301. * @param array defines the array of number to store
  37302. * @returns true if the value was set
  37303. */
  37304. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37305. /**
  37306. * Set the value of an uniform to an array of number (stored as vec2)
  37307. * @param uniform defines the webGL uniform location where to store the value
  37308. * @param array defines the array of number to store
  37309. * @returns true if the value was set
  37310. */
  37311. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37312. /**
  37313. * Set the value of an uniform to an array of number (stored as vec3)
  37314. * @param uniform defines the webGL uniform location where to store the value
  37315. * @param array defines the array of number to store
  37316. * @returns true if the value was set
  37317. */
  37318. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37319. /**
  37320. * Set the value of an uniform to an array of number (stored as vec4)
  37321. * @param uniform defines the webGL uniform location where to store the value
  37322. * @param array defines the array of number to store
  37323. * @returns true if the value was set
  37324. */
  37325. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37326. /**
  37327. * Set the value of an uniform to an array of float32 (stored as matrices)
  37328. * @param uniform defines the webGL uniform location where to store the value
  37329. * @param matrices defines the array of float32 to store
  37330. * @returns true if the value was set
  37331. */
  37332. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  37333. /**
  37334. * Set the value of an uniform to a matrix (3x3)
  37335. * @param uniform defines the webGL uniform location where to store the value
  37336. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37337. * @returns true if the value was set
  37338. */
  37339. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37340. /**
  37341. * Set the value of an uniform to a matrix (2x2)
  37342. * @param uniform defines the webGL uniform location where to store the value
  37343. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37344. * @returns true if the value was set
  37345. */
  37346. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37347. /**
  37348. * Set the value of an uniform to a number (float)
  37349. * @param uniform defines the webGL uniform location where to store the value
  37350. * @param value defines the float number to store
  37351. * @returns true if the value was transfered
  37352. */
  37353. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37354. /**
  37355. * Set the value of an uniform to a vec2
  37356. * @param uniform defines the webGL uniform location where to store the value
  37357. * @param x defines the 1st component of the value
  37358. * @param y defines the 2nd component of the value
  37359. * @returns true if the value was set
  37360. */
  37361. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  37362. /**
  37363. * Set the value of an uniform to a vec3
  37364. * @param uniform defines the webGL uniform location where to store the value
  37365. * @param x defines the 1st component of the value
  37366. * @param y defines the 2nd component of the value
  37367. * @param z defines the 3rd component of the value
  37368. * @returns true if the value was set
  37369. */
  37370. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  37371. /**
  37372. * Set the value of an uniform to a vec4
  37373. * @param uniform defines the webGL uniform location where to store the value
  37374. * @param x defines the 1st component of the value
  37375. * @param y defines the 2nd component of the value
  37376. * @param z defines the 3rd component of the value
  37377. * @param w defines the 4th component of the value
  37378. * @returns true if the value was set
  37379. */
  37380. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  37381. /**
  37382. * Apply all cached states (depth, culling, stencil and alpha)
  37383. */
  37384. applyStates(): void;
  37385. /**
  37386. * Enable or disable color writing
  37387. * @param enable defines the state to set
  37388. */
  37389. setColorWrite(enable: boolean): void;
  37390. /**
  37391. * Gets a boolean indicating if color writing is enabled
  37392. * @returns the current color writing state
  37393. */
  37394. getColorWrite(): boolean;
  37395. /**
  37396. * Gets the depth culling state manager
  37397. */
  37398. get depthCullingState(): DepthCullingState;
  37399. /**
  37400. * Gets the alpha state manager
  37401. */
  37402. get alphaState(): AlphaState;
  37403. /**
  37404. * Gets the stencil state manager
  37405. */
  37406. get stencilState(): StencilState;
  37407. /**
  37408. * Clears the list of texture accessible through engine.
  37409. * This can help preventing texture load conflict due to name collision.
  37410. */
  37411. clearInternalTexturesCache(): void;
  37412. /**
  37413. * Force the entire cache to be cleared
  37414. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37415. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37416. */
  37417. wipeCaches(bruteForce?: boolean): void;
  37418. /** @hidden */
  37419. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37420. min: number;
  37421. mag: number;
  37422. };
  37423. /** @hidden */
  37424. _createTexture(): WebGLTexture;
  37425. /**
  37426. * Usually called from Texture.ts.
  37427. * Passed information to create a WebGLTexture
  37428. * @param url defines a value which contains one of the following:
  37429. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37430. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37431. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37432. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37433. * @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)
  37434. * @param scene needed for loading to the correct scene
  37435. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37436. * @param onLoad optional callback to be called upon successful completion
  37437. * @param onError optional callback to be called upon failure
  37438. * @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
  37439. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37440. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37441. * @param forcedExtension defines the extension to use to pick the right loader
  37442. * @param mimeType defines an optional mime type
  37443. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37444. */
  37445. 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;
  37446. /**
  37447. * Loads an image as an HTMLImageElement.
  37448. * @param input url string, ArrayBuffer, or Blob to load
  37449. * @param onLoad callback called when the image successfully loads
  37450. * @param onError callback called when the image fails to load
  37451. * @param offlineProvider offline provider for caching
  37452. * @param mimeType optional mime type
  37453. * @returns the HTMLImageElement of the loaded image
  37454. * @hidden
  37455. */
  37456. 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>;
  37457. /**
  37458. * @hidden
  37459. */
  37460. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37461. private _unpackFlipYCached;
  37462. /**
  37463. * In case you are sharing the context with other applications, it might
  37464. * be interested to not cache the unpack flip y state to ensure a consistent
  37465. * value would be set.
  37466. */
  37467. enableUnpackFlipYCached: boolean;
  37468. /** @hidden */
  37469. _unpackFlipY(value: boolean): void;
  37470. /** @hidden */
  37471. _getUnpackAlignement(): number;
  37472. private _getTextureTarget;
  37473. /**
  37474. * Update the sampling mode of a given texture
  37475. * @param samplingMode defines the required sampling mode
  37476. * @param texture defines the texture to update
  37477. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37478. */
  37479. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37480. /**
  37481. * Update the sampling mode of a given texture
  37482. * @param texture defines the texture to update
  37483. * @param wrapU defines the texture wrap mode of the u coordinates
  37484. * @param wrapV defines the texture wrap mode of the v coordinates
  37485. * @param wrapR defines the texture wrap mode of the r coordinates
  37486. */
  37487. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37488. /** @hidden */
  37489. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37490. width: number;
  37491. height: number;
  37492. layers?: number;
  37493. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37494. /** @hidden */
  37495. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37496. /** @hidden */
  37497. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37498. /**
  37499. * Update a portion of an internal texture
  37500. * @param texture defines the texture to update
  37501. * @param imageData defines the data to store into the texture
  37502. * @param xOffset defines the x coordinates of the update rectangle
  37503. * @param yOffset defines the y coordinates of the update rectangle
  37504. * @param width defines the width of the update rectangle
  37505. * @param height defines the height of the update rectangle
  37506. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37507. * @param lod defines the lod level to update (0 by default)
  37508. */
  37509. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37510. /** @hidden */
  37511. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37512. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37513. private _prepareWebGLTexture;
  37514. /** @hidden */
  37515. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37516. private _getDepthStencilBuffer;
  37517. /** @hidden */
  37518. _releaseFramebufferObjects(texture: InternalTexture): void;
  37519. /** @hidden */
  37520. _releaseTexture(texture: InternalTexture): void;
  37521. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37522. protected _setProgram(program: WebGLProgram): void;
  37523. protected _boundUniforms: {
  37524. [key: number]: WebGLUniformLocation;
  37525. };
  37526. /**
  37527. * Binds an effect to the webGL context
  37528. * @param effect defines the effect to bind
  37529. */
  37530. bindSamplers(effect: Effect): void;
  37531. private _activateCurrentTexture;
  37532. /** @hidden */
  37533. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37534. /** @hidden */
  37535. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37536. /**
  37537. * Unbind all textures from the webGL context
  37538. */
  37539. unbindAllTextures(): void;
  37540. /**
  37541. * Sets a texture to the according uniform.
  37542. * @param channel The texture channel
  37543. * @param uniform The uniform to set
  37544. * @param texture The texture to apply
  37545. */
  37546. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37547. private _bindSamplerUniformToChannel;
  37548. private _getTextureWrapMode;
  37549. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37550. /**
  37551. * Sets an array of texture to the webGL context
  37552. * @param channel defines the channel where the texture array must be set
  37553. * @param uniform defines the associated uniform location
  37554. * @param textures defines the array of textures to bind
  37555. */
  37556. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37557. /** @hidden */
  37558. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37559. private _setTextureParameterFloat;
  37560. private _setTextureParameterInteger;
  37561. /**
  37562. * Unbind all vertex attributes from the webGL context
  37563. */
  37564. unbindAllAttributes(): void;
  37565. /**
  37566. * 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
  37567. */
  37568. releaseEffects(): void;
  37569. /**
  37570. * Dispose and release all associated resources
  37571. */
  37572. dispose(): void;
  37573. /**
  37574. * Attach a new callback raised when context lost event is fired
  37575. * @param callback defines the callback to call
  37576. */
  37577. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37578. /**
  37579. * Attach a new callback raised when context restored event is fired
  37580. * @param callback defines the callback to call
  37581. */
  37582. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37583. /**
  37584. * Get the current error code of the webGL context
  37585. * @returns the error code
  37586. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37587. */
  37588. getError(): number;
  37589. private _canRenderToFloatFramebuffer;
  37590. private _canRenderToHalfFloatFramebuffer;
  37591. private _canRenderToFramebuffer;
  37592. /** @hidden */
  37593. _getWebGLTextureType(type: number): number;
  37594. /** @hidden */
  37595. _getInternalFormat(format: number): number;
  37596. /** @hidden */
  37597. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37598. /** @hidden */
  37599. _getRGBAMultiSampleBufferFormat(type: number): number;
  37600. /** @hidden */
  37601. _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;
  37602. /**
  37603. * Loads a file from a url
  37604. * @param url url to load
  37605. * @param onSuccess callback called when the file successfully loads
  37606. * @param onProgress callback called while file is loading (if the server supports this mode)
  37607. * @param offlineProvider defines the offline provider for caching
  37608. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37609. * @param onError callback called when the file fails to load
  37610. * @returns a file request object
  37611. * @hidden
  37612. */
  37613. 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;
  37614. /**
  37615. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37616. * @param x defines the x coordinate of the rectangle where pixels must be read
  37617. * @param y defines the y coordinate of the rectangle where pixels must be read
  37618. * @param width defines the width of the rectangle where pixels must be read
  37619. * @param height defines the height of the rectangle where pixels must be read
  37620. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37621. * @returns a Uint8Array containing RGBA colors
  37622. */
  37623. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37624. private static _isSupported;
  37625. /**
  37626. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37627. * @returns true if the engine can be created
  37628. * @ignorenaming
  37629. */
  37630. static isSupported(): boolean;
  37631. /**
  37632. * Find the next highest power of two.
  37633. * @param x Number to start search from.
  37634. * @return Next highest power of two.
  37635. */
  37636. static CeilingPOT(x: number): number;
  37637. /**
  37638. * Find the next lowest power of two.
  37639. * @param x Number to start search from.
  37640. * @return Next lowest power of two.
  37641. */
  37642. static FloorPOT(x: number): number;
  37643. /**
  37644. * Find the nearest power of two.
  37645. * @param x Number to start search from.
  37646. * @return Next nearest power of two.
  37647. */
  37648. static NearestPOT(x: number): number;
  37649. /**
  37650. * Get the closest exponent of two
  37651. * @param value defines the value to approximate
  37652. * @param max defines the maximum value to return
  37653. * @param mode defines how to define the closest value
  37654. * @returns closest exponent of two of the given value
  37655. */
  37656. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37657. /**
  37658. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37659. * @param func - the function to be called
  37660. * @param requester - the object that will request the next frame. Falls back to window.
  37661. * @returns frame number
  37662. */
  37663. static QueueNewFrame(func: () => void, requester?: any): number;
  37664. /**
  37665. * Gets host document
  37666. * @returns the host document object
  37667. */
  37668. getHostDocument(): Nullable<Document>;
  37669. }
  37670. }
  37671. declare module "babylonjs/Maths/sphericalPolynomial" {
  37672. import { Vector3 } from "babylonjs/Maths/math.vector";
  37673. import { Color3 } from "babylonjs/Maths/math.color";
  37674. /**
  37675. * Class representing spherical harmonics coefficients to the 3rd degree
  37676. */
  37677. export class SphericalHarmonics {
  37678. /**
  37679. * Defines whether or not the harmonics have been prescaled for rendering.
  37680. */
  37681. preScaled: boolean;
  37682. /**
  37683. * The l0,0 coefficients of the spherical harmonics
  37684. */
  37685. l00: Vector3;
  37686. /**
  37687. * The l1,-1 coefficients of the spherical harmonics
  37688. */
  37689. l1_1: Vector3;
  37690. /**
  37691. * The l1,0 coefficients of the spherical harmonics
  37692. */
  37693. l10: Vector3;
  37694. /**
  37695. * The l1,1 coefficients of the spherical harmonics
  37696. */
  37697. l11: Vector3;
  37698. /**
  37699. * The l2,-2 coefficients of the spherical harmonics
  37700. */
  37701. l2_2: Vector3;
  37702. /**
  37703. * The l2,-1 coefficients of the spherical harmonics
  37704. */
  37705. l2_1: Vector3;
  37706. /**
  37707. * The l2,0 coefficients of the spherical harmonics
  37708. */
  37709. l20: Vector3;
  37710. /**
  37711. * The l2,1 coefficients of the spherical harmonics
  37712. */
  37713. l21: Vector3;
  37714. /**
  37715. * The l2,2 coefficients of the spherical harmonics
  37716. */
  37717. l22: Vector3;
  37718. /**
  37719. * Adds a light to the spherical harmonics
  37720. * @param direction the direction of the light
  37721. * @param color the color of the light
  37722. * @param deltaSolidAngle the delta solid angle of the light
  37723. */
  37724. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37725. /**
  37726. * Scales the spherical harmonics by the given amount
  37727. * @param scale the amount to scale
  37728. */
  37729. scaleInPlace(scale: number): void;
  37730. /**
  37731. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37732. *
  37733. * ```
  37734. * E_lm = A_l * L_lm
  37735. * ```
  37736. *
  37737. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37738. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37739. * the scaling factors are given in equation 9.
  37740. */
  37741. convertIncidentRadianceToIrradiance(): void;
  37742. /**
  37743. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37744. *
  37745. * ```
  37746. * L = (1/pi) * E * rho
  37747. * ```
  37748. *
  37749. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37750. */
  37751. convertIrradianceToLambertianRadiance(): void;
  37752. /**
  37753. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37754. * required operations at run time.
  37755. *
  37756. * This is simply done by scaling back the SH with Ylm constants parameter.
  37757. * The trigonometric part being applied by the shader at run time.
  37758. */
  37759. preScaleForRendering(): void;
  37760. /**
  37761. * Constructs a spherical harmonics from an array.
  37762. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37763. * @returns the spherical harmonics
  37764. */
  37765. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37766. /**
  37767. * Gets the spherical harmonics from polynomial
  37768. * @param polynomial the spherical polynomial
  37769. * @returns the spherical harmonics
  37770. */
  37771. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37772. }
  37773. /**
  37774. * Class representing spherical polynomial coefficients to the 3rd degree
  37775. */
  37776. export class SphericalPolynomial {
  37777. private _harmonics;
  37778. /**
  37779. * The spherical harmonics used to create the polynomials.
  37780. */
  37781. get preScaledHarmonics(): SphericalHarmonics;
  37782. /**
  37783. * The x coefficients of the spherical polynomial
  37784. */
  37785. x: Vector3;
  37786. /**
  37787. * The y coefficients of the spherical polynomial
  37788. */
  37789. y: Vector3;
  37790. /**
  37791. * The z coefficients of the spherical polynomial
  37792. */
  37793. z: Vector3;
  37794. /**
  37795. * The xx coefficients of the spherical polynomial
  37796. */
  37797. xx: Vector3;
  37798. /**
  37799. * The yy coefficients of the spherical polynomial
  37800. */
  37801. yy: Vector3;
  37802. /**
  37803. * The zz coefficients of the spherical polynomial
  37804. */
  37805. zz: Vector3;
  37806. /**
  37807. * The xy coefficients of the spherical polynomial
  37808. */
  37809. xy: Vector3;
  37810. /**
  37811. * The yz coefficients of the spherical polynomial
  37812. */
  37813. yz: Vector3;
  37814. /**
  37815. * The zx coefficients of the spherical polynomial
  37816. */
  37817. zx: Vector3;
  37818. /**
  37819. * Adds an ambient color to the spherical polynomial
  37820. * @param color the color to add
  37821. */
  37822. addAmbient(color: Color3): void;
  37823. /**
  37824. * Scales the spherical polynomial by the given amount
  37825. * @param scale the amount to scale
  37826. */
  37827. scaleInPlace(scale: number): void;
  37828. /**
  37829. * Gets the spherical polynomial from harmonics
  37830. * @param harmonics the spherical harmonics
  37831. * @returns the spherical polynomial
  37832. */
  37833. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37834. /**
  37835. * Constructs a spherical polynomial from an array.
  37836. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37837. * @returns the spherical polynomial
  37838. */
  37839. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37840. }
  37841. }
  37842. declare module "babylonjs/Materials/Textures/internalTexture" {
  37843. import { Observable } from "babylonjs/Misc/observable";
  37844. import { Nullable, int } from "babylonjs/types";
  37845. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37846. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37847. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37848. /**
  37849. * Defines the source of the internal texture
  37850. */
  37851. export enum InternalTextureSource {
  37852. /**
  37853. * The source of the texture data is unknown
  37854. */
  37855. Unknown = 0,
  37856. /**
  37857. * Texture data comes from an URL
  37858. */
  37859. Url = 1,
  37860. /**
  37861. * Texture data is only used for temporary storage
  37862. */
  37863. Temp = 2,
  37864. /**
  37865. * Texture data comes from raw data (ArrayBuffer)
  37866. */
  37867. Raw = 3,
  37868. /**
  37869. * Texture content is dynamic (video or dynamic texture)
  37870. */
  37871. Dynamic = 4,
  37872. /**
  37873. * Texture content is generated by rendering to it
  37874. */
  37875. RenderTarget = 5,
  37876. /**
  37877. * Texture content is part of a multi render target process
  37878. */
  37879. MultiRenderTarget = 6,
  37880. /**
  37881. * Texture data comes from a cube data file
  37882. */
  37883. Cube = 7,
  37884. /**
  37885. * Texture data comes from a raw cube data
  37886. */
  37887. CubeRaw = 8,
  37888. /**
  37889. * Texture data come from a prefiltered cube data file
  37890. */
  37891. CubePrefiltered = 9,
  37892. /**
  37893. * Texture content is raw 3D data
  37894. */
  37895. Raw3D = 10,
  37896. /**
  37897. * Texture content is raw 2D array data
  37898. */
  37899. Raw2DArray = 11,
  37900. /**
  37901. * Texture content is a depth texture
  37902. */
  37903. Depth = 12,
  37904. /**
  37905. * Texture data comes from a raw cube data encoded with RGBD
  37906. */
  37907. CubeRawRGBD = 13
  37908. }
  37909. /**
  37910. * Class used to store data associated with WebGL texture data for the engine
  37911. * This class should not be used directly
  37912. */
  37913. export class InternalTexture {
  37914. /** @hidden */
  37915. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37916. /**
  37917. * Defines if the texture is ready
  37918. */
  37919. isReady: boolean;
  37920. /**
  37921. * Defines if the texture is a cube texture
  37922. */
  37923. isCube: boolean;
  37924. /**
  37925. * Defines if the texture contains 3D data
  37926. */
  37927. is3D: boolean;
  37928. /**
  37929. * Defines if the texture contains 2D array data
  37930. */
  37931. is2DArray: boolean;
  37932. /**
  37933. * Defines if the texture contains multiview data
  37934. */
  37935. isMultiview: boolean;
  37936. /**
  37937. * Gets the URL used to load this texture
  37938. */
  37939. url: string;
  37940. /**
  37941. * Gets the sampling mode of the texture
  37942. */
  37943. samplingMode: number;
  37944. /**
  37945. * Gets a boolean indicating if the texture needs mipmaps generation
  37946. */
  37947. generateMipMaps: boolean;
  37948. /**
  37949. * Gets the number of samples used by the texture (WebGL2+ only)
  37950. */
  37951. samples: number;
  37952. /**
  37953. * Gets the type of the texture (int, float...)
  37954. */
  37955. type: number;
  37956. /**
  37957. * Gets the format of the texture (RGB, RGBA...)
  37958. */
  37959. format: number;
  37960. /**
  37961. * Observable called when the texture is loaded
  37962. */
  37963. onLoadedObservable: Observable<InternalTexture>;
  37964. /**
  37965. * Gets the width of the texture
  37966. */
  37967. width: number;
  37968. /**
  37969. * Gets the height of the texture
  37970. */
  37971. height: number;
  37972. /**
  37973. * Gets the depth of the texture
  37974. */
  37975. depth: number;
  37976. /**
  37977. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37978. */
  37979. baseWidth: number;
  37980. /**
  37981. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37982. */
  37983. baseHeight: number;
  37984. /**
  37985. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37986. */
  37987. baseDepth: number;
  37988. /**
  37989. * Gets a boolean indicating if the texture is inverted on Y axis
  37990. */
  37991. invertY: boolean;
  37992. /** @hidden */
  37993. _invertVScale: boolean;
  37994. /** @hidden */
  37995. _associatedChannel: number;
  37996. /** @hidden */
  37997. _source: InternalTextureSource;
  37998. /** @hidden */
  37999. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  38000. /** @hidden */
  38001. _bufferView: Nullable<ArrayBufferView>;
  38002. /** @hidden */
  38003. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38004. /** @hidden */
  38005. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  38006. /** @hidden */
  38007. _size: number;
  38008. /** @hidden */
  38009. _extension: string;
  38010. /** @hidden */
  38011. _files: Nullable<string[]>;
  38012. /** @hidden */
  38013. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38014. /** @hidden */
  38015. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38016. /** @hidden */
  38017. _framebuffer: Nullable<WebGLFramebuffer>;
  38018. /** @hidden */
  38019. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38020. /** @hidden */
  38021. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38022. /** @hidden */
  38023. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38024. /** @hidden */
  38025. _attachments: Nullable<number[]>;
  38026. /** @hidden */
  38027. _textureArray: Nullable<InternalTexture[]>;
  38028. /** @hidden */
  38029. _cachedCoordinatesMode: Nullable<number>;
  38030. /** @hidden */
  38031. _cachedWrapU: Nullable<number>;
  38032. /** @hidden */
  38033. _cachedWrapV: Nullable<number>;
  38034. /** @hidden */
  38035. _cachedWrapR: Nullable<number>;
  38036. /** @hidden */
  38037. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38038. /** @hidden */
  38039. _isDisabled: boolean;
  38040. /** @hidden */
  38041. _compression: Nullable<string>;
  38042. /** @hidden */
  38043. _generateStencilBuffer: boolean;
  38044. /** @hidden */
  38045. _generateDepthBuffer: boolean;
  38046. /** @hidden */
  38047. _comparisonFunction: number;
  38048. /** @hidden */
  38049. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38050. /** @hidden */
  38051. _lodGenerationScale: number;
  38052. /** @hidden */
  38053. _lodGenerationOffset: number;
  38054. /** @hidden */
  38055. _depthStencilTexture: Nullable<InternalTexture>;
  38056. /** @hidden */
  38057. _colorTextureArray: Nullable<WebGLTexture>;
  38058. /** @hidden */
  38059. _depthStencilTextureArray: Nullable<WebGLTexture>;
  38060. /** @hidden */
  38061. _lodTextureHigh: Nullable<BaseTexture>;
  38062. /** @hidden */
  38063. _lodTextureMid: Nullable<BaseTexture>;
  38064. /** @hidden */
  38065. _lodTextureLow: Nullable<BaseTexture>;
  38066. /** @hidden */
  38067. _isRGBD: boolean;
  38068. /** @hidden */
  38069. _linearSpecularLOD: boolean;
  38070. /** @hidden */
  38071. _irradianceTexture: Nullable<BaseTexture>;
  38072. /** @hidden */
  38073. _webGLTexture: Nullable<WebGLTexture>;
  38074. /** @hidden */
  38075. _references: number;
  38076. /** @hidden */
  38077. _gammaSpace: Nullable<boolean>;
  38078. private _engine;
  38079. /**
  38080. * Gets the Engine the texture belongs to.
  38081. * @returns The babylon engine
  38082. */
  38083. getEngine(): ThinEngine;
  38084. /**
  38085. * Gets the data source type of the texture
  38086. */
  38087. get source(): InternalTextureSource;
  38088. /**
  38089. * Creates a new InternalTexture
  38090. * @param engine defines the engine to use
  38091. * @param source defines the type of data that will be used
  38092. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38093. */
  38094. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  38095. /**
  38096. * Increments the number of references (ie. the number of Texture that point to it)
  38097. */
  38098. incrementReferences(): void;
  38099. /**
  38100. * Change the size of the texture (not the size of the content)
  38101. * @param width defines the new width
  38102. * @param height defines the new height
  38103. * @param depth defines the new depth (1 by default)
  38104. */
  38105. updateSize(width: int, height: int, depth?: int): void;
  38106. /** @hidden */
  38107. _rebuild(): void;
  38108. /** @hidden */
  38109. _swapAndDie(target: InternalTexture): void;
  38110. /**
  38111. * Dispose the current allocated resources
  38112. */
  38113. dispose(): void;
  38114. }
  38115. }
  38116. declare module "babylonjs/Audio/analyser" {
  38117. import { Scene } from "babylonjs/scene";
  38118. /**
  38119. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38120. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38121. */
  38122. export class Analyser {
  38123. /**
  38124. * Gets or sets the smoothing
  38125. * @ignorenaming
  38126. */
  38127. SMOOTHING: number;
  38128. /**
  38129. * Gets or sets the FFT table size
  38130. * @ignorenaming
  38131. */
  38132. FFT_SIZE: number;
  38133. /**
  38134. * Gets or sets the bar graph amplitude
  38135. * @ignorenaming
  38136. */
  38137. BARGRAPHAMPLITUDE: number;
  38138. /**
  38139. * Gets or sets the position of the debug canvas
  38140. * @ignorenaming
  38141. */
  38142. DEBUGCANVASPOS: {
  38143. x: number;
  38144. y: number;
  38145. };
  38146. /**
  38147. * Gets or sets the debug canvas size
  38148. * @ignorenaming
  38149. */
  38150. DEBUGCANVASSIZE: {
  38151. width: number;
  38152. height: number;
  38153. };
  38154. private _byteFreqs;
  38155. private _byteTime;
  38156. private _floatFreqs;
  38157. private _webAudioAnalyser;
  38158. private _debugCanvas;
  38159. private _debugCanvasContext;
  38160. private _scene;
  38161. private _registerFunc;
  38162. private _audioEngine;
  38163. /**
  38164. * Creates a new analyser
  38165. * @param scene defines hosting scene
  38166. */
  38167. constructor(scene: Scene);
  38168. /**
  38169. * Get the number of data values you will have to play with for the visualization
  38170. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38171. * @returns a number
  38172. */
  38173. getFrequencyBinCount(): number;
  38174. /**
  38175. * Gets the current frequency data as a byte array
  38176. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38177. * @returns a Uint8Array
  38178. */
  38179. getByteFrequencyData(): Uint8Array;
  38180. /**
  38181. * Gets the current waveform as a byte array
  38182. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38183. * @returns a Uint8Array
  38184. */
  38185. getByteTimeDomainData(): Uint8Array;
  38186. /**
  38187. * Gets the current frequency data as a float array
  38188. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38189. * @returns a Float32Array
  38190. */
  38191. getFloatFrequencyData(): Float32Array;
  38192. /**
  38193. * Renders the debug canvas
  38194. */
  38195. drawDebugCanvas(): void;
  38196. /**
  38197. * Stops rendering the debug canvas and removes it
  38198. */
  38199. stopDebugCanvas(): void;
  38200. /**
  38201. * Connects two audio nodes
  38202. * @param inputAudioNode defines first node to connect
  38203. * @param outputAudioNode defines second node to connect
  38204. */
  38205. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38206. /**
  38207. * Releases all associated resources
  38208. */
  38209. dispose(): void;
  38210. }
  38211. }
  38212. declare module "babylonjs/Audio/audioEngine" {
  38213. import { IDisposable } from "babylonjs/scene";
  38214. import { Analyser } from "babylonjs/Audio/analyser";
  38215. import { Nullable } from "babylonjs/types";
  38216. import { Observable } from "babylonjs/Misc/observable";
  38217. /**
  38218. * This represents an audio engine and it is responsible
  38219. * to play, synchronize and analyse sounds throughout the application.
  38220. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38221. */
  38222. export interface IAudioEngine extends IDisposable {
  38223. /**
  38224. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38225. */
  38226. readonly canUseWebAudio: boolean;
  38227. /**
  38228. * Gets the current AudioContext if available.
  38229. */
  38230. readonly audioContext: Nullable<AudioContext>;
  38231. /**
  38232. * The master gain node defines the global audio volume of your audio engine.
  38233. */
  38234. readonly masterGain: GainNode;
  38235. /**
  38236. * Gets whether or not mp3 are supported by your browser.
  38237. */
  38238. readonly isMP3supported: boolean;
  38239. /**
  38240. * Gets whether or not ogg are supported by your browser.
  38241. */
  38242. readonly isOGGsupported: boolean;
  38243. /**
  38244. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38245. * @ignoreNaming
  38246. */
  38247. WarnedWebAudioUnsupported: boolean;
  38248. /**
  38249. * Defines if the audio engine relies on a custom unlocked button.
  38250. * In this case, the embedded button will not be displayed.
  38251. */
  38252. useCustomUnlockedButton: boolean;
  38253. /**
  38254. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38255. */
  38256. readonly unlocked: boolean;
  38257. /**
  38258. * Event raised when audio has been unlocked on the browser.
  38259. */
  38260. onAudioUnlockedObservable: Observable<AudioEngine>;
  38261. /**
  38262. * Event raised when audio has been locked on the browser.
  38263. */
  38264. onAudioLockedObservable: Observable<AudioEngine>;
  38265. /**
  38266. * Flags the audio engine in Locked state.
  38267. * This happens due to new browser policies preventing audio to autoplay.
  38268. */
  38269. lock(): void;
  38270. /**
  38271. * Unlocks the audio engine once a user action has been done on the dom.
  38272. * This is helpful to resume play once browser policies have been satisfied.
  38273. */
  38274. unlock(): void;
  38275. /**
  38276. * Gets the global volume sets on the master gain.
  38277. * @returns the global volume if set or -1 otherwise
  38278. */
  38279. getGlobalVolume(): number;
  38280. /**
  38281. * Sets the global volume of your experience (sets on the master gain).
  38282. * @param newVolume Defines the new global volume of the application
  38283. */
  38284. setGlobalVolume(newVolume: number): void;
  38285. /**
  38286. * Connect the audio engine to an audio analyser allowing some amazing
  38287. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38288. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38289. * @param analyser The analyser to connect to the engine
  38290. */
  38291. connectToAnalyser(analyser: Analyser): void;
  38292. }
  38293. /**
  38294. * This represents the default audio engine used in babylon.
  38295. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38296. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38297. */
  38298. export class AudioEngine implements IAudioEngine {
  38299. private _audioContext;
  38300. private _audioContextInitialized;
  38301. private _muteButton;
  38302. private _hostElement;
  38303. /**
  38304. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38305. */
  38306. canUseWebAudio: boolean;
  38307. /**
  38308. * The master gain node defines the global audio volume of your audio engine.
  38309. */
  38310. masterGain: GainNode;
  38311. /**
  38312. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38313. * @ignoreNaming
  38314. */
  38315. WarnedWebAudioUnsupported: boolean;
  38316. /**
  38317. * Gets whether or not mp3 are supported by your browser.
  38318. */
  38319. isMP3supported: boolean;
  38320. /**
  38321. * Gets whether or not ogg are supported by your browser.
  38322. */
  38323. isOGGsupported: boolean;
  38324. /**
  38325. * Gets whether audio has been unlocked on the device.
  38326. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38327. * a user interaction has happened.
  38328. */
  38329. unlocked: boolean;
  38330. /**
  38331. * Defines if the audio engine relies on a custom unlocked button.
  38332. * In this case, the embedded button will not be displayed.
  38333. */
  38334. useCustomUnlockedButton: boolean;
  38335. /**
  38336. * Event raised when audio has been unlocked on the browser.
  38337. */
  38338. onAudioUnlockedObservable: Observable<AudioEngine>;
  38339. /**
  38340. * Event raised when audio has been locked on the browser.
  38341. */
  38342. onAudioLockedObservable: Observable<AudioEngine>;
  38343. /**
  38344. * Gets the current AudioContext if available.
  38345. */
  38346. get audioContext(): Nullable<AudioContext>;
  38347. private _connectedAnalyser;
  38348. /**
  38349. * Instantiates a new audio engine.
  38350. *
  38351. * There should be only one per page as some browsers restrict the number
  38352. * of audio contexts you can create.
  38353. * @param hostElement defines the host element where to display the mute icon if necessary
  38354. */
  38355. constructor(hostElement?: Nullable<HTMLElement>);
  38356. /**
  38357. * Flags the audio engine in Locked state.
  38358. * This happens due to new browser policies preventing audio to autoplay.
  38359. */
  38360. lock(): void;
  38361. /**
  38362. * Unlocks the audio engine once a user action has been done on the dom.
  38363. * This is helpful to resume play once browser policies have been satisfied.
  38364. */
  38365. unlock(): void;
  38366. private _resumeAudioContext;
  38367. private _initializeAudioContext;
  38368. private _tryToRun;
  38369. private _triggerRunningState;
  38370. private _triggerSuspendedState;
  38371. private _displayMuteButton;
  38372. private _moveButtonToTopLeft;
  38373. private _onResize;
  38374. private _hideMuteButton;
  38375. /**
  38376. * Destroy and release the resources associated with the audio ccontext.
  38377. */
  38378. dispose(): void;
  38379. /**
  38380. * Gets the global volume sets on the master gain.
  38381. * @returns the global volume if set or -1 otherwise
  38382. */
  38383. getGlobalVolume(): number;
  38384. /**
  38385. * Sets the global volume of your experience (sets on the master gain).
  38386. * @param newVolume Defines the new global volume of the application
  38387. */
  38388. setGlobalVolume(newVolume: number): void;
  38389. /**
  38390. * Connect the audio engine to an audio analyser allowing some amazing
  38391. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38392. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38393. * @param analyser The analyser to connect to the engine
  38394. */
  38395. connectToAnalyser(analyser: Analyser): void;
  38396. }
  38397. }
  38398. declare module "babylonjs/Loading/loadingScreen" {
  38399. /**
  38400. * Interface used to present a loading screen while loading a scene
  38401. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38402. */
  38403. export interface ILoadingScreen {
  38404. /**
  38405. * Function called to display the loading screen
  38406. */
  38407. displayLoadingUI: () => void;
  38408. /**
  38409. * Function called to hide the loading screen
  38410. */
  38411. hideLoadingUI: () => void;
  38412. /**
  38413. * Gets or sets the color to use for the background
  38414. */
  38415. loadingUIBackgroundColor: string;
  38416. /**
  38417. * Gets or sets the text to display while loading
  38418. */
  38419. loadingUIText: string;
  38420. }
  38421. /**
  38422. * Class used for the default loading screen
  38423. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38424. */
  38425. export class DefaultLoadingScreen implements ILoadingScreen {
  38426. private _renderingCanvas;
  38427. private _loadingText;
  38428. private _loadingDivBackgroundColor;
  38429. private _loadingDiv;
  38430. private _loadingTextDiv;
  38431. /** Gets or sets the logo url to use for the default loading screen */
  38432. static DefaultLogoUrl: string;
  38433. /** Gets or sets the spinner url to use for the default loading screen */
  38434. static DefaultSpinnerUrl: string;
  38435. /**
  38436. * Creates a new default loading screen
  38437. * @param _renderingCanvas defines the canvas used to render the scene
  38438. * @param _loadingText defines the default text to display
  38439. * @param _loadingDivBackgroundColor defines the default background color
  38440. */
  38441. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38442. /**
  38443. * Function called to display the loading screen
  38444. */
  38445. displayLoadingUI(): void;
  38446. /**
  38447. * Function called to hide the loading screen
  38448. */
  38449. hideLoadingUI(): void;
  38450. /**
  38451. * Gets or sets the text to display while loading
  38452. */
  38453. set loadingUIText(text: string);
  38454. get loadingUIText(): string;
  38455. /**
  38456. * Gets or sets the color to use for the background
  38457. */
  38458. get loadingUIBackgroundColor(): string;
  38459. set loadingUIBackgroundColor(color: string);
  38460. private _resizeLoadingUI;
  38461. }
  38462. }
  38463. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38464. /**
  38465. * Interface for any object that can request an animation frame
  38466. */
  38467. export interface ICustomAnimationFrameRequester {
  38468. /**
  38469. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38470. */
  38471. renderFunction?: Function;
  38472. /**
  38473. * Called to request the next frame to render to
  38474. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38475. */
  38476. requestAnimationFrame: Function;
  38477. /**
  38478. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38479. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38480. */
  38481. requestID?: number;
  38482. }
  38483. }
  38484. declare module "babylonjs/Misc/performanceMonitor" {
  38485. /**
  38486. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38487. */
  38488. export class PerformanceMonitor {
  38489. private _enabled;
  38490. private _rollingFrameTime;
  38491. private _lastFrameTimeMs;
  38492. /**
  38493. * constructor
  38494. * @param frameSampleSize The number of samples required to saturate the sliding window
  38495. */
  38496. constructor(frameSampleSize?: number);
  38497. /**
  38498. * Samples current frame
  38499. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38500. */
  38501. sampleFrame(timeMs?: number): void;
  38502. /**
  38503. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38504. */
  38505. get averageFrameTime(): number;
  38506. /**
  38507. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38508. */
  38509. get averageFrameTimeVariance(): number;
  38510. /**
  38511. * Returns the frame time of the most recent frame
  38512. */
  38513. get instantaneousFrameTime(): number;
  38514. /**
  38515. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38516. */
  38517. get averageFPS(): number;
  38518. /**
  38519. * Returns the average framerate in frames per second using the most recent frame time
  38520. */
  38521. get instantaneousFPS(): number;
  38522. /**
  38523. * Returns true if enough samples have been taken to completely fill the sliding window
  38524. */
  38525. get isSaturated(): boolean;
  38526. /**
  38527. * Enables contributions to the sliding window sample set
  38528. */
  38529. enable(): void;
  38530. /**
  38531. * Disables contributions to the sliding window sample set
  38532. * Samples will not be interpolated over the disabled period
  38533. */
  38534. disable(): void;
  38535. /**
  38536. * Returns true if sampling is enabled
  38537. */
  38538. get isEnabled(): boolean;
  38539. /**
  38540. * Resets performance monitor
  38541. */
  38542. reset(): void;
  38543. }
  38544. /**
  38545. * RollingAverage
  38546. *
  38547. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38548. */
  38549. export class RollingAverage {
  38550. /**
  38551. * Current average
  38552. */
  38553. average: number;
  38554. /**
  38555. * Current variance
  38556. */
  38557. variance: number;
  38558. protected _samples: Array<number>;
  38559. protected _sampleCount: number;
  38560. protected _pos: number;
  38561. protected _m2: number;
  38562. /**
  38563. * constructor
  38564. * @param length The number of samples required to saturate the sliding window
  38565. */
  38566. constructor(length: number);
  38567. /**
  38568. * Adds a sample to the sample set
  38569. * @param v The sample value
  38570. */
  38571. add(v: number): void;
  38572. /**
  38573. * Returns previously added values or null if outside of history or outside the sliding window domain
  38574. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38575. * @return Value previously recorded with add() or null if outside of range
  38576. */
  38577. history(i: number): number;
  38578. /**
  38579. * Returns true if enough samples have been taken to completely fill the sliding window
  38580. * @return true if sample-set saturated
  38581. */
  38582. isSaturated(): boolean;
  38583. /**
  38584. * Resets the rolling average (equivalent to 0 samples taken so far)
  38585. */
  38586. reset(): void;
  38587. /**
  38588. * Wraps a value around the sample range boundaries
  38589. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38590. * @return Wrapped position in sample range
  38591. */
  38592. protected _wrapPosition(i: number): number;
  38593. }
  38594. }
  38595. declare module "babylonjs/Misc/perfCounter" {
  38596. /**
  38597. * This class is used to track a performance counter which is number based.
  38598. * The user has access to many properties which give statistics of different nature.
  38599. *
  38600. * The implementer can track two kinds of Performance Counter: time and count.
  38601. * 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.
  38602. * 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.
  38603. */
  38604. export class PerfCounter {
  38605. /**
  38606. * Gets or sets a global boolean to turn on and off all the counters
  38607. */
  38608. static Enabled: boolean;
  38609. /**
  38610. * Returns the smallest value ever
  38611. */
  38612. get min(): number;
  38613. /**
  38614. * Returns the biggest value ever
  38615. */
  38616. get max(): number;
  38617. /**
  38618. * Returns the average value since the performance counter is running
  38619. */
  38620. get average(): number;
  38621. /**
  38622. * Returns the average value of the last second the counter was monitored
  38623. */
  38624. get lastSecAverage(): number;
  38625. /**
  38626. * Returns the current value
  38627. */
  38628. get current(): number;
  38629. /**
  38630. * Gets the accumulated total
  38631. */
  38632. get total(): number;
  38633. /**
  38634. * Gets the total value count
  38635. */
  38636. get count(): number;
  38637. /**
  38638. * Creates a new counter
  38639. */
  38640. constructor();
  38641. /**
  38642. * Call this method to start monitoring a new frame.
  38643. * 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.
  38644. */
  38645. fetchNewFrame(): void;
  38646. /**
  38647. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38648. * @param newCount the count value to add to the monitored count
  38649. * @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.
  38650. */
  38651. addCount(newCount: number, fetchResult: boolean): void;
  38652. /**
  38653. * Start monitoring this performance counter
  38654. */
  38655. beginMonitoring(): void;
  38656. /**
  38657. * Compute the time lapsed since the previous beginMonitoring() call.
  38658. * @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
  38659. */
  38660. endMonitoring(newFrame?: boolean): void;
  38661. private _fetchResult;
  38662. private _startMonitoringTime;
  38663. private _min;
  38664. private _max;
  38665. private _average;
  38666. private _current;
  38667. private _totalValueCount;
  38668. private _totalAccumulated;
  38669. private _lastSecAverage;
  38670. private _lastSecAccumulated;
  38671. private _lastSecTime;
  38672. private _lastSecValueCount;
  38673. }
  38674. }
  38675. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38677. import { Nullable } from "babylonjs/types";
  38678. module "babylonjs/Engines/thinEngine" {
  38679. interface ThinEngine {
  38680. /** @hidden */
  38681. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38682. }
  38683. }
  38684. }
  38685. declare module "babylonjs/Engines/engine" {
  38686. import { Observable } from "babylonjs/Misc/observable";
  38687. import { Nullable } from "babylonjs/types";
  38688. import { Scene } from "babylonjs/scene";
  38689. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38690. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38691. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38692. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38693. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38694. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38695. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38696. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38697. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38698. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38699. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38700. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38701. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38702. import "babylonjs/Engines/Extensions/engine.alpha";
  38703. import "babylonjs/Engines/Extensions/engine.readTexture";
  38704. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38705. import { Material } from "babylonjs/Materials/material";
  38706. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38707. /**
  38708. * Defines the interface used by display changed events
  38709. */
  38710. export interface IDisplayChangedEventArgs {
  38711. /** Gets the vrDisplay object (if any) */
  38712. vrDisplay: Nullable<any>;
  38713. /** Gets a boolean indicating if webVR is supported */
  38714. vrSupported: boolean;
  38715. }
  38716. /**
  38717. * Defines the interface used by objects containing a viewport (like a camera)
  38718. */
  38719. interface IViewportOwnerLike {
  38720. /**
  38721. * Gets or sets the viewport
  38722. */
  38723. viewport: IViewportLike;
  38724. }
  38725. /**
  38726. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38727. */
  38728. export class Engine extends ThinEngine {
  38729. /** Defines that alpha blending is disabled */
  38730. static readonly ALPHA_DISABLE: number;
  38731. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38732. static readonly ALPHA_ADD: number;
  38733. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38734. static readonly ALPHA_COMBINE: number;
  38735. /** Defines that alpha blending to DEST - SRC * DEST */
  38736. static readonly ALPHA_SUBTRACT: number;
  38737. /** Defines that alpha blending to SRC * DEST */
  38738. static readonly ALPHA_MULTIPLY: number;
  38739. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38740. static readonly ALPHA_MAXIMIZED: number;
  38741. /** Defines that alpha blending to SRC + DEST */
  38742. static readonly ALPHA_ONEONE: number;
  38743. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38744. static readonly ALPHA_PREMULTIPLIED: number;
  38745. /**
  38746. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38747. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38748. */
  38749. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38750. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38751. static readonly ALPHA_INTERPOLATE: number;
  38752. /**
  38753. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38754. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38755. */
  38756. static readonly ALPHA_SCREENMODE: number;
  38757. /** Defines that the ressource is not delayed*/
  38758. static readonly DELAYLOADSTATE_NONE: number;
  38759. /** Defines that the ressource was successfully delay loaded */
  38760. static readonly DELAYLOADSTATE_LOADED: number;
  38761. /** Defines that the ressource is currently delay loading */
  38762. static readonly DELAYLOADSTATE_LOADING: number;
  38763. /** Defines that the ressource is delayed and has not started loading */
  38764. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38765. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38766. static readonly NEVER: number;
  38767. /** 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 */
  38768. static readonly ALWAYS: number;
  38769. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38770. static readonly LESS: number;
  38771. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38772. static readonly EQUAL: number;
  38773. /** 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 */
  38774. static readonly LEQUAL: number;
  38775. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38776. static readonly GREATER: number;
  38777. /** 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 */
  38778. static readonly GEQUAL: number;
  38779. /** 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 */
  38780. static readonly NOTEQUAL: number;
  38781. /** Passed to stencilOperation to specify that stencil value must be kept */
  38782. static readonly KEEP: number;
  38783. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38784. static readonly REPLACE: number;
  38785. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38786. static readonly INCR: number;
  38787. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38788. static readonly DECR: number;
  38789. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38790. static readonly INVERT: number;
  38791. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38792. static readonly INCR_WRAP: number;
  38793. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38794. static readonly DECR_WRAP: number;
  38795. /** Texture is not repeating outside of 0..1 UVs */
  38796. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38797. /** Texture is repeating outside of 0..1 UVs */
  38798. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38799. /** Texture is repeating and mirrored */
  38800. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38801. /** ALPHA */
  38802. static readonly TEXTUREFORMAT_ALPHA: number;
  38803. /** LUMINANCE */
  38804. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38805. /** LUMINANCE_ALPHA */
  38806. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38807. /** RGB */
  38808. static readonly TEXTUREFORMAT_RGB: number;
  38809. /** RGBA */
  38810. static readonly TEXTUREFORMAT_RGBA: number;
  38811. /** RED */
  38812. static readonly TEXTUREFORMAT_RED: number;
  38813. /** RED (2nd reference) */
  38814. static readonly TEXTUREFORMAT_R: number;
  38815. /** RG */
  38816. static readonly TEXTUREFORMAT_RG: number;
  38817. /** RED_INTEGER */
  38818. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38819. /** RED_INTEGER (2nd reference) */
  38820. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38821. /** RG_INTEGER */
  38822. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38823. /** RGB_INTEGER */
  38824. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38825. /** RGBA_INTEGER */
  38826. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38827. /** UNSIGNED_BYTE */
  38828. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38829. /** UNSIGNED_BYTE (2nd reference) */
  38830. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38831. /** FLOAT */
  38832. static readonly TEXTURETYPE_FLOAT: number;
  38833. /** HALF_FLOAT */
  38834. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38835. /** BYTE */
  38836. static readonly TEXTURETYPE_BYTE: number;
  38837. /** SHORT */
  38838. static readonly TEXTURETYPE_SHORT: number;
  38839. /** UNSIGNED_SHORT */
  38840. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38841. /** INT */
  38842. static readonly TEXTURETYPE_INT: number;
  38843. /** UNSIGNED_INT */
  38844. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38845. /** UNSIGNED_SHORT_4_4_4_4 */
  38846. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38847. /** UNSIGNED_SHORT_5_5_5_1 */
  38848. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38849. /** UNSIGNED_SHORT_5_6_5 */
  38850. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38851. /** UNSIGNED_INT_2_10_10_10_REV */
  38852. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38853. /** UNSIGNED_INT_24_8 */
  38854. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38855. /** UNSIGNED_INT_10F_11F_11F_REV */
  38856. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38857. /** UNSIGNED_INT_5_9_9_9_REV */
  38858. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38859. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38860. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38861. /** nearest is mag = nearest and min = nearest and mip = linear */
  38862. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38863. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38864. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38865. /** Trilinear is mag = linear and min = linear and mip = linear */
  38866. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38867. /** nearest is mag = nearest and min = nearest and mip = linear */
  38868. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38869. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38870. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38871. /** Trilinear is mag = linear and min = linear and mip = linear */
  38872. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38873. /** mag = nearest and min = nearest and mip = nearest */
  38874. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38875. /** mag = nearest and min = linear and mip = nearest */
  38876. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38877. /** mag = nearest and min = linear and mip = linear */
  38878. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38879. /** mag = nearest and min = linear and mip = none */
  38880. static readonly TEXTURE_NEAREST_LINEAR: number;
  38881. /** mag = nearest and min = nearest and mip = none */
  38882. static readonly TEXTURE_NEAREST_NEAREST: number;
  38883. /** mag = linear and min = nearest and mip = nearest */
  38884. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38885. /** mag = linear and min = nearest and mip = linear */
  38886. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38887. /** mag = linear and min = linear and mip = none */
  38888. static readonly TEXTURE_LINEAR_LINEAR: number;
  38889. /** mag = linear and min = nearest and mip = none */
  38890. static readonly TEXTURE_LINEAR_NEAREST: number;
  38891. /** Explicit coordinates mode */
  38892. static readonly TEXTURE_EXPLICIT_MODE: number;
  38893. /** Spherical coordinates mode */
  38894. static readonly TEXTURE_SPHERICAL_MODE: number;
  38895. /** Planar coordinates mode */
  38896. static readonly TEXTURE_PLANAR_MODE: number;
  38897. /** Cubic coordinates mode */
  38898. static readonly TEXTURE_CUBIC_MODE: number;
  38899. /** Projection coordinates mode */
  38900. static readonly TEXTURE_PROJECTION_MODE: number;
  38901. /** Skybox coordinates mode */
  38902. static readonly TEXTURE_SKYBOX_MODE: number;
  38903. /** Inverse Cubic coordinates mode */
  38904. static readonly TEXTURE_INVCUBIC_MODE: number;
  38905. /** Equirectangular coordinates mode */
  38906. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38907. /** Equirectangular Fixed coordinates mode */
  38908. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38909. /** Equirectangular Fixed Mirrored coordinates mode */
  38910. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38911. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38912. static readonly SCALEMODE_FLOOR: number;
  38913. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38914. static readonly SCALEMODE_NEAREST: number;
  38915. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38916. static readonly SCALEMODE_CEILING: number;
  38917. /**
  38918. * Returns the current npm package of the sdk
  38919. */
  38920. static get NpmPackage(): string;
  38921. /**
  38922. * Returns the current version of the framework
  38923. */
  38924. static get Version(): string;
  38925. /** Gets the list of created engines */
  38926. static get Instances(): Engine[];
  38927. /**
  38928. * Gets the latest created engine
  38929. */
  38930. static get LastCreatedEngine(): Nullable<Engine>;
  38931. /**
  38932. * Gets the latest created scene
  38933. */
  38934. static get LastCreatedScene(): Nullable<Scene>;
  38935. /**
  38936. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38937. * @param flag defines which part of the materials must be marked as dirty
  38938. * @param predicate defines a predicate used to filter which materials should be affected
  38939. */
  38940. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38941. /**
  38942. * Method called to create the default loading screen.
  38943. * This can be overriden in your own app.
  38944. * @param canvas The rendering canvas element
  38945. * @returns The loading screen
  38946. */
  38947. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38948. /**
  38949. * Method called to create the default rescale post process on each engine.
  38950. */
  38951. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38952. /**
  38953. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38954. **/
  38955. enableOfflineSupport: boolean;
  38956. /**
  38957. * 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)
  38958. **/
  38959. disableManifestCheck: boolean;
  38960. /**
  38961. * Gets the list of created scenes
  38962. */
  38963. scenes: Scene[];
  38964. /**
  38965. * Event raised when a new scene is created
  38966. */
  38967. onNewSceneAddedObservable: Observable<Scene>;
  38968. /**
  38969. * Gets the list of created postprocesses
  38970. */
  38971. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38972. /**
  38973. * Gets a boolean indicating if the pointer is currently locked
  38974. */
  38975. isPointerLock: boolean;
  38976. /**
  38977. * Observable event triggered each time the rendering canvas is resized
  38978. */
  38979. onResizeObservable: Observable<Engine>;
  38980. /**
  38981. * Observable event triggered each time the canvas loses focus
  38982. */
  38983. onCanvasBlurObservable: Observable<Engine>;
  38984. /**
  38985. * Observable event triggered each time the canvas gains focus
  38986. */
  38987. onCanvasFocusObservable: Observable<Engine>;
  38988. /**
  38989. * Observable event triggered each time the canvas receives pointerout event
  38990. */
  38991. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38992. /**
  38993. * Observable raised when the engine begins a new frame
  38994. */
  38995. onBeginFrameObservable: Observable<Engine>;
  38996. /**
  38997. * If set, will be used to request the next animation frame for the render loop
  38998. */
  38999. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  39000. /**
  39001. * Observable raised when the engine ends the current frame
  39002. */
  39003. onEndFrameObservable: Observable<Engine>;
  39004. /**
  39005. * Observable raised when the engine is about to compile a shader
  39006. */
  39007. onBeforeShaderCompilationObservable: Observable<Engine>;
  39008. /**
  39009. * Observable raised when the engine has jsut compiled a shader
  39010. */
  39011. onAfterShaderCompilationObservable: Observable<Engine>;
  39012. /**
  39013. * Gets the audio engine
  39014. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39015. * @ignorenaming
  39016. */
  39017. static audioEngine: IAudioEngine;
  39018. /**
  39019. * Default AudioEngine factory responsible of creating the Audio Engine.
  39020. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  39021. */
  39022. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  39023. /**
  39024. * Default offline support factory responsible of creating a tool used to store data locally.
  39025. * By default, this will create a Database object if the workload has been embedded.
  39026. */
  39027. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  39028. private _loadingScreen;
  39029. private _pointerLockRequested;
  39030. private _rescalePostProcess;
  39031. private _deterministicLockstep;
  39032. private _lockstepMaxSteps;
  39033. private _timeStep;
  39034. protected get _supportsHardwareTextureRescaling(): boolean;
  39035. private _fps;
  39036. private _deltaTime;
  39037. /** @hidden */
  39038. _drawCalls: PerfCounter;
  39039. /** 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 */
  39040. canvasTabIndex: number;
  39041. /**
  39042. * Turn this value on if you want to pause FPS computation when in background
  39043. */
  39044. disablePerformanceMonitorInBackground: boolean;
  39045. private _performanceMonitor;
  39046. /**
  39047. * Gets the performance monitor attached to this engine
  39048. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39049. */
  39050. get performanceMonitor(): PerformanceMonitor;
  39051. private _onFocus;
  39052. private _onBlur;
  39053. private _onCanvasPointerOut;
  39054. private _onCanvasBlur;
  39055. private _onCanvasFocus;
  39056. private _onFullscreenChange;
  39057. private _onPointerLockChange;
  39058. /**
  39059. * Gets the HTML element used to attach event listeners
  39060. * @returns a HTML element
  39061. */
  39062. getInputElement(): Nullable<HTMLElement>;
  39063. /**
  39064. * Creates a new engine
  39065. * @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
  39066. * @param antialias defines enable antialiasing (default: false)
  39067. * @param options defines further options to be sent to the getContext() function
  39068. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39069. */
  39070. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39071. /**
  39072. * Gets current aspect ratio
  39073. * @param viewportOwner defines the camera to use to get the aspect ratio
  39074. * @param useScreen defines if screen size must be used (or the current render target if any)
  39075. * @returns a number defining the aspect ratio
  39076. */
  39077. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  39078. /**
  39079. * Gets current screen aspect ratio
  39080. * @returns a number defining the aspect ratio
  39081. */
  39082. getScreenAspectRatio(): number;
  39083. /**
  39084. * Gets the client rect of the HTML canvas attached with the current webGL context
  39085. * @returns a client rectanglee
  39086. */
  39087. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  39088. /**
  39089. * Gets the client rect of the HTML element used for events
  39090. * @returns a client rectanglee
  39091. */
  39092. getInputElementClientRect(): Nullable<ClientRect>;
  39093. /**
  39094. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  39095. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39096. * @returns true if engine is in deterministic lock step mode
  39097. */
  39098. isDeterministicLockStep(): boolean;
  39099. /**
  39100. * Gets the max steps when engine is running in deterministic lock step
  39101. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39102. * @returns the max steps
  39103. */
  39104. getLockstepMaxSteps(): number;
  39105. /**
  39106. * Returns the time in ms between steps when using deterministic lock step.
  39107. * @returns time step in (ms)
  39108. */
  39109. getTimeStep(): number;
  39110. /**
  39111. * Force the mipmap generation for the given render target texture
  39112. * @param texture defines the render target texture to use
  39113. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39114. */
  39115. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39116. /** States */
  39117. /**
  39118. * Set various states to the webGL context
  39119. * @param culling defines backface culling state
  39120. * @param zOffset defines the value to apply to zOffset (0 by default)
  39121. * @param force defines if states must be applied even if cache is up to date
  39122. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39123. */
  39124. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39125. /**
  39126. * Set the z offset to apply to current rendering
  39127. * @param value defines the offset to apply
  39128. */
  39129. setZOffset(value: number): void;
  39130. /**
  39131. * Gets the current value of the zOffset
  39132. * @returns the current zOffset state
  39133. */
  39134. getZOffset(): number;
  39135. /**
  39136. * Enable or disable depth buffering
  39137. * @param enable defines the state to set
  39138. */
  39139. setDepthBuffer(enable: boolean): void;
  39140. /**
  39141. * Gets a boolean indicating if depth writing is enabled
  39142. * @returns the current depth writing state
  39143. */
  39144. getDepthWrite(): boolean;
  39145. /**
  39146. * Enable or disable depth writing
  39147. * @param enable defines the state to set
  39148. */
  39149. setDepthWrite(enable: boolean): void;
  39150. /**
  39151. * Gets a boolean indicating if stencil buffer is enabled
  39152. * @returns the current stencil buffer state
  39153. */
  39154. getStencilBuffer(): boolean;
  39155. /**
  39156. * Enable or disable the stencil buffer
  39157. * @param enable defines if the stencil buffer must be enabled or disabled
  39158. */
  39159. setStencilBuffer(enable: boolean): void;
  39160. /**
  39161. * Gets the current stencil mask
  39162. * @returns a number defining the new stencil mask to use
  39163. */
  39164. getStencilMask(): number;
  39165. /**
  39166. * Sets the current stencil mask
  39167. * @param mask defines the new stencil mask to use
  39168. */
  39169. setStencilMask(mask: number): void;
  39170. /**
  39171. * Gets the current stencil function
  39172. * @returns a number defining the stencil function to use
  39173. */
  39174. getStencilFunction(): number;
  39175. /**
  39176. * Gets the current stencil reference value
  39177. * @returns a number defining the stencil reference value to use
  39178. */
  39179. getStencilFunctionReference(): number;
  39180. /**
  39181. * Gets the current stencil mask
  39182. * @returns a number defining the stencil mask to use
  39183. */
  39184. getStencilFunctionMask(): number;
  39185. /**
  39186. * Sets the current stencil function
  39187. * @param stencilFunc defines the new stencil function to use
  39188. */
  39189. setStencilFunction(stencilFunc: number): void;
  39190. /**
  39191. * Sets the current stencil reference
  39192. * @param reference defines the new stencil reference to use
  39193. */
  39194. setStencilFunctionReference(reference: number): void;
  39195. /**
  39196. * Sets the current stencil mask
  39197. * @param mask defines the new stencil mask to use
  39198. */
  39199. setStencilFunctionMask(mask: number): void;
  39200. /**
  39201. * Gets the current stencil operation when stencil fails
  39202. * @returns a number defining stencil operation to use when stencil fails
  39203. */
  39204. getStencilOperationFail(): number;
  39205. /**
  39206. * Gets the current stencil operation when depth fails
  39207. * @returns a number defining stencil operation to use when depth fails
  39208. */
  39209. getStencilOperationDepthFail(): number;
  39210. /**
  39211. * Gets the current stencil operation when stencil passes
  39212. * @returns a number defining stencil operation to use when stencil passes
  39213. */
  39214. getStencilOperationPass(): number;
  39215. /**
  39216. * Sets the stencil operation to use when stencil fails
  39217. * @param operation defines the stencil operation to use when stencil fails
  39218. */
  39219. setStencilOperationFail(operation: number): void;
  39220. /**
  39221. * Sets the stencil operation to use when depth fails
  39222. * @param operation defines the stencil operation to use when depth fails
  39223. */
  39224. setStencilOperationDepthFail(operation: number): void;
  39225. /**
  39226. * Sets the stencil operation to use when stencil passes
  39227. * @param operation defines the stencil operation to use when stencil passes
  39228. */
  39229. setStencilOperationPass(operation: number): void;
  39230. /**
  39231. * Sets a boolean indicating if the dithering state is enabled or disabled
  39232. * @param value defines the dithering state
  39233. */
  39234. setDitheringState(value: boolean): void;
  39235. /**
  39236. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39237. * @param value defines the rasterizer state
  39238. */
  39239. setRasterizerState(value: boolean): void;
  39240. /**
  39241. * Gets the current depth function
  39242. * @returns a number defining the depth function
  39243. */
  39244. getDepthFunction(): Nullable<number>;
  39245. /**
  39246. * Sets the current depth function
  39247. * @param depthFunc defines the function to use
  39248. */
  39249. setDepthFunction(depthFunc: number): void;
  39250. /**
  39251. * Sets the current depth function to GREATER
  39252. */
  39253. setDepthFunctionToGreater(): void;
  39254. /**
  39255. * Sets the current depth function to GEQUAL
  39256. */
  39257. setDepthFunctionToGreaterOrEqual(): void;
  39258. /**
  39259. * Sets the current depth function to LESS
  39260. */
  39261. setDepthFunctionToLess(): void;
  39262. /**
  39263. * Sets the current depth function to LEQUAL
  39264. */
  39265. setDepthFunctionToLessOrEqual(): void;
  39266. private _cachedStencilBuffer;
  39267. private _cachedStencilFunction;
  39268. private _cachedStencilMask;
  39269. private _cachedStencilOperationPass;
  39270. private _cachedStencilOperationFail;
  39271. private _cachedStencilOperationDepthFail;
  39272. private _cachedStencilReference;
  39273. /**
  39274. * Caches the the state of the stencil buffer
  39275. */
  39276. cacheStencilState(): void;
  39277. /**
  39278. * Restores the state of the stencil buffer
  39279. */
  39280. restoreStencilState(): void;
  39281. /**
  39282. * Directly set the WebGL Viewport
  39283. * @param x defines the x coordinate of the viewport (in screen space)
  39284. * @param y defines the y coordinate of the viewport (in screen space)
  39285. * @param width defines the width of the viewport (in screen space)
  39286. * @param height defines the height of the viewport (in screen space)
  39287. * @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
  39288. */
  39289. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39290. /**
  39291. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39292. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39293. * @param y defines the y-coordinate of the corner of the clear rectangle
  39294. * @param width defines the width of the clear rectangle
  39295. * @param height defines the height of the clear rectangle
  39296. * @param clearColor defines the clear color
  39297. */
  39298. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39299. /**
  39300. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39301. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39302. * @param y defines the y-coordinate of the corner of the clear rectangle
  39303. * @param width defines the width of the clear rectangle
  39304. * @param height defines the height of the clear rectangle
  39305. */
  39306. enableScissor(x: number, y: number, width: number, height: number): void;
  39307. /**
  39308. * Disable previously set scissor test rectangle
  39309. */
  39310. disableScissor(): void;
  39311. protected _reportDrawCall(): void;
  39312. /**
  39313. * Initializes a webVR display and starts listening to display change events
  39314. * The onVRDisplayChangedObservable will be notified upon these changes
  39315. * @returns The onVRDisplayChangedObservable
  39316. */
  39317. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39318. /** @hidden */
  39319. _prepareVRComponent(): void;
  39320. /** @hidden */
  39321. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39322. /** @hidden */
  39323. _submitVRFrame(): void;
  39324. /**
  39325. * Call this function to leave webVR mode
  39326. * Will do nothing if webVR is not supported or if there is no webVR device
  39327. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39328. */
  39329. disableVR(): void;
  39330. /**
  39331. * Gets a boolean indicating that the system is in VR mode and is presenting
  39332. * @returns true if VR mode is engaged
  39333. */
  39334. isVRPresenting(): boolean;
  39335. /** @hidden */
  39336. _requestVRFrame(): void;
  39337. /** @hidden */
  39338. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39339. /**
  39340. * Gets the source code of the vertex shader associated with a specific webGL program
  39341. * @param program defines the program to use
  39342. * @returns a string containing the source code of the vertex shader associated with the program
  39343. */
  39344. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39345. /**
  39346. * Gets the source code of the fragment shader associated with a specific webGL program
  39347. * @param program defines the program to use
  39348. * @returns a string containing the source code of the fragment shader associated with the program
  39349. */
  39350. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39351. /**
  39352. * Sets a depth stencil texture from a render target to the according uniform.
  39353. * @param channel The texture channel
  39354. * @param uniform The uniform to set
  39355. * @param texture The render target texture containing the depth stencil texture to apply
  39356. */
  39357. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39358. /**
  39359. * Sets a texture to the webGL context from a postprocess
  39360. * @param channel defines the channel to use
  39361. * @param postProcess defines the source postprocess
  39362. */
  39363. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39364. /**
  39365. * Binds the output of the passed in post process to the texture channel specified
  39366. * @param channel The channel the texture should be bound to
  39367. * @param postProcess The post process which's output should be bound
  39368. */
  39369. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39370. protected _rebuildBuffers(): void;
  39371. /** @hidden */
  39372. _renderFrame(): void;
  39373. _renderLoop(): void;
  39374. /** @hidden */
  39375. _renderViews(): boolean;
  39376. /**
  39377. * Toggle full screen mode
  39378. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39379. */
  39380. switchFullscreen(requestPointerLock: boolean): void;
  39381. /**
  39382. * Enters full screen mode
  39383. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39384. */
  39385. enterFullscreen(requestPointerLock: boolean): void;
  39386. /**
  39387. * Exits full screen mode
  39388. */
  39389. exitFullscreen(): void;
  39390. /**
  39391. * Enters Pointerlock mode
  39392. */
  39393. enterPointerlock(): void;
  39394. /**
  39395. * Exits Pointerlock mode
  39396. */
  39397. exitPointerlock(): void;
  39398. /**
  39399. * Begin a new frame
  39400. */
  39401. beginFrame(): void;
  39402. /**
  39403. * Enf the current frame
  39404. */
  39405. endFrame(): void;
  39406. resize(): void;
  39407. /**
  39408. * Force a specific size of the canvas
  39409. * @param width defines the new canvas' width
  39410. * @param height defines the new canvas' height
  39411. * @returns true if the size was changed
  39412. */
  39413. setSize(width: number, height: number): boolean;
  39414. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39415. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39416. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39417. _releaseTexture(texture: InternalTexture): void;
  39418. /**
  39419. * @hidden
  39420. * Rescales a texture
  39421. * @param source input texutre
  39422. * @param destination destination texture
  39423. * @param scene scene to use to render the resize
  39424. * @param internalFormat format to use when resizing
  39425. * @param onComplete callback to be called when resize has completed
  39426. */
  39427. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39428. /**
  39429. * Gets the current framerate
  39430. * @returns a number representing the framerate
  39431. */
  39432. getFps(): number;
  39433. /**
  39434. * Gets the time spent between current and previous frame
  39435. * @returns a number representing the delta time in ms
  39436. */
  39437. getDeltaTime(): number;
  39438. private _measureFps;
  39439. /** @hidden */
  39440. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39441. /**
  39442. * Updates the sample count of a render target texture
  39443. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39444. * @param texture defines the texture to update
  39445. * @param samples defines the sample count to set
  39446. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39447. */
  39448. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39449. /**
  39450. * Updates a depth texture Comparison Mode and Function.
  39451. * If the comparison Function is equal to 0, the mode will be set to none.
  39452. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39453. * @param texture The texture to set the comparison function for
  39454. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39455. */
  39456. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39457. /**
  39458. * Creates a webGL buffer to use with instanciation
  39459. * @param capacity defines the size of the buffer
  39460. * @returns the webGL buffer
  39461. */
  39462. createInstancesBuffer(capacity: number): DataBuffer;
  39463. /**
  39464. * Delete a webGL buffer used with instanciation
  39465. * @param buffer defines the webGL buffer to delete
  39466. */
  39467. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39468. private _clientWaitAsync;
  39469. /** @hidden */
  39470. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39471. dispose(): void;
  39472. private _disableTouchAction;
  39473. /**
  39474. * Display the loading screen
  39475. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39476. */
  39477. displayLoadingUI(): void;
  39478. /**
  39479. * Hide the loading screen
  39480. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39481. */
  39482. hideLoadingUI(): void;
  39483. /**
  39484. * Gets the current loading screen object
  39485. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39486. */
  39487. get loadingScreen(): ILoadingScreen;
  39488. /**
  39489. * Sets the current loading screen object
  39490. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39491. */
  39492. set loadingScreen(loadingScreen: ILoadingScreen);
  39493. /**
  39494. * Sets the current loading screen text
  39495. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39496. */
  39497. set loadingUIText(text: string);
  39498. /**
  39499. * Sets the current loading screen background color
  39500. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39501. */
  39502. set loadingUIBackgroundColor(color: string);
  39503. /** Pointerlock and fullscreen */
  39504. /**
  39505. * Ask the browser to promote the current element to pointerlock mode
  39506. * @param element defines the DOM element to promote
  39507. */
  39508. static _RequestPointerlock(element: HTMLElement): void;
  39509. /**
  39510. * Asks the browser to exit pointerlock mode
  39511. */
  39512. static _ExitPointerlock(): void;
  39513. /**
  39514. * Ask the browser to promote the current element to fullscreen rendering mode
  39515. * @param element defines the DOM element to promote
  39516. */
  39517. static _RequestFullscreen(element: HTMLElement): void;
  39518. /**
  39519. * Asks the browser to exit fullscreen mode
  39520. */
  39521. static _ExitFullscreen(): void;
  39522. }
  39523. }
  39524. declare module "babylonjs/Engines/engineStore" {
  39525. import { Nullable } from "babylonjs/types";
  39526. import { Engine } from "babylonjs/Engines/engine";
  39527. import { Scene } from "babylonjs/scene";
  39528. /**
  39529. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39530. * during the life time of the application.
  39531. */
  39532. export class EngineStore {
  39533. /** Gets the list of created engines */
  39534. static Instances: import("babylonjs/Engines/engine").Engine[];
  39535. /** @hidden */
  39536. static _LastCreatedScene: Nullable<Scene>;
  39537. /**
  39538. * Gets the latest created engine
  39539. */
  39540. static get LastCreatedEngine(): Nullable<Engine>;
  39541. /**
  39542. * Gets the latest created scene
  39543. */
  39544. static get LastCreatedScene(): Nullable<Scene>;
  39545. /**
  39546. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39547. * @ignorenaming
  39548. */
  39549. static UseFallbackTexture: boolean;
  39550. /**
  39551. * Texture content used if a texture cannot loaded
  39552. * @ignorenaming
  39553. */
  39554. static FallbackTexture: string;
  39555. }
  39556. }
  39557. declare module "babylonjs/Misc/promise" {
  39558. /**
  39559. * Helper class that provides a small promise polyfill
  39560. */
  39561. export class PromisePolyfill {
  39562. /**
  39563. * Static function used to check if the polyfill is required
  39564. * If this is the case then the function will inject the polyfill to window.Promise
  39565. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39566. */
  39567. static Apply(force?: boolean): void;
  39568. }
  39569. }
  39570. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39571. /**
  39572. * Interface for screenshot methods with describe argument called `size` as object with options
  39573. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39574. */
  39575. export interface IScreenshotSize {
  39576. /**
  39577. * number in pixels for canvas height
  39578. */
  39579. height?: number;
  39580. /**
  39581. * multiplier allowing render at a higher or lower resolution
  39582. * If value is defined then height and width will be ignored and taken from camera
  39583. */
  39584. precision?: number;
  39585. /**
  39586. * number in pixels for canvas width
  39587. */
  39588. width?: number;
  39589. }
  39590. }
  39591. declare module "babylonjs/Misc/tools" {
  39592. import { Nullable, float } from "babylonjs/types";
  39593. import { DomManagement } from "babylonjs/Misc/domManagement";
  39594. import { WebRequest } from "babylonjs/Misc/webRequest";
  39595. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39596. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39597. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39598. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39599. import { Camera } from "babylonjs/Cameras/camera";
  39600. import { Engine } from "babylonjs/Engines/engine";
  39601. interface IColor4Like {
  39602. r: float;
  39603. g: float;
  39604. b: float;
  39605. a: float;
  39606. }
  39607. /**
  39608. * Class containing a set of static utilities functions
  39609. */
  39610. export class Tools {
  39611. /**
  39612. * Gets or sets the base URL to use to load assets
  39613. */
  39614. static get BaseUrl(): string;
  39615. static set BaseUrl(value: string);
  39616. /**
  39617. * Enable/Disable Custom HTTP Request Headers globally.
  39618. * default = false
  39619. * @see CustomRequestHeaders
  39620. */
  39621. static UseCustomRequestHeaders: boolean;
  39622. /**
  39623. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39624. * i.e. when loading files, where the server/service expects an Authorization header
  39625. */
  39626. static CustomRequestHeaders: {
  39627. [key: string]: string;
  39628. };
  39629. /**
  39630. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39631. */
  39632. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39633. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39634. /**
  39635. * Default behaviour for cors in the application.
  39636. * It can be a string if the expected behavior is identical in the entire app.
  39637. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39638. */
  39639. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39640. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39641. /**
  39642. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39643. * @ignorenaming
  39644. */
  39645. static get UseFallbackTexture(): boolean;
  39646. static set UseFallbackTexture(value: boolean);
  39647. /**
  39648. * Use this object to register external classes like custom textures or material
  39649. * to allow the laoders to instantiate them
  39650. */
  39651. static get RegisteredExternalClasses(): {
  39652. [key: string]: Object;
  39653. };
  39654. static set RegisteredExternalClasses(classes: {
  39655. [key: string]: Object;
  39656. });
  39657. /**
  39658. * Texture content used if a texture cannot loaded
  39659. * @ignorenaming
  39660. */
  39661. static get fallbackTexture(): string;
  39662. static set fallbackTexture(value: string);
  39663. /**
  39664. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39665. * @param u defines the coordinate on X axis
  39666. * @param v defines the coordinate on Y axis
  39667. * @param width defines the width of the source data
  39668. * @param height defines the height of the source data
  39669. * @param pixels defines the source byte array
  39670. * @param color defines the output color
  39671. */
  39672. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39673. /**
  39674. * Interpolates between a and b via alpha
  39675. * @param a The lower value (returned when alpha = 0)
  39676. * @param b The upper value (returned when alpha = 1)
  39677. * @param alpha The interpolation-factor
  39678. * @return The mixed value
  39679. */
  39680. static Mix(a: number, b: number, alpha: number): number;
  39681. /**
  39682. * Tries to instantiate a new object from a given class name
  39683. * @param className defines the class name to instantiate
  39684. * @returns the new object or null if the system was not able to do the instantiation
  39685. */
  39686. static Instantiate(className: string): any;
  39687. /**
  39688. * Provides a slice function that will work even on IE
  39689. * @param data defines the array to slice
  39690. * @param start defines the start of the data (optional)
  39691. * @param end defines the end of the data (optional)
  39692. * @returns the new sliced array
  39693. */
  39694. static Slice<T>(data: T, start?: number, end?: number): T;
  39695. /**
  39696. * Polyfill for setImmediate
  39697. * @param action defines the action to execute after the current execution block
  39698. */
  39699. static SetImmediate(action: () => void): void;
  39700. /**
  39701. * Function indicating if a number is an exponent of 2
  39702. * @param value defines the value to test
  39703. * @returns true if the value is an exponent of 2
  39704. */
  39705. static IsExponentOfTwo(value: number): boolean;
  39706. private static _tmpFloatArray;
  39707. /**
  39708. * Returns the nearest 32-bit single precision float representation of a Number
  39709. * @param value A Number. If the parameter is of a different type, it will get converted
  39710. * to a number or to NaN if it cannot be converted
  39711. * @returns number
  39712. */
  39713. static FloatRound(value: number): number;
  39714. /**
  39715. * Extracts the filename from a path
  39716. * @param path defines the path to use
  39717. * @returns the filename
  39718. */
  39719. static GetFilename(path: string): string;
  39720. /**
  39721. * Extracts the "folder" part of a path (everything before the filename).
  39722. * @param uri The URI to extract the info from
  39723. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39724. * @returns The "folder" part of the path
  39725. */
  39726. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39727. /**
  39728. * Extracts text content from a DOM element hierarchy
  39729. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39730. */
  39731. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39732. /**
  39733. * Convert an angle in radians to degrees
  39734. * @param angle defines the angle to convert
  39735. * @returns the angle in degrees
  39736. */
  39737. static ToDegrees(angle: number): number;
  39738. /**
  39739. * Convert an angle in degrees to radians
  39740. * @param angle defines the angle to convert
  39741. * @returns the angle in radians
  39742. */
  39743. static ToRadians(angle: number): number;
  39744. /**
  39745. * Returns an array if obj is not an array
  39746. * @param obj defines the object to evaluate as an array
  39747. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39748. * @returns either obj directly if obj is an array or a new array containing obj
  39749. */
  39750. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39751. /**
  39752. * Gets the pointer prefix to use
  39753. * @param engine defines the engine we are finding the prefix for
  39754. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39755. */
  39756. static GetPointerPrefix(engine: Engine): string;
  39757. /**
  39758. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39759. * @param url define the url we are trying
  39760. * @param element define the dom element where to configure the cors policy
  39761. */
  39762. static SetCorsBehavior(url: string | string[], element: {
  39763. crossOrigin: string | null;
  39764. }): void;
  39765. /**
  39766. * Removes unwanted characters from an url
  39767. * @param url defines the url to clean
  39768. * @returns the cleaned url
  39769. */
  39770. static CleanUrl(url: string): string;
  39771. /**
  39772. * Gets or sets a function used to pre-process url before using them to load assets
  39773. */
  39774. static get PreprocessUrl(): (url: string) => string;
  39775. static set PreprocessUrl(processor: (url: string) => string);
  39776. /**
  39777. * Loads an image as an HTMLImageElement.
  39778. * @param input url string, ArrayBuffer, or Blob to load
  39779. * @param onLoad callback called when the image successfully loads
  39780. * @param onError callback called when the image fails to load
  39781. * @param offlineProvider offline provider for caching
  39782. * @param mimeType optional mime type
  39783. * @returns the HTMLImageElement of the loaded image
  39784. */
  39785. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39786. /**
  39787. * Loads a file from a url
  39788. * @param url url string, ArrayBuffer, or Blob to load
  39789. * @param onSuccess callback called when the file successfully loads
  39790. * @param onProgress callback called while file is loading (if the server supports this mode)
  39791. * @param offlineProvider defines the offline provider for caching
  39792. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39793. * @param onError callback called when the file fails to load
  39794. * @returns a file request object
  39795. */
  39796. 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;
  39797. /**
  39798. * Loads a file from a url
  39799. * @param url the file url to load
  39800. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39801. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39802. */
  39803. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39804. /**
  39805. * Load a script (identified by an url). When the url returns, the
  39806. * content of this file is added into a new script element, attached to the DOM (body element)
  39807. * @param scriptUrl defines the url of the script to laod
  39808. * @param onSuccess defines the callback called when the script is loaded
  39809. * @param onError defines the callback to call if an error occurs
  39810. * @param scriptId defines the id of the script element
  39811. */
  39812. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39813. /**
  39814. * Load an asynchronous script (identified by an url). When the url returns, the
  39815. * content of this file is added into a new script element, attached to the DOM (body element)
  39816. * @param scriptUrl defines the url of the script to laod
  39817. * @param scriptId defines the id of the script element
  39818. * @returns a promise request object
  39819. */
  39820. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39821. /**
  39822. * Loads a file from a blob
  39823. * @param fileToLoad defines the blob to use
  39824. * @param callback defines the callback to call when data is loaded
  39825. * @param progressCallback defines the callback to call during loading process
  39826. * @returns a file request object
  39827. */
  39828. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39829. /**
  39830. * Reads a file from a File object
  39831. * @param file defines the file to load
  39832. * @param onSuccess defines the callback to call when data is loaded
  39833. * @param onProgress defines the callback to call during loading process
  39834. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39835. * @param onError defines the callback to call when an error occurs
  39836. * @returns a file request object
  39837. */
  39838. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39839. /**
  39840. * Creates a data url from a given string content
  39841. * @param content defines the content to convert
  39842. * @returns the new data url link
  39843. */
  39844. static FileAsURL(content: string): string;
  39845. /**
  39846. * Format the given number to a specific decimal format
  39847. * @param value defines the number to format
  39848. * @param decimals defines the number of decimals to use
  39849. * @returns the formatted string
  39850. */
  39851. static Format(value: number, decimals?: number): string;
  39852. /**
  39853. * Tries to copy an object by duplicating every property
  39854. * @param source defines the source object
  39855. * @param destination defines the target object
  39856. * @param doNotCopyList defines a list of properties to avoid
  39857. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39858. */
  39859. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39860. /**
  39861. * Gets a boolean indicating if the given object has no own property
  39862. * @param obj defines the object to test
  39863. * @returns true if object has no own property
  39864. */
  39865. static IsEmpty(obj: any): boolean;
  39866. /**
  39867. * Function used to register events at window level
  39868. * @param windowElement defines the Window object to use
  39869. * @param events defines the events to register
  39870. */
  39871. static RegisterTopRootEvents(windowElement: Window, events: {
  39872. name: string;
  39873. handler: Nullable<(e: FocusEvent) => any>;
  39874. }[]): void;
  39875. /**
  39876. * Function used to unregister events from window level
  39877. * @param windowElement defines the Window object to use
  39878. * @param events defines the events to unregister
  39879. */
  39880. static UnregisterTopRootEvents(windowElement: Window, events: {
  39881. name: string;
  39882. handler: Nullable<(e: FocusEvent) => any>;
  39883. }[]): void;
  39884. /**
  39885. * @ignore
  39886. */
  39887. static _ScreenshotCanvas: HTMLCanvasElement;
  39888. /**
  39889. * Dumps the current bound framebuffer
  39890. * @param width defines the rendering width
  39891. * @param height defines the rendering height
  39892. * @param engine defines the hosting engine
  39893. * @param successCallback defines the callback triggered once the data are available
  39894. * @param mimeType defines the mime type of the result
  39895. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39896. */
  39897. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39898. /**
  39899. * Converts the canvas data to blob.
  39900. * This acts as a polyfill for browsers not supporting the to blob function.
  39901. * @param canvas Defines the canvas to extract the data from
  39902. * @param successCallback Defines the callback triggered once the data are available
  39903. * @param mimeType Defines the mime type of the result
  39904. */
  39905. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39906. /**
  39907. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39908. * @param successCallback defines the callback triggered once the data are available
  39909. * @param mimeType defines the mime type of the result
  39910. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39911. */
  39912. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39913. /**
  39914. * Downloads a blob in the browser
  39915. * @param blob defines the blob to download
  39916. * @param fileName defines the name of the downloaded file
  39917. */
  39918. static Download(blob: Blob, fileName: string): void;
  39919. /**
  39920. * Captures a screenshot of the current rendering
  39921. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39922. * @param engine defines the rendering engine
  39923. * @param camera defines the source camera
  39924. * @param size This parameter can be set to a single number or to an object with the
  39925. * following (optional) properties: precision, width, height. If a single number is passed,
  39926. * it will be used for both width and height. If an object is passed, the screenshot size
  39927. * will be derived from the parameters. The precision property is a multiplier allowing
  39928. * rendering at a higher or lower resolution
  39929. * @param successCallback defines the callback receives a single parameter which contains the
  39930. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39931. * src parameter of an <img> to display it
  39932. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39933. * Check your browser for supported MIME types
  39934. */
  39935. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39936. /**
  39937. * Captures a screenshot of the current rendering
  39938. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39939. * @param engine defines the rendering engine
  39940. * @param camera defines the source camera
  39941. * @param size This parameter can be set to a single number or to an object with the
  39942. * following (optional) properties: precision, width, height. If a single number is passed,
  39943. * it will be used for both width and height. If an object is passed, the screenshot size
  39944. * will be derived from the parameters. The precision property is a multiplier allowing
  39945. * rendering at a higher or lower resolution
  39946. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39947. * Check your browser for supported MIME types
  39948. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39949. * to the src parameter of an <img> to display it
  39950. */
  39951. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39952. /**
  39953. * Generates an image screenshot from the specified camera.
  39954. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39955. * @param engine The engine to use for rendering
  39956. * @param camera The camera to use for rendering
  39957. * @param size This parameter can be set to a single number or to an object with the
  39958. * following (optional) properties: precision, width, height. If a single number is passed,
  39959. * it will be used for both width and height. If an object is passed, the screenshot size
  39960. * will be derived from the parameters. The precision property is a multiplier allowing
  39961. * rendering at a higher or lower resolution
  39962. * @param successCallback The callback receives a single parameter which contains the
  39963. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39964. * src parameter of an <img> to display it
  39965. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39966. * Check your browser for supported MIME types
  39967. * @param samples Texture samples (default: 1)
  39968. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39969. * @param fileName A name for for the downloaded file.
  39970. */
  39971. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39972. /**
  39973. * Generates an image screenshot from the specified camera.
  39974. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39975. * @param engine The engine to use for rendering
  39976. * @param camera The camera to use for rendering
  39977. * @param size This parameter can be set to a single number or to an object with the
  39978. * following (optional) properties: precision, width, height. If a single number is passed,
  39979. * it will be used for both width and height. If an object is passed, the screenshot size
  39980. * will be derived from the parameters. The precision property is a multiplier allowing
  39981. * rendering at a higher or lower resolution
  39982. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39983. * Check your browser for supported MIME types
  39984. * @param samples Texture samples (default: 1)
  39985. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39986. * @param fileName A name for for the downloaded file.
  39987. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39988. * to the src parameter of an <img> to display it
  39989. */
  39990. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39991. /**
  39992. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39993. * Be aware Math.random() could cause collisions, but:
  39994. * "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"
  39995. * @returns a pseudo random id
  39996. */
  39997. static RandomId(): string;
  39998. /**
  39999. * Test if the given uri is a base64 string
  40000. * @param uri The uri to test
  40001. * @return True if the uri is a base64 string or false otherwise
  40002. */
  40003. static IsBase64(uri: string): boolean;
  40004. /**
  40005. * Decode the given base64 uri.
  40006. * @param uri The uri to decode
  40007. * @return The decoded base64 data.
  40008. */
  40009. static DecodeBase64(uri: string): ArrayBuffer;
  40010. /**
  40011. * Gets the absolute url.
  40012. * @param url the input url
  40013. * @return the absolute url
  40014. */
  40015. static GetAbsoluteUrl(url: string): string;
  40016. /**
  40017. * No log
  40018. */
  40019. static readonly NoneLogLevel: number;
  40020. /**
  40021. * Only message logs
  40022. */
  40023. static readonly MessageLogLevel: number;
  40024. /**
  40025. * Only warning logs
  40026. */
  40027. static readonly WarningLogLevel: number;
  40028. /**
  40029. * Only error logs
  40030. */
  40031. static readonly ErrorLogLevel: number;
  40032. /**
  40033. * All logs
  40034. */
  40035. static readonly AllLogLevel: number;
  40036. /**
  40037. * Gets a value indicating the number of loading errors
  40038. * @ignorenaming
  40039. */
  40040. static get errorsCount(): number;
  40041. /**
  40042. * Callback called when a new log is added
  40043. */
  40044. static OnNewCacheEntry: (entry: string) => void;
  40045. /**
  40046. * Log a message to the console
  40047. * @param message defines the message to log
  40048. */
  40049. static Log(message: string): void;
  40050. /**
  40051. * Write a warning message to the console
  40052. * @param message defines the message to log
  40053. */
  40054. static Warn(message: string): void;
  40055. /**
  40056. * Write an error message to the console
  40057. * @param message defines the message to log
  40058. */
  40059. static Error(message: string): void;
  40060. /**
  40061. * Gets current log cache (list of logs)
  40062. */
  40063. static get LogCache(): string;
  40064. /**
  40065. * Clears the log cache
  40066. */
  40067. static ClearLogCache(): void;
  40068. /**
  40069. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40070. */
  40071. static set LogLevels(level: number);
  40072. /**
  40073. * Checks if the window object exists
  40074. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  40075. */
  40076. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  40077. /**
  40078. * No performance log
  40079. */
  40080. static readonly PerformanceNoneLogLevel: number;
  40081. /**
  40082. * Use user marks to log performance
  40083. */
  40084. static readonly PerformanceUserMarkLogLevel: number;
  40085. /**
  40086. * Log performance to the console
  40087. */
  40088. static readonly PerformanceConsoleLogLevel: number;
  40089. private static _performance;
  40090. /**
  40091. * Sets the current performance log level
  40092. */
  40093. static set PerformanceLogLevel(level: number);
  40094. private static _StartPerformanceCounterDisabled;
  40095. private static _EndPerformanceCounterDisabled;
  40096. private static _StartUserMark;
  40097. private static _EndUserMark;
  40098. private static _StartPerformanceConsole;
  40099. private static _EndPerformanceConsole;
  40100. /**
  40101. * Starts a performance counter
  40102. */
  40103. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40104. /**
  40105. * Ends a specific performance coutner
  40106. */
  40107. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40108. /**
  40109. * Gets either window.performance.now() if supported or Date.now() else
  40110. */
  40111. static get Now(): number;
  40112. /**
  40113. * This method will return the name of the class used to create the instance of the given object.
  40114. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40115. * @param object the object to get the class name from
  40116. * @param isType defines if the object is actually a type
  40117. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40118. */
  40119. static GetClassName(object: any, isType?: boolean): string;
  40120. /**
  40121. * Gets the first element of an array satisfying a given predicate
  40122. * @param array defines the array to browse
  40123. * @param predicate defines the predicate to use
  40124. * @returns null if not found or the element
  40125. */
  40126. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40127. /**
  40128. * This method will return the name of the full name of the class, including its owning module (if any).
  40129. * 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).
  40130. * @param object the object to get the class name from
  40131. * @param isType defines if the object is actually a type
  40132. * @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.
  40133. * @ignorenaming
  40134. */
  40135. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40136. /**
  40137. * Returns a promise that resolves after the given amount of time.
  40138. * @param delay Number of milliseconds to delay
  40139. * @returns Promise that resolves after the given amount of time
  40140. */
  40141. static DelayAsync(delay: number): Promise<void>;
  40142. /**
  40143. * Utility function to detect if the current user agent is Safari
  40144. * @returns whether or not the current user agent is safari
  40145. */
  40146. static IsSafari(): boolean;
  40147. }
  40148. /**
  40149. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40150. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40151. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40152. * @param name The name of the class, case should be preserved
  40153. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40154. */
  40155. export function className(name: string, module?: string): (target: Object) => void;
  40156. /**
  40157. * An implementation of a loop for asynchronous functions.
  40158. */
  40159. export class AsyncLoop {
  40160. /**
  40161. * Defines the number of iterations for the loop
  40162. */
  40163. iterations: number;
  40164. /**
  40165. * Defines the current index of the loop.
  40166. */
  40167. index: number;
  40168. private _done;
  40169. private _fn;
  40170. private _successCallback;
  40171. /**
  40172. * Constructor.
  40173. * @param iterations the number of iterations.
  40174. * @param func the function to run each iteration
  40175. * @param successCallback the callback that will be called upon succesful execution
  40176. * @param offset starting offset.
  40177. */
  40178. constructor(
  40179. /**
  40180. * Defines the number of iterations for the loop
  40181. */
  40182. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40183. /**
  40184. * Execute the next iteration. Must be called after the last iteration was finished.
  40185. */
  40186. executeNext(): void;
  40187. /**
  40188. * Break the loop and run the success callback.
  40189. */
  40190. breakLoop(): void;
  40191. /**
  40192. * Create and run an async loop.
  40193. * @param iterations the number of iterations.
  40194. * @param fn the function to run each iteration
  40195. * @param successCallback the callback that will be called upon succesful execution
  40196. * @param offset starting offset.
  40197. * @returns the created async loop object
  40198. */
  40199. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40200. /**
  40201. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40202. * @param iterations total number of iterations
  40203. * @param syncedIterations number of synchronous iterations in each async iteration.
  40204. * @param fn the function to call each iteration.
  40205. * @param callback a success call back that will be called when iterating stops.
  40206. * @param breakFunction a break condition (optional)
  40207. * @param timeout timeout settings for the setTimeout function. default - 0.
  40208. * @returns the created async loop object
  40209. */
  40210. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40211. }
  40212. }
  40213. declare module "babylonjs/Misc/stringDictionary" {
  40214. import { Nullable } from "babylonjs/types";
  40215. /**
  40216. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40217. * The underlying implementation relies on an associative array to ensure the best performances.
  40218. * The value can be anything including 'null' but except 'undefined'
  40219. */
  40220. export class StringDictionary<T> {
  40221. /**
  40222. * This will clear this dictionary and copy the content from the 'source' one.
  40223. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40224. * @param source the dictionary to take the content from and copy to this dictionary
  40225. */
  40226. copyFrom(source: StringDictionary<T>): void;
  40227. /**
  40228. * Get a value based from its key
  40229. * @param key the given key to get the matching value from
  40230. * @return the value if found, otherwise undefined is returned
  40231. */
  40232. get(key: string): T | undefined;
  40233. /**
  40234. * Get a value from its key or add it if it doesn't exist.
  40235. * This method will ensure you that a given key/data will be present in the dictionary.
  40236. * @param key the given key to get the matching value from
  40237. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40238. * The factory will only be invoked if there's no data for the given key.
  40239. * @return the value corresponding to the key.
  40240. */
  40241. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40242. /**
  40243. * Get a value from its key if present in the dictionary otherwise add it
  40244. * @param key the key to get the value from
  40245. * @param val if there's no such key/value pair in the dictionary add it with this value
  40246. * @return the value corresponding to the key
  40247. */
  40248. getOrAdd(key: string, val: T): T;
  40249. /**
  40250. * Check if there's a given key in the dictionary
  40251. * @param key the key to check for
  40252. * @return true if the key is present, false otherwise
  40253. */
  40254. contains(key: string): boolean;
  40255. /**
  40256. * Add a new key and its corresponding value
  40257. * @param key the key to add
  40258. * @param value the value corresponding to the key
  40259. * @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
  40260. */
  40261. add(key: string, value: T): boolean;
  40262. /**
  40263. * Update a specific value associated to a key
  40264. * @param key defines the key to use
  40265. * @param value defines the value to store
  40266. * @returns true if the value was updated (or false if the key was not found)
  40267. */
  40268. set(key: string, value: T): boolean;
  40269. /**
  40270. * Get the element of the given key and remove it from the dictionary
  40271. * @param key defines the key to search
  40272. * @returns the value associated with the key or null if not found
  40273. */
  40274. getAndRemove(key: string): Nullable<T>;
  40275. /**
  40276. * Remove a key/value from the dictionary.
  40277. * @param key the key to remove
  40278. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40279. */
  40280. remove(key: string): boolean;
  40281. /**
  40282. * Clear the whole content of the dictionary
  40283. */
  40284. clear(): void;
  40285. /**
  40286. * Gets the current count
  40287. */
  40288. get count(): number;
  40289. /**
  40290. * Execute a callback on each key/val of the dictionary.
  40291. * Note that you can remove any element in this dictionary in the callback implementation
  40292. * @param callback the callback to execute on a given key/value pair
  40293. */
  40294. forEach(callback: (key: string, val: T) => void): void;
  40295. /**
  40296. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40297. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40298. * Note that you can remove any element in this dictionary in the callback implementation
  40299. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40300. * @returns the first item
  40301. */
  40302. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40303. private _count;
  40304. private _data;
  40305. }
  40306. }
  40307. declare module "babylonjs/Collisions/collisionCoordinator" {
  40308. import { Nullable } from "babylonjs/types";
  40309. import { Scene } from "babylonjs/scene";
  40310. import { Vector3 } from "babylonjs/Maths/math.vector";
  40311. import { Collider } from "babylonjs/Collisions/collider";
  40312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40313. /** @hidden */
  40314. export interface ICollisionCoordinator {
  40315. createCollider(): Collider;
  40316. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40317. init(scene: Scene): void;
  40318. }
  40319. /** @hidden */
  40320. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40321. private _scene;
  40322. private _scaledPosition;
  40323. private _scaledVelocity;
  40324. private _finalPosition;
  40325. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40326. createCollider(): Collider;
  40327. init(scene: Scene): void;
  40328. private _collideWithWorld;
  40329. }
  40330. }
  40331. declare module "babylonjs/Inputs/scene.inputManager" {
  40332. import { Nullable } from "babylonjs/types";
  40333. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40334. import { Vector2 } from "babylonjs/Maths/math.vector";
  40335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40336. import { Scene } from "babylonjs/scene";
  40337. /**
  40338. * Class used to manage all inputs for the scene.
  40339. */
  40340. export class InputManager {
  40341. /** The distance in pixel that you have to move to prevent some events */
  40342. static DragMovementThreshold: number;
  40343. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40344. static LongPressDelay: number;
  40345. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40346. static DoubleClickDelay: number;
  40347. /** If you need to check double click without raising a single click at first click, enable this flag */
  40348. static ExclusiveDoubleClickMode: boolean;
  40349. /** 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. */
  40350. private _alreadyAttached;
  40351. private _wheelEventName;
  40352. private _onPointerMove;
  40353. private _onPointerDown;
  40354. private _onPointerUp;
  40355. private _initClickEvent;
  40356. private _initActionManager;
  40357. private _delayedSimpleClick;
  40358. private _delayedSimpleClickTimeout;
  40359. private _previousDelayedSimpleClickTimeout;
  40360. private _meshPickProceed;
  40361. private _previousButtonPressed;
  40362. private _currentPickResult;
  40363. private _previousPickResult;
  40364. private _totalPointersPressed;
  40365. private _doubleClickOccured;
  40366. private _pointerOverMesh;
  40367. private _pickedDownMesh;
  40368. private _pickedUpMesh;
  40369. private _pointerX;
  40370. private _pointerY;
  40371. private _unTranslatedPointerX;
  40372. private _unTranslatedPointerY;
  40373. private _startingPointerPosition;
  40374. private _previousStartingPointerPosition;
  40375. private _startingPointerTime;
  40376. private _previousStartingPointerTime;
  40377. private _pointerCaptures;
  40378. private _meshUnderPointerId;
  40379. private _onKeyDown;
  40380. private _onKeyUp;
  40381. private _onCanvasFocusObserver;
  40382. private _onCanvasBlurObserver;
  40383. private _scene;
  40384. /**
  40385. * Creates a new InputManager
  40386. * @param scene defines the hosting scene
  40387. */
  40388. constructor(scene: Scene);
  40389. /**
  40390. * Gets the mesh that is currently under the pointer
  40391. */
  40392. get meshUnderPointer(): Nullable<AbstractMesh>;
  40393. /**
  40394. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40395. * @param pointerId the pointer id to use
  40396. * @returns The mesh under this pointer id or null if not found
  40397. */
  40398. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40399. /**
  40400. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40401. */
  40402. get unTranslatedPointer(): Vector2;
  40403. /**
  40404. * Gets or sets the current on-screen X position of the pointer
  40405. */
  40406. get pointerX(): number;
  40407. set pointerX(value: number);
  40408. /**
  40409. * Gets or sets the current on-screen Y position of the pointer
  40410. */
  40411. get pointerY(): number;
  40412. set pointerY(value: number);
  40413. private _updatePointerPosition;
  40414. private _processPointerMove;
  40415. private _setRayOnPointerInfo;
  40416. private _checkPrePointerObservable;
  40417. /**
  40418. * Use this method to simulate a pointer move on a mesh
  40419. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40420. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40421. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40422. */
  40423. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40424. /**
  40425. * Use this method to simulate a pointer down on a mesh
  40426. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40427. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40428. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40429. */
  40430. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40431. private _processPointerDown;
  40432. /** @hidden */
  40433. _isPointerSwiping(): boolean;
  40434. /**
  40435. * Use this method to simulate a pointer up on a mesh
  40436. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40437. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40438. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40439. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40440. */
  40441. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40442. private _processPointerUp;
  40443. /**
  40444. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40445. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40446. * @returns true if the pointer was captured
  40447. */
  40448. isPointerCaptured(pointerId?: number): boolean;
  40449. /**
  40450. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40451. * @param attachUp defines if you want to attach events to pointerup
  40452. * @param attachDown defines if you want to attach events to pointerdown
  40453. * @param attachMove defines if you want to attach events to pointermove
  40454. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40455. */
  40456. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40457. /**
  40458. * Detaches all event handlers
  40459. */
  40460. detachControl(): void;
  40461. /**
  40462. * Force the value of meshUnderPointer
  40463. * @param mesh defines the mesh to use
  40464. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40465. */
  40466. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40467. /**
  40468. * Gets the mesh under the pointer
  40469. * @returns a Mesh or null if no mesh is under the pointer
  40470. */
  40471. getPointerOverMesh(): Nullable<AbstractMesh>;
  40472. }
  40473. }
  40474. declare module "babylonjs/Animations/animationGroup" {
  40475. import { Animatable } from "babylonjs/Animations/animatable";
  40476. import { Animation } from "babylonjs/Animations/animation";
  40477. import { Scene, IDisposable } from "babylonjs/scene";
  40478. import { Observable } from "babylonjs/Misc/observable";
  40479. import { Nullable } from "babylonjs/types";
  40480. import "babylonjs/Animations/animatable";
  40481. /**
  40482. * This class defines the direct association between an animation and a target
  40483. */
  40484. export class TargetedAnimation {
  40485. /**
  40486. * Animation to perform
  40487. */
  40488. animation: Animation;
  40489. /**
  40490. * Target to animate
  40491. */
  40492. target: any;
  40493. /**
  40494. * Returns the string "TargetedAnimation"
  40495. * @returns "TargetedAnimation"
  40496. */
  40497. getClassName(): string;
  40498. /**
  40499. * Serialize the object
  40500. * @returns the JSON object representing the current entity
  40501. */
  40502. serialize(): any;
  40503. }
  40504. /**
  40505. * Use this class to create coordinated animations on multiple targets
  40506. */
  40507. export class AnimationGroup implements IDisposable {
  40508. /** The name of the animation group */
  40509. name: string;
  40510. private _scene;
  40511. private _targetedAnimations;
  40512. private _animatables;
  40513. private _from;
  40514. private _to;
  40515. private _isStarted;
  40516. private _isPaused;
  40517. private _speedRatio;
  40518. private _loopAnimation;
  40519. private _isAdditive;
  40520. /**
  40521. * Gets or sets the unique id of the node
  40522. */
  40523. uniqueId: number;
  40524. /**
  40525. * This observable will notify when one animation have ended
  40526. */
  40527. onAnimationEndObservable: Observable<TargetedAnimation>;
  40528. /**
  40529. * Observer raised when one animation loops
  40530. */
  40531. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40532. /**
  40533. * Observer raised when all animations have looped
  40534. */
  40535. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40536. /**
  40537. * This observable will notify when all animations have ended.
  40538. */
  40539. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40540. /**
  40541. * This observable will notify when all animations have paused.
  40542. */
  40543. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40544. /**
  40545. * This observable will notify when all animations are playing.
  40546. */
  40547. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40548. /**
  40549. * Gets the first frame
  40550. */
  40551. get from(): number;
  40552. /**
  40553. * Gets the last frame
  40554. */
  40555. get to(): number;
  40556. /**
  40557. * Define if the animations are started
  40558. */
  40559. get isStarted(): boolean;
  40560. /**
  40561. * Gets a value indicating that the current group is playing
  40562. */
  40563. get isPlaying(): boolean;
  40564. /**
  40565. * Gets or sets the speed ratio to use for all animations
  40566. */
  40567. get speedRatio(): number;
  40568. /**
  40569. * Gets or sets the speed ratio to use for all animations
  40570. */
  40571. set speedRatio(value: number);
  40572. /**
  40573. * Gets or sets if all animations should loop or not
  40574. */
  40575. get loopAnimation(): boolean;
  40576. set loopAnimation(value: boolean);
  40577. /**
  40578. * Gets or sets if all animations should be evaluated additively
  40579. */
  40580. get isAdditive(): boolean;
  40581. set isAdditive(value: boolean);
  40582. /**
  40583. * Gets the targeted animations for this animation group
  40584. */
  40585. get targetedAnimations(): Array<TargetedAnimation>;
  40586. /**
  40587. * returning the list of animatables controlled by this animation group.
  40588. */
  40589. get animatables(): Array<Animatable>;
  40590. /**
  40591. * Gets the list of target animations
  40592. */
  40593. get children(): TargetedAnimation[];
  40594. /**
  40595. * Instantiates a new Animation Group.
  40596. * This helps managing several animations at once.
  40597. * @see https://doc.babylonjs.com/how_to/group
  40598. * @param name Defines the name of the group
  40599. * @param scene Defines the scene the group belongs to
  40600. */
  40601. constructor(
  40602. /** The name of the animation group */
  40603. name: string, scene?: Nullable<Scene>);
  40604. /**
  40605. * Add an animation (with its target) in the group
  40606. * @param animation defines the animation we want to add
  40607. * @param target defines the target of the animation
  40608. * @returns the TargetedAnimation object
  40609. */
  40610. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40611. /**
  40612. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40613. * It can add constant keys at begin or end
  40614. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40615. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40616. * @returns the animation group
  40617. */
  40618. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40619. private _animationLoopCount;
  40620. private _animationLoopFlags;
  40621. private _processLoop;
  40622. /**
  40623. * Start all animations on given targets
  40624. * @param loop defines if animations must loop
  40625. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40626. * @param from defines the from key (optional)
  40627. * @param to defines the to key (optional)
  40628. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40629. * @returns the current animation group
  40630. */
  40631. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40632. /**
  40633. * Pause all animations
  40634. * @returns the animation group
  40635. */
  40636. pause(): AnimationGroup;
  40637. /**
  40638. * Play all animations to initial state
  40639. * This function will start() the animations if they were not started or will restart() them if they were paused
  40640. * @param loop defines if animations must loop
  40641. * @returns the animation group
  40642. */
  40643. play(loop?: boolean): AnimationGroup;
  40644. /**
  40645. * Reset all animations to initial state
  40646. * @returns the animation group
  40647. */
  40648. reset(): AnimationGroup;
  40649. /**
  40650. * Restart animations from key 0
  40651. * @returns the animation group
  40652. */
  40653. restart(): AnimationGroup;
  40654. /**
  40655. * Stop all animations
  40656. * @returns the animation group
  40657. */
  40658. stop(): AnimationGroup;
  40659. /**
  40660. * Set animation weight for all animatables
  40661. * @param weight defines the weight to use
  40662. * @return the animationGroup
  40663. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40664. */
  40665. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40666. /**
  40667. * Synchronize and normalize all animatables with a source animatable
  40668. * @param root defines the root animatable to synchronize with
  40669. * @return the animationGroup
  40670. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40671. */
  40672. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40673. /**
  40674. * Goes to a specific frame in this animation group
  40675. * @param frame the frame number to go to
  40676. * @return the animationGroup
  40677. */
  40678. goToFrame(frame: number): AnimationGroup;
  40679. /**
  40680. * Dispose all associated resources
  40681. */
  40682. dispose(): void;
  40683. private _checkAnimationGroupEnded;
  40684. /**
  40685. * Clone the current animation group and returns a copy
  40686. * @param newName defines the name of the new group
  40687. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40688. * @returns the new aniamtion group
  40689. */
  40690. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40691. /**
  40692. * Serializes the animationGroup to an object
  40693. * @returns Serialized object
  40694. */
  40695. serialize(): any;
  40696. /**
  40697. * Returns a new AnimationGroup object parsed from the source provided.
  40698. * @param parsedAnimationGroup defines the source
  40699. * @param scene defines the scene that will receive the animationGroup
  40700. * @returns a new AnimationGroup
  40701. */
  40702. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40703. /**
  40704. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40705. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40706. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40707. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40708. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40709. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40710. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40711. */
  40712. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40713. /**
  40714. * Returns the string "AnimationGroup"
  40715. * @returns "AnimationGroup"
  40716. */
  40717. getClassName(): string;
  40718. /**
  40719. * Creates a detailled string about the object
  40720. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40721. * @returns a string representing the object
  40722. */
  40723. toString(fullDetails?: boolean): string;
  40724. }
  40725. }
  40726. declare module "babylonjs/scene" {
  40727. import { Nullable } from "babylonjs/types";
  40728. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40729. import { Observable } from "babylonjs/Misc/observable";
  40730. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40731. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40732. import { Geometry } from "babylonjs/Meshes/geometry";
  40733. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40734. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40736. import { Mesh } from "babylonjs/Meshes/mesh";
  40737. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40738. import { Bone } from "babylonjs/Bones/bone";
  40739. import { Skeleton } from "babylonjs/Bones/skeleton";
  40740. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40741. import { Camera } from "babylonjs/Cameras/camera";
  40742. import { AbstractScene } from "babylonjs/abstractScene";
  40743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40744. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40745. import { Material } from "babylonjs/Materials/material";
  40746. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40747. import { Effect } from "babylonjs/Materials/effect";
  40748. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40749. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40750. import { Light } from "babylonjs/Lights/light";
  40751. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40752. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40753. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40754. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40755. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40756. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40757. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40758. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40759. import { Engine } from "babylonjs/Engines/engine";
  40760. import { Node } from "babylonjs/node";
  40761. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40762. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40763. import { WebRequest } from "babylonjs/Misc/webRequest";
  40764. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40765. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40766. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40767. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40768. import { Plane } from "babylonjs/Maths/math.plane";
  40769. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40770. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40771. import { Ray } from "babylonjs/Culling/ray";
  40772. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40773. import { Animation } from "babylonjs/Animations/animation";
  40774. import { Animatable } from "babylonjs/Animations/animatable";
  40775. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40776. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40777. import { Collider } from "babylonjs/Collisions/collider";
  40778. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40779. /**
  40780. * Define an interface for all classes that will hold resources
  40781. */
  40782. export interface IDisposable {
  40783. /**
  40784. * Releases all held resources
  40785. */
  40786. dispose(): void;
  40787. }
  40788. /** Interface defining initialization parameters for Scene class */
  40789. export interface SceneOptions {
  40790. /**
  40791. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40792. * It will improve performance when the number of geometries becomes important.
  40793. */
  40794. useGeometryUniqueIdsMap?: boolean;
  40795. /**
  40796. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40797. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40798. */
  40799. useMaterialMeshMap?: boolean;
  40800. /**
  40801. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40802. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40803. */
  40804. useClonedMeshMap?: boolean;
  40805. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40806. virtual?: boolean;
  40807. }
  40808. /**
  40809. * Represents a scene to be rendered by the engine.
  40810. * @see https://doc.babylonjs.com/features/scene
  40811. */
  40812. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40813. /** The fog is deactivated */
  40814. static readonly FOGMODE_NONE: number;
  40815. /** The fog density is following an exponential function */
  40816. static readonly FOGMODE_EXP: number;
  40817. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40818. static readonly FOGMODE_EXP2: number;
  40819. /** The fog density is following a linear function. */
  40820. static readonly FOGMODE_LINEAR: number;
  40821. /**
  40822. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40823. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40824. */
  40825. static MinDeltaTime: number;
  40826. /**
  40827. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40828. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40829. */
  40830. static MaxDeltaTime: number;
  40831. /**
  40832. * Factory used to create the default material.
  40833. * @param name The name of the material to create
  40834. * @param scene The scene to create the material for
  40835. * @returns The default material
  40836. */
  40837. static DefaultMaterialFactory(scene: Scene): Material;
  40838. /**
  40839. * Factory used to create the a collision coordinator.
  40840. * @returns The collision coordinator
  40841. */
  40842. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40843. /** @hidden */
  40844. _inputManager: InputManager;
  40845. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40846. cameraToUseForPointers: Nullable<Camera>;
  40847. /** @hidden */
  40848. readonly _isScene: boolean;
  40849. /** @hidden */
  40850. _blockEntityCollection: boolean;
  40851. /**
  40852. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40853. */
  40854. autoClear: boolean;
  40855. /**
  40856. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40857. */
  40858. autoClearDepthAndStencil: boolean;
  40859. /**
  40860. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40861. */
  40862. clearColor: Color4;
  40863. /**
  40864. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40865. */
  40866. ambientColor: Color3;
  40867. /**
  40868. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40869. * It should only be one of the following (if not the default embedded one):
  40870. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40871. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40872. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40873. * The material properties need to be setup according to the type of texture in use.
  40874. */
  40875. environmentBRDFTexture: BaseTexture;
  40876. /**
  40877. * Texture used in all pbr material as the reflection texture.
  40878. * As in the majority of the scene they are the same (exception for multi room and so on),
  40879. * this is easier to reference from here than from all the materials.
  40880. */
  40881. get environmentTexture(): Nullable<BaseTexture>;
  40882. /**
  40883. * Texture used in all pbr material as the reflection texture.
  40884. * As in the majority of the scene they are the same (exception for multi room and so on),
  40885. * this is easier to set here than in all the materials.
  40886. */
  40887. set environmentTexture(value: Nullable<BaseTexture>);
  40888. /** @hidden */
  40889. protected _environmentIntensity: number;
  40890. /**
  40891. * Intensity of the environment in all pbr material.
  40892. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40893. * As in the majority of the scene they are the same (exception for multi room and so on),
  40894. * this is easier to reference from here than from all the materials.
  40895. */
  40896. get environmentIntensity(): number;
  40897. /**
  40898. * Intensity of the environment in all pbr material.
  40899. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40900. * As in the majority of the scene they are the same (exception for multi room and so on),
  40901. * this is easier to set here than in all the materials.
  40902. */
  40903. set environmentIntensity(value: number);
  40904. /** @hidden */
  40905. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40906. /**
  40907. * Default image processing configuration used either in the rendering
  40908. * Forward main pass or through the imageProcessingPostProcess if present.
  40909. * As in the majority of the scene they are the same (exception for multi camera),
  40910. * this is easier to reference from here than from all the materials and post process.
  40911. *
  40912. * No setter as we it is a shared configuration, you can set the values instead.
  40913. */
  40914. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40915. private _forceWireframe;
  40916. /**
  40917. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40918. */
  40919. set forceWireframe(value: boolean);
  40920. get forceWireframe(): boolean;
  40921. private _skipFrustumClipping;
  40922. /**
  40923. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40924. */
  40925. set skipFrustumClipping(value: boolean);
  40926. get skipFrustumClipping(): boolean;
  40927. private _forcePointsCloud;
  40928. /**
  40929. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40930. */
  40931. set forcePointsCloud(value: boolean);
  40932. get forcePointsCloud(): boolean;
  40933. /**
  40934. * Gets or sets the active clipplane 1
  40935. */
  40936. clipPlane: Nullable<Plane>;
  40937. /**
  40938. * Gets or sets the active clipplane 2
  40939. */
  40940. clipPlane2: Nullable<Plane>;
  40941. /**
  40942. * Gets or sets the active clipplane 3
  40943. */
  40944. clipPlane3: Nullable<Plane>;
  40945. /**
  40946. * Gets or sets the active clipplane 4
  40947. */
  40948. clipPlane4: Nullable<Plane>;
  40949. /**
  40950. * Gets or sets the active clipplane 5
  40951. */
  40952. clipPlane5: Nullable<Plane>;
  40953. /**
  40954. * Gets or sets the active clipplane 6
  40955. */
  40956. clipPlane6: Nullable<Plane>;
  40957. /**
  40958. * Gets or sets a boolean indicating if animations are enabled
  40959. */
  40960. animationsEnabled: boolean;
  40961. private _animationPropertiesOverride;
  40962. /**
  40963. * Gets or sets the animation properties override
  40964. */
  40965. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40966. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40967. /**
  40968. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40969. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40970. */
  40971. useConstantAnimationDeltaTime: boolean;
  40972. /**
  40973. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40974. * Please note that it requires to run a ray cast through the scene on every frame
  40975. */
  40976. constantlyUpdateMeshUnderPointer: boolean;
  40977. /**
  40978. * Defines the HTML cursor to use when hovering over interactive elements
  40979. */
  40980. hoverCursor: string;
  40981. /**
  40982. * Defines the HTML default cursor to use (empty by default)
  40983. */
  40984. defaultCursor: string;
  40985. /**
  40986. * Defines whether cursors are handled by the scene.
  40987. */
  40988. doNotHandleCursors: boolean;
  40989. /**
  40990. * This is used to call preventDefault() on pointer down
  40991. * in order to block unwanted artifacts like system double clicks
  40992. */
  40993. preventDefaultOnPointerDown: boolean;
  40994. /**
  40995. * This is used to call preventDefault() on pointer up
  40996. * in order to block unwanted artifacts like system double clicks
  40997. */
  40998. preventDefaultOnPointerUp: boolean;
  40999. /**
  41000. * Gets or sets user defined metadata
  41001. */
  41002. metadata: any;
  41003. /**
  41004. * For internal use only. Please do not use.
  41005. */
  41006. reservedDataStore: any;
  41007. /**
  41008. * Gets the name of the plugin used to load this scene (null by default)
  41009. */
  41010. loadingPluginName: string;
  41011. /**
  41012. * Use this array to add regular expressions used to disable offline support for specific urls
  41013. */
  41014. disableOfflineSupportExceptionRules: RegExp[];
  41015. /**
  41016. * An event triggered when the scene is disposed.
  41017. */
  41018. onDisposeObservable: Observable<Scene>;
  41019. private _onDisposeObserver;
  41020. /** Sets a function to be executed when this scene is disposed. */
  41021. set onDispose(callback: () => void);
  41022. /**
  41023. * An event triggered before rendering the scene (right after animations and physics)
  41024. */
  41025. onBeforeRenderObservable: Observable<Scene>;
  41026. private _onBeforeRenderObserver;
  41027. /** Sets a function to be executed before rendering this scene */
  41028. set beforeRender(callback: Nullable<() => void>);
  41029. /**
  41030. * An event triggered after rendering the scene
  41031. */
  41032. onAfterRenderObservable: Observable<Scene>;
  41033. /**
  41034. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  41035. */
  41036. onAfterRenderCameraObservable: Observable<Camera>;
  41037. private _onAfterRenderObserver;
  41038. /** Sets a function to be executed after rendering this scene */
  41039. set afterRender(callback: Nullable<() => void>);
  41040. /**
  41041. * An event triggered before animating the scene
  41042. */
  41043. onBeforeAnimationsObservable: Observable<Scene>;
  41044. /**
  41045. * An event triggered after animations processing
  41046. */
  41047. onAfterAnimationsObservable: Observable<Scene>;
  41048. /**
  41049. * An event triggered before draw calls are ready to be sent
  41050. */
  41051. onBeforeDrawPhaseObservable: Observable<Scene>;
  41052. /**
  41053. * An event triggered after draw calls have been sent
  41054. */
  41055. onAfterDrawPhaseObservable: Observable<Scene>;
  41056. /**
  41057. * An event triggered when the scene is ready
  41058. */
  41059. onReadyObservable: Observable<Scene>;
  41060. /**
  41061. * An event triggered before rendering a camera
  41062. */
  41063. onBeforeCameraRenderObservable: Observable<Camera>;
  41064. private _onBeforeCameraRenderObserver;
  41065. /** Sets a function to be executed before rendering a camera*/
  41066. set beforeCameraRender(callback: () => void);
  41067. /**
  41068. * An event triggered after rendering a camera
  41069. */
  41070. onAfterCameraRenderObservable: Observable<Camera>;
  41071. private _onAfterCameraRenderObserver;
  41072. /** Sets a function to be executed after rendering a camera*/
  41073. set afterCameraRender(callback: () => void);
  41074. /**
  41075. * An event triggered when active meshes evaluation is about to start
  41076. */
  41077. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  41078. /**
  41079. * An event triggered when active meshes evaluation is done
  41080. */
  41081. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  41082. /**
  41083. * An event triggered when particles rendering is about to start
  41084. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41085. */
  41086. onBeforeParticlesRenderingObservable: Observable<Scene>;
  41087. /**
  41088. * An event triggered when particles rendering is done
  41089. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41090. */
  41091. onAfterParticlesRenderingObservable: Observable<Scene>;
  41092. /**
  41093. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  41094. */
  41095. onDataLoadedObservable: Observable<Scene>;
  41096. /**
  41097. * An event triggered when a camera is created
  41098. */
  41099. onNewCameraAddedObservable: Observable<Camera>;
  41100. /**
  41101. * An event triggered when a camera is removed
  41102. */
  41103. onCameraRemovedObservable: Observable<Camera>;
  41104. /**
  41105. * An event triggered when a light is created
  41106. */
  41107. onNewLightAddedObservable: Observable<Light>;
  41108. /**
  41109. * An event triggered when a light is removed
  41110. */
  41111. onLightRemovedObservable: Observable<Light>;
  41112. /**
  41113. * An event triggered when a geometry is created
  41114. */
  41115. onNewGeometryAddedObservable: Observable<Geometry>;
  41116. /**
  41117. * An event triggered when a geometry is removed
  41118. */
  41119. onGeometryRemovedObservable: Observable<Geometry>;
  41120. /**
  41121. * An event triggered when a transform node is created
  41122. */
  41123. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41124. /**
  41125. * An event triggered when a transform node is removed
  41126. */
  41127. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41128. /**
  41129. * An event triggered when a mesh is created
  41130. */
  41131. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41132. /**
  41133. * An event triggered when a mesh is removed
  41134. */
  41135. onMeshRemovedObservable: Observable<AbstractMesh>;
  41136. /**
  41137. * An event triggered when a skeleton is created
  41138. */
  41139. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41140. /**
  41141. * An event triggered when a skeleton is removed
  41142. */
  41143. onSkeletonRemovedObservable: Observable<Skeleton>;
  41144. /**
  41145. * An event triggered when a material is created
  41146. */
  41147. onNewMaterialAddedObservable: Observable<Material>;
  41148. /**
  41149. * An event triggered when a material is removed
  41150. */
  41151. onMaterialRemovedObservable: Observable<Material>;
  41152. /**
  41153. * An event triggered when a texture is created
  41154. */
  41155. onNewTextureAddedObservable: Observable<BaseTexture>;
  41156. /**
  41157. * An event triggered when a texture is removed
  41158. */
  41159. onTextureRemovedObservable: Observable<BaseTexture>;
  41160. /**
  41161. * An event triggered when render targets are about to be rendered
  41162. * Can happen multiple times per frame.
  41163. */
  41164. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41165. /**
  41166. * An event triggered when render targets were rendered.
  41167. * Can happen multiple times per frame.
  41168. */
  41169. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41170. /**
  41171. * An event triggered before calculating deterministic simulation step
  41172. */
  41173. onBeforeStepObservable: Observable<Scene>;
  41174. /**
  41175. * An event triggered after calculating deterministic simulation step
  41176. */
  41177. onAfterStepObservable: Observable<Scene>;
  41178. /**
  41179. * An event triggered when the activeCamera property is updated
  41180. */
  41181. onActiveCameraChanged: Observable<Scene>;
  41182. /**
  41183. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41184. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41185. * 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)
  41186. */
  41187. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41188. /**
  41189. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41190. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41191. * 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)
  41192. */
  41193. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41194. /**
  41195. * This Observable will when a mesh has been imported into the scene.
  41196. */
  41197. onMeshImportedObservable: Observable<AbstractMesh>;
  41198. /**
  41199. * This Observable will when an animation file has been imported into the scene.
  41200. */
  41201. onAnimationFileImportedObservable: Observable<Scene>;
  41202. /**
  41203. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41204. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41205. */
  41206. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41207. /** @hidden */
  41208. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41209. /**
  41210. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41211. */
  41212. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41213. /**
  41214. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41215. */
  41216. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41217. /**
  41218. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41219. */
  41220. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41221. /** Callback called when a pointer move is detected */
  41222. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41223. /** Callback called when a pointer down is detected */
  41224. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41225. /** Callback called when a pointer up is detected */
  41226. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41227. /** Callback called when a pointer pick is detected */
  41228. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41229. /**
  41230. * 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).
  41231. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41232. */
  41233. onPrePointerObservable: Observable<PointerInfoPre>;
  41234. /**
  41235. * Observable event triggered each time an input event is received from the rendering canvas
  41236. */
  41237. onPointerObservable: Observable<PointerInfo>;
  41238. /**
  41239. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41240. */
  41241. get unTranslatedPointer(): Vector2;
  41242. /**
  41243. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41244. */
  41245. static get DragMovementThreshold(): number;
  41246. static set DragMovementThreshold(value: number);
  41247. /**
  41248. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41249. */
  41250. static get LongPressDelay(): number;
  41251. static set LongPressDelay(value: number);
  41252. /**
  41253. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41254. */
  41255. static get DoubleClickDelay(): number;
  41256. static set DoubleClickDelay(value: number);
  41257. /** If you need to check double click without raising a single click at first click, enable this flag */
  41258. static get ExclusiveDoubleClickMode(): boolean;
  41259. static set ExclusiveDoubleClickMode(value: boolean);
  41260. /** @hidden */
  41261. _mirroredCameraPosition: Nullable<Vector3>;
  41262. /**
  41263. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41264. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41265. */
  41266. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41267. /**
  41268. * Observable event triggered each time an keyboard event is received from the hosting window
  41269. */
  41270. onKeyboardObservable: Observable<KeyboardInfo>;
  41271. private _useRightHandedSystem;
  41272. /**
  41273. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41274. */
  41275. set useRightHandedSystem(value: boolean);
  41276. get useRightHandedSystem(): boolean;
  41277. private _timeAccumulator;
  41278. private _currentStepId;
  41279. private _currentInternalStep;
  41280. /**
  41281. * Sets the step Id used by deterministic lock step
  41282. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41283. * @param newStepId defines the step Id
  41284. */
  41285. setStepId(newStepId: number): void;
  41286. /**
  41287. * Gets the step Id used by deterministic lock step
  41288. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41289. * @returns the step Id
  41290. */
  41291. getStepId(): number;
  41292. /**
  41293. * Gets the internal step used by deterministic lock step
  41294. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41295. * @returns the internal step
  41296. */
  41297. getInternalStep(): number;
  41298. private _fogEnabled;
  41299. /**
  41300. * Gets or sets a boolean indicating if fog is enabled on this scene
  41301. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41302. * (Default is true)
  41303. */
  41304. set fogEnabled(value: boolean);
  41305. get fogEnabled(): boolean;
  41306. private _fogMode;
  41307. /**
  41308. * Gets or sets the fog mode to use
  41309. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41310. * | mode | value |
  41311. * | --- | --- |
  41312. * | FOGMODE_NONE | 0 |
  41313. * | FOGMODE_EXP | 1 |
  41314. * | FOGMODE_EXP2 | 2 |
  41315. * | FOGMODE_LINEAR | 3 |
  41316. */
  41317. set fogMode(value: number);
  41318. get fogMode(): number;
  41319. /**
  41320. * Gets or sets the fog color to use
  41321. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41322. * (Default is Color3(0.2, 0.2, 0.3))
  41323. */
  41324. fogColor: Color3;
  41325. /**
  41326. * Gets or sets the fog density to use
  41327. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41328. * (Default is 0.1)
  41329. */
  41330. fogDensity: number;
  41331. /**
  41332. * Gets or sets the fog start distance to use
  41333. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41334. * (Default is 0)
  41335. */
  41336. fogStart: number;
  41337. /**
  41338. * Gets or sets the fog end distance to use
  41339. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41340. * (Default is 1000)
  41341. */
  41342. fogEnd: number;
  41343. /**
  41344. * Flag indicating that the frame buffer binding is handled by another component
  41345. */
  41346. prePass: boolean;
  41347. private _shadowsEnabled;
  41348. /**
  41349. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41350. */
  41351. set shadowsEnabled(value: boolean);
  41352. get shadowsEnabled(): boolean;
  41353. private _lightsEnabled;
  41354. /**
  41355. * Gets or sets a boolean indicating if lights are enabled on this scene
  41356. */
  41357. set lightsEnabled(value: boolean);
  41358. get lightsEnabled(): boolean;
  41359. /** All of the active cameras added to this scene. */
  41360. activeCameras: Camera[];
  41361. /** @hidden */
  41362. _activeCamera: Nullable<Camera>;
  41363. /** Gets or sets the current active camera */
  41364. get activeCamera(): Nullable<Camera>;
  41365. set activeCamera(value: Nullable<Camera>);
  41366. private _defaultMaterial;
  41367. /** The default material used on meshes when no material is affected */
  41368. get defaultMaterial(): Material;
  41369. /** The default material used on meshes when no material is affected */
  41370. set defaultMaterial(value: Material);
  41371. private _texturesEnabled;
  41372. /**
  41373. * Gets or sets a boolean indicating if textures are enabled on this scene
  41374. */
  41375. set texturesEnabled(value: boolean);
  41376. get texturesEnabled(): boolean;
  41377. /**
  41378. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41379. */
  41380. physicsEnabled: boolean;
  41381. /**
  41382. * Gets or sets a boolean indicating if particles are enabled on this scene
  41383. */
  41384. particlesEnabled: boolean;
  41385. /**
  41386. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41387. */
  41388. spritesEnabled: boolean;
  41389. private _skeletonsEnabled;
  41390. /**
  41391. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41392. */
  41393. set skeletonsEnabled(value: boolean);
  41394. get skeletonsEnabled(): boolean;
  41395. /**
  41396. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41397. */
  41398. lensFlaresEnabled: boolean;
  41399. /**
  41400. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41401. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41402. */
  41403. collisionsEnabled: boolean;
  41404. private _collisionCoordinator;
  41405. /** @hidden */
  41406. get collisionCoordinator(): ICollisionCoordinator;
  41407. /**
  41408. * Defines the gravity applied to this scene (used only for collisions)
  41409. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41410. */
  41411. gravity: Vector3;
  41412. /**
  41413. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41414. */
  41415. postProcessesEnabled: boolean;
  41416. /**
  41417. * Gets the current postprocess manager
  41418. */
  41419. postProcessManager: PostProcessManager;
  41420. /**
  41421. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41422. */
  41423. renderTargetsEnabled: boolean;
  41424. /**
  41425. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41426. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41427. */
  41428. dumpNextRenderTargets: boolean;
  41429. /**
  41430. * The list of user defined render targets added to the scene
  41431. */
  41432. customRenderTargets: RenderTargetTexture[];
  41433. /**
  41434. * Defines if texture loading must be delayed
  41435. * If true, textures will only be loaded when they need to be rendered
  41436. */
  41437. useDelayedTextureLoading: boolean;
  41438. /**
  41439. * Gets the list of meshes imported to the scene through SceneLoader
  41440. */
  41441. importedMeshesFiles: String[];
  41442. /**
  41443. * Gets or sets a boolean indicating if probes are enabled on this scene
  41444. */
  41445. probesEnabled: boolean;
  41446. /**
  41447. * Gets or sets the current offline provider to use to store scene data
  41448. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41449. */
  41450. offlineProvider: IOfflineProvider;
  41451. /**
  41452. * Gets or sets the action manager associated with the scene
  41453. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41454. */
  41455. actionManager: AbstractActionManager;
  41456. private _meshesForIntersections;
  41457. /**
  41458. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41459. */
  41460. proceduralTexturesEnabled: boolean;
  41461. private _engine;
  41462. private _totalVertices;
  41463. /** @hidden */
  41464. _activeIndices: PerfCounter;
  41465. /** @hidden */
  41466. _activeParticles: PerfCounter;
  41467. /** @hidden */
  41468. _activeBones: PerfCounter;
  41469. private _animationRatio;
  41470. /** @hidden */
  41471. _animationTimeLast: number;
  41472. /** @hidden */
  41473. _animationTime: number;
  41474. /**
  41475. * Gets or sets a general scale for animation speed
  41476. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41477. */
  41478. animationTimeScale: number;
  41479. /** @hidden */
  41480. _cachedMaterial: Nullable<Material>;
  41481. /** @hidden */
  41482. _cachedEffect: Nullable<Effect>;
  41483. /** @hidden */
  41484. _cachedVisibility: Nullable<number>;
  41485. private _renderId;
  41486. private _frameId;
  41487. private _executeWhenReadyTimeoutId;
  41488. private _intermediateRendering;
  41489. private _viewUpdateFlag;
  41490. private _projectionUpdateFlag;
  41491. /** @hidden */
  41492. _toBeDisposed: Nullable<IDisposable>[];
  41493. private _activeRequests;
  41494. /** @hidden */
  41495. _pendingData: any[];
  41496. private _isDisposed;
  41497. /**
  41498. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41499. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41500. */
  41501. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41502. private _activeMeshes;
  41503. private _processedMaterials;
  41504. private _renderTargets;
  41505. /** @hidden */
  41506. _activeParticleSystems: SmartArray<IParticleSystem>;
  41507. private _activeSkeletons;
  41508. private _softwareSkinnedMeshes;
  41509. private _renderingManager;
  41510. /** @hidden */
  41511. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41512. private _transformMatrix;
  41513. private _sceneUbo;
  41514. /** @hidden */
  41515. _viewMatrix: Matrix;
  41516. private _projectionMatrix;
  41517. /** @hidden */
  41518. _forcedViewPosition: Nullable<Vector3>;
  41519. /** @hidden */
  41520. _frustumPlanes: Plane[];
  41521. /**
  41522. * Gets the list of frustum planes (built from the active camera)
  41523. */
  41524. get frustumPlanes(): Plane[];
  41525. /**
  41526. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41527. * This is useful if there are more lights that the maximum simulteanous authorized
  41528. */
  41529. requireLightSorting: boolean;
  41530. /** @hidden */
  41531. readonly useMaterialMeshMap: boolean;
  41532. /** @hidden */
  41533. readonly useClonedMeshMap: boolean;
  41534. private _externalData;
  41535. private _uid;
  41536. /**
  41537. * @hidden
  41538. * Backing store of defined scene components.
  41539. */
  41540. _components: ISceneComponent[];
  41541. /**
  41542. * @hidden
  41543. * Backing store of defined scene components.
  41544. */
  41545. _serializableComponents: ISceneSerializableComponent[];
  41546. /**
  41547. * List of components to register on the next registration step.
  41548. */
  41549. private _transientComponents;
  41550. /**
  41551. * Registers the transient components if needed.
  41552. */
  41553. private _registerTransientComponents;
  41554. /**
  41555. * @hidden
  41556. * Add a component to the scene.
  41557. * Note that the ccomponent could be registered on th next frame if this is called after
  41558. * the register component stage.
  41559. * @param component Defines the component to add to the scene
  41560. */
  41561. _addComponent(component: ISceneComponent): void;
  41562. /**
  41563. * @hidden
  41564. * Gets a component from the scene.
  41565. * @param name defines the name of the component to retrieve
  41566. * @returns the component or null if not present
  41567. */
  41568. _getComponent(name: string): Nullable<ISceneComponent>;
  41569. /**
  41570. * @hidden
  41571. * Defines the actions happening before camera updates.
  41572. */
  41573. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41574. /**
  41575. * @hidden
  41576. * Defines the actions happening before clear the canvas.
  41577. */
  41578. _beforeClearStage: Stage<SimpleStageAction>;
  41579. /**
  41580. * @hidden
  41581. * Defines the actions when collecting render targets for the frame.
  41582. */
  41583. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41584. /**
  41585. * @hidden
  41586. * Defines the actions happening for one camera in the frame.
  41587. */
  41588. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41589. /**
  41590. * @hidden
  41591. * Defines the actions happening during the per mesh ready checks.
  41592. */
  41593. _isReadyForMeshStage: Stage<MeshStageAction>;
  41594. /**
  41595. * @hidden
  41596. * Defines the actions happening before evaluate active mesh checks.
  41597. */
  41598. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41599. /**
  41600. * @hidden
  41601. * Defines the actions happening during the evaluate sub mesh checks.
  41602. */
  41603. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41604. /**
  41605. * @hidden
  41606. * Defines the actions happening during the active mesh stage.
  41607. */
  41608. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41609. /**
  41610. * @hidden
  41611. * Defines the actions happening during the per camera render target step.
  41612. */
  41613. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41614. /**
  41615. * @hidden
  41616. * Defines the actions happening just before the active camera is drawing.
  41617. */
  41618. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41619. /**
  41620. * @hidden
  41621. * Defines the actions happening just before a render target is drawing.
  41622. */
  41623. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41624. /**
  41625. * @hidden
  41626. * Defines the actions happening just before a rendering group is drawing.
  41627. */
  41628. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41629. /**
  41630. * @hidden
  41631. * Defines the actions happening just before a mesh is drawing.
  41632. */
  41633. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41634. /**
  41635. * @hidden
  41636. * Defines the actions happening just after a mesh has been drawn.
  41637. */
  41638. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41639. /**
  41640. * @hidden
  41641. * Defines the actions happening just after a rendering group has been drawn.
  41642. */
  41643. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41644. /**
  41645. * @hidden
  41646. * Defines the actions happening just after the active camera has been drawn.
  41647. */
  41648. _afterCameraDrawStage: Stage<CameraStageAction>;
  41649. /**
  41650. * @hidden
  41651. * Defines the actions happening just after a render target has been drawn.
  41652. */
  41653. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41654. /**
  41655. * @hidden
  41656. * Defines the actions happening just after rendering all cameras and computing intersections.
  41657. */
  41658. _afterRenderStage: Stage<SimpleStageAction>;
  41659. /**
  41660. * @hidden
  41661. * Defines the actions happening when a pointer move event happens.
  41662. */
  41663. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41664. /**
  41665. * @hidden
  41666. * Defines the actions happening when a pointer down event happens.
  41667. */
  41668. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41669. /**
  41670. * @hidden
  41671. * Defines the actions happening when a pointer up event happens.
  41672. */
  41673. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41674. /**
  41675. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41676. */
  41677. private geometriesByUniqueId;
  41678. /**
  41679. * Creates a new Scene
  41680. * @param engine defines the engine to use to render this scene
  41681. * @param options defines the scene options
  41682. */
  41683. constructor(engine: Engine, options?: SceneOptions);
  41684. /**
  41685. * Gets a string identifying the name of the class
  41686. * @returns "Scene" string
  41687. */
  41688. getClassName(): string;
  41689. private _defaultMeshCandidates;
  41690. /**
  41691. * @hidden
  41692. */
  41693. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41694. private _defaultSubMeshCandidates;
  41695. /**
  41696. * @hidden
  41697. */
  41698. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41699. /**
  41700. * Sets the default candidate providers for the scene.
  41701. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41702. * and getCollidingSubMeshCandidates to their default function
  41703. */
  41704. setDefaultCandidateProviders(): void;
  41705. /**
  41706. * Gets the mesh that is currently under the pointer
  41707. */
  41708. get meshUnderPointer(): Nullable<AbstractMesh>;
  41709. /**
  41710. * Gets or sets the current on-screen X position of the pointer
  41711. */
  41712. get pointerX(): number;
  41713. set pointerX(value: number);
  41714. /**
  41715. * Gets or sets the current on-screen Y position of the pointer
  41716. */
  41717. get pointerY(): number;
  41718. set pointerY(value: number);
  41719. /**
  41720. * Gets the cached material (ie. the latest rendered one)
  41721. * @returns the cached material
  41722. */
  41723. getCachedMaterial(): Nullable<Material>;
  41724. /**
  41725. * Gets the cached effect (ie. the latest rendered one)
  41726. * @returns the cached effect
  41727. */
  41728. getCachedEffect(): Nullable<Effect>;
  41729. /**
  41730. * Gets the cached visibility state (ie. the latest rendered one)
  41731. * @returns the cached visibility state
  41732. */
  41733. getCachedVisibility(): Nullable<number>;
  41734. /**
  41735. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41736. * @param material defines the current material
  41737. * @param effect defines the current effect
  41738. * @param visibility defines the current visibility state
  41739. * @returns true if one parameter is not cached
  41740. */
  41741. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41742. /**
  41743. * Gets the engine associated with the scene
  41744. * @returns an Engine
  41745. */
  41746. getEngine(): Engine;
  41747. /**
  41748. * Gets the total number of vertices rendered per frame
  41749. * @returns the total number of vertices rendered per frame
  41750. */
  41751. getTotalVertices(): number;
  41752. /**
  41753. * Gets the performance counter for total vertices
  41754. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41755. */
  41756. get totalVerticesPerfCounter(): PerfCounter;
  41757. /**
  41758. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41759. * @returns the total number of active indices rendered per frame
  41760. */
  41761. getActiveIndices(): number;
  41762. /**
  41763. * Gets the performance counter for active indices
  41764. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41765. */
  41766. get totalActiveIndicesPerfCounter(): PerfCounter;
  41767. /**
  41768. * Gets the total number of active particles rendered per frame
  41769. * @returns the total number of active particles rendered per frame
  41770. */
  41771. getActiveParticles(): number;
  41772. /**
  41773. * Gets the performance counter for active particles
  41774. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41775. */
  41776. get activeParticlesPerfCounter(): PerfCounter;
  41777. /**
  41778. * Gets the total number of active bones rendered per frame
  41779. * @returns the total number of active bones rendered per frame
  41780. */
  41781. getActiveBones(): number;
  41782. /**
  41783. * Gets the performance counter for active bones
  41784. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41785. */
  41786. get activeBonesPerfCounter(): PerfCounter;
  41787. /**
  41788. * Gets the array of active meshes
  41789. * @returns an array of AbstractMesh
  41790. */
  41791. getActiveMeshes(): SmartArray<AbstractMesh>;
  41792. /**
  41793. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41794. * @returns a number
  41795. */
  41796. getAnimationRatio(): number;
  41797. /**
  41798. * Gets an unique Id for the current render phase
  41799. * @returns a number
  41800. */
  41801. getRenderId(): number;
  41802. /**
  41803. * Gets an unique Id for the current frame
  41804. * @returns a number
  41805. */
  41806. getFrameId(): number;
  41807. /** Call this function if you want to manually increment the render Id*/
  41808. incrementRenderId(): void;
  41809. private _createUbo;
  41810. /**
  41811. * Use this method to simulate a pointer move on a mesh
  41812. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41813. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41814. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41815. * @returns the current scene
  41816. */
  41817. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41818. /**
  41819. * Use this method to simulate a pointer down on a mesh
  41820. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41821. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41822. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41823. * @returns the current scene
  41824. */
  41825. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41826. /**
  41827. * Use this method to simulate a pointer up on a mesh
  41828. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41829. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41830. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41831. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41832. * @returns the current scene
  41833. */
  41834. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41835. /**
  41836. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41837. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41838. * @returns true if the pointer was captured
  41839. */
  41840. isPointerCaptured(pointerId?: number): boolean;
  41841. /**
  41842. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41843. * @param attachUp defines if you want to attach events to pointerup
  41844. * @param attachDown defines if you want to attach events to pointerdown
  41845. * @param attachMove defines if you want to attach events to pointermove
  41846. */
  41847. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41848. /** Detaches all event handlers*/
  41849. detachControl(): void;
  41850. /**
  41851. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41852. * Delay loaded resources are not taking in account
  41853. * @return true if all required resources are ready
  41854. */
  41855. isReady(): boolean;
  41856. /** Resets all cached information relative to material (including effect and visibility) */
  41857. resetCachedMaterial(): void;
  41858. /**
  41859. * Registers a function to be called before every frame render
  41860. * @param func defines the function to register
  41861. */
  41862. registerBeforeRender(func: () => void): void;
  41863. /**
  41864. * Unregisters a function called before every frame render
  41865. * @param func defines the function to unregister
  41866. */
  41867. unregisterBeforeRender(func: () => void): void;
  41868. /**
  41869. * Registers a function to be called after every frame render
  41870. * @param func defines the function to register
  41871. */
  41872. registerAfterRender(func: () => void): void;
  41873. /**
  41874. * Unregisters a function called after every frame render
  41875. * @param func defines the function to unregister
  41876. */
  41877. unregisterAfterRender(func: () => void): void;
  41878. private _executeOnceBeforeRender;
  41879. /**
  41880. * The provided function will run before render once and will be disposed afterwards.
  41881. * A timeout delay can be provided so that the function will be executed in N ms.
  41882. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41883. * @param func The function to be executed.
  41884. * @param timeout optional delay in ms
  41885. */
  41886. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41887. /** @hidden */
  41888. _addPendingData(data: any): void;
  41889. /** @hidden */
  41890. _removePendingData(data: any): void;
  41891. /**
  41892. * Returns the number of items waiting to be loaded
  41893. * @returns the number of items waiting to be loaded
  41894. */
  41895. getWaitingItemsCount(): number;
  41896. /**
  41897. * Returns a boolean indicating if the scene is still loading data
  41898. */
  41899. get isLoading(): boolean;
  41900. /**
  41901. * Registers a function to be executed when the scene is ready
  41902. * @param {Function} func - the function to be executed
  41903. */
  41904. executeWhenReady(func: () => void): void;
  41905. /**
  41906. * Returns a promise that resolves when the scene is ready
  41907. * @returns A promise that resolves when the scene is ready
  41908. */
  41909. whenReadyAsync(): Promise<void>;
  41910. /** @hidden */
  41911. _checkIsReady(): void;
  41912. /**
  41913. * Gets all animatable attached to the scene
  41914. */
  41915. get animatables(): Animatable[];
  41916. /**
  41917. * Resets the last animation time frame.
  41918. * Useful to override when animations start running when loading a scene for the first time.
  41919. */
  41920. resetLastAnimationTimeFrame(): void;
  41921. /**
  41922. * Gets the current view matrix
  41923. * @returns a Matrix
  41924. */
  41925. getViewMatrix(): Matrix;
  41926. /**
  41927. * Gets the current projection matrix
  41928. * @returns a Matrix
  41929. */
  41930. getProjectionMatrix(): Matrix;
  41931. /**
  41932. * Gets the current transform matrix
  41933. * @returns a Matrix made of View * Projection
  41934. */
  41935. getTransformMatrix(): Matrix;
  41936. /**
  41937. * Sets the current transform matrix
  41938. * @param viewL defines the View matrix to use
  41939. * @param projectionL defines the Projection matrix to use
  41940. * @param viewR defines the right View matrix to use (if provided)
  41941. * @param projectionR defines the right Projection matrix to use (if provided)
  41942. */
  41943. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41944. /**
  41945. * Gets the uniform buffer used to store scene data
  41946. * @returns a UniformBuffer
  41947. */
  41948. getSceneUniformBuffer(): UniformBuffer;
  41949. /**
  41950. * Gets an unique (relatively to the current scene) Id
  41951. * @returns an unique number for the scene
  41952. */
  41953. getUniqueId(): number;
  41954. /**
  41955. * Add a mesh to the list of scene's meshes
  41956. * @param newMesh defines the mesh to add
  41957. * @param recursive if all child meshes should also be added to the scene
  41958. */
  41959. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41960. /**
  41961. * Remove a mesh for the list of scene's meshes
  41962. * @param toRemove defines the mesh to remove
  41963. * @param recursive if all child meshes should also be removed from the scene
  41964. * @returns the index where the mesh was in the mesh list
  41965. */
  41966. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41967. /**
  41968. * Add a transform node to the list of scene's transform nodes
  41969. * @param newTransformNode defines the transform node to add
  41970. */
  41971. addTransformNode(newTransformNode: TransformNode): void;
  41972. /**
  41973. * Remove a transform node for the list of scene's transform nodes
  41974. * @param toRemove defines the transform node to remove
  41975. * @returns the index where the transform node was in the transform node list
  41976. */
  41977. removeTransformNode(toRemove: TransformNode): number;
  41978. /**
  41979. * Remove a skeleton for the list of scene's skeletons
  41980. * @param toRemove defines the skeleton to remove
  41981. * @returns the index where the skeleton was in the skeleton list
  41982. */
  41983. removeSkeleton(toRemove: Skeleton): number;
  41984. /**
  41985. * Remove a morph target for the list of scene's morph targets
  41986. * @param toRemove defines the morph target to remove
  41987. * @returns the index where the morph target was in the morph target list
  41988. */
  41989. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41990. /**
  41991. * Remove a light for the list of scene's lights
  41992. * @param toRemove defines the light to remove
  41993. * @returns the index where the light was in the light list
  41994. */
  41995. removeLight(toRemove: Light): number;
  41996. /**
  41997. * Remove a camera for the list of scene's cameras
  41998. * @param toRemove defines the camera to remove
  41999. * @returns the index where the camera was in the camera list
  42000. */
  42001. removeCamera(toRemove: Camera): number;
  42002. /**
  42003. * Remove a particle system for the list of scene's particle systems
  42004. * @param toRemove defines the particle system to remove
  42005. * @returns the index where the particle system was in the particle system list
  42006. */
  42007. removeParticleSystem(toRemove: IParticleSystem): number;
  42008. /**
  42009. * Remove a animation for the list of scene's animations
  42010. * @param toRemove defines the animation to remove
  42011. * @returns the index where the animation was in the animation list
  42012. */
  42013. removeAnimation(toRemove: Animation): number;
  42014. /**
  42015. * Will stop the animation of the given target
  42016. * @param target - the target
  42017. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  42018. * @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)
  42019. */
  42020. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  42021. /**
  42022. * Removes the given animation group from this scene.
  42023. * @param toRemove The animation group to remove
  42024. * @returns The index of the removed animation group
  42025. */
  42026. removeAnimationGroup(toRemove: AnimationGroup): number;
  42027. /**
  42028. * Removes the given multi-material from this scene.
  42029. * @param toRemove The multi-material to remove
  42030. * @returns The index of the removed multi-material
  42031. */
  42032. removeMultiMaterial(toRemove: MultiMaterial): number;
  42033. /**
  42034. * Removes the given material from this scene.
  42035. * @param toRemove The material to remove
  42036. * @returns The index of the removed material
  42037. */
  42038. removeMaterial(toRemove: Material): number;
  42039. /**
  42040. * Removes the given action manager from this scene.
  42041. * @param toRemove The action manager to remove
  42042. * @returns The index of the removed action manager
  42043. */
  42044. removeActionManager(toRemove: AbstractActionManager): number;
  42045. /**
  42046. * Removes the given texture from this scene.
  42047. * @param toRemove The texture to remove
  42048. * @returns The index of the removed texture
  42049. */
  42050. removeTexture(toRemove: BaseTexture): number;
  42051. /**
  42052. * Adds the given light to this scene
  42053. * @param newLight The light to add
  42054. */
  42055. addLight(newLight: Light): void;
  42056. /**
  42057. * Sorts the list list based on light priorities
  42058. */
  42059. sortLightsByPriority(): void;
  42060. /**
  42061. * Adds the given camera to this scene
  42062. * @param newCamera The camera to add
  42063. */
  42064. addCamera(newCamera: Camera): void;
  42065. /**
  42066. * Adds the given skeleton to this scene
  42067. * @param newSkeleton The skeleton to add
  42068. */
  42069. addSkeleton(newSkeleton: Skeleton): void;
  42070. /**
  42071. * Adds the given particle system to this scene
  42072. * @param newParticleSystem The particle system to add
  42073. */
  42074. addParticleSystem(newParticleSystem: IParticleSystem): void;
  42075. /**
  42076. * Adds the given animation to this scene
  42077. * @param newAnimation The animation to add
  42078. */
  42079. addAnimation(newAnimation: Animation): void;
  42080. /**
  42081. * Adds the given animation group to this scene.
  42082. * @param newAnimationGroup The animation group to add
  42083. */
  42084. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  42085. /**
  42086. * Adds the given multi-material to this scene
  42087. * @param newMultiMaterial The multi-material to add
  42088. */
  42089. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  42090. /**
  42091. * Adds the given material to this scene
  42092. * @param newMaterial The material to add
  42093. */
  42094. addMaterial(newMaterial: Material): void;
  42095. /**
  42096. * Adds the given morph target to this scene
  42097. * @param newMorphTargetManager The morph target to add
  42098. */
  42099. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  42100. /**
  42101. * Adds the given geometry to this scene
  42102. * @param newGeometry The geometry to add
  42103. */
  42104. addGeometry(newGeometry: Geometry): void;
  42105. /**
  42106. * Adds the given action manager to this scene
  42107. * @param newActionManager The action manager to add
  42108. */
  42109. addActionManager(newActionManager: AbstractActionManager): void;
  42110. /**
  42111. * Adds the given texture to this scene.
  42112. * @param newTexture The texture to add
  42113. */
  42114. addTexture(newTexture: BaseTexture): void;
  42115. /**
  42116. * Switch active camera
  42117. * @param newCamera defines the new active camera
  42118. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42119. */
  42120. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42121. /**
  42122. * sets the active camera of the scene using its ID
  42123. * @param id defines the camera's ID
  42124. * @return the new active camera or null if none found.
  42125. */
  42126. setActiveCameraByID(id: string): Nullable<Camera>;
  42127. /**
  42128. * sets the active camera of the scene using its name
  42129. * @param name defines the camera's name
  42130. * @returns the new active camera or null if none found.
  42131. */
  42132. setActiveCameraByName(name: string): Nullable<Camera>;
  42133. /**
  42134. * get an animation group using its name
  42135. * @param name defines the material's name
  42136. * @return the animation group or null if none found.
  42137. */
  42138. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42139. /**
  42140. * Get a material using its unique id
  42141. * @param uniqueId defines the material's unique id
  42142. * @return the material or null if none found.
  42143. */
  42144. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42145. /**
  42146. * get a material using its id
  42147. * @param id defines the material's ID
  42148. * @return the material or null if none found.
  42149. */
  42150. getMaterialByID(id: string): Nullable<Material>;
  42151. /**
  42152. * Gets a the last added material using a given id
  42153. * @param id defines the material's ID
  42154. * @return the last material with the given id or null if none found.
  42155. */
  42156. getLastMaterialByID(id: string): Nullable<Material>;
  42157. /**
  42158. * Gets a material using its name
  42159. * @param name defines the material's name
  42160. * @return the material or null if none found.
  42161. */
  42162. getMaterialByName(name: string): Nullable<Material>;
  42163. /**
  42164. * Get a texture using its unique id
  42165. * @param uniqueId defines the texture's unique id
  42166. * @return the texture or null if none found.
  42167. */
  42168. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42169. /**
  42170. * Gets a camera using its id
  42171. * @param id defines the id to look for
  42172. * @returns the camera or null if not found
  42173. */
  42174. getCameraByID(id: string): Nullable<Camera>;
  42175. /**
  42176. * Gets a camera using its unique id
  42177. * @param uniqueId defines the unique id to look for
  42178. * @returns the camera or null if not found
  42179. */
  42180. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42181. /**
  42182. * Gets a camera using its name
  42183. * @param name defines the camera's name
  42184. * @return the camera or null if none found.
  42185. */
  42186. getCameraByName(name: string): Nullable<Camera>;
  42187. /**
  42188. * Gets a bone using its id
  42189. * @param id defines the bone's id
  42190. * @return the bone or null if not found
  42191. */
  42192. getBoneByID(id: string): Nullable<Bone>;
  42193. /**
  42194. * Gets a bone using its id
  42195. * @param name defines the bone's name
  42196. * @return the bone or null if not found
  42197. */
  42198. getBoneByName(name: string): Nullable<Bone>;
  42199. /**
  42200. * Gets a light node using its name
  42201. * @param name defines the the light's name
  42202. * @return the light or null if none found.
  42203. */
  42204. getLightByName(name: string): Nullable<Light>;
  42205. /**
  42206. * Gets a light node using its id
  42207. * @param id defines the light's id
  42208. * @return the light or null if none found.
  42209. */
  42210. getLightByID(id: string): Nullable<Light>;
  42211. /**
  42212. * Gets a light node using its scene-generated unique ID
  42213. * @param uniqueId defines the light's unique id
  42214. * @return the light or null if none found.
  42215. */
  42216. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42217. /**
  42218. * Gets a particle system by id
  42219. * @param id defines the particle system id
  42220. * @return the corresponding system or null if none found
  42221. */
  42222. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42223. /**
  42224. * Gets a geometry using its ID
  42225. * @param id defines the geometry's id
  42226. * @return the geometry or null if none found.
  42227. */
  42228. getGeometryByID(id: string): Nullable<Geometry>;
  42229. private _getGeometryByUniqueID;
  42230. /**
  42231. * Add a new geometry to this scene
  42232. * @param geometry defines the geometry to be added to the scene.
  42233. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42234. * @return a boolean defining if the geometry was added or not
  42235. */
  42236. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42237. /**
  42238. * Removes an existing geometry
  42239. * @param geometry defines the geometry to be removed from the scene
  42240. * @return a boolean defining if the geometry was removed or not
  42241. */
  42242. removeGeometry(geometry: Geometry): boolean;
  42243. /**
  42244. * Gets the list of geometries attached to the scene
  42245. * @returns an array of Geometry
  42246. */
  42247. getGeometries(): Geometry[];
  42248. /**
  42249. * Gets the first added mesh found of a given ID
  42250. * @param id defines the id to search for
  42251. * @return the mesh found or null if not found at all
  42252. */
  42253. getMeshByID(id: string): Nullable<AbstractMesh>;
  42254. /**
  42255. * Gets a list of meshes using their id
  42256. * @param id defines the id to search for
  42257. * @returns a list of meshes
  42258. */
  42259. getMeshesByID(id: string): Array<AbstractMesh>;
  42260. /**
  42261. * Gets the first added transform node found of a given ID
  42262. * @param id defines the id to search for
  42263. * @return the found transform node or null if not found at all.
  42264. */
  42265. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42266. /**
  42267. * Gets a transform node with its auto-generated unique id
  42268. * @param uniqueId efines the unique id to search for
  42269. * @return the found transform node or null if not found at all.
  42270. */
  42271. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42272. /**
  42273. * Gets a list of transform nodes using their id
  42274. * @param id defines the id to search for
  42275. * @returns a list of transform nodes
  42276. */
  42277. getTransformNodesByID(id: string): Array<TransformNode>;
  42278. /**
  42279. * Gets a mesh with its auto-generated unique id
  42280. * @param uniqueId defines the unique id to search for
  42281. * @return the found mesh or null if not found at all.
  42282. */
  42283. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42284. /**
  42285. * Gets a the last added mesh using a given id
  42286. * @param id defines the id to search for
  42287. * @return the found mesh or null if not found at all.
  42288. */
  42289. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42290. /**
  42291. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42292. * @param id defines the id to search for
  42293. * @return the found node or null if not found at all
  42294. */
  42295. getLastEntryByID(id: string): Nullable<Node>;
  42296. /**
  42297. * Gets a node (Mesh, Camera, Light) using a given id
  42298. * @param id defines the id to search for
  42299. * @return the found node or null if not found at all
  42300. */
  42301. getNodeByID(id: string): Nullable<Node>;
  42302. /**
  42303. * Gets a node (Mesh, Camera, Light) using a given name
  42304. * @param name defines the name to search for
  42305. * @return the found node or null if not found at all.
  42306. */
  42307. getNodeByName(name: string): Nullable<Node>;
  42308. /**
  42309. * Gets a mesh using a given name
  42310. * @param name defines the name to search for
  42311. * @return the found mesh or null if not found at all.
  42312. */
  42313. getMeshByName(name: string): Nullable<AbstractMesh>;
  42314. /**
  42315. * Gets a transform node using a given name
  42316. * @param name defines the name to search for
  42317. * @return the found transform node or null if not found at all.
  42318. */
  42319. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42320. /**
  42321. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42322. * @param id defines the id to search for
  42323. * @return the found skeleton or null if not found at all.
  42324. */
  42325. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42326. /**
  42327. * Gets a skeleton using a given auto generated unique id
  42328. * @param uniqueId defines the unique id to search for
  42329. * @return the found skeleton or null if not found at all.
  42330. */
  42331. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42332. /**
  42333. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42334. * @param id defines the id to search for
  42335. * @return the found skeleton or null if not found at all.
  42336. */
  42337. getSkeletonById(id: string): Nullable<Skeleton>;
  42338. /**
  42339. * Gets a skeleton using a given name
  42340. * @param name defines the name to search for
  42341. * @return the found skeleton or null if not found at all.
  42342. */
  42343. getSkeletonByName(name: string): Nullable<Skeleton>;
  42344. /**
  42345. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42346. * @param id defines the id to search for
  42347. * @return the found morph target manager or null if not found at all.
  42348. */
  42349. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42350. /**
  42351. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42352. * @param id defines the id to search for
  42353. * @return the found morph target or null if not found at all.
  42354. */
  42355. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42356. /**
  42357. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42358. * @param name defines the name to search for
  42359. * @return the found morph target or null if not found at all.
  42360. */
  42361. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42362. /**
  42363. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42364. * @param name defines the name to search for
  42365. * @return the found post process or null if not found at all.
  42366. */
  42367. getPostProcessByName(name: string): Nullable<PostProcess>;
  42368. /**
  42369. * Gets a boolean indicating if the given mesh is active
  42370. * @param mesh defines the mesh to look for
  42371. * @returns true if the mesh is in the active list
  42372. */
  42373. isActiveMesh(mesh: AbstractMesh): boolean;
  42374. /**
  42375. * Return a unique id as a string which can serve as an identifier for the scene
  42376. */
  42377. get uid(): string;
  42378. /**
  42379. * Add an externaly attached data from its key.
  42380. * This method call will fail and return false, if such key already exists.
  42381. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42382. * @param key the unique key that identifies the data
  42383. * @param data the data object to associate to the key for this Engine instance
  42384. * @return true if no such key were already present and the data was added successfully, false otherwise
  42385. */
  42386. addExternalData<T>(key: string, data: T): boolean;
  42387. /**
  42388. * Get an externaly attached data from its key
  42389. * @param key the unique key that identifies the data
  42390. * @return the associated data, if present (can be null), or undefined if not present
  42391. */
  42392. getExternalData<T>(key: string): Nullable<T>;
  42393. /**
  42394. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42395. * @param key the unique key that identifies the data
  42396. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42397. * @return the associated data, can be null if the factory returned null.
  42398. */
  42399. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42400. /**
  42401. * Remove an externaly attached data from the Engine instance
  42402. * @param key the unique key that identifies the data
  42403. * @return true if the data was successfully removed, false if it doesn't exist
  42404. */
  42405. removeExternalData(key: string): boolean;
  42406. private _evaluateSubMesh;
  42407. /**
  42408. * Clear the processed materials smart array preventing retention point in material dispose.
  42409. */
  42410. freeProcessedMaterials(): void;
  42411. private _preventFreeActiveMeshesAndRenderingGroups;
  42412. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42413. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42414. * when disposing several meshes in a row or a hierarchy of meshes.
  42415. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42416. */
  42417. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42418. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42419. /**
  42420. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42421. */
  42422. freeActiveMeshes(): void;
  42423. /**
  42424. * Clear the info related to rendering groups preventing retention points during dispose.
  42425. */
  42426. freeRenderingGroups(): void;
  42427. /** @hidden */
  42428. _isInIntermediateRendering(): boolean;
  42429. /**
  42430. * Lambda returning the list of potentially active meshes.
  42431. */
  42432. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42433. /**
  42434. * Lambda returning the list of potentially active sub meshes.
  42435. */
  42436. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42437. /**
  42438. * Lambda returning the list of potentially intersecting sub meshes.
  42439. */
  42440. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42441. /**
  42442. * Lambda returning the list of potentially colliding sub meshes.
  42443. */
  42444. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42445. private _activeMeshesFrozen;
  42446. private _skipEvaluateActiveMeshesCompletely;
  42447. /**
  42448. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42449. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42450. * @returns the current scene
  42451. */
  42452. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42453. /**
  42454. * Use this function to restart evaluating active meshes on every frame
  42455. * @returns the current scene
  42456. */
  42457. unfreezeActiveMeshes(): Scene;
  42458. private _evaluateActiveMeshes;
  42459. private _activeMesh;
  42460. /**
  42461. * Update the transform matrix to update from the current active camera
  42462. * @param force defines a boolean used to force the update even if cache is up to date
  42463. */
  42464. updateTransformMatrix(force?: boolean): void;
  42465. private _bindFrameBuffer;
  42466. /** @hidden */
  42467. _allowPostProcessClearColor: boolean;
  42468. /** @hidden */
  42469. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42470. private _processSubCameras;
  42471. private _checkIntersections;
  42472. /** @hidden */
  42473. _advancePhysicsEngineStep(step: number): void;
  42474. /**
  42475. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42476. */
  42477. getDeterministicFrameTime: () => number;
  42478. /** @hidden */
  42479. _animate(): void;
  42480. /** Execute all animations (for a frame) */
  42481. animate(): void;
  42482. /**
  42483. * Render the scene
  42484. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42485. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42486. */
  42487. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42488. /**
  42489. * Freeze all materials
  42490. * A frozen material will not be updatable but should be faster to render
  42491. */
  42492. freezeMaterials(): void;
  42493. /**
  42494. * Unfreeze all materials
  42495. * A frozen material will not be updatable but should be faster to render
  42496. */
  42497. unfreezeMaterials(): void;
  42498. /**
  42499. * Releases all held ressources
  42500. */
  42501. dispose(): void;
  42502. /**
  42503. * Gets if the scene is already disposed
  42504. */
  42505. get isDisposed(): boolean;
  42506. /**
  42507. * Call this function to reduce memory footprint of the scene.
  42508. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42509. */
  42510. clearCachedVertexData(): void;
  42511. /**
  42512. * This function will remove the local cached buffer data from texture.
  42513. * It will save memory but will prevent the texture from being rebuilt
  42514. */
  42515. cleanCachedTextureBuffer(): void;
  42516. /**
  42517. * Get the world extend vectors with an optional filter
  42518. *
  42519. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42520. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42521. */
  42522. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42523. min: Vector3;
  42524. max: Vector3;
  42525. };
  42526. /**
  42527. * Creates a ray that can be used to pick in the scene
  42528. * @param x defines the x coordinate of the origin (on-screen)
  42529. * @param y defines the y coordinate of the origin (on-screen)
  42530. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42531. * @param camera defines the camera to use for the picking
  42532. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42533. * @returns a Ray
  42534. */
  42535. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42536. /**
  42537. * Creates a ray that can be used to pick in the scene
  42538. * @param x defines the x coordinate of the origin (on-screen)
  42539. * @param y defines the y coordinate of the origin (on-screen)
  42540. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42541. * @param result defines the ray where to store the picking ray
  42542. * @param camera defines the camera to use for the picking
  42543. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42544. * @returns the current scene
  42545. */
  42546. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42547. /**
  42548. * Creates a ray that can be used to pick in the scene
  42549. * @param x defines the x coordinate of the origin (on-screen)
  42550. * @param y defines the y coordinate of the origin (on-screen)
  42551. * @param camera defines the camera to use for the picking
  42552. * @returns a Ray
  42553. */
  42554. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42555. /**
  42556. * Creates a ray that can be used to pick in the scene
  42557. * @param x defines the x coordinate of the origin (on-screen)
  42558. * @param y defines the y coordinate of the origin (on-screen)
  42559. * @param result defines the ray where to store the picking ray
  42560. * @param camera defines the camera to use for the picking
  42561. * @returns the current scene
  42562. */
  42563. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42564. /** Launch a ray to try to pick a mesh in the scene
  42565. * @param x position on screen
  42566. * @param y position on screen
  42567. * @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
  42568. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42569. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42570. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42571. * @returns a PickingInfo
  42572. */
  42573. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42574. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42575. * @param x position on screen
  42576. * @param y position on screen
  42577. * @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
  42578. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42579. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42580. * @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)
  42581. */
  42582. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42583. /** Use the given ray to pick a mesh in the scene
  42584. * @param ray The ray to use to pick meshes
  42585. * @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
  42586. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42587. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42588. * @returns a PickingInfo
  42589. */
  42590. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42591. /**
  42592. * Launch a ray to try to pick a mesh in the scene
  42593. * @param x X position on screen
  42594. * @param y Y position on screen
  42595. * @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
  42596. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42597. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42598. * @returns an array of PickingInfo
  42599. */
  42600. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42601. /**
  42602. * Launch a ray to try to pick a mesh in the scene
  42603. * @param ray Ray to use
  42604. * @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
  42605. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42606. * @returns an array of PickingInfo
  42607. */
  42608. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42609. /**
  42610. * Force the value of meshUnderPointer
  42611. * @param mesh defines the mesh to use
  42612. * @param pointerId optional pointer id when using more than one pointer
  42613. */
  42614. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42615. /**
  42616. * Gets the mesh under the pointer
  42617. * @returns a Mesh or null if no mesh is under the pointer
  42618. */
  42619. getPointerOverMesh(): Nullable<AbstractMesh>;
  42620. /** @hidden */
  42621. _rebuildGeometries(): void;
  42622. /** @hidden */
  42623. _rebuildTextures(): void;
  42624. private _getByTags;
  42625. /**
  42626. * Get a list of meshes by tags
  42627. * @param tagsQuery defines the tags query to use
  42628. * @param forEach defines a predicate used to filter results
  42629. * @returns an array of Mesh
  42630. */
  42631. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42632. /**
  42633. * Get a list of cameras by tags
  42634. * @param tagsQuery defines the tags query to use
  42635. * @param forEach defines a predicate used to filter results
  42636. * @returns an array of Camera
  42637. */
  42638. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42639. /**
  42640. * Get a list of lights by tags
  42641. * @param tagsQuery defines the tags query to use
  42642. * @param forEach defines a predicate used to filter results
  42643. * @returns an array of Light
  42644. */
  42645. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42646. /**
  42647. * Get a list of materials by tags
  42648. * @param tagsQuery defines the tags query to use
  42649. * @param forEach defines a predicate used to filter results
  42650. * @returns an array of Material
  42651. */
  42652. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42653. /**
  42654. * Get a list of transform nodes by tags
  42655. * @param tagsQuery defines the tags query to use
  42656. * @param forEach defines a predicate used to filter results
  42657. * @returns an array of TransformNode
  42658. */
  42659. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42660. /**
  42661. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42662. * This allowed control for front to back rendering or reversly depending of the special needs.
  42663. *
  42664. * @param renderingGroupId The rendering group id corresponding to its index
  42665. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42666. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42667. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42668. */
  42669. 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;
  42670. /**
  42671. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42672. *
  42673. * @param renderingGroupId The rendering group id corresponding to its index
  42674. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42675. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42676. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42677. */
  42678. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42679. /**
  42680. * Gets the current auto clear configuration for one rendering group of the rendering
  42681. * manager.
  42682. * @param index the rendering group index to get the information for
  42683. * @returns The auto clear setup for the requested rendering group
  42684. */
  42685. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42686. private _blockMaterialDirtyMechanism;
  42687. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42688. get blockMaterialDirtyMechanism(): boolean;
  42689. set blockMaterialDirtyMechanism(value: boolean);
  42690. /**
  42691. * Will flag all materials as dirty to trigger new shader compilation
  42692. * @param flag defines the flag used to specify which material part must be marked as dirty
  42693. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42694. */
  42695. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42696. /** @hidden */
  42697. _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;
  42698. /** @hidden */
  42699. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42700. /** @hidden */
  42701. _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;
  42702. /** @hidden */
  42703. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42704. /** @hidden */
  42705. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42706. /** @hidden */
  42707. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42708. }
  42709. }
  42710. declare module "babylonjs/assetContainer" {
  42711. import { AbstractScene } from "babylonjs/abstractScene";
  42712. import { Scene } from "babylonjs/scene";
  42713. import { Mesh } from "babylonjs/Meshes/mesh";
  42714. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42715. import { Skeleton } from "babylonjs/Bones/skeleton";
  42716. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42717. import { Animatable } from "babylonjs/Animations/animatable";
  42718. import { Nullable } from "babylonjs/types";
  42719. import { Node } from "babylonjs/node";
  42720. /**
  42721. * Set of assets to keep when moving a scene into an asset container.
  42722. */
  42723. export class KeepAssets extends AbstractScene {
  42724. }
  42725. /**
  42726. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42727. */
  42728. export class InstantiatedEntries {
  42729. /**
  42730. * List of new root nodes (eg. nodes with no parent)
  42731. */
  42732. rootNodes: TransformNode[];
  42733. /**
  42734. * List of new skeletons
  42735. */
  42736. skeletons: Skeleton[];
  42737. /**
  42738. * List of new animation groups
  42739. */
  42740. animationGroups: AnimationGroup[];
  42741. }
  42742. /**
  42743. * Container with a set of assets that can be added or removed from a scene.
  42744. */
  42745. export class AssetContainer extends AbstractScene {
  42746. private _wasAddedToScene;
  42747. /**
  42748. * The scene the AssetContainer belongs to.
  42749. */
  42750. scene: Scene;
  42751. /**
  42752. * Instantiates an AssetContainer.
  42753. * @param scene The scene the AssetContainer belongs to.
  42754. */
  42755. constructor(scene: Scene);
  42756. /**
  42757. * Instantiate or clone all meshes and add the new ones to the scene.
  42758. * Skeletons and animation groups will all be cloned
  42759. * @param nameFunction defines an optional function used to get new names for clones
  42760. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42761. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42762. */
  42763. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42764. /**
  42765. * Adds all the assets from the container to the scene.
  42766. */
  42767. addAllToScene(): void;
  42768. /**
  42769. * Removes all the assets in the container from the scene
  42770. */
  42771. removeAllFromScene(): void;
  42772. /**
  42773. * Disposes all the assets in the container
  42774. */
  42775. dispose(): void;
  42776. private _moveAssets;
  42777. /**
  42778. * Removes all the assets contained in the scene and adds them to the container.
  42779. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42780. */
  42781. moveAllFromScene(keepAssets?: KeepAssets): void;
  42782. /**
  42783. * 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.
  42784. * @returns the root mesh
  42785. */
  42786. createRootMesh(): Mesh;
  42787. /**
  42788. * Merge animations (direct and animation groups) from this asset container into a scene
  42789. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42790. * @param animatables set of animatables to retarget to a node from the scene
  42791. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42792. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42793. */
  42794. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42795. }
  42796. }
  42797. declare module "babylonjs/abstractScene" {
  42798. import { Scene } from "babylonjs/scene";
  42799. import { Nullable } from "babylonjs/types";
  42800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42801. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42802. import { Geometry } from "babylonjs/Meshes/geometry";
  42803. import { Skeleton } from "babylonjs/Bones/skeleton";
  42804. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42805. import { AssetContainer } from "babylonjs/assetContainer";
  42806. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42807. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42808. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42809. import { Material } from "babylonjs/Materials/material";
  42810. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42811. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42812. import { Camera } from "babylonjs/Cameras/camera";
  42813. import { Light } from "babylonjs/Lights/light";
  42814. import { Node } from "babylonjs/node";
  42815. import { Animation } from "babylonjs/Animations/animation";
  42816. /**
  42817. * Defines how the parser contract is defined.
  42818. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42819. */
  42820. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42821. /**
  42822. * Defines how the individual parser contract is defined.
  42823. * These parser can parse an individual asset
  42824. */
  42825. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42826. /**
  42827. * Base class of the scene acting as a container for the different elements composing a scene.
  42828. * This class is dynamically extended by the different components of the scene increasing
  42829. * flexibility and reducing coupling
  42830. */
  42831. export abstract class AbstractScene {
  42832. /**
  42833. * Stores the list of available parsers in the application.
  42834. */
  42835. private static _BabylonFileParsers;
  42836. /**
  42837. * Stores the list of available individual parsers in the application.
  42838. */
  42839. private static _IndividualBabylonFileParsers;
  42840. /**
  42841. * Adds a parser in the list of available ones
  42842. * @param name Defines the name of the parser
  42843. * @param parser Defines the parser to add
  42844. */
  42845. static AddParser(name: string, parser: BabylonFileParser): void;
  42846. /**
  42847. * Gets a general parser from the list of avaialble ones
  42848. * @param name Defines the name of the parser
  42849. * @returns the requested parser or null
  42850. */
  42851. static GetParser(name: string): Nullable<BabylonFileParser>;
  42852. /**
  42853. * Adds n individual parser in the list of available ones
  42854. * @param name Defines the name of the parser
  42855. * @param parser Defines the parser to add
  42856. */
  42857. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42858. /**
  42859. * Gets an individual parser from the list of avaialble ones
  42860. * @param name Defines the name of the parser
  42861. * @returns the requested parser or null
  42862. */
  42863. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42864. /**
  42865. * Parser json data and populate both a scene and its associated container object
  42866. * @param jsonData Defines the data to parse
  42867. * @param scene Defines the scene to parse the data for
  42868. * @param container Defines the container attached to the parsing sequence
  42869. * @param rootUrl Defines the root url of the data
  42870. */
  42871. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42872. /**
  42873. * Gets the list of root nodes (ie. nodes with no parent)
  42874. */
  42875. rootNodes: Node[];
  42876. /** All of the cameras added to this scene
  42877. * @see https://doc.babylonjs.com/babylon101/cameras
  42878. */
  42879. cameras: Camera[];
  42880. /**
  42881. * All of the lights added to this scene
  42882. * @see https://doc.babylonjs.com/babylon101/lights
  42883. */
  42884. lights: Light[];
  42885. /**
  42886. * All of the (abstract) meshes added to this scene
  42887. */
  42888. meshes: AbstractMesh[];
  42889. /**
  42890. * The list of skeletons added to the scene
  42891. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42892. */
  42893. skeletons: Skeleton[];
  42894. /**
  42895. * All of the particle systems added to this scene
  42896. * @see https://doc.babylonjs.com/babylon101/particles
  42897. */
  42898. particleSystems: IParticleSystem[];
  42899. /**
  42900. * Gets a list of Animations associated with the scene
  42901. */
  42902. animations: Animation[];
  42903. /**
  42904. * All of the animation groups added to this scene
  42905. * @see https://doc.babylonjs.com/how_to/group
  42906. */
  42907. animationGroups: AnimationGroup[];
  42908. /**
  42909. * All of the multi-materials added to this scene
  42910. * @see https://doc.babylonjs.com/how_to/multi_materials
  42911. */
  42912. multiMaterials: MultiMaterial[];
  42913. /**
  42914. * All of the materials added to this scene
  42915. * In the context of a Scene, it is not supposed to be modified manually.
  42916. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42917. * Note also that the order of the Material within the array is not significant and might change.
  42918. * @see https://doc.babylonjs.com/babylon101/materials
  42919. */
  42920. materials: Material[];
  42921. /**
  42922. * The list of morph target managers added to the scene
  42923. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42924. */
  42925. morphTargetManagers: MorphTargetManager[];
  42926. /**
  42927. * The list of geometries used in the scene.
  42928. */
  42929. geometries: Geometry[];
  42930. /**
  42931. * All of the tranform nodes added to this scene
  42932. * In the context of a Scene, it is not supposed to be modified manually.
  42933. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42934. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42935. * @see https://doc.babylonjs.com/how_to/transformnode
  42936. */
  42937. transformNodes: TransformNode[];
  42938. /**
  42939. * ActionManagers available on the scene.
  42940. */
  42941. actionManagers: AbstractActionManager[];
  42942. /**
  42943. * Textures to keep.
  42944. */
  42945. textures: BaseTexture[];
  42946. /** @hidden */
  42947. protected _environmentTexture: Nullable<BaseTexture>;
  42948. /**
  42949. * Texture used in all pbr material as the reflection texture.
  42950. * As in the majority of the scene they are the same (exception for multi room and so on),
  42951. * this is easier to reference from here than from all the materials.
  42952. */
  42953. get environmentTexture(): Nullable<BaseTexture>;
  42954. set environmentTexture(value: Nullable<BaseTexture>);
  42955. /**
  42956. * The list of postprocesses added to the scene
  42957. */
  42958. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42959. /**
  42960. * @returns all meshes, lights, cameras, transformNodes and bones
  42961. */
  42962. getNodes(): Array<Node>;
  42963. }
  42964. }
  42965. declare module "babylonjs/Audio/sound" {
  42966. import { Observable } from "babylonjs/Misc/observable";
  42967. import { Vector3 } from "babylonjs/Maths/math.vector";
  42968. import { Nullable } from "babylonjs/types";
  42969. import { Scene } from "babylonjs/scene";
  42970. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42971. /**
  42972. * Interface used to define options for Sound class
  42973. */
  42974. export interface ISoundOptions {
  42975. /**
  42976. * Does the sound autoplay once loaded.
  42977. */
  42978. autoplay?: boolean;
  42979. /**
  42980. * Does the sound loop after it finishes playing once.
  42981. */
  42982. loop?: boolean;
  42983. /**
  42984. * Sound's volume
  42985. */
  42986. volume?: number;
  42987. /**
  42988. * Is it a spatial sound?
  42989. */
  42990. spatialSound?: boolean;
  42991. /**
  42992. * Maximum distance to hear that sound
  42993. */
  42994. maxDistance?: number;
  42995. /**
  42996. * Uses user defined attenuation function
  42997. */
  42998. useCustomAttenuation?: boolean;
  42999. /**
  43000. * Define the roll off factor of spatial sounds.
  43001. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43002. */
  43003. rolloffFactor?: number;
  43004. /**
  43005. * Define the reference distance the sound should be heard perfectly.
  43006. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43007. */
  43008. refDistance?: number;
  43009. /**
  43010. * Define the distance attenuation model the sound will follow.
  43011. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43012. */
  43013. distanceModel?: string;
  43014. /**
  43015. * Defines the playback speed (1 by default)
  43016. */
  43017. playbackRate?: number;
  43018. /**
  43019. * Defines if the sound is from a streaming source
  43020. */
  43021. streaming?: boolean;
  43022. /**
  43023. * Defines an optional length (in seconds) inside the sound file
  43024. */
  43025. length?: number;
  43026. /**
  43027. * Defines an optional offset (in seconds) inside the sound file
  43028. */
  43029. offset?: number;
  43030. /**
  43031. * If true, URLs will not be required to state the audio file codec to use.
  43032. */
  43033. skipCodecCheck?: boolean;
  43034. }
  43035. /**
  43036. * Defines a sound that can be played in the application.
  43037. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  43038. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43039. */
  43040. export class Sound {
  43041. /**
  43042. * The name of the sound in the scene.
  43043. */
  43044. name: string;
  43045. /**
  43046. * Does the sound autoplay once loaded.
  43047. */
  43048. autoplay: boolean;
  43049. /**
  43050. * Does the sound loop after it finishes playing once.
  43051. */
  43052. loop: boolean;
  43053. /**
  43054. * Does the sound use a custom attenuation curve to simulate the falloff
  43055. * happening when the source gets further away from the camera.
  43056. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43057. */
  43058. useCustomAttenuation: boolean;
  43059. /**
  43060. * The sound track id this sound belongs to.
  43061. */
  43062. soundTrackId: number;
  43063. /**
  43064. * Is this sound currently played.
  43065. */
  43066. isPlaying: boolean;
  43067. /**
  43068. * Is this sound currently paused.
  43069. */
  43070. isPaused: boolean;
  43071. /**
  43072. * Does this sound enables spatial sound.
  43073. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43074. */
  43075. spatialSound: boolean;
  43076. /**
  43077. * Define the reference distance the sound should be heard perfectly.
  43078. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43079. */
  43080. refDistance: number;
  43081. /**
  43082. * Define the roll off factor of spatial sounds.
  43083. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43084. */
  43085. rolloffFactor: number;
  43086. /**
  43087. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  43088. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43089. */
  43090. maxDistance: number;
  43091. /**
  43092. * Define the distance attenuation model the sound will follow.
  43093. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43094. */
  43095. distanceModel: string;
  43096. /**
  43097. * @hidden
  43098. * Back Compat
  43099. **/
  43100. onended: () => any;
  43101. /**
  43102. * Gets or sets an object used to store user defined information for the sound.
  43103. */
  43104. metadata: any;
  43105. /**
  43106. * Observable event when the current playing sound finishes.
  43107. */
  43108. onEndedObservable: Observable<Sound>;
  43109. private _panningModel;
  43110. private _playbackRate;
  43111. private _streaming;
  43112. private _startTime;
  43113. private _startOffset;
  43114. private _position;
  43115. /** @hidden */
  43116. _positionInEmitterSpace: boolean;
  43117. private _localDirection;
  43118. private _volume;
  43119. private _isReadyToPlay;
  43120. private _isDirectional;
  43121. private _readyToPlayCallback;
  43122. private _audioBuffer;
  43123. private _soundSource;
  43124. private _streamingSource;
  43125. private _soundPanner;
  43126. private _soundGain;
  43127. private _inputAudioNode;
  43128. private _outputAudioNode;
  43129. private _coneInnerAngle;
  43130. private _coneOuterAngle;
  43131. private _coneOuterGain;
  43132. private _scene;
  43133. private _connectedTransformNode;
  43134. private _customAttenuationFunction;
  43135. private _registerFunc;
  43136. private _isOutputConnected;
  43137. private _htmlAudioElement;
  43138. private _urlType;
  43139. private _length?;
  43140. private _offset?;
  43141. /** @hidden */
  43142. static _SceneComponentInitialization: (scene: Scene) => void;
  43143. /**
  43144. * Create a sound and attach it to a scene
  43145. * @param name Name of your sound
  43146. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43147. * @param scene defines the scene the sound belongs to
  43148. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43149. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43150. */
  43151. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43152. /**
  43153. * Release the sound and its associated resources
  43154. */
  43155. dispose(): void;
  43156. /**
  43157. * Gets if the sounds is ready to be played or not.
  43158. * @returns true if ready, otherwise false
  43159. */
  43160. isReady(): boolean;
  43161. private _soundLoaded;
  43162. /**
  43163. * Sets the data of the sound from an audiobuffer
  43164. * @param audioBuffer The audioBuffer containing the data
  43165. */
  43166. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43167. /**
  43168. * Updates the current sounds options such as maxdistance, loop...
  43169. * @param options A JSON object containing values named as the object properties
  43170. */
  43171. updateOptions(options: ISoundOptions): void;
  43172. private _createSpatialParameters;
  43173. private _updateSpatialParameters;
  43174. /**
  43175. * Switch the panning model to HRTF:
  43176. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43177. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43178. */
  43179. switchPanningModelToHRTF(): void;
  43180. /**
  43181. * Switch the panning model to Equal Power:
  43182. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43183. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43184. */
  43185. switchPanningModelToEqualPower(): void;
  43186. private _switchPanningModel;
  43187. /**
  43188. * Connect this sound to a sound track audio node like gain...
  43189. * @param soundTrackAudioNode the sound track audio node to connect to
  43190. */
  43191. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43192. /**
  43193. * Transform this sound into a directional source
  43194. * @param coneInnerAngle Size of the inner cone in degree
  43195. * @param coneOuterAngle Size of the outer cone in degree
  43196. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43197. */
  43198. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43199. /**
  43200. * Gets or sets the inner angle for the directional cone.
  43201. */
  43202. get directionalConeInnerAngle(): number;
  43203. /**
  43204. * Gets or sets the inner angle for the directional cone.
  43205. */
  43206. set directionalConeInnerAngle(value: number);
  43207. /**
  43208. * Gets or sets the outer angle for the directional cone.
  43209. */
  43210. get directionalConeOuterAngle(): number;
  43211. /**
  43212. * Gets or sets the outer angle for the directional cone.
  43213. */
  43214. set directionalConeOuterAngle(value: number);
  43215. /**
  43216. * Sets the position of the emitter if spatial sound is enabled
  43217. * @param newPosition Defines the new posisiton
  43218. */
  43219. setPosition(newPosition: Vector3): void;
  43220. /**
  43221. * Sets the local direction of the emitter if spatial sound is enabled
  43222. * @param newLocalDirection Defines the new local direction
  43223. */
  43224. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43225. private _updateDirection;
  43226. /** @hidden */
  43227. updateDistanceFromListener(): void;
  43228. /**
  43229. * Sets a new custom attenuation function for the sound.
  43230. * @param callback Defines the function used for the attenuation
  43231. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43232. */
  43233. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43234. /**
  43235. * Play the sound
  43236. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43237. * @param offset (optional) Start the sound at a specific time in seconds
  43238. * @param length (optional) Sound duration (in seconds)
  43239. */
  43240. play(time?: number, offset?: number, length?: number): void;
  43241. private _onended;
  43242. /**
  43243. * Stop the sound
  43244. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43245. */
  43246. stop(time?: number): void;
  43247. /**
  43248. * Put the sound in pause
  43249. */
  43250. pause(): void;
  43251. /**
  43252. * Sets a dedicated volume for this sounds
  43253. * @param newVolume Define the new volume of the sound
  43254. * @param time Define time for gradual change to new volume
  43255. */
  43256. setVolume(newVolume: number, time?: number): void;
  43257. /**
  43258. * Set the sound play back rate
  43259. * @param newPlaybackRate Define the playback rate the sound should be played at
  43260. */
  43261. setPlaybackRate(newPlaybackRate: number): void;
  43262. /**
  43263. * Gets the volume of the sound.
  43264. * @returns the volume of the sound
  43265. */
  43266. getVolume(): number;
  43267. /**
  43268. * Attach the sound to a dedicated mesh
  43269. * @param transformNode The transform node to connect the sound with
  43270. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43271. */
  43272. attachToMesh(transformNode: TransformNode): void;
  43273. /**
  43274. * Detach the sound from the previously attached mesh
  43275. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43276. */
  43277. detachFromMesh(): void;
  43278. private _onRegisterAfterWorldMatrixUpdate;
  43279. /**
  43280. * Clone the current sound in the scene.
  43281. * @returns the new sound clone
  43282. */
  43283. clone(): Nullable<Sound>;
  43284. /**
  43285. * Gets the current underlying audio buffer containing the data
  43286. * @returns the audio buffer
  43287. */
  43288. getAudioBuffer(): Nullable<AudioBuffer>;
  43289. /**
  43290. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43291. * @returns the source node
  43292. */
  43293. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43294. /**
  43295. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43296. * @returns the gain node
  43297. */
  43298. getSoundGain(): Nullable<GainNode>;
  43299. /**
  43300. * Serializes the Sound in a JSON representation
  43301. * @returns the JSON representation of the sound
  43302. */
  43303. serialize(): any;
  43304. /**
  43305. * Parse a JSON representation of a sound to innstantiate in a given scene
  43306. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43307. * @param scene Define the scene the new parsed sound should be created in
  43308. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43309. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43310. * @returns the newly parsed sound
  43311. */
  43312. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43313. }
  43314. }
  43315. declare module "babylonjs/Actions/directAudioActions" {
  43316. import { Action } from "babylonjs/Actions/action";
  43317. import { Condition } from "babylonjs/Actions/condition";
  43318. import { Sound } from "babylonjs/Audio/sound";
  43319. /**
  43320. * This defines an action helpful to play a defined sound on a triggered action.
  43321. */
  43322. export class PlaySoundAction extends Action {
  43323. private _sound;
  43324. /**
  43325. * Instantiate the action
  43326. * @param triggerOptions defines the trigger options
  43327. * @param sound defines the sound to play
  43328. * @param condition defines the trigger related conditions
  43329. */
  43330. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43331. /** @hidden */
  43332. _prepare(): void;
  43333. /**
  43334. * Execute the action and play the sound.
  43335. */
  43336. execute(): void;
  43337. /**
  43338. * Serializes the actions and its related information.
  43339. * @param parent defines the object to serialize in
  43340. * @returns the serialized object
  43341. */
  43342. serialize(parent: any): any;
  43343. }
  43344. /**
  43345. * This defines an action helpful to stop a defined sound on a triggered action.
  43346. */
  43347. export class StopSoundAction extends Action {
  43348. private _sound;
  43349. /**
  43350. * Instantiate the action
  43351. * @param triggerOptions defines the trigger options
  43352. * @param sound defines the sound to stop
  43353. * @param condition defines the trigger related conditions
  43354. */
  43355. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43356. /** @hidden */
  43357. _prepare(): void;
  43358. /**
  43359. * Execute the action and stop the sound.
  43360. */
  43361. execute(): void;
  43362. /**
  43363. * Serializes the actions and its related information.
  43364. * @param parent defines the object to serialize in
  43365. * @returns the serialized object
  43366. */
  43367. serialize(parent: any): any;
  43368. }
  43369. }
  43370. declare module "babylonjs/Actions/interpolateValueAction" {
  43371. import { Action } from "babylonjs/Actions/action";
  43372. import { Condition } from "babylonjs/Actions/condition";
  43373. import { Observable } from "babylonjs/Misc/observable";
  43374. /**
  43375. * This defines an action responsible to change the value of a property
  43376. * by interpolating between its current value and the newly set one once triggered.
  43377. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43378. */
  43379. export class InterpolateValueAction extends Action {
  43380. /**
  43381. * Defines the path of the property where the value should be interpolated
  43382. */
  43383. propertyPath: string;
  43384. /**
  43385. * Defines the target value at the end of the interpolation.
  43386. */
  43387. value: any;
  43388. /**
  43389. * Defines the time it will take for the property to interpolate to the value.
  43390. */
  43391. duration: number;
  43392. /**
  43393. * Defines if the other scene animations should be stopped when the action has been triggered
  43394. */
  43395. stopOtherAnimations?: boolean;
  43396. /**
  43397. * Defines a callback raised once the interpolation animation has been done.
  43398. */
  43399. onInterpolationDone?: () => void;
  43400. /**
  43401. * Observable triggered once the interpolation animation has been done.
  43402. */
  43403. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43404. private _target;
  43405. private _effectiveTarget;
  43406. private _property;
  43407. /**
  43408. * Instantiate the action
  43409. * @param triggerOptions defines the trigger options
  43410. * @param target defines the object containing the value to interpolate
  43411. * @param propertyPath defines the path to the property in the target object
  43412. * @param value defines the target value at the end of the interpolation
  43413. * @param duration deines the time it will take for the property to interpolate to the value.
  43414. * @param condition defines the trigger related conditions
  43415. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43416. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43417. */
  43418. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43419. /** @hidden */
  43420. _prepare(): void;
  43421. /**
  43422. * Execute the action starts the value interpolation.
  43423. */
  43424. execute(): void;
  43425. /**
  43426. * Serializes the actions and its related information.
  43427. * @param parent defines the object to serialize in
  43428. * @returns the serialized object
  43429. */
  43430. serialize(parent: any): any;
  43431. }
  43432. }
  43433. declare module "babylonjs/Actions/index" {
  43434. export * from "babylonjs/Actions/abstractActionManager";
  43435. export * from "babylonjs/Actions/action";
  43436. export * from "babylonjs/Actions/actionEvent";
  43437. export * from "babylonjs/Actions/actionManager";
  43438. export * from "babylonjs/Actions/condition";
  43439. export * from "babylonjs/Actions/directActions";
  43440. export * from "babylonjs/Actions/directAudioActions";
  43441. export * from "babylonjs/Actions/interpolateValueAction";
  43442. }
  43443. declare module "babylonjs/Animations/index" {
  43444. export * from "babylonjs/Animations/animatable";
  43445. export * from "babylonjs/Animations/animation";
  43446. export * from "babylonjs/Animations/animationGroup";
  43447. export * from "babylonjs/Animations/animationPropertiesOverride";
  43448. export * from "babylonjs/Animations/easing";
  43449. export * from "babylonjs/Animations/runtimeAnimation";
  43450. export * from "babylonjs/Animations/animationEvent";
  43451. export * from "babylonjs/Animations/animationGroup";
  43452. export * from "babylonjs/Animations/animationKey";
  43453. export * from "babylonjs/Animations/animationRange";
  43454. export * from "babylonjs/Animations/animatable.interface";
  43455. }
  43456. declare module "babylonjs/Audio/soundTrack" {
  43457. import { Sound } from "babylonjs/Audio/sound";
  43458. import { Analyser } from "babylonjs/Audio/analyser";
  43459. import { Scene } from "babylonjs/scene";
  43460. /**
  43461. * Options allowed during the creation of a sound track.
  43462. */
  43463. export interface ISoundTrackOptions {
  43464. /**
  43465. * The volume the sound track should take during creation
  43466. */
  43467. volume?: number;
  43468. /**
  43469. * Define if the sound track is the main sound track of the scene
  43470. */
  43471. mainTrack?: boolean;
  43472. }
  43473. /**
  43474. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43475. * It will be also used in a future release to apply effects on a specific track.
  43476. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43477. */
  43478. export class SoundTrack {
  43479. /**
  43480. * The unique identifier of the sound track in the scene.
  43481. */
  43482. id: number;
  43483. /**
  43484. * The list of sounds included in the sound track.
  43485. */
  43486. soundCollection: Array<Sound>;
  43487. private _outputAudioNode;
  43488. private _scene;
  43489. private _connectedAnalyser;
  43490. private _options;
  43491. private _isInitialized;
  43492. /**
  43493. * Creates a new sound track.
  43494. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43495. * @param scene Define the scene the sound track belongs to
  43496. * @param options
  43497. */
  43498. constructor(scene: Scene, options?: ISoundTrackOptions);
  43499. private _initializeSoundTrackAudioGraph;
  43500. /**
  43501. * Release the sound track and its associated resources
  43502. */
  43503. dispose(): void;
  43504. /**
  43505. * Adds a sound to this sound track
  43506. * @param sound define the cound to add
  43507. * @ignoreNaming
  43508. */
  43509. AddSound(sound: Sound): void;
  43510. /**
  43511. * Removes a sound to this sound track
  43512. * @param sound define the cound to remove
  43513. * @ignoreNaming
  43514. */
  43515. RemoveSound(sound: Sound): void;
  43516. /**
  43517. * Set a global volume for the full sound track.
  43518. * @param newVolume Define the new volume of the sound track
  43519. */
  43520. setVolume(newVolume: number): void;
  43521. /**
  43522. * Switch the panning model to HRTF:
  43523. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43524. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43525. */
  43526. switchPanningModelToHRTF(): void;
  43527. /**
  43528. * Switch the panning model to Equal Power:
  43529. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43530. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43531. */
  43532. switchPanningModelToEqualPower(): void;
  43533. /**
  43534. * Connect the sound track to an audio analyser allowing some amazing
  43535. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43536. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43537. * @param analyser The analyser to connect to the engine
  43538. */
  43539. connectToAnalyser(analyser: Analyser): void;
  43540. }
  43541. }
  43542. declare module "babylonjs/Audio/audioSceneComponent" {
  43543. import { Sound } from "babylonjs/Audio/sound";
  43544. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43545. import { Nullable } from "babylonjs/types";
  43546. import { Vector3 } from "babylonjs/Maths/math.vector";
  43547. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43548. import { Scene } from "babylonjs/scene";
  43549. import { AbstractScene } from "babylonjs/abstractScene";
  43550. import "babylonjs/Audio/audioEngine";
  43551. module "babylonjs/abstractScene" {
  43552. interface AbstractScene {
  43553. /**
  43554. * The list of sounds used in the scene.
  43555. */
  43556. sounds: Nullable<Array<Sound>>;
  43557. }
  43558. }
  43559. module "babylonjs/scene" {
  43560. interface Scene {
  43561. /**
  43562. * @hidden
  43563. * Backing field
  43564. */
  43565. _mainSoundTrack: SoundTrack;
  43566. /**
  43567. * The main sound track played by the scene.
  43568. * It cotains your primary collection of sounds.
  43569. */
  43570. mainSoundTrack: SoundTrack;
  43571. /**
  43572. * The list of sound tracks added to the scene
  43573. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43574. */
  43575. soundTracks: Nullable<Array<SoundTrack>>;
  43576. /**
  43577. * Gets a sound using a given name
  43578. * @param name defines the name to search for
  43579. * @return the found sound or null if not found at all.
  43580. */
  43581. getSoundByName(name: string): Nullable<Sound>;
  43582. /**
  43583. * Gets or sets if audio support is enabled
  43584. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43585. */
  43586. audioEnabled: boolean;
  43587. /**
  43588. * Gets or sets if audio will be output to headphones
  43589. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43590. */
  43591. headphone: boolean;
  43592. /**
  43593. * Gets or sets custom audio listener position provider
  43594. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43595. */
  43596. audioListenerPositionProvider: Nullable<() => Vector3>;
  43597. /**
  43598. * Gets or sets a refresh rate when using 3D audio positioning
  43599. */
  43600. audioPositioningRefreshRate: number;
  43601. }
  43602. }
  43603. /**
  43604. * Defines the sound scene component responsible to manage any sounds
  43605. * in a given scene.
  43606. */
  43607. export class AudioSceneComponent implements ISceneSerializableComponent {
  43608. private static _CameraDirectionLH;
  43609. private static _CameraDirectionRH;
  43610. /**
  43611. * The component name helpfull to identify the component in the list of scene components.
  43612. */
  43613. readonly name: string;
  43614. /**
  43615. * The scene the component belongs to.
  43616. */
  43617. scene: Scene;
  43618. private _audioEnabled;
  43619. /**
  43620. * Gets whether audio is enabled or not.
  43621. * Please use related enable/disable method to switch state.
  43622. */
  43623. get audioEnabled(): boolean;
  43624. private _headphone;
  43625. /**
  43626. * Gets whether audio is outputing to headphone or not.
  43627. * Please use the according Switch methods to change output.
  43628. */
  43629. get headphone(): boolean;
  43630. /**
  43631. * Gets or sets a refresh rate when using 3D audio positioning
  43632. */
  43633. audioPositioningRefreshRate: number;
  43634. private _audioListenerPositionProvider;
  43635. /**
  43636. * Gets the current audio listener position provider
  43637. */
  43638. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43639. /**
  43640. * Sets a custom listener position for all sounds in the scene
  43641. * By default, this is the position of the first active camera
  43642. */
  43643. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43644. /**
  43645. * Creates a new instance of the component for the given scene
  43646. * @param scene Defines the scene to register the component in
  43647. */
  43648. constructor(scene: Scene);
  43649. /**
  43650. * Registers the component in a given scene
  43651. */
  43652. register(): void;
  43653. /**
  43654. * Rebuilds the elements related to this component in case of
  43655. * context lost for instance.
  43656. */
  43657. rebuild(): void;
  43658. /**
  43659. * Serializes the component data to the specified json object
  43660. * @param serializationObject The object to serialize to
  43661. */
  43662. serialize(serializationObject: any): void;
  43663. /**
  43664. * Adds all the elements from the container to the scene
  43665. * @param container the container holding the elements
  43666. */
  43667. addFromContainer(container: AbstractScene): void;
  43668. /**
  43669. * Removes all the elements in the container from the scene
  43670. * @param container contains the elements to remove
  43671. * @param dispose if the removed element should be disposed (default: false)
  43672. */
  43673. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43674. /**
  43675. * Disposes the component and the associated ressources.
  43676. */
  43677. dispose(): void;
  43678. /**
  43679. * Disables audio in the associated scene.
  43680. */
  43681. disableAudio(): void;
  43682. /**
  43683. * Enables audio in the associated scene.
  43684. */
  43685. enableAudio(): void;
  43686. /**
  43687. * Switch audio to headphone output.
  43688. */
  43689. switchAudioModeForHeadphones(): void;
  43690. /**
  43691. * Switch audio to normal speakers.
  43692. */
  43693. switchAudioModeForNormalSpeakers(): void;
  43694. private _cachedCameraDirection;
  43695. private _cachedCameraPosition;
  43696. private _lastCheck;
  43697. private _afterRender;
  43698. }
  43699. }
  43700. declare module "babylonjs/Audio/weightedsound" {
  43701. import { Sound } from "babylonjs/Audio/sound";
  43702. /**
  43703. * Wraps one or more Sound objects and selects one with random weight for playback.
  43704. */
  43705. export class WeightedSound {
  43706. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43707. loop: boolean;
  43708. private _coneInnerAngle;
  43709. private _coneOuterAngle;
  43710. private _volume;
  43711. /** A Sound is currently playing. */
  43712. isPlaying: boolean;
  43713. /** A Sound is currently paused. */
  43714. isPaused: boolean;
  43715. private _sounds;
  43716. private _weights;
  43717. private _currentIndex?;
  43718. /**
  43719. * Creates a new WeightedSound from the list of sounds given.
  43720. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43721. * @param sounds Array of Sounds that will be selected from.
  43722. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43723. */
  43724. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43725. /**
  43726. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43727. */
  43728. get directionalConeInnerAngle(): number;
  43729. /**
  43730. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43731. */
  43732. set directionalConeInnerAngle(value: number);
  43733. /**
  43734. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43735. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43736. */
  43737. get directionalConeOuterAngle(): number;
  43738. /**
  43739. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43740. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43741. */
  43742. set directionalConeOuterAngle(value: number);
  43743. /**
  43744. * Playback volume.
  43745. */
  43746. get volume(): number;
  43747. /**
  43748. * Playback volume.
  43749. */
  43750. set volume(value: number);
  43751. private _onended;
  43752. /**
  43753. * Suspend playback
  43754. */
  43755. pause(): void;
  43756. /**
  43757. * Stop playback
  43758. */
  43759. stop(): void;
  43760. /**
  43761. * Start playback.
  43762. * @param startOffset Position the clip head at a specific time in seconds.
  43763. */
  43764. play(startOffset?: number): void;
  43765. }
  43766. }
  43767. declare module "babylonjs/Audio/index" {
  43768. export * from "babylonjs/Audio/analyser";
  43769. export * from "babylonjs/Audio/audioEngine";
  43770. export * from "babylonjs/Audio/audioSceneComponent";
  43771. export * from "babylonjs/Audio/sound";
  43772. export * from "babylonjs/Audio/soundTrack";
  43773. export * from "babylonjs/Audio/weightedsound";
  43774. }
  43775. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43776. import { Behavior } from "babylonjs/Behaviors/behavior";
  43777. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43778. import { BackEase } from "babylonjs/Animations/easing";
  43779. /**
  43780. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43781. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43782. */
  43783. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43784. /**
  43785. * Gets the name of the behavior.
  43786. */
  43787. get name(): string;
  43788. /**
  43789. * The easing function used by animations
  43790. */
  43791. static EasingFunction: BackEase;
  43792. /**
  43793. * The easing mode used by animations
  43794. */
  43795. static EasingMode: number;
  43796. /**
  43797. * The duration of the animation, in milliseconds
  43798. */
  43799. transitionDuration: number;
  43800. /**
  43801. * Length of the distance animated by the transition when lower radius is reached
  43802. */
  43803. lowerRadiusTransitionRange: number;
  43804. /**
  43805. * Length of the distance animated by the transition when upper radius is reached
  43806. */
  43807. upperRadiusTransitionRange: number;
  43808. private _autoTransitionRange;
  43809. /**
  43810. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43811. */
  43812. get autoTransitionRange(): boolean;
  43813. /**
  43814. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43815. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43816. */
  43817. set autoTransitionRange(value: boolean);
  43818. private _attachedCamera;
  43819. private _onAfterCheckInputsObserver;
  43820. private _onMeshTargetChangedObserver;
  43821. /**
  43822. * Initializes the behavior.
  43823. */
  43824. init(): void;
  43825. /**
  43826. * Attaches the behavior to its arc rotate camera.
  43827. * @param camera Defines the camera to attach the behavior to
  43828. */
  43829. attach(camera: ArcRotateCamera): void;
  43830. /**
  43831. * Detaches the behavior from its current arc rotate camera.
  43832. */
  43833. detach(): void;
  43834. private _radiusIsAnimating;
  43835. private _radiusBounceTransition;
  43836. private _animatables;
  43837. private _cachedWheelPrecision;
  43838. /**
  43839. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43840. * @param radiusLimit The limit to check against.
  43841. * @return Bool to indicate if at limit.
  43842. */
  43843. private _isRadiusAtLimit;
  43844. /**
  43845. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43846. * @param radiusDelta The delta by which to animate to. Can be negative.
  43847. */
  43848. private _applyBoundRadiusAnimation;
  43849. /**
  43850. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43851. */
  43852. protected _clearAnimationLocks(): void;
  43853. /**
  43854. * Stops and removes all animations that have been applied to the camera
  43855. */
  43856. stopAllAnimations(): void;
  43857. }
  43858. }
  43859. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43860. import { Behavior } from "babylonjs/Behaviors/behavior";
  43861. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43862. import { ExponentialEase } from "babylonjs/Animations/easing";
  43863. import { Nullable } from "babylonjs/types";
  43864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43865. import { Vector3 } from "babylonjs/Maths/math.vector";
  43866. /**
  43867. * 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.
  43868. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43869. */
  43870. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43871. /**
  43872. * Gets the name of the behavior.
  43873. */
  43874. get name(): string;
  43875. private _mode;
  43876. private _radiusScale;
  43877. private _positionScale;
  43878. private _defaultElevation;
  43879. private _elevationReturnTime;
  43880. private _elevationReturnWaitTime;
  43881. private _zoomStopsAnimation;
  43882. private _framingTime;
  43883. /**
  43884. * The easing function used by animations
  43885. */
  43886. static EasingFunction: ExponentialEase;
  43887. /**
  43888. * The easing mode used by animations
  43889. */
  43890. static EasingMode: number;
  43891. /**
  43892. * Sets the current mode used by the behavior
  43893. */
  43894. set mode(mode: number);
  43895. /**
  43896. * Gets current mode used by the behavior.
  43897. */
  43898. get mode(): number;
  43899. /**
  43900. * Sets the scale applied to the radius (1 by default)
  43901. */
  43902. set radiusScale(radius: number);
  43903. /**
  43904. * Gets the scale applied to the radius
  43905. */
  43906. get radiusScale(): number;
  43907. /**
  43908. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43909. */
  43910. set positionScale(scale: number);
  43911. /**
  43912. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43913. */
  43914. get positionScale(): number;
  43915. /**
  43916. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43917. * behaviour is triggered, in radians.
  43918. */
  43919. set defaultElevation(elevation: number);
  43920. /**
  43921. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43922. * behaviour is triggered, in radians.
  43923. */
  43924. get defaultElevation(): number;
  43925. /**
  43926. * Sets the time (in milliseconds) taken to return to the default beta position.
  43927. * Negative value indicates camera should not return to default.
  43928. */
  43929. set elevationReturnTime(speed: number);
  43930. /**
  43931. * Gets the time (in milliseconds) taken to return to the default beta position.
  43932. * Negative value indicates camera should not return to default.
  43933. */
  43934. get elevationReturnTime(): number;
  43935. /**
  43936. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43937. */
  43938. set elevationReturnWaitTime(time: number);
  43939. /**
  43940. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43941. */
  43942. get elevationReturnWaitTime(): number;
  43943. /**
  43944. * Sets the flag that indicates if user zooming should stop animation.
  43945. */
  43946. set zoomStopsAnimation(flag: boolean);
  43947. /**
  43948. * Gets the flag that indicates if user zooming should stop animation.
  43949. */
  43950. get zoomStopsAnimation(): boolean;
  43951. /**
  43952. * Sets the transition time when framing the mesh, in milliseconds
  43953. */
  43954. set framingTime(time: number);
  43955. /**
  43956. * Gets the transition time when framing the mesh, in milliseconds
  43957. */
  43958. get framingTime(): number;
  43959. /**
  43960. * Define if the behavior should automatically change the configured
  43961. * camera limits and sensibilities.
  43962. */
  43963. autoCorrectCameraLimitsAndSensibility: boolean;
  43964. private _onPrePointerObservableObserver;
  43965. private _onAfterCheckInputsObserver;
  43966. private _onMeshTargetChangedObserver;
  43967. private _attachedCamera;
  43968. private _isPointerDown;
  43969. private _lastInteractionTime;
  43970. /**
  43971. * Initializes the behavior.
  43972. */
  43973. init(): void;
  43974. /**
  43975. * Attaches the behavior to its arc rotate camera.
  43976. * @param camera Defines the camera to attach the behavior to
  43977. */
  43978. attach(camera: ArcRotateCamera): void;
  43979. /**
  43980. * Detaches the behavior from its current arc rotate camera.
  43981. */
  43982. detach(): void;
  43983. private _animatables;
  43984. private _betaIsAnimating;
  43985. private _betaTransition;
  43986. private _radiusTransition;
  43987. private _vectorTransition;
  43988. /**
  43989. * Targets the given mesh and updates zoom level accordingly.
  43990. * @param mesh The mesh to target.
  43991. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43992. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43993. */
  43994. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43995. /**
  43996. * Targets the given mesh with its children and updates zoom level accordingly.
  43997. * @param mesh The mesh to target.
  43998. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43999. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44000. */
  44001. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44002. /**
  44003. * Targets the given meshes with their children and updates zoom level accordingly.
  44004. * @param meshes The mesh to target.
  44005. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44006. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44007. */
  44008. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44009. /**
  44010. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  44011. * @param minimumWorld Determines the smaller position of the bounding box extend
  44012. * @param maximumWorld Determines the bigger position of the bounding box extend
  44013. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44014. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44015. */
  44016. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44017. /**
  44018. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  44019. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  44020. * frustum width.
  44021. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  44022. * to fully enclose the mesh in the viewing frustum.
  44023. */
  44024. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  44025. /**
  44026. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  44027. * is automatically returned to its default position (expected to be above ground plane).
  44028. */
  44029. private _maintainCameraAboveGround;
  44030. /**
  44031. * Returns the frustum slope based on the canvas ratio and camera FOV
  44032. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  44033. */
  44034. private _getFrustumSlope;
  44035. /**
  44036. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  44037. */
  44038. private _clearAnimationLocks;
  44039. /**
  44040. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44041. */
  44042. private _applyUserInteraction;
  44043. /**
  44044. * Stops and removes all animations that have been applied to the camera
  44045. */
  44046. stopAllAnimations(): void;
  44047. /**
  44048. * Gets a value indicating if the user is moving the camera
  44049. */
  44050. get isUserIsMoving(): boolean;
  44051. /**
  44052. * The camera can move all the way towards the mesh.
  44053. */
  44054. static IgnoreBoundsSizeMode: number;
  44055. /**
  44056. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  44057. */
  44058. static FitFrustumSidesMode: number;
  44059. }
  44060. }
  44061. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  44062. import { Nullable } from "babylonjs/types";
  44063. import { Camera } from "babylonjs/Cameras/camera";
  44064. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44065. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44066. /**
  44067. * Base class for Camera Pointer Inputs.
  44068. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  44069. * for example usage.
  44070. */
  44071. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  44072. /**
  44073. * Defines the camera the input is attached to.
  44074. */
  44075. abstract camera: Camera;
  44076. /**
  44077. * Whether keyboard modifier keys are pressed at time of last mouse event.
  44078. */
  44079. protected _altKey: boolean;
  44080. protected _ctrlKey: boolean;
  44081. protected _metaKey: boolean;
  44082. protected _shiftKey: boolean;
  44083. /**
  44084. * Which mouse buttons were pressed at time of last mouse event.
  44085. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  44086. */
  44087. protected _buttonsPressed: number;
  44088. /**
  44089. * Defines the buttons associated with the input to handle camera move.
  44090. */
  44091. buttons: number[];
  44092. /**
  44093. * Attach the input controls to a specific dom element to get the input from.
  44094. * @param element Defines the element the controls should be listened from
  44095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44096. */
  44097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44098. /**
  44099. * Detach the current controls from the specified dom element.
  44100. * @param element Defines the element to stop listening the inputs from
  44101. */
  44102. detachControl(element: Nullable<HTMLElement>): void;
  44103. /**
  44104. * Gets the class name of the current input.
  44105. * @returns the class name
  44106. */
  44107. getClassName(): string;
  44108. /**
  44109. * Get the friendly name associated with the input class.
  44110. * @returns the input friendly name
  44111. */
  44112. getSimpleName(): string;
  44113. /**
  44114. * Called on pointer POINTERDOUBLETAP event.
  44115. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44116. */
  44117. protected onDoubleTap(type: string): void;
  44118. /**
  44119. * Called on pointer POINTERMOVE event if only a single touch is active.
  44120. * Override this method to provide functionality.
  44121. */
  44122. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44123. /**
  44124. * Called on pointer POINTERMOVE event if multiple touches are active.
  44125. * Override this method to provide functionality.
  44126. */
  44127. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44128. /**
  44129. * Called on JS contextmenu event.
  44130. * Override this method to provide functionality.
  44131. */
  44132. protected onContextMenu(evt: PointerEvent): void;
  44133. /**
  44134. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44135. * press.
  44136. * Override this method to provide functionality.
  44137. */
  44138. protected onButtonDown(evt: PointerEvent): void;
  44139. /**
  44140. * Called each time a new POINTERUP event occurs. Ie, for each button
  44141. * release.
  44142. * Override this method to provide functionality.
  44143. */
  44144. protected onButtonUp(evt: PointerEvent): void;
  44145. /**
  44146. * Called when window becomes inactive.
  44147. * Override this method to provide functionality.
  44148. */
  44149. protected onLostFocus(): void;
  44150. private _pointerInput;
  44151. private _observer;
  44152. private _onLostFocus;
  44153. private pointA;
  44154. private pointB;
  44155. }
  44156. }
  44157. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44158. import { Nullable } from "babylonjs/types";
  44159. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44160. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44161. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44162. /**
  44163. * Manage the pointers inputs to control an arc rotate camera.
  44164. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44165. */
  44166. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44167. /**
  44168. * Defines the camera the input is attached to.
  44169. */
  44170. camera: ArcRotateCamera;
  44171. /**
  44172. * Gets the class name of the current input.
  44173. * @returns the class name
  44174. */
  44175. getClassName(): string;
  44176. /**
  44177. * Defines the buttons associated with the input to handle camera move.
  44178. */
  44179. buttons: number[];
  44180. /**
  44181. * Defines the pointer angular sensibility along the X axis or how fast is
  44182. * the camera rotating.
  44183. */
  44184. angularSensibilityX: number;
  44185. /**
  44186. * Defines the pointer angular sensibility along the Y axis or how fast is
  44187. * the camera rotating.
  44188. */
  44189. angularSensibilityY: number;
  44190. /**
  44191. * Defines the pointer pinch precision or how fast is the camera zooming.
  44192. */
  44193. pinchPrecision: number;
  44194. /**
  44195. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44196. * from 0.
  44197. * It defines the percentage of current camera.radius to use as delta when
  44198. * pinch zoom is used.
  44199. */
  44200. pinchDeltaPercentage: number;
  44201. /**
  44202. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44203. * that any object in the plane at the camera's target point will scale
  44204. * perfectly with finger motion.
  44205. * Overrides pinchDeltaPercentage and pinchPrecision.
  44206. */
  44207. useNaturalPinchZoom: boolean;
  44208. /**
  44209. * Defines the pointer panning sensibility or how fast is the camera moving.
  44210. */
  44211. panningSensibility: number;
  44212. /**
  44213. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44214. */
  44215. multiTouchPanning: boolean;
  44216. /**
  44217. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44218. * zoom (pinch) through multitouch.
  44219. */
  44220. multiTouchPanAndZoom: boolean;
  44221. /**
  44222. * Revers pinch action direction.
  44223. */
  44224. pinchInwards: boolean;
  44225. private _isPanClick;
  44226. private _twoFingerActivityCount;
  44227. private _isPinching;
  44228. /**
  44229. * Called on pointer POINTERMOVE event if only a single touch is active.
  44230. */
  44231. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44232. /**
  44233. * Called on pointer POINTERDOUBLETAP event.
  44234. */
  44235. protected onDoubleTap(type: string): void;
  44236. /**
  44237. * Called on pointer POINTERMOVE event if multiple touches are active.
  44238. */
  44239. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44240. /**
  44241. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44242. * press.
  44243. */
  44244. protected onButtonDown(evt: PointerEvent): void;
  44245. /**
  44246. * Called each time a new POINTERUP event occurs. Ie, for each button
  44247. * release.
  44248. */
  44249. protected onButtonUp(evt: PointerEvent): void;
  44250. /**
  44251. * Called when window becomes inactive.
  44252. */
  44253. protected onLostFocus(): void;
  44254. }
  44255. }
  44256. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44257. import { Nullable } from "babylonjs/types";
  44258. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44259. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44260. /**
  44261. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44262. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44263. */
  44264. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44265. /**
  44266. * Defines the camera the input is attached to.
  44267. */
  44268. camera: ArcRotateCamera;
  44269. /**
  44270. * Defines the list of key codes associated with the up action (increase alpha)
  44271. */
  44272. keysUp: number[];
  44273. /**
  44274. * Defines the list of key codes associated with the down action (decrease alpha)
  44275. */
  44276. keysDown: number[];
  44277. /**
  44278. * Defines the list of key codes associated with the left action (increase beta)
  44279. */
  44280. keysLeft: number[];
  44281. /**
  44282. * Defines the list of key codes associated with the right action (decrease beta)
  44283. */
  44284. keysRight: number[];
  44285. /**
  44286. * Defines the list of key codes associated with the reset action.
  44287. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44288. */
  44289. keysReset: number[];
  44290. /**
  44291. * Defines the panning sensibility of the inputs.
  44292. * (How fast is the camera panning)
  44293. */
  44294. panningSensibility: number;
  44295. /**
  44296. * Defines the zooming sensibility of the inputs.
  44297. * (How fast is the camera zooming)
  44298. */
  44299. zoomingSensibility: number;
  44300. /**
  44301. * Defines whether maintaining the alt key down switch the movement mode from
  44302. * orientation to zoom.
  44303. */
  44304. useAltToZoom: boolean;
  44305. /**
  44306. * Rotation speed of the camera
  44307. */
  44308. angularSpeed: number;
  44309. private _keys;
  44310. private _ctrlPressed;
  44311. private _altPressed;
  44312. private _onCanvasBlurObserver;
  44313. private _onKeyboardObserver;
  44314. private _engine;
  44315. private _scene;
  44316. /**
  44317. * Attach the input controls to a specific dom element to get the input from.
  44318. * @param element Defines the element the controls should be listened from
  44319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44320. */
  44321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44322. /**
  44323. * Detach the current controls from the specified dom element.
  44324. * @param element Defines the element to stop listening the inputs from
  44325. */
  44326. detachControl(element: Nullable<HTMLElement>): void;
  44327. /**
  44328. * Update the current camera state depending on the inputs that have been used this frame.
  44329. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44330. */
  44331. checkInputs(): void;
  44332. /**
  44333. * Gets the class name of the current intput.
  44334. * @returns the class name
  44335. */
  44336. getClassName(): string;
  44337. /**
  44338. * Get the friendly name associated with the input class.
  44339. * @returns the input friendly name
  44340. */
  44341. getSimpleName(): string;
  44342. }
  44343. }
  44344. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44345. import { Nullable } from "babylonjs/types";
  44346. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44347. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44348. /**
  44349. * Manage the mouse wheel inputs to control an arc rotate camera.
  44350. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44351. */
  44352. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44353. /**
  44354. * Defines the camera the input is attached to.
  44355. */
  44356. camera: ArcRotateCamera;
  44357. /**
  44358. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44359. */
  44360. wheelPrecision: number;
  44361. /**
  44362. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44363. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44364. */
  44365. wheelDeltaPercentage: number;
  44366. private _wheel;
  44367. private _observer;
  44368. private computeDeltaFromMouseWheelLegacyEvent;
  44369. /**
  44370. * Attach the input controls to a specific dom element to get the input from.
  44371. * @param element Defines the element the controls should be listened from
  44372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44373. */
  44374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44375. /**
  44376. * Detach the current controls from the specified dom element.
  44377. * @param element Defines the element to stop listening the inputs from
  44378. */
  44379. detachControl(element: Nullable<HTMLElement>): void;
  44380. /**
  44381. * Gets the class name of the current intput.
  44382. * @returns the class name
  44383. */
  44384. getClassName(): string;
  44385. /**
  44386. * Get the friendly name associated with the input class.
  44387. * @returns the input friendly name
  44388. */
  44389. getSimpleName(): string;
  44390. }
  44391. }
  44392. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44393. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44394. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44395. /**
  44396. * Default Inputs manager for the ArcRotateCamera.
  44397. * It groups all the default supported inputs for ease of use.
  44398. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44399. */
  44400. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44401. /**
  44402. * Instantiates a new ArcRotateCameraInputsManager.
  44403. * @param camera Defines the camera the inputs belong to
  44404. */
  44405. constructor(camera: ArcRotateCamera);
  44406. /**
  44407. * Add mouse wheel input support to the input manager.
  44408. * @returns the current input manager
  44409. */
  44410. addMouseWheel(): ArcRotateCameraInputsManager;
  44411. /**
  44412. * Add pointers input support to the input manager.
  44413. * @returns the current input manager
  44414. */
  44415. addPointers(): ArcRotateCameraInputsManager;
  44416. /**
  44417. * Add keyboard input support to the input manager.
  44418. * @returns the current input manager
  44419. */
  44420. addKeyboard(): ArcRotateCameraInputsManager;
  44421. }
  44422. }
  44423. declare module "babylonjs/Cameras/arcRotateCamera" {
  44424. import { Observable } from "babylonjs/Misc/observable";
  44425. import { Nullable } from "babylonjs/types";
  44426. import { Scene } from "babylonjs/scene";
  44427. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44429. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44430. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44431. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44432. import { Camera } from "babylonjs/Cameras/camera";
  44433. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44434. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44435. import { Collider } from "babylonjs/Collisions/collider";
  44436. /**
  44437. * This represents an orbital type of camera.
  44438. *
  44439. * 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.
  44440. * 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.
  44441. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44442. */
  44443. export class ArcRotateCamera extends TargetCamera {
  44444. /**
  44445. * Defines the rotation angle of the camera along the longitudinal axis.
  44446. */
  44447. alpha: number;
  44448. /**
  44449. * Defines the rotation angle of the camera along the latitudinal axis.
  44450. */
  44451. beta: number;
  44452. /**
  44453. * Defines the radius of the camera from it s target point.
  44454. */
  44455. radius: number;
  44456. protected _target: Vector3;
  44457. protected _targetHost: Nullable<AbstractMesh>;
  44458. /**
  44459. * Defines the target point of the camera.
  44460. * The camera looks towards it form the radius distance.
  44461. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44462. */
  44463. get target(): Vector3;
  44464. set target(value: Vector3);
  44465. /**
  44466. * Define the current local position of the camera in the scene
  44467. */
  44468. get position(): Vector3;
  44469. set position(newPosition: Vector3);
  44470. protected _upToYMatrix: Matrix;
  44471. protected _YToUpMatrix: Matrix;
  44472. /**
  44473. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44474. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44475. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44476. */
  44477. set upVector(vec: Vector3);
  44478. get upVector(): Vector3;
  44479. /**
  44480. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44481. */
  44482. setMatUp(): void;
  44483. /**
  44484. * Current inertia value on the longitudinal axis.
  44485. * The bigger this number the longer it will take for the camera to stop.
  44486. */
  44487. inertialAlphaOffset: number;
  44488. /**
  44489. * Current inertia value on the latitudinal axis.
  44490. * The bigger this number the longer it will take for the camera to stop.
  44491. */
  44492. inertialBetaOffset: number;
  44493. /**
  44494. * Current inertia value on the radius axis.
  44495. * The bigger this number the longer it will take for the camera to stop.
  44496. */
  44497. inertialRadiusOffset: number;
  44498. /**
  44499. * Minimum allowed angle on the longitudinal axis.
  44500. * This can help limiting how the Camera is able to move in the scene.
  44501. */
  44502. lowerAlphaLimit: Nullable<number>;
  44503. /**
  44504. * Maximum allowed angle on the longitudinal axis.
  44505. * This can help limiting how the Camera is able to move in the scene.
  44506. */
  44507. upperAlphaLimit: Nullable<number>;
  44508. /**
  44509. * Minimum allowed angle on the latitudinal axis.
  44510. * This can help limiting how the Camera is able to move in the scene.
  44511. */
  44512. lowerBetaLimit: number;
  44513. /**
  44514. * Maximum allowed angle on the latitudinal axis.
  44515. * This can help limiting how the Camera is able to move in the scene.
  44516. */
  44517. upperBetaLimit: number;
  44518. /**
  44519. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44520. * This can help limiting how the Camera is able to move in the scene.
  44521. */
  44522. lowerRadiusLimit: Nullable<number>;
  44523. /**
  44524. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44525. * This can help limiting how the Camera is able to move in the scene.
  44526. */
  44527. upperRadiusLimit: Nullable<number>;
  44528. /**
  44529. * Defines the current inertia value used during panning of the camera along the X axis.
  44530. */
  44531. inertialPanningX: number;
  44532. /**
  44533. * Defines the current inertia value used during panning of the camera along the Y axis.
  44534. */
  44535. inertialPanningY: number;
  44536. /**
  44537. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44538. * Basically if your fingers moves away from more than this distance you will be considered
  44539. * in pinch mode.
  44540. */
  44541. pinchToPanMaxDistance: number;
  44542. /**
  44543. * Defines the maximum distance the camera can pan.
  44544. * This could help keeping the cammera always in your scene.
  44545. */
  44546. panningDistanceLimit: Nullable<number>;
  44547. /**
  44548. * Defines the target of the camera before paning.
  44549. */
  44550. panningOriginTarget: Vector3;
  44551. /**
  44552. * Defines the value of the inertia used during panning.
  44553. * 0 would mean stop inertia and one would mean no decelleration at all.
  44554. */
  44555. panningInertia: number;
  44556. /**
  44557. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44558. */
  44559. get angularSensibilityX(): number;
  44560. set angularSensibilityX(value: number);
  44561. /**
  44562. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44563. */
  44564. get angularSensibilityY(): number;
  44565. set angularSensibilityY(value: number);
  44566. /**
  44567. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44568. */
  44569. get pinchPrecision(): number;
  44570. set pinchPrecision(value: number);
  44571. /**
  44572. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44573. * It will be used instead of pinchDeltaPrecision if different from 0.
  44574. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44575. */
  44576. get pinchDeltaPercentage(): number;
  44577. set pinchDeltaPercentage(value: number);
  44578. /**
  44579. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44580. * and pinch delta percentage.
  44581. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44582. * that any object in the plane at the camera's target point will scale
  44583. * perfectly with finger motion.
  44584. */
  44585. get useNaturalPinchZoom(): boolean;
  44586. set useNaturalPinchZoom(value: boolean);
  44587. /**
  44588. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44589. */
  44590. get panningSensibility(): number;
  44591. set panningSensibility(value: number);
  44592. /**
  44593. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44594. */
  44595. get keysUp(): number[];
  44596. set keysUp(value: number[]);
  44597. /**
  44598. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44599. */
  44600. get keysDown(): number[];
  44601. set keysDown(value: number[]);
  44602. /**
  44603. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44604. */
  44605. get keysLeft(): number[];
  44606. set keysLeft(value: number[]);
  44607. /**
  44608. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44609. */
  44610. get keysRight(): number[];
  44611. set keysRight(value: number[]);
  44612. /**
  44613. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44614. */
  44615. get wheelPrecision(): number;
  44616. set wheelPrecision(value: number);
  44617. /**
  44618. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44619. * It will be used instead of pinchDeltaPrecision if different from 0.
  44620. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44621. */
  44622. get wheelDeltaPercentage(): number;
  44623. set wheelDeltaPercentage(value: number);
  44624. /**
  44625. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44626. */
  44627. zoomOnFactor: number;
  44628. /**
  44629. * Defines a screen offset for the camera position.
  44630. */
  44631. targetScreenOffset: Vector2;
  44632. /**
  44633. * Allows the camera to be completely reversed.
  44634. * If false the camera can not arrive upside down.
  44635. */
  44636. allowUpsideDown: boolean;
  44637. /**
  44638. * Define if double tap/click is used to restore the previously saved state of the camera.
  44639. */
  44640. useInputToRestoreState: boolean;
  44641. /** @hidden */
  44642. _viewMatrix: Matrix;
  44643. /** @hidden */
  44644. _useCtrlForPanning: boolean;
  44645. /** @hidden */
  44646. _panningMouseButton: number;
  44647. /**
  44648. * Defines the input associated to the camera.
  44649. */
  44650. inputs: ArcRotateCameraInputsManager;
  44651. /** @hidden */
  44652. _reset: () => void;
  44653. /**
  44654. * Defines the allowed panning axis.
  44655. */
  44656. panningAxis: Vector3;
  44657. protected _localDirection: Vector3;
  44658. protected _transformedDirection: Vector3;
  44659. private _bouncingBehavior;
  44660. /**
  44661. * Gets the bouncing behavior of the camera if it has been enabled.
  44662. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44663. */
  44664. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44665. /**
  44666. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44667. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44668. */
  44669. get useBouncingBehavior(): boolean;
  44670. set useBouncingBehavior(value: boolean);
  44671. private _framingBehavior;
  44672. /**
  44673. * Gets the framing behavior of the camera if it has been enabled.
  44674. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44675. */
  44676. get framingBehavior(): Nullable<FramingBehavior>;
  44677. /**
  44678. * Defines if the framing behavior of the camera is enabled on the camera.
  44679. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44680. */
  44681. get useFramingBehavior(): boolean;
  44682. set useFramingBehavior(value: boolean);
  44683. private _autoRotationBehavior;
  44684. /**
  44685. * Gets the auto rotation behavior of the camera if it has been enabled.
  44686. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44687. */
  44688. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44689. /**
  44690. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44691. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44692. */
  44693. get useAutoRotationBehavior(): boolean;
  44694. set useAutoRotationBehavior(value: boolean);
  44695. /**
  44696. * Observable triggered when the mesh target has been changed on the camera.
  44697. */
  44698. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44699. /**
  44700. * Event raised when the camera is colliding with a mesh.
  44701. */
  44702. onCollide: (collidedMesh: AbstractMesh) => void;
  44703. /**
  44704. * Defines whether the camera should check collision with the objects oh the scene.
  44705. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44706. */
  44707. checkCollisions: boolean;
  44708. /**
  44709. * Defines the collision radius of the camera.
  44710. * This simulates a sphere around the camera.
  44711. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44712. */
  44713. collisionRadius: Vector3;
  44714. protected _collider: Collider;
  44715. protected _previousPosition: Vector3;
  44716. protected _collisionVelocity: Vector3;
  44717. protected _newPosition: Vector3;
  44718. protected _previousAlpha: number;
  44719. protected _previousBeta: number;
  44720. protected _previousRadius: number;
  44721. protected _collisionTriggered: boolean;
  44722. protected _targetBoundingCenter: Nullable<Vector3>;
  44723. private _computationVector;
  44724. /**
  44725. * Instantiates a new ArcRotateCamera in a given scene
  44726. * @param name Defines the name of the camera
  44727. * @param alpha Defines the camera rotation along the logitudinal axis
  44728. * @param beta Defines the camera rotation along the latitudinal axis
  44729. * @param radius Defines the camera distance from its target
  44730. * @param target Defines the camera target
  44731. * @param scene Defines the scene the camera belongs to
  44732. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44733. */
  44734. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44735. /** @hidden */
  44736. _initCache(): void;
  44737. /** @hidden */
  44738. _updateCache(ignoreParentClass?: boolean): void;
  44739. protected _getTargetPosition(): Vector3;
  44740. private _storedAlpha;
  44741. private _storedBeta;
  44742. private _storedRadius;
  44743. private _storedTarget;
  44744. private _storedTargetScreenOffset;
  44745. /**
  44746. * Stores the current state of the camera (alpha, beta, radius and target)
  44747. * @returns the camera itself
  44748. */
  44749. storeState(): Camera;
  44750. /**
  44751. * @hidden
  44752. * Restored camera state. You must call storeState() first
  44753. */
  44754. _restoreStateValues(): boolean;
  44755. /** @hidden */
  44756. _isSynchronizedViewMatrix(): boolean;
  44757. /**
  44758. * Attached controls to the current camera.
  44759. * @param element Defines the element the controls should be listened from
  44760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44761. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44762. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44763. */
  44764. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44765. /**
  44766. * Detach the current controls from the camera.
  44767. * The camera will stop reacting to inputs.
  44768. * @param element Defines the element to stop listening the inputs from
  44769. */
  44770. detachControl(element: HTMLElement): void;
  44771. /** @hidden */
  44772. _checkInputs(): void;
  44773. protected _checkLimits(): void;
  44774. /**
  44775. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44776. */
  44777. rebuildAnglesAndRadius(): void;
  44778. /**
  44779. * Use a position to define the current camera related information like alpha, beta and radius
  44780. * @param position Defines the position to set the camera at
  44781. */
  44782. setPosition(position: Vector3): void;
  44783. /**
  44784. * Defines the target the camera should look at.
  44785. * This will automatically adapt alpha beta and radius to fit within the new target.
  44786. * @param target Defines the new target as a Vector or a mesh
  44787. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44788. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44789. */
  44790. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44791. /** @hidden */
  44792. _getViewMatrix(): Matrix;
  44793. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44794. /**
  44795. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44796. * @param meshes Defines the mesh to zoom on
  44797. * @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)
  44798. */
  44799. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44800. /**
  44801. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44802. * The target will be changed but the radius
  44803. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44804. * @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)
  44805. */
  44806. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44807. min: Vector3;
  44808. max: Vector3;
  44809. distance: number;
  44810. }, doNotUpdateMaxZ?: boolean): void;
  44811. /**
  44812. * @override
  44813. * Override Camera.createRigCamera
  44814. */
  44815. createRigCamera(name: string, cameraIndex: number): Camera;
  44816. /**
  44817. * @hidden
  44818. * @override
  44819. * Override Camera._updateRigCameras
  44820. */
  44821. _updateRigCameras(): void;
  44822. /**
  44823. * Destroy the camera and release the current resources hold by it.
  44824. */
  44825. dispose(): void;
  44826. /**
  44827. * Gets the current object class name.
  44828. * @return the class name
  44829. */
  44830. getClassName(): string;
  44831. }
  44832. }
  44833. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44834. import { Behavior } from "babylonjs/Behaviors/behavior";
  44835. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44836. /**
  44837. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44838. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44839. */
  44840. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44841. /**
  44842. * Gets the name of the behavior.
  44843. */
  44844. get name(): string;
  44845. private _zoomStopsAnimation;
  44846. private _idleRotationSpeed;
  44847. private _idleRotationWaitTime;
  44848. private _idleRotationSpinupTime;
  44849. /**
  44850. * Sets the flag that indicates if user zooming should stop animation.
  44851. */
  44852. set zoomStopsAnimation(flag: boolean);
  44853. /**
  44854. * Gets the flag that indicates if user zooming should stop animation.
  44855. */
  44856. get zoomStopsAnimation(): boolean;
  44857. /**
  44858. * Sets the default speed at which the camera rotates around the model.
  44859. */
  44860. set idleRotationSpeed(speed: number);
  44861. /**
  44862. * Gets the default speed at which the camera rotates around the model.
  44863. */
  44864. get idleRotationSpeed(): number;
  44865. /**
  44866. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44867. */
  44868. set idleRotationWaitTime(time: number);
  44869. /**
  44870. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44871. */
  44872. get idleRotationWaitTime(): number;
  44873. /**
  44874. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44875. */
  44876. set idleRotationSpinupTime(time: number);
  44877. /**
  44878. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44879. */
  44880. get idleRotationSpinupTime(): number;
  44881. /**
  44882. * Gets a value indicating if the camera is currently rotating because of this behavior
  44883. */
  44884. get rotationInProgress(): boolean;
  44885. private _onPrePointerObservableObserver;
  44886. private _onAfterCheckInputsObserver;
  44887. private _attachedCamera;
  44888. private _isPointerDown;
  44889. private _lastFrameTime;
  44890. private _lastInteractionTime;
  44891. private _cameraRotationSpeed;
  44892. /**
  44893. * Initializes the behavior.
  44894. */
  44895. init(): void;
  44896. /**
  44897. * Attaches the behavior to its arc rotate camera.
  44898. * @param camera Defines the camera to attach the behavior to
  44899. */
  44900. attach(camera: ArcRotateCamera): void;
  44901. /**
  44902. * Detaches the behavior from its current arc rotate camera.
  44903. */
  44904. detach(): void;
  44905. /**
  44906. * Returns true if user is scrolling.
  44907. * @return true if user is scrolling.
  44908. */
  44909. private _userIsZooming;
  44910. private _lastFrameRadius;
  44911. private _shouldAnimationStopForInteraction;
  44912. /**
  44913. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44914. */
  44915. private _applyUserInteraction;
  44916. private _userIsMoving;
  44917. }
  44918. }
  44919. declare module "babylonjs/Behaviors/Cameras/index" {
  44920. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44921. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44922. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44923. }
  44924. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44925. import { Mesh } from "babylonjs/Meshes/mesh";
  44926. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44927. import { Behavior } from "babylonjs/Behaviors/behavior";
  44928. /**
  44929. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44930. */
  44931. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44932. private ui;
  44933. /**
  44934. * The name of the behavior
  44935. */
  44936. name: string;
  44937. /**
  44938. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44939. */
  44940. distanceAwayFromFace: number;
  44941. /**
  44942. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44943. */
  44944. distanceAwayFromBottomOfFace: number;
  44945. private _faceVectors;
  44946. private _target;
  44947. private _scene;
  44948. private _onRenderObserver;
  44949. private _tmpMatrix;
  44950. private _tmpVector;
  44951. /**
  44952. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44953. * @param ui The transform node that should be attched to the mesh
  44954. */
  44955. constructor(ui: TransformNode);
  44956. /**
  44957. * Initializes the behavior
  44958. */
  44959. init(): void;
  44960. private _closestFace;
  44961. private _zeroVector;
  44962. private _lookAtTmpMatrix;
  44963. private _lookAtToRef;
  44964. /**
  44965. * Attaches the AttachToBoxBehavior to the passed in mesh
  44966. * @param target The mesh that the specified node will be attached to
  44967. */
  44968. attach(target: Mesh): void;
  44969. /**
  44970. * Detaches the behavior from the mesh
  44971. */
  44972. detach(): void;
  44973. }
  44974. }
  44975. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44976. import { Behavior } from "babylonjs/Behaviors/behavior";
  44977. import { Mesh } from "babylonjs/Meshes/mesh";
  44978. /**
  44979. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44980. */
  44981. export class FadeInOutBehavior implements Behavior<Mesh> {
  44982. /**
  44983. * Time in milliseconds to delay before fading in (Default: 0)
  44984. */
  44985. delay: number;
  44986. /**
  44987. * Time in milliseconds for the mesh to fade in (Default: 300)
  44988. */
  44989. fadeInTime: number;
  44990. private _millisecondsPerFrame;
  44991. private _hovered;
  44992. private _hoverValue;
  44993. private _ownerNode;
  44994. /**
  44995. * Instatiates the FadeInOutBehavior
  44996. */
  44997. constructor();
  44998. /**
  44999. * The name of the behavior
  45000. */
  45001. get name(): string;
  45002. /**
  45003. * Initializes the behavior
  45004. */
  45005. init(): void;
  45006. /**
  45007. * Attaches the fade behavior on the passed in mesh
  45008. * @param ownerNode The mesh that will be faded in/out once attached
  45009. */
  45010. attach(ownerNode: Mesh): void;
  45011. /**
  45012. * Detaches the behavior from the mesh
  45013. */
  45014. detach(): void;
  45015. /**
  45016. * Triggers the mesh to begin fading in or out
  45017. * @param value if the object should fade in or out (true to fade in)
  45018. */
  45019. fadeIn(value: boolean): void;
  45020. private _update;
  45021. private _setAllVisibility;
  45022. }
  45023. }
  45024. declare module "babylonjs/Misc/pivotTools" {
  45025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45026. /**
  45027. * Class containing a set of static utilities functions for managing Pivots
  45028. * @hidden
  45029. */
  45030. export class PivotTools {
  45031. private static _PivotCached;
  45032. private static _OldPivotPoint;
  45033. private static _PivotTranslation;
  45034. private static _PivotTmpVector;
  45035. private static _PivotPostMultiplyPivotMatrix;
  45036. /** @hidden */
  45037. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  45038. /** @hidden */
  45039. static _RestorePivotPoint(mesh: AbstractMesh): void;
  45040. }
  45041. }
  45042. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  45043. import { Scene } from "babylonjs/scene";
  45044. import { Vector4 } from "babylonjs/Maths/math.vector";
  45045. import { Mesh } from "babylonjs/Meshes/mesh";
  45046. import { Nullable } from "babylonjs/types";
  45047. import { Plane } from "babylonjs/Maths/math.plane";
  45048. /**
  45049. * Class containing static functions to help procedurally build meshes
  45050. */
  45051. export class PlaneBuilder {
  45052. /**
  45053. * Creates a plane mesh
  45054. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  45055. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  45056. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  45057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45060. * @param name defines the name of the mesh
  45061. * @param options defines the options used to create the mesh
  45062. * @param scene defines the hosting scene
  45063. * @returns the plane mesh
  45064. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  45065. */
  45066. static CreatePlane(name: string, options: {
  45067. size?: number;
  45068. width?: number;
  45069. height?: number;
  45070. sideOrientation?: number;
  45071. frontUVs?: Vector4;
  45072. backUVs?: Vector4;
  45073. updatable?: boolean;
  45074. sourcePlane?: Plane;
  45075. }, scene?: Nullable<Scene>): Mesh;
  45076. }
  45077. }
  45078. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  45079. import { Behavior } from "babylonjs/Behaviors/behavior";
  45080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45081. import { Observable } from "babylonjs/Misc/observable";
  45082. import { Vector3 } from "babylonjs/Maths/math.vector";
  45083. import { Ray } from "babylonjs/Culling/ray";
  45084. import "babylonjs/Meshes/Builders/planeBuilder";
  45085. /**
  45086. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  45087. */
  45088. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  45089. private static _AnyMouseID;
  45090. /**
  45091. * Abstract mesh the behavior is set on
  45092. */
  45093. attachedNode: AbstractMesh;
  45094. private _dragPlane;
  45095. private _scene;
  45096. private _pointerObserver;
  45097. private _beforeRenderObserver;
  45098. private static _planeScene;
  45099. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  45100. /**
  45101. * 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)
  45102. */
  45103. maxDragAngle: number;
  45104. /**
  45105. * @hidden
  45106. */
  45107. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45108. /**
  45109. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45110. */
  45111. currentDraggingPointerID: number;
  45112. /**
  45113. * The last position where the pointer hit the drag plane in world space
  45114. */
  45115. lastDragPosition: Vector3;
  45116. /**
  45117. * If the behavior is currently in a dragging state
  45118. */
  45119. dragging: boolean;
  45120. /**
  45121. * 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)
  45122. */
  45123. dragDeltaRatio: number;
  45124. /**
  45125. * If the drag plane orientation should be updated during the dragging (Default: true)
  45126. */
  45127. updateDragPlane: boolean;
  45128. private _debugMode;
  45129. private _moving;
  45130. /**
  45131. * Fires each time the attached mesh is dragged with the pointer
  45132. * * delta between last drag position and current drag position in world space
  45133. * * dragDistance along the drag axis
  45134. * * dragPlaneNormal normal of the current drag plane used during the drag
  45135. * * dragPlanePoint in world space where the drag intersects the drag plane
  45136. */
  45137. onDragObservable: Observable<{
  45138. delta: Vector3;
  45139. dragPlanePoint: Vector3;
  45140. dragPlaneNormal: Vector3;
  45141. dragDistance: number;
  45142. pointerId: number;
  45143. }>;
  45144. /**
  45145. * Fires each time a drag begins (eg. mouse down on mesh)
  45146. */
  45147. onDragStartObservable: Observable<{
  45148. dragPlanePoint: Vector3;
  45149. pointerId: number;
  45150. }>;
  45151. /**
  45152. * Fires each time a drag ends (eg. mouse release after drag)
  45153. */
  45154. onDragEndObservable: Observable<{
  45155. dragPlanePoint: Vector3;
  45156. pointerId: number;
  45157. }>;
  45158. /**
  45159. * If the attached mesh should be moved when dragged
  45160. */
  45161. moveAttached: boolean;
  45162. /**
  45163. * If the drag behavior will react to drag events (Default: true)
  45164. */
  45165. enabled: boolean;
  45166. /**
  45167. * If pointer events should start and release the drag (Default: true)
  45168. */
  45169. startAndReleaseDragOnPointerEvents: boolean;
  45170. /**
  45171. * If camera controls should be detached during the drag
  45172. */
  45173. detachCameraControls: boolean;
  45174. /**
  45175. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45176. */
  45177. useObjectOrientationForDragging: boolean;
  45178. private _options;
  45179. /**
  45180. * Gets the options used by the behavior
  45181. */
  45182. get options(): {
  45183. dragAxis?: Vector3;
  45184. dragPlaneNormal?: Vector3;
  45185. };
  45186. /**
  45187. * Sets the options used by the behavior
  45188. */
  45189. set options(options: {
  45190. dragAxis?: Vector3;
  45191. dragPlaneNormal?: Vector3;
  45192. });
  45193. /**
  45194. * Creates a pointer drag behavior that can be attached to a mesh
  45195. * @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)
  45196. */
  45197. constructor(options?: {
  45198. dragAxis?: Vector3;
  45199. dragPlaneNormal?: Vector3;
  45200. });
  45201. /**
  45202. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45203. */
  45204. validateDrag: (targetPosition: Vector3) => boolean;
  45205. /**
  45206. * The name of the behavior
  45207. */
  45208. get name(): string;
  45209. /**
  45210. * Initializes the behavior
  45211. */
  45212. init(): void;
  45213. private _tmpVector;
  45214. private _alternatePickedPoint;
  45215. private _worldDragAxis;
  45216. private _targetPosition;
  45217. private _attachedElement;
  45218. /**
  45219. * Attaches the drag behavior the passed in mesh
  45220. * @param ownerNode The mesh that will be dragged around once attached
  45221. * @param predicate Predicate to use for pick filtering
  45222. */
  45223. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45224. /**
  45225. * Force relase the drag action by code.
  45226. */
  45227. releaseDrag(): void;
  45228. private _startDragRay;
  45229. private _lastPointerRay;
  45230. /**
  45231. * Simulates the start of a pointer drag event on the behavior
  45232. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45233. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45234. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45235. */
  45236. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45237. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45238. private _dragDelta;
  45239. protected _moveDrag(ray: Ray): void;
  45240. private _pickWithRayOnDragPlane;
  45241. private _pointA;
  45242. private _pointC;
  45243. private _localAxis;
  45244. private _lookAt;
  45245. private _updateDragPlanePosition;
  45246. /**
  45247. * Detaches the behavior from the mesh
  45248. */
  45249. detach(): void;
  45250. }
  45251. }
  45252. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45253. import { Mesh } from "babylonjs/Meshes/mesh";
  45254. import { Behavior } from "babylonjs/Behaviors/behavior";
  45255. /**
  45256. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45257. */
  45258. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45259. private _dragBehaviorA;
  45260. private _dragBehaviorB;
  45261. private _startDistance;
  45262. private _initialScale;
  45263. private _targetScale;
  45264. private _ownerNode;
  45265. private _sceneRenderObserver;
  45266. /**
  45267. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45268. */
  45269. constructor();
  45270. /**
  45271. * The name of the behavior
  45272. */
  45273. get name(): string;
  45274. /**
  45275. * Initializes the behavior
  45276. */
  45277. init(): void;
  45278. private _getCurrentDistance;
  45279. /**
  45280. * Attaches the scale behavior the passed in mesh
  45281. * @param ownerNode The mesh that will be scaled around once attached
  45282. */
  45283. attach(ownerNode: Mesh): void;
  45284. /**
  45285. * Detaches the behavior from the mesh
  45286. */
  45287. detach(): void;
  45288. }
  45289. }
  45290. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45291. import { Behavior } from "babylonjs/Behaviors/behavior";
  45292. import { Mesh } from "babylonjs/Meshes/mesh";
  45293. import { Observable } from "babylonjs/Misc/observable";
  45294. /**
  45295. * 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
  45296. */
  45297. export class SixDofDragBehavior implements Behavior<Mesh> {
  45298. private static _virtualScene;
  45299. private _ownerNode;
  45300. private _sceneRenderObserver;
  45301. private _scene;
  45302. private _targetPosition;
  45303. private _virtualOriginMesh;
  45304. private _virtualDragMesh;
  45305. private _pointerObserver;
  45306. private _moving;
  45307. private _startingOrientation;
  45308. private _attachedElement;
  45309. /**
  45310. * 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)
  45311. */
  45312. private zDragFactor;
  45313. /**
  45314. * If the object should rotate to face the drag origin
  45315. */
  45316. rotateDraggedObject: boolean;
  45317. /**
  45318. * If the behavior is currently in a dragging state
  45319. */
  45320. dragging: boolean;
  45321. /**
  45322. * 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)
  45323. */
  45324. dragDeltaRatio: number;
  45325. /**
  45326. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45327. */
  45328. currentDraggingPointerID: number;
  45329. /**
  45330. * If camera controls should be detached during the drag
  45331. */
  45332. detachCameraControls: boolean;
  45333. /**
  45334. * Fires each time a drag starts
  45335. */
  45336. onDragStartObservable: Observable<{}>;
  45337. /**
  45338. * Fires each time a drag ends (eg. mouse release after drag)
  45339. */
  45340. onDragEndObservable: Observable<{}>;
  45341. /**
  45342. * 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
  45343. */
  45344. constructor();
  45345. /**
  45346. * The name of the behavior
  45347. */
  45348. get name(): string;
  45349. /**
  45350. * Initializes the behavior
  45351. */
  45352. init(): void;
  45353. /**
  45354. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45355. */
  45356. private get _pointerCamera();
  45357. /**
  45358. * Attaches the scale behavior the passed in mesh
  45359. * @param ownerNode The mesh that will be scaled around once attached
  45360. */
  45361. attach(ownerNode: Mesh): void;
  45362. /**
  45363. * Detaches the behavior from the mesh
  45364. */
  45365. detach(): void;
  45366. }
  45367. }
  45368. declare module "babylonjs/Behaviors/Meshes/index" {
  45369. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45370. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45371. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45372. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45373. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45374. }
  45375. declare module "babylonjs/Behaviors/index" {
  45376. export * from "babylonjs/Behaviors/behavior";
  45377. export * from "babylonjs/Behaviors/Cameras/index";
  45378. export * from "babylonjs/Behaviors/Meshes/index";
  45379. }
  45380. declare module "babylonjs/Bones/boneIKController" {
  45381. import { Bone } from "babylonjs/Bones/bone";
  45382. import { Vector3 } from "babylonjs/Maths/math.vector";
  45383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45384. import { Nullable } from "babylonjs/types";
  45385. /**
  45386. * Class used to apply inverse kinematics to bones
  45387. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45388. */
  45389. export class BoneIKController {
  45390. private static _tmpVecs;
  45391. private static _tmpQuat;
  45392. private static _tmpMats;
  45393. /**
  45394. * Gets or sets the target mesh
  45395. */
  45396. targetMesh: AbstractMesh;
  45397. /** Gets or sets the mesh used as pole */
  45398. poleTargetMesh: AbstractMesh;
  45399. /**
  45400. * Gets or sets the bone used as pole
  45401. */
  45402. poleTargetBone: Nullable<Bone>;
  45403. /**
  45404. * Gets or sets the target position
  45405. */
  45406. targetPosition: Vector3;
  45407. /**
  45408. * Gets or sets the pole target position
  45409. */
  45410. poleTargetPosition: Vector3;
  45411. /**
  45412. * Gets or sets the pole target local offset
  45413. */
  45414. poleTargetLocalOffset: Vector3;
  45415. /**
  45416. * Gets or sets the pole angle
  45417. */
  45418. poleAngle: number;
  45419. /**
  45420. * Gets or sets the mesh associated with the controller
  45421. */
  45422. mesh: AbstractMesh;
  45423. /**
  45424. * 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)
  45425. */
  45426. slerpAmount: number;
  45427. private _bone1Quat;
  45428. private _bone1Mat;
  45429. private _bone2Ang;
  45430. private _bone1;
  45431. private _bone2;
  45432. private _bone1Length;
  45433. private _bone2Length;
  45434. private _maxAngle;
  45435. private _maxReach;
  45436. private _rightHandedSystem;
  45437. private _bendAxis;
  45438. private _slerping;
  45439. private _adjustRoll;
  45440. /**
  45441. * Gets or sets maximum allowed angle
  45442. */
  45443. get maxAngle(): number;
  45444. set maxAngle(value: number);
  45445. /**
  45446. * Creates a new BoneIKController
  45447. * @param mesh defines the mesh to control
  45448. * @param bone defines the bone to control
  45449. * @param options defines options to set up the controller
  45450. */
  45451. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45452. targetMesh?: AbstractMesh;
  45453. poleTargetMesh?: AbstractMesh;
  45454. poleTargetBone?: Bone;
  45455. poleTargetLocalOffset?: Vector3;
  45456. poleAngle?: number;
  45457. bendAxis?: Vector3;
  45458. maxAngle?: number;
  45459. slerpAmount?: number;
  45460. });
  45461. private _setMaxAngle;
  45462. /**
  45463. * Force the controller to update the bones
  45464. */
  45465. update(): void;
  45466. }
  45467. }
  45468. declare module "babylonjs/Bones/boneLookController" {
  45469. import { Vector3 } from "babylonjs/Maths/math.vector";
  45470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45471. import { Bone } from "babylonjs/Bones/bone";
  45472. import { Space } from "babylonjs/Maths/math.axis";
  45473. /**
  45474. * Class used to make a bone look toward a point in space
  45475. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45476. */
  45477. export class BoneLookController {
  45478. private static _tmpVecs;
  45479. private static _tmpQuat;
  45480. private static _tmpMats;
  45481. /**
  45482. * The target Vector3 that the bone will look at
  45483. */
  45484. target: Vector3;
  45485. /**
  45486. * The mesh that the bone is attached to
  45487. */
  45488. mesh: AbstractMesh;
  45489. /**
  45490. * The bone that will be looking to the target
  45491. */
  45492. bone: Bone;
  45493. /**
  45494. * The up axis of the coordinate system that is used when the bone is rotated
  45495. */
  45496. upAxis: Vector3;
  45497. /**
  45498. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45499. */
  45500. upAxisSpace: Space;
  45501. /**
  45502. * Used to make an adjustment to the yaw of the bone
  45503. */
  45504. adjustYaw: number;
  45505. /**
  45506. * Used to make an adjustment to the pitch of the bone
  45507. */
  45508. adjustPitch: number;
  45509. /**
  45510. * Used to make an adjustment to the roll of the bone
  45511. */
  45512. adjustRoll: number;
  45513. /**
  45514. * 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)
  45515. */
  45516. slerpAmount: number;
  45517. private _minYaw;
  45518. private _maxYaw;
  45519. private _minPitch;
  45520. private _maxPitch;
  45521. private _minYawSin;
  45522. private _minYawCos;
  45523. private _maxYawSin;
  45524. private _maxYawCos;
  45525. private _midYawConstraint;
  45526. private _minPitchTan;
  45527. private _maxPitchTan;
  45528. private _boneQuat;
  45529. private _slerping;
  45530. private _transformYawPitch;
  45531. private _transformYawPitchInv;
  45532. private _firstFrameSkipped;
  45533. private _yawRange;
  45534. private _fowardAxis;
  45535. /**
  45536. * Gets or sets the minimum yaw angle that the bone can look to
  45537. */
  45538. get minYaw(): number;
  45539. set minYaw(value: number);
  45540. /**
  45541. * Gets or sets the maximum yaw angle that the bone can look to
  45542. */
  45543. get maxYaw(): number;
  45544. set maxYaw(value: number);
  45545. /**
  45546. * Gets or sets the minimum pitch angle that the bone can look to
  45547. */
  45548. get minPitch(): number;
  45549. set minPitch(value: number);
  45550. /**
  45551. * Gets or sets the maximum pitch angle that the bone can look to
  45552. */
  45553. get maxPitch(): number;
  45554. set maxPitch(value: number);
  45555. /**
  45556. * Create a BoneLookController
  45557. * @param mesh the mesh that the bone belongs to
  45558. * @param bone the bone that will be looking to the target
  45559. * @param target the target Vector3 to look at
  45560. * @param options optional settings:
  45561. * * maxYaw: the maximum angle the bone will yaw to
  45562. * * minYaw: the minimum angle the bone will yaw to
  45563. * * maxPitch: the maximum angle the bone will pitch to
  45564. * * minPitch: the minimum angle the bone will yaw to
  45565. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45566. * * upAxis: the up axis of the coordinate system
  45567. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45568. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45569. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45570. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45571. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45572. * * adjustRoll: used to make an adjustment to the roll of the bone
  45573. **/
  45574. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45575. maxYaw?: number;
  45576. minYaw?: number;
  45577. maxPitch?: number;
  45578. minPitch?: number;
  45579. slerpAmount?: number;
  45580. upAxis?: Vector3;
  45581. upAxisSpace?: Space;
  45582. yawAxis?: Vector3;
  45583. pitchAxis?: Vector3;
  45584. adjustYaw?: number;
  45585. adjustPitch?: number;
  45586. adjustRoll?: number;
  45587. });
  45588. /**
  45589. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45590. */
  45591. update(): void;
  45592. private _getAngleDiff;
  45593. private _getAngleBetween;
  45594. private _isAngleBetween;
  45595. }
  45596. }
  45597. declare module "babylonjs/Bones/index" {
  45598. export * from "babylonjs/Bones/bone";
  45599. export * from "babylonjs/Bones/boneIKController";
  45600. export * from "babylonjs/Bones/boneLookController";
  45601. export * from "babylonjs/Bones/skeleton";
  45602. }
  45603. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45604. import { Nullable } from "babylonjs/types";
  45605. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45606. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45607. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45608. /**
  45609. * Manage the gamepad inputs to control an arc rotate camera.
  45610. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45611. */
  45612. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45613. /**
  45614. * Defines the camera the input is attached to.
  45615. */
  45616. camera: ArcRotateCamera;
  45617. /**
  45618. * Defines the gamepad the input is gathering event from.
  45619. */
  45620. gamepad: Nullable<Gamepad>;
  45621. /**
  45622. * Defines the gamepad rotation sensiblity.
  45623. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45624. */
  45625. gamepadRotationSensibility: number;
  45626. /**
  45627. * Defines the gamepad move sensiblity.
  45628. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45629. */
  45630. gamepadMoveSensibility: number;
  45631. private _yAxisScale;
  45632. /**
  45633. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45634. */
  45635. get invertYAxis(): boolean;
  45636. set invertYAxis(value: boolean);
  45637. private _onGamepadConnectedObserver;
  45638. private _onGamepadDisconnectedObserver;
  45639. /**
  45640. * Attach the input controls to a specific dom element to get the input from.
  45641. * @param element Defines the element the controls should be listened from
  45642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45643. */
  45644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45645. /**
  45646. * Detach the current controls from the specified dom element.
  45647. * @param element Defines the element to stop listening the inputs from
  45648. */
  45649. detachControl(element: Nullable<HTMLElement>): void;
  45650. /**
  45651. * Update the current camera state depending on the inputs that have been used this frame.
  45652. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45653. */
  45654. checkInputs(): void;
  45655. /**
  45656. * Gets the class name of the current intput.
  45657. * @returns the class name
  45658. */
  45659. getClassName(): string;
  45660. /**
  45661. * Get the friendly name associated with the input class.
  45662. * @returns the input friendly name
  45663. */
  45664. getSimpleName(): string;
  45665. }
  45666. }
  45667. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45668. import { Nullable } from "babylonjs/types";
  45669. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45670. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45671. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45672. interface ArcRotateCameraInputsManager {
  45673. /**
  45674. * Add orientation input support to the input manager.
  45675. * @returns the current input manager
  45676. */
  45677. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45678. }
  45679. }
  45680. /**
  45681. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45682. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45683. */
  45684. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45685. /**
  45686. * Defines the camera the input is attached to.
  45687. */
  45688. camera: ArcRotateCamera;
  45689. /**
  45690. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45691. */
  45692. alphaCorrection: number;
  45693. /**
  45694. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45695. */
  45696. gammaCorrection: number;
  45697. private _alpha;
  45698. private _gamma;
  45699. private _dirty;
  45700. private _deviceOrientationHandler;
  45701. /**
  45702. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45703. */
  45704. constructor();
  45705. /**
  45706. * Attach the input controls to a specific dom element to get the input from.
  45707. * @param element Defines the element the controls should be listened from
  45708. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45709. */
  45710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45711. /** @hidden */
  45712. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45713. /**
  45714. * Update the current camera state depending on the inputs that have been used this frame.
  45715. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45716. */
  45717. checkInputs(): void;
  45718. /**
  45719. * Detach the current controls from the specified dom element.
  45720. * @param element Defines the element to stop listening the inputs from
  45721. */
  45722. detachControl(element: Nullable<HTMLElement>): void;
  45723. /**
  45724. * Gets the class name of the current intput.
  45725. * @returns the class name
  45726. */
  45727. getClassName(): string;
  45728. /**
  45729. * Get the friendly name associated with the input class.
  45730. * @returns the input friendly name
  45731. */
  45732. getSimpleName(): string;
  45733. }
  45734. }
  45735. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45736. import { Nullable } from "babylonjs/types";
  45737. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45738. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45739. /**
  45740. * Listen to mouse events to control the camera.
  45741. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45742. */
  45743. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45744. /**
  45745. * Defines the camera the input is attached to.
  45746. */
  45747. camera: FlyCamera;
  45748. /**
  45749. * Defines if touch is enabled. (Default is true.)
  45750. */
  45751. touchEnabled: boolean;
  45752. /**
  45753. * Defines the buttons associated with the input to handle camera rotation.
  45754. */
  45755. buttons: number[];
  45756. /**
  45757. * Assign buttons for Yaw control.
  45758. */
  45759. buttonsYaw: number[];
  45760. /**
  45761. * Assign buttons for Pitch control.
  45762. */
  45763. buttonsPitch: number[];
  45764. /**
  45765. * Assign buttons for Roll control.
  45766. */
  45767. buttonsRoll: number[];
  45768. /**
  45769. * Detect if any button is being pressed while mouse is moved.
  45770. * -1 = Mouse locked.
  45771. * 0 = Left button.
  45772. * 1 = Middle Button.
  45773. * 2 = Right Button.
  45774. */
  45775. activeButton: number;
  45776. /**
  45777. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45778. * Higher values reduce its sensitivity.
  45779. */
  45780. angularSensibility: number;
  45781. private _mousemoveCallback;
  45782. private _observer;
  45783. private _rollObserver;
  45784. private previousPosition;
  45785. private noPreventDefault;
  45786. private element;
  45787. /**
  45788. * Listen to mouse events to control the camera.
  45789. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45790. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45791. */
  45792. constructor(touchEnabled?: boolean);
  45793. /**
  45794. * Attach the mouse control to the HTML DOM element.
  45795. * @param element Defines the element that listens to the input events.
  45796. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45797. */
  45798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45799. /**
  45800. * Detach the current controls from the specified dom element.
  45801. * @param element Defines the element to stop listening the inputs from
  45802. */
  45803. detachControl(element: Nullable<HTMLElement>): void;
  45804. /**
  45805. * Gets the class name of the current input.
  45806. * @returns the class name.
  45807. */
  45808. getClassName(): string;
  45809. /**
  45810. * Get the friendly name associated with the input class.
  45811. * @returns the input's friendly name.
  45812. */
  45813. getSimpleName(): string;
  45814. private _pointerInput;
  45815. private _onMouseMove;
  45816. /**
  45817. * Rotate camera by mouse offset.
  45818. */
  45819. private rotateCamera;
  45820. }
  45821. }
  45822. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45823. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45824. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45825. /**
  45826. * Default Inputs manager for the FlyCamera.
  45827. * It groups all the default supported inputs for ease of use.
  45828. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45829. */
  45830. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45831. /**
  45832. * Instantiates a new FlyCameraInputsManager.
  45833. * @param camera Defines the camera the inputs belong to.
  45834. */
  45835. constructor(camera: FlyCamera);
  45836. /**
  45837. * Add keyboard input support to the input manager.
  45838. * @returns the new FlyCameraKeyboardMoveInput().
  45839. */
  45840. addKeyboard(): FlyCameraInputsManager;
  45841. /**
  45842. * Add mouse input support to the input manager.
  45843. * @param touchEnabled Enable touch screen support.
  45844. * @returns the new FlyCameraMouseInput().
  45845. */
  45846. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45847. }
  45848. }
  45849. declare module "babylonjs/Cameras/flyCamera" {
  45850. import { Scene } from "babylonjs/scene";
  45851. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45853. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45854. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45855. /**
  45856. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45857. * such as in a 3D Space Shooter or a Flight Simulator.
  45858. */
  45859. export class FlyCamera extends TargetCamera {
  45860. /**
  45861. * Define the collision ellipsoid of the camera.
  45862. * This is helpful for simulating a camera body, like a player's body.
  45863. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45864. */
  45865. ellipsoid: Vector3;
  45866. /**
  45867. * Define an offset for the position of the ellipsoid around the camera.
  45868. * This can be helpful if the camera is attached away from the player's body center,
  45869. * such as at its head.
  45870. */
  45871. ellipsoidOffset: Vector3;
  45872. /**
  45873. * Enable or disable collisions of the camera with the rest of the scene objects.
  45874. */
  45875. checkCollisions: boolean;
  45876. /**
  45877. * Enable or disable gravity on the camera.
  45878. */
  45879. applyGravity: boolean;
  45880. /**
  45881. * Define the current direction the camera is moving to.
  45882. */
  45883. cameraDirection: Vector3;
  45884. /**
  45885. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45886. * This overrides and empties cameraRotation.
  45887. */
  45888. rotationQuaternion: Quaternion;
  45889. /**
  45890. * Track Roll to maintain the wanted Rolling when looking around.
  45891. */
  45892. _trackRoll: number;
  45893. /**
  45894. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45895. */
  45896. rollCorrect: number;
  45897. /**
  45898. * Mimic a banked turn, Rolling the camera when Yawing.
  45899. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45900. */
  45901. bankedTurn: boolean;
  45902. /**
  45903. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45904. */
  45905. bankedTurnLimit: number;
  45906. /**
  45907. * Value of 0 disables the banked Roll.
  45908. * Value of 1 is equal to the Yaw angle in radians.
  45909. */
  45910. bankedTurnMultiplier: number;
  45911. /**
  45912. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45913. */
  45914. inputs: FlyCameraInputsManager;
  45915. /**
  45916. * Gets the input sensibility for mouse input.
  45917. * Higher values reduce sensitivity.
  45918. */
  45919. get angularSensibility(): number;
  45920. /**
  45921. * Sets the input sensibility for a mouse input.
  45922. * Higher values reduce sensitivity.
  45923. */
  45924. set angularSensibility(value: number);
  45925. /**
  45926. * Get the keys for camera movement forward.
  45927. */
  45928. get keysForward(): number[];
  45929. /**
  45930. * Set the keys for camera movement forward.
  45931. */
  45932. set keysForward(value: number[]);
  45933. /**
  45934. * Get the keys for camera movement backward.
  45935. */
  45936. get keysBackward(): number[];
  45937. set keysBackward(value: number[]);
  45938. /**
  45939. * Get the keys for camera movement up.
  45940. */
  45941. get keysUp(): number[];
  45942. /**
  45943. * Set the keys for camera movement up.
  45944. */
  45945. set keysUp(value: number[]);
  45946. /**
  45947. * Get the keys for camera movement down.
  45948. */
  45949. get keysDown(): number[];
  45950. /**
  45951. * Set the keys for camera movement down.
  45952. */
  45953. set keysDown(value: number[]);
  45954. /**
  45955. * Get the keys for camera movement left.
  45956. */
  45957. get keysLeft(): number[];
  45958. /**
  45959. * Set the keys for camera movement left.
  45960. */
  45961. set keysLeft(value: number[]);
  45962. /**
  45963. * Set the keys for camera movement right.
  45964. */
  45965. get keysRight(): number[];
  45966. /**
  45967. * Set the keys for camera movement right.
  45968. */
  45969. set keysRight(value: number[]);
  45970. /**
  45971. * Event raised when the camera collides with a mesh in the scene.
  45972. */
  45973. onCollide: (collidedMesh: AbstractMesh) => void;
  45974. private _collider;
  45975. private _needMoveForGravity;
  45976. private _oldPosition;
  45977. private _diffPosition;
  45978. private _newPosition;
  45979. /** @hidden */
  45980. _localDirection: Vector3;
  45981. /** @hidden */
  45982. _transformedDirection: Vector3;
  45983. /**
  45984. * Instantiates a FlyCamera.
  45985. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45986. * such as in a 3D Space Shooter or a Flight Simulator.
  45987. * @param name Define the name of the camera in the scene.
  45988. * @param position Define the starting position of the camera in the scene.
  45989. * @param scene Define the scene the camera belongs to.
  45990. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45991. */
  45992. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45993. /**
  45994. * Attach a control to the HTML DOM element.
  45995. * @param element Defines the element that listens to the input events.
  45996. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45997. */
  45998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45999. /**
  46000. * Detach a control from the HTML DOM element.
  46001. * The camera will stop reacting to that input.
  46002. * @param element Defines the element that listens to the input events.
  46003. */
  46004. detachControl(element: HTMLElement): void;
  46005. private _collisionMask;
  46006. /**
  46007. * Get the mask that the camera ignores in collision events.
  46008. */
  46009. get collisionMask(): number;
  46010. /**
  46011. * Set the mask that the camera ignores in collision events.
  46012. */
  46013. set collisionMask(mask: number);
  46014. /** @hidden */
  46015. _collideWithWorld(displacement: Vector3): void;
  46016. /** @hidden */
  46017. private _onCollisionPositionChange;
  46018. /** @hidden */
  46019. _checkInputs(): void;
  46020. /** @hidden */
  46021. _decideIfNeedsToMove(): boolean;
  46022. /** @hidden */
  46023. _updatePosition(): void;
  46024. /**
  46025. * Restore the Roll to its target value at the rate specified.
  46026. * @param rate - Higher means slower restoring.
  46027. * @hidden
  46028. */
  46029. restoreRoll(rate: number): void;
  46030. /**
  46031. * Destroy the camera and release the current resources held by it.
  46032. */
  46033. dispose(): void;
  46034. /**
  46035. * Get the current object class name.
  46036. * @returns the class name.
  46037. */
  46038. getClassName(): string;
  46039. }
  46040. }
  46041. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  46042. import { Nullable } from "babylonjs/types";
  46043. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46044. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  46045. /**
  46046. * Listen to keyboard events to control the camera.
  46047. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46048. */
  46049. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  46050. /**
  46051. * Defines the camera the input is attached to.
  46052. */
  46053. camera: FlyCamera;
  46054. /**
  46055. * The list of keyboard keys used to control the forward move of the camera.
  46056. */
  46057. keysForward: number[];
  46058. /**
  46059. * The list of keyboard keys used to control the backward move of the camera.
  46060. */
  46061. keysBackward: number[];
  46062. /**
  46063. * The list of keyboard keys used to control the forward move of the camera.
  46064. */
  46065. keysUp: number[];
  46066. /**
  46067. * The list of keyboard keys used to control the backward move of the camera.
  46068. */
  46069. keysDown: number[];
  46070. /**
  46071. * The list of keyboard keys used to control the right strafe move of the camera.
  46072. */
  46073. keysRight: number[];
  46074. /**
  46075. * The list of keyboard keys used to control the left strafe move of the camera.
  46076. */
  46077. keysLeft: number[];
  46078. private _keys;
  46079. private _onCanvasBlurObserver;
  46080. private _onKeyboardObserver;
  46081. private _engine;
  46082. private _scene;
  46083. /**
  46084. * Attach the input controls to a specific dom element to get the input from.
  46085. * @param element Defines the element the controls should be listened from
  46086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46087. */
  46088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46089. /**
  46090. * Detach the current controls from the specified dom element.
  46091. * @param element Defines the element to stop listening the inputs from
  46092. */
  46093. detachControl(element: Nullable<HTMLElement>): void;
  46094. /**
  46095. * Gets the class name of the current intput.
  46096. * @returns the class name
  46097. */
  46098. getClassName(): string;
  46099. /** @hidden */
  46100. _onLostFocus(e: FocusEvent): void;
  46101. /**
  46102. * Get the friendly name associated with the input class.
  46103. * @returns the input friendly name
  46104. */
  46105. getSimpleName(): string;
  46106. /**
  46107. * Update the current camera state depending on the inputs that have been used this frame.
  46108. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46109. */
  46110. checkInputs(): void;
  46111. }
  46112. }
  46113. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46114. import { Nullable } from "babylonjs/types";
  46115. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46116. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46117. /**
  46118. * Manage the mouse wheel inputs to control a follow camera.
  46119. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46120. */
  46121. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46122. /**
  46123. * Defines the camera the input is attached to.
  46124. */
  46125. camera: FollowCamera;
  46126. /**
  46127. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46128. */
  46129. axisControlRadius: boolean;
  46130. /**
  46131. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46132. */
  46133. axisControlHeight: boolean;
  46134. /**
  46135. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46136. */
  46137. axisControlRotation: boolean;
  46138. /**
  46139. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46140. * relation to mouseWheel events.
  46141. */
  46142. wheelPrecision: number;
  46143. /**
  46144. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46145. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46146. */
  46147. wheelDeltaPercentage: number;
  46148. private _wheel;
  46149. private _observer;
  46150. /**
  46151. * Attach the input controls to a specific dom element to get the input from.
  46152. * @param element Defines the element the controls should be listened from
  46153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46154. */
  46155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46156. /**
  46157. * Detach the current controls from the specified dom element.
  46158. * @param element Defines the element to stop listening the inputs from
  46159. */
  46160. detachControl(element: Nullable<HTMLElement>): void;
  46161. /**
  46162. * Gets the class name of the current intput.
  46163. * @returns the class name
  46164. */
  46165. getClassName(): string;
  46166. /**
  46167. * Get the friendly name associated with the input class.
  46168. * @returns the input friendly name
  46169. */
  46170. getSimpleName(): string;
  46171. }
  46172. }
  46173. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46174. import { Nullable } from "babylonjs/types";
  46175. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46176. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46177. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46178. /**
  46179. * Manage the pointers inputs to control an follow camera.
  46180. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46181. */
  46182. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46183. /**
  46184. * Defines the camera the input is attached to.
  46185. */
  46186. camera: FollowCamera;
  46187. /**
  46188. * Gets the class name of the current input.
  46189. * @returns the class name
  46190. */
  46191. getClassName(): string;
  46192. /**
  46193. * Defines the pointer angular sensibility along the X axis or how fast is
  46194. * the camera rotating.
  46195. * A negative number will reverse the axis direction.
  46196. */
  46197. angularSensibilityX: number;
  46198. /**
  46199. * Defines the pointer angular sensibility along the Y axis or how fast is
  46200. * the camera rotating.
  46201. * A negative number will reverse the axis direction.
  46202. */
  46203. angularSensibilityY: number;
  46204. /**
  46205. * Defines the pointer pinch precision or how fast is the camera zooming.
  46206. * A negative number will reverse the axis direction.
  46207. */
  46208. pinchPrecision: number;
  46209. /**
  46210. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46211. * from 0.
  46212. * It defines the percentage of current camera.radius to use as delta when
  46213. * pinch zoom is used.
  46214. */
  46215. pinchDeltaPercentage: number;
  46216. /**
  46217. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46218. */
  46219. axisXControlRadius: boolean;
  46220. /**
  46221. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46222. */
  46223. axisXControlHeight: boolean;
  46224. /**
  46225. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46226. */
  46227. axisXControlRotation: boolean;
  46228. /**
  46229. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46230. */
  46231. axisYControlRadius: boolean;
  46232. /**
  46233. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46234. */
  46235. axisYControlHeight: boolean;
  46236. /**
  46237. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46238. */
  46239. axisYControlRotation: boolean;
  46240. /**
  46241. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46242. */
  46243. axisPinchControlRadius: boolean;
  46244. /**
  46245. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46246. */
  46247. axisPinchControlHeight: boolean;
  46248. /**
  46249. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46250. */
  46251. axisPinchControlRotation: boolean;
  46252. /**
  46253. * Log error messages if basic misconfiguration has occurred.
  46254. */
  46255. warningEnable: boolean;
  46256. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46257. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46258. private _warningCounter;
  46259. private _warning;
  46260. }
  46261. }
  46262. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46263. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46264. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46265. /**
  46266. * Default Inputs manager for the FollowCamera.
  46267. * It groups all the default supported inputs for ease of use.
  46268. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46269. */
  46270. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46271. /**
  46272. * Instantiates a new FollowCameraInputsManager.
  46273. * @param camera Defines the camera the inputs belong to
  46274. */
  46275. constructor(camera: FollowCamera);
  46276. /**
  46277. * Add keyboard input support to the input manager.
  46278. * @returns the current input manager
  46279. */
  46280. addKeyboard(): FollowCameraInputsManager;
  46281. /**
  46282. * Add mouse wheel input support to the input manager.
  46283. * @returns the current input manager
  46284. */
  46285. addMouseWheel(): FollowCameraInputsManager;
  46286. /**
  46287. * Add pointers input support to the input manager.
  46288. * @returns the current input manager
  46289. */
  46290. addPointers(): FollowCameraInputsManager;
  46291. /**
  46292. * Add orientation input support to the input manager.
  46293. * @returns the current input manager
  46294. */
  46295. addVRDeviceOrientation(): FollowCameraInputsManager;
  46296. }
  46297. }
  46298. declare module "babylonjs/Cameras/followCamera" {
  46299. import { Nullable } from "babylonjs/types";
  46300. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46301. import { Scene } from "babylonjs/scene";
  46302. import { Vector3 } from "babylonjs/Maths/math.vector";
  46303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46304. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46305. /**
  46306. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46307. * an arc rotate version arcFollowCamera are available.
  46308. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46309. */
  46310. export class FollowCamera extends TargetCamera {
  46311. /**
  46312. * Distance the follow camera should follow an object at
  46313. */
  46314. radius: number;
  46315. /**
  46316. * Minimum allowed distance of the camera to the axis of rotation
  46317. * (The camera can not get closer).
  46318. * This can help limiting how the Camera is able to move in the scene.
  46319. */
  46320. lowerRadiusLimit: Nullable<number>;
  46321. /**
  46322. * Maximum allowed distance of the camera to the axis of rotation
  46323. * (The camera can not get further).
  46324. * This can help limiting how the Camera is able to move in the scene.
  46325. */
  46326. upperRadiusLimit: Nullable<number>;
  46327. /**
  46328. * Define a rotation offset between the camera and the object it follows
  46329. */
  46330. rotationOffset: number;
  46331. /**
  46332. * Minimum allowed angle to camera position relative to target object.
  46333. * This can help limiting how the Camera is able to move in the scene.
  46334. */
  46335. lowerRotationOffsetLimit: Nullable<number>;
  46336. /**
  46337. * Maximum allowed angle to camera position relative to target object.
  46338. * This can help limiting how the Camera is able to move in the scene.
  46339. */
  46340. upperRotationOffsetLimit: Nullable<number>;
  46341. /**
  46342. * Define a height offset between the camera and the object it follows.
  46343. * It can help following an object from the top (like a car chaing a plane)
  46344. */
  46345. heightOffset: number;
  46346. /**
  46347. * Minimum allowed height of camera position relative to target object.
  46348. * This can help limiting how the Camera is able to move in the scene.
  46349. */
  46350. lowerHeightOffsetLimit: Nullable<number>;
  46351. /**
  46352. * Maximum allowed height of camera position relative to target object.
  46353. * This can help limiting how the Camera is able to move in the scene.
  46354. */
  46355. upperHeightOffsetLimit: Nullable<number>;
  46356. /**
  46357. * Define how fast the camera can accelerate to follow it s target.
  46358. */
  46359. cameraAcceleration: number;
  46360. /**
  46361. * Define the speed limit of the camera following an object.
  46362. */
  46363. maxCameraSpeed: number;
  46364. /**
  46365. * Define the target of the camera.
  46366. */
  46367. lockedTarget: Nullable<AbstractMesh>;
  46368. /**
  46369. * Defines the input associated with the camera.
  46370. */
  46371. inputs: FollowCameraInputsManager;
  46372. /**
  46373. * Instantiates the follow camera.
  46374. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46375. * @param name Define the name of the camera in the scene
  46376. * @param position Define the position of the camera
  46377. * @param scene Define the scene the camera belong to
  46378. * @param lockedTarget Define the target of the camera
  46379. */
  46380. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46381. private _follow;
  46382. /**
  46383. * Attached controls to the current camera.
  46384. * @param element Defines the element the controls should be listened from
  46385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46386. */
  46387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46388. /**
  46389. * Detach the current controls from the camera.
  46390. * The camera will stop reacting to inputs.
  46391. * @param element Defines the element to stop listening the inputs from
  46392. */
  46393. detachControl(element: HTMLElement): void;
  46394. /** @hidden */
  46395. _checkInputs(): void;
  46396. private _checkLimits;
  46397. /**
  46398. * Gets the camera class name.
  46399. * @returns the class name
  46400. */
  46401. getClassName(): string;
  46402. }
  46403. /**
  46404. * Arc Rotate version of the follow camera.
  46405. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46406. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46407. */
  46408. export class ArcFollowCamera extends TargetCamera {
  46409. /** The longitudinal angle of the camera */
  46410. alpha: number;
  46411. /** The latitudinal angle of the camera */
  46412. beta: number;
  46413. /** The radius of the camera from its target */
  46414. radius: number;
  46415. private _cartesianCoordinates;
  46416. /** Define the camera target (the mesh it should follow) */
  46417. private _meshTarget;
  46418. /**
  46419. * Instantiates a new ArcFollowCamera
  46420. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46421. * @param name Define the name of the camera
  46422. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46423. * @param beta Define the rotation angle of the camera around the elevation axis
  46424. * @param radius Define the radius of the camera from its target point
  46425. * @param target Define the target of the camera
  46426. * @param scene Define the scene the camera belongs to
  46427. */
  46428. constructor(name: string,
  46429. /** The longitudinal angle of the camera */
  46430. alpha: number,
  46431. /** The latitudinal angle of the camera */
  46432. beta: number,
  46433. /** The radius of the camera from its target */
  46434. radius: number,
  46435. /** Define the camera target (the mesh it should follow) */
  46436. target: Nullable<AbstractMesh>, scene: Scene);
  46437. private _follow;
  46438. /** @hidden */
  46439. _checkInputs(): void;
  46440. /**
  46441. * Returns the class name of the object.
  46442. * It is mostly used internally for serialization purposes.
  46443. */
  46444. getClassName(): string;
  46445. }
  46446. }
  46447. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46448. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46449. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46450. import { Nullable } from "babylonjs/types";
  46451. /**
  46452. * Manage the keyboard inputs to control the movement of a follow camera.
  46453. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46454. */
  46455. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46456. /**
  46457. * Defines the camera the input is attached to.
  46458. */
  46459. camera: FollowCamera;
  46460. /**
  46461. * Defines the list of key codes associated with the up action (increase heightOffset)
  46462. */
  46463. keysHeightOffsetIncr: number[];
  46464. /**
  46465. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46466. */
  46467. keysHeightOffsetDecr: number[];
  46468. /**
  46469. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46470. */
  46471. keysHeightOffsetModifierAlt: boolean;
  46472. /**
  46473. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46474. */
  46475. keysHeightOffsetModifierCtrl: boolean;
  46476. /**
  46477. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46478. */
  46479. keysHeightOffsetModifierShift: boolean;
  46480. /**
  46481. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46482. */
  46483. keysRotationOffsetIncr: number[];
  46484. /**
  46485. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46486. */
  46487. keysRotationOffsetDecr: number[];
  46488. /**
  46489. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46490. */
  46491. keysRotationOffsetModifierAlt: boolean;
  46492. /**
  46493. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46494. */
  46495. keysRotationOffsetModifierCtrl: boolean;
  46496. /**
  46497. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46498. */
  46499. keysRotationOffsetModifierShift: boolean;
  46500. /**
  46501. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46502. */
  46503. keysRadiusIncr: number[];
  46504. /**
  46505. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46506. */
  46507. keysRadiusDecr: number[];
  46508. /**
  46509. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46510. */
  46511. keysRadiusModifierAlt: boolean;
  46512. /**
  46513. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46514. */
  46515. keysRadiusModifierCtrl: boolean;
  46516. /**
  46517. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46518. */
  46519. keysRadiusModifierShift: boolean;
  46520. /**
  46521. * Defines the rate of change of heightOffset.
  46522. */
  46523. heightSensibility: number;
  46524. /**
  46525. * Defines the rate of change of rotationOffset.
  46526. */
  46527. rotationSensibility: number;
  46528. /**
  46529. * Defines the rate of change of radius.
  46530. */
  46531. radiusSensibility: number;
  46532. private _keys;
  46533. private _ctrlPressed;
  46534. private _altPressed;
  46535. private _shiftPressed;
  46536. private _onCanvasBlurObserver;
  46537. private _onKeyboardObserver;
  46538. private _engine;
  46539. private _scene;
  46540. /**
  46541. * Attach the input controls to a specific dom element to get the input from.
  46542. * @param element Defines the element the controls should be listened from
  46543. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46544. */
  46545. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46546. /**
  46547. * Detach the current controls from the specified dom element.
  46548. * @param element Defines the element to stop listening the inputs from
  46549. */
  46550. detachControl(element: Nullable<HTMLElement>): void;
  46551. /**
  46552. * Update the current camera state depending on the inputs that have been used this frame.
  46553. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46554. */
  46555. checkInputs(): void;
  46556. /**
  46557. * Gets the class name of the current input.
  46558. * @returns the class name
  46559. */
  46560. getClassName(): string;
  46561. /**
  46562. * Get the friendly name associated with the input class.
  46563. * @returns the input friendly name
  46564. */
  46565. getSimpleName(): string;
  46566. /**
  46567. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46568. * allow modification of the heightOffset value.
  46569. */
  46570. private _modifierHeightOffset;
  46571. /**
  46572. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46573. * allow modification of the rotationOffset value.
  46574. */
  46575. private _modifierRotationOffset;
  46576. /**
  46577. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46578. * allow modification of the radius value.
  46579. */
  46580. private _modifierRadius;
  46581. }
  46582. }
  46583. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46584. import { Nullable } from "babylonjs/types";
  46585. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46586. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46587. import { Observable } from "babylonjs/Misc/observable";
  46588. module "babylonjs/Cameras/freeCameraInputsManager" {
  46589. interface FreeCameraInputsManager {
  46590. /**
  46591. * @hidden
  46592. */
  46593. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46594. /**
  46595. * Add orientation input support to the input manager.
  46596. * @returns the current input manager
  46597. */
  46598. addDeviceOrientation(): FreeCameraInputsManager;
  46599. }
  46600. }
  46601. /**
  46602. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46603. * Screen rotation is taken into account.
  46604. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46605. */
  46606. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46607. private _camera;
  46608. private _screenOrientationAngle;
  46609. private _constantTranform;
  46610. private _screenQuaternion;
  46611. private _alpha;
  46612. private _beta;
  46613. private _gamma;
  46614. /**
  46615. * Can be used to detect if a device orientation sensor is available on a device
  46616. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46617. * @returns a promise that will resolve on orientation change
  46618. */
  46619. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46620. /**
  46621. * @hidden
  46622. */
  46623. _onDeviceOrientationChangedObservable: Observable<void>;
  46624. /**
  46625. * Instantiates a new input
  46626. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46627. */
  46628. constructor();
  46629. /**
  46630. * Define the camera controlled by the input.
  46631. */
  46632. get camera(): FreeCamera;
  46633. set camera(camera: FreeCamera);
  46634. /**
  46635. * Attach the input controls to a specific dom element to get the input from.
  46636. * @param element Defines the element the controls should be listened from
  46637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46638. */
  46639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46640. private _orientationChanged;
  46641. private _deviceOrientation;
  46642. /**
  46643. * Detach the current controls from the specified dom element.
  46644. * @param element Defines the element to stop listening the inputs from
  46645. */
  46646. detachControl(element: Nullable<HTMLElement>): void;
  46647. /**
  46648. * Update the current camera state depending on the inputs that have been used this frame.
  46649. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46650. */
  46651. checkInputs(): void;
  46652. /**
  46653. * Gets the class name of the current intput.
  46654. * @returns the class name
  46655. */
  46656. getClassName(): string;
  46657. /**
  46658. * Get the friendly name associated with the input class.
  46659. * @returns the input friendly name
  46660. */
  46661. getSimpleName(): string;
  46662. }
  46663. }
  46664. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46665. import { Nullable } from "babylonjs/types";
  46666. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46667. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46668. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46669. /**
  46670. * Manage the gamepad inputs to control a free camera.
  46671. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46672. */
  46673. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46674. /**
  46675. * Define the camera the input is attached to.
  46676. */
  46677. camera: FreeCamera;
  46678. /**
  46679. * Define the Gamepad controlling the input
  46680. */
  46681. gamepad: Nullable<Gamepad>;
  46682. /**
  46683. * Defines the gamepad rotation sensiblity.
  46684. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46685. */
  46686. gamepadAngularSensibility: number;
  46687. /**
  46688. * Defines the gamepad move sensiblity.
  46689. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46690. */
  46691. gamepadMoveSensibility: number;
  46692. private _yAxisScale;
  46693. /**
  46694. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46695. */
  46696. get invertYAxis(): boolean;
  46697. set invertYAxis(value: boolean);
  46698. private _onGamepadConnectedObserver;
  46699. private _onGamepadDisconnectedObserver;
  46700. private _cameraTransform;
  46701. private _deltaTransform;
  46702. private _vector3;
  46703. private _vector2;
  46704. /**
  46705. * Attach the input controls to a specific dom element to get the input from.
  46706. * @param element Defines the element the controls should be listened from
  46707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46708. */
  46709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46710. /**
  46711. * Detach the current controls from the specified dom element.
  46712. * @param element Defines the element to stop listening the inputs from
  46713. */
  46714. detachControl(element: Nullable<HTMLElement>): void;
  46715. /**
  46716. * Update the current camera state depending on the inputs that have been used this frame.
  46717. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46718. */
  46719. checkInputs(): void;
  46720. /**
  46721. * Gets the class name of the current intput.
  46722. * @returns the class name
  46723. */
  46724. getClassName(): string;
  46725. /**
  46726. * Get the friendly name associated with the input class.
  46727. * @returns the input friendly name
  46728. */
  46729. getSimpleName(): string;
  46730. }
  46731. }
  46732. declare module "babylonjs/Misc/virtualJoystick" {
  46733. import { Nullable } from "babylonjs/types";
  46734. import { Vector3 } from "babylonjs/Maths/math.vector";
  46735. /**
  46736. * Defines the potential axis of a Joystick
  46737. */
  46738. export enum JoystickAxis {
  46739. /** X axis */
  46740. X = 0,
  46741. /** Y axis */
  46742. Y = 1,
  46743. /** Z axis */
  46744. Z = 2
  46745. }
  46746. /**
  46747. * Represents the different customization options available
  46748. * for VirtualJoystick
  46749. */
  46750. interface VirtualJoystickCustomizations {
  46751. /**
  46752. * Size of the joystick's puck
  46753. */
  46754. puckSize: number;
  46755. /**
  46756. * Size of the joystick's container
  46757. */
  46758. containerSize: number;
  46759. /**
  46760. * Color of the joystick && puck
  46761. */
  46762. color: string;
  46763. /**
  46764. * Image URL for the joystick's puck
  46765. */
  46766. puckImage?: string;
  46767. /**
  46768. * Image URL for the joystick's container
  46769. */
  46770. containerImage?: string;
  46771. /**
  46772. * Defines the unmoving position of the joystick container
  46773. */
  46774. position?: {
  46775. x: number;
  46776. y: number;
  46777. };
  46778. /**
  46779. * Defines whether or not the joystick container is always visible
  46780. */
  46781. alwaysVisible: boolean;
  46782. /**
  46783. * Defines whether or not to limit the movement of the puck to the joystick's container
  46784. */
  46785. limitToContainer: boolean;
  46786. }
  46787. /**
  46788. * Class used to define virtual joystick (used in touch mode)
  46789. */
  46790. export class VirtualJoystick {
  46791. /**
  46792. * Gets or sets a boolean indicating that left and right values must be inverted
  46793. */
  46794. reverseLeftRight: boolean;
  46795. /**
  46796. * Gets or sets a boolean indicating that up and down values must be inverted
  46797. */
  46798. reverseUpDown: boolean;
  46799. /**
  46800. * Gets the offset value for the position (ie. the change of the position value)
  46801. */
  46802. deltaPosition: Vector3;
  46803. /**
  46804. * Gets a boolean indicating if the virtual joystick was pressed
  46805. */
  46806. pressed: boolean;
  46807. /**
  46808. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46809. */
  46810. static Canvas: Nullable<HTMLCanvasElement>;
  46811. /**
  46812. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46813. */
  46814. limitToContainer: boolean;
  46815. private static _globalJoystickIndex;
  46816. private static _alwaysVisibleSticks;
  46817. private static vjCanvasContext;
  46818. private static vjCanvasWidth;
  46819. private static vjCanvasHeight;
  46820. private static halfWidth;
  46821. private static _GetDefaultOptions;
  46822. private _action;
  46823. private _axisTargetedByLeftAndRight;
  46824. private _axisTargetedByUpAndDown;
  46825. private _joystickSensibility;
  46826. private _inversedSensibility;
  46827. private _joystickPointerID;
  46828. private _joystickColor;
  46829. private _joystickPointerPos;
  46830. private _joystickPreviousPointerPos;
  46831. private _joystickPointerStartPos;
  46832. private _deltaJoystickVector;
  46833. private _leftJoystick;
  46834. private _touches;
  46835. private _joystickPosition;
  46836. private _alwaysVisible;
  46837. private _puckImage;
  46838. private _containerImage;
  46839. private _joystickPuckSize;
  46840. private _joystickContainerSize;
  46841. private _clearPuckSize;
  46842. private _clearContainerSize;
  46843. private _clearPuckSizeOffset;
  46844. private _clearContainerSizeOffset;
  46845. private _onPointerDownHandlerRef;
  46846. private _onPointerMoveHandlerRef;
  46847. private _onPointerUpHandlerRef;
  46848. private _onResize;
  46849. /**
  46850. * Creates a new virtual joystick
  46851. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46852. * @param customizations Defines the options we want to customize the VirtualJoystick
  46853. */
  46854. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46855. /**
  46856. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46857. * @param newJoystickSensibility defines the new sensibility
  46858. */
  46859. setJoystickSensibility(newJoystickSensibility: number): void;
  46860. private _onPointerDown;
  46861. private _onPointerMove;
  46862. private _onPointerUp;
  46863. /**
  46864. * Change the color of the virtual joystick
  46865. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46866. */
  46867. setJoystickColor(newColor: string): void;
  46868. /**
  46869. * Size of the joystick's container
  46870. */
  46871. set containerSize(newSize: number);
  46872. get containerSize(): number;
  46873. /**
  46874. * Size of the joystick's puck
  46875. */
  46876. set puckSize(newSize: number);
  46877. get puckSize(): number;
  46878. /**
  46879. * Clears the set position of the joystick
  46880. */
  46881. clearPosition(): void;
  46882. /**
  46883. * Defines whether or not the joystick container is always visible
  46884. */
  46885. set alwaysVisible(value: boolean);
  46886. get alwaysVisible(): boolean;
  46887. /**
  46888. * Sets the constant position of the Joystick container
  46889. * @param x X axis coordinate
  46890. * @param y Y axis coordinate
  46891. */
  46892. setPosition(x: number, y: number): void;
  46893. /**
  46894. * Defines a callback to call when the joystick is touched
  46895. * @param action defines the callback
  46896. */
  46897. setActionOnTouch(action: () => any): void;
  46898. /**
  46899. * Defines which axis you'd like to control for left & right
  46900. * @param axis defines the axis to use
  46901. */
  46902. setAxisForLeftRight(axis: JoystickAxis): void;
  46903. /**
  46904. * Defines which axis you'd like to control for up & down
  46905. * @param axis defines the axis to use
  46906. */
  46907. setAxisForUpDown(axis: JoystickAxis): void;
  46908. /**
  46909. * Clears the canvas from the previous puck / container draw
  46910. */
  46911. private _clearPreviousDraw;
  46912. /**
  46913. * Loads `urlPath` to be used for the container's image
  46914. * @param urlPath defines the urlPath of an image to use
  46915. */
  46916. setContainerImage(urlPath: string): void;
  46917. /**
  46918. * Loads `urlPath` to be used for the puck's image
  46919. * @param urlPath defines the urlPath of an image to use
  46920. */
  46921. setPuckImage(urlPath: string): void;
  46922. /**
  46923. * Draws the Virtual Joystick's container
  46924. */
  46925. private _drawContainer;
  46926. /**
  46927. * Draws the Virtual Joystick's puck
  46928. */
  46929. private _drawPuck;
  46930. private _drawVirtualJoystick;
  46931. /**
  46932. * Release internal HTML canvas
  46933. */
  46934. releaseCanvas(): void;
  46935. }
  46936. }
  46937. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46938. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46939. import { Nullable } from "babylonjs/types";
  46940. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46941. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46942. module "babylonjs/Cameras/freeCameraInputsManager" {
  46943. interface FreeCameraInputsManager {
  46944. /**
  46945. * Add virtual joystick input support to the input manager.
  46946. * @returns the current input manager
  46947. */
  46948. addVirtualJoystick(): FreeCameraInputsManager;
  46949. }
  46950. }
  46951. /**
  46952. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46953. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46954. */
  46955. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46956. /**
  46957. * Defines the camera the input is attached to.
  46958. */
  46959. camera: FreeCamera;
  46960. private _leftjoystick;
  46961. private _rightjoystick;
  46962. /**
  46963. * Gets the left stick of the virtual joystick.
  46964. * @returns The virtual Joystick
  46965. */
  46966. getLeftJoystick(): VirtualJoystick;
  46967. /**
  46968. * Gets the right stick of the virtual joystick.
  46969. * @returns The virtual Joystick
  46970. */
  46971. getRightJoystick(): VirtualJoystick;
  46972. /**
  46973. * Update the current camera state depending on the inputs that have been used this frame.
  46974. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46975. */
  46976. checkInputs(): void;
  46977. /**
  46978. * Attach the input controls to a specific dom element to get the input from.
  46979. * @param element Defines the element the controls should be listened from
  46980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46981. */
  46982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46983. /**
  46984. * Detach the current controls from the specified dom element.
  46985. * @param element Defines the element to stop listening the inputs from
  46986. */
  46987. detachControl(element: Nullable<HTMLElement>): void;
  46988. /**
  46989. * Gets the class name of the current intput.
  46990. * @returns the class name
  46991. */
  46992. getClassName(): string;
  46993. /**
  46994. * Get the friendly name associated with the input class.
  46995. * @returns the input friendly name
  46996. */
  46997. getSimpleName(): string;
  46998. }
  46999. }
  47000. declare module "babylonjs/Cameras/Inputs/index" {
  47001. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  47002. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  47003. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  47004. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  47005. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47006. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  47007. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  47008. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  47009. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  47010. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  47011. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47012. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  47013. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  47014. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  47015. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  47016. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47017. }
  47018. declare module "babylonjs/Cameras/touchCamera" {
  47019. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47020. import { Scene } from "babylonjs/scene";
  47021. import { Vector3 } from "babylonjs/Maths/math.vector";
  47022. /**
  47023. * This represents a FPS type of camera controlled by touch.
  47024. * This is like a universal camera minus the Gamepad controls.
  47025. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47026. */
  47027. export class TouchCamera extends FreeCamera {
  47028. /**
  47029. * Defines the touch sensibility for rotation.
  47030. * The higher the faster.
  47031. */
  47032. get touchAngularSensibility(): number;
  47033. set touchAngularSensibility(value: number);
  47034. /**
  47035. * Defines the touch sensibility for move.
  47036. * The higher the faster.
  47037. */
  47038. get touchMoveSensibility(): number;
  47039. set touchMoveSensibility(value: number);
  47040. /**
  47041. * Instantiates a new touch camera.
  47042. * This represents a FPS type of camera controlled by touch.
  47043. * This is like a universal camera minus the Gamepad controls.
  47044. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47045. * @param name Define the name of the camera in the scene
  47046. * @param position Define the start position of the camera in the scene
  47047. * @param scene Define the scene the camera belongs to
  47048. */
  47049. constructor(name: string, position: Vector3, scene: Scene);
  47050. /**
  47051. * Gets the current object class name.
  47052. * @return the class name
  47053. */
  47054. getClassName(): string;
  47055. /** @hidden */
  47056. _setupInputs(): void;
  47057. }
  47058. }
  47059. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  47060. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47061. import { Scene } from "babylonjs/scene";
  47062. import { Vector3 } from "babylonjs/Maths/math.vector";
  47063. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47064. import { Axis } from "babylonjs/Maths/math.axis";
  47065. /**
  47066. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  47067. * being tilted forward or back and left or right.
  47068. */
  47069. export class DeviceOrientationCamera extends FreeCamera {
  47070. private _initialQuaternion;
  47071. private _quaternionCache;
  47072. private _tmpDragQuaternion;
  47073. private _disablePointerInputWhenUsingDeviceOrientation;
  47074. /**
  47075. * Creates a new device orientation camera
  47076. * @param name The name of the camera
  47077. * @param position The start position camera
  47078. * @param scene The scene the camera belongs to
  47079. */
  47080. constructor(name: string, position: Vector3, scene: Scene);
  47081. /**
  47082. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  47083. */
  47084. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  47085. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  47086. private _dragFactor;
  47087. /**
  47088. * Enabled turning on the y axis when the orientation sensor is active
  47089. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  47090. */
  47091. enableHorizontalDragging(dragFactor?: number): void;
  47092. /**
  47093. * Gets the current instance class name ("DeviceOrientationCamera").
  47094. * This helps avoiding instanceof at run time.
  47095. * @returns the class name
  47096. */
  47097. getClassName(): string;
  47098. /**
  47099. * @hidden
  47100. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  47101. */
  47102. _checkInputs(): void;
  47103. /**
  47104. * Reset the camera to its default orientation on the specified axis only.
  47105. * @param axis The axis to reset
  47106. */
  47107. resetToCurrentRotation(axis?: Axis): void;
  47108. }
  47109. }
  47110. declare module "babylonjs/Gamepads/xboxGamepad" {
  47111. import { Observable } from "babylonjs/Misc/observable";
  47112. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47113. /**
  47114. * Defines supported buttons for XBox360 compatible gamepads
  47115. */
  47116. export enum Xbox360Button {
  47117. /** A */
  47118. A = 0,
  47119. /** B */
  47120. B = 1,
  47121. /** X */
  47122. X = 2,
  47123. /** Y */
  47124. Y = 3,
  47125. /** Left button */
  47126. LB = 4,
  47127. /** Right button */
  47128. RB = 5,
  47129. /** Back */
  47130. Back = 8,
  47131. /** Start */
  47132. Start = 9,
  47133. /** Left stick */
  47134. LeftStick = 10,
  47135. /** Right stick */
  47136. RightStick = 11
  47137. }
  47138. /** Defines values for XBox360 DPad */
  47139. export enum Xbox360Dpad {
  47140. /** Up */
  47141. Up = 12,
  47142. /** Down */
  47143. Down = 13,
  47144. /** Left */
  47145. Left = 14,
  47146. /** Right */
  47147. Right = 15
  47148. }
  47149. /**
  47150. * Defines a XBox360 gamepad
  47151. */
  47152. export class Xbox360Pad extends Gamepad {
  47153. private _leftTrigger;
  47154. private _rightTrigger;
  47155. private _onlefttriggerchanged;
  47156. private _onrighttriggerchanged;
  47157. private _onbuttondown;
  47158. private _onbuttonup;
  47159. private _ondpaddown;
  47160. private _ondpadup;
  47161. /** Observable raised when a button is pressed */
  47162. onButtonDownObservable: Observable<Xbox360Button>;
  47163. /** Observable raised when a button is released */
  47164. onButtonUpObservable: Observable<Xbox360Button>;
  47165. /** Observable raised when a pad is pressed */
  47166. onPadDownObservable: Observable<Xbox360Dpad>;
  47167. /** Observable raised when a pad is released */
  47168. onPadUpObservable: Observable<Xbox360Dpad>;
  47169. private _buttonA;
  47170. private _buttonB;
  47171. private _buttonX;
  47172. private _buttonY;
  47173. private _buttonBack;
  47174. private _buttonStart;
  47175. private _buttonLB;
  47176. private _buttonRB;
  47177. private _buttonLeftStick;
  47178. private _buttonRightStick;
  47179. private _dPadUp;
  47180. private _dPadDown;
  47181. private _dPadLeft;
  47182. private _dPadRight;
  47183. private _isXboxOnePad;
  47184. /**
  47185. * Creates a new XBox360 gamepad object
  47186. * @param id defines the id of this gamepad
  47187. * @param index defines its index
  47188. * @param gamepad defines the internal HTML gamepad object
  47189. * @param xboxOne defines if it is a XBox One gamepad
  47190. */
  47191. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47192. /**
  47193. * Defines the callback to call when left trigger is pressed
  47194. * @param callback defines the callback to use
  47195. */
  47196. onlefttriggerchanged(callback: (value: number) => void): void;
  47197. /**
  47198. * Defines the callback to call when right trigger is pressed
  47199. * @param callback defines the callback to use
  47200. */
  47201. onrighttriggerchanged(callback: (value: number) => void): void;
  47202. /**
  47203. * Gets the left trigger value
  47204. */
  47205. get leftTrigger(): number;
  47206. /**
  47207. * Sets the left trigger value
  47208. */
  47209. set leftTrigger(newValue: number);
  47210. /**
  47211. * Gets the right trigger value
  47212. */
  47213. get rightTrigger(): number;
  47214. /**
  47215. * Sets the right trigger value
  47216. */
  47217. set rightTrigger(newValue: number);
  47218. /**
  47219. * Defines the callback to call when a button is pressed
  47220. * @param callback defines the callback to use
  47221. */
  47222. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47223. /**
  47224. * Defines the callback to call when a button is released
  47225. * @param callback defines the callback to use
  47226. */
  47227. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47228. /**
  47229. * Defines the callback to call when a pad is pressed
  47230. * @param callback defines the callback to use
  47231. */
  47232. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47233. /**
  47234. * Defines the callback to call when a pad is released
  47235. * @param callback defines the callback to use
  47236. */
  47237. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47238. private _setButtonValue;
  47239. private _setDPadValue;
  47240. /**
  47241. * Gets the value of the `A` button
  47242. */
  47243. get buttonA(): number;
  47244. /**
  47245. * Sets the value of the `A` button
  47246. */
  47247. set buttonA(value: number);
  47248. /**
  47249. * Gets the value of the `B` button
  47250. */
  47251. get buttonB(): number;
  47252. /**
  47253. * Sets the value of the `B` button
  47254. */
  47255. set buttonB(value: number);
  47256. /**
  47257. * Gets the value of the `X` button
  47258. */
  47259. get buttonX(): number;
  47260. /**
  47261. * Sets the value of the `X` button
  47262. */
  47263. set buttonX(value: number);
  47264. /**
  47265. * Gets the value of the `Y` button
  47266. */
  47267. get buttonY(): number;
  47268. /**
  47269. * Sets the value of the `Y` button
  47270. */
  47271. set buttonY(value: number);
  47272. /**
  47273. * Gets the value of the `Start` button
  47274. */
  47275. get buttonStart(): number;
  47276. /**
  47277. * Sets the value of the `Start` button
  47278. */
  47279. set buttonStart(value: number);
  47280. /**
  47281. * Gets the value of the `Back` button
  47282. */
  47283. get buttonBack(): number;
  47284. /**
  47285. * Sets the value of the `Back` button
  47286. */
  47287. set buttonBack(value: number);
  47288. /**
  47289. * Gets the value of the `Left` button
  47290. */
  47291. get buttonLB(): number;
  47292. /**
  47293. * Sets the value of the `Left` button
  47294. */
  47295. set buttonLB(value: number);
  47296. /**
  47297. * Gets the value of the `Right` button
  47298. */
  47299. get buttonRB(): number;
  47300. /**
  47301. * Sets the value of the `Right` button
  47302. */
  47303. set buttonRB(value: number);
  47304. /**
  47305. * Gets the value of the Left joystick
  47306. */
  47307. get buttonLeftStick(): number;
  47308. /**
  47309. * Sets the value of the Left joystick
  47310. */
  47311. set buttonLeftStick(value: number);
  47312. /**
  47313. * Gets the value of the Right joystick
  47314. */
  47315. get buttonRightStick(): number;
  47316. /**
  47317. * Sets the value of the Right joystick
  47318. */
  47319. set buttonRightStick(value: number);
  47320. /**
  47321. * Gets the value of D-pad up
  47322. */
  47323. get dPadUp(): number;
  47324. /**
  47325. * Sets the value of D-pad up
  47326. */
  47327. set dPadUp(value: number);
  47328. /**
  47329. * Gets the value of D-pad down
  47330. */
  47331. get dPadDown(): number;
  47332. /**
  47333. * Sets the value of D-pad down
  47334. */
  47335. set dPadDown(value: number);
  47336. /**
  47337. * Gets the value of D-pad left
  47338. */
  47339. get dPadLeft(): number;
  47340. /**
  47341. * Sets the value of D-pad left
  47342. */
  47343. set dPadLeft(value: number);
  47344. /**
  47345. * Gets the value of D-pad right
  47346. */
  47347. get dPadRight(): number;
  47348. /**
  47349. * Sets the value of D-pad right
  47350. */
  47351. set dPadRight(value: number);
  47352. /**
  47353. * Force the gamepad to synchronize with device values
  47354. */
  47355. update(): void;
  47356. /**
  47357. * Disposes the gamepad
  47358. */
  47359. dispose(): void;
  47360. }
  47361. }
  47362. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47363. import { Observable } from "babylonjs/Misc/observable";
  47364. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47365. /**
  47366. * Defines supported buttons for DualShock compatible gamepads
  47367. */
  47368. export enum DualShockButton {
  47369. /** Cross */
  47370. Cross = 0,
  47371. /** Circle */
  47372. Circle = 1,
  47373. /** Square */
  47374. Square = 2,
  47375. /** Triangle */
  47376. Triangle = 3,
  47377. /** L1 */
  47378. L1 = 4,
  47379. /** R1 */
  47380. R1 = 5,
  47381. /** Share */
  47382. Share = 8,
  47383. /** Options */
  47384. Options = 9,
  47385. /** Left stick */
  47386. LeftStick = 10,
  47387. /** Right stick */
  47388. RightStick = 11
  47389. }
  47390. /** Defines values for DualShock DPad */
  47391. export enum DualShockDpad {
  47392. /** Up */
  47393. Up = 12,
  47394. /** Down */
  47395. Down = 13,
  47396. /** Left */
  47397. Left = 14,
  47398. /** Right */
  47399. Right = 15
  47400. }
  47401. /**
  47402. * Defines a DualShock gamepad
  47403. */
  47404. export class DualShockPad extends Gamepad {
  47405. private _leftTrigger;
  47406. private _rightTrigger;
  47407. private _onlefttriggerchanged;
  47408. private _onrighttriggerchanged;
  47409. private _onbuttondown;
  47410. private _onbuttonup;
  47411. private _ondpaddown;
  47412. private _ondpadup;
  47413. /** Observable raised when a button is pressed */
  47414. onButtonDownObservable: Observable<DualShockButton>;
  47415. /** Observable raised when a button is released */
  47416. onButtonUpObservable: Observable<DualShockButton>;
  47417. /** Observable raised when a pad is pressed */
  47418. onPadDownObservable: Observable<DualShockDpad>;
  47419. /** Observable raised when a pad is released */
  47420. onPadUpObservable: Observable<DualShockDpad>;
  47421. private _buttonCross;
  47422. private _buttonCircle;
  47423. private _buttonSquare;
  47424. private _buttonTriangle;
  47425. private _buttonShare;
  47426. private _buttonOptions;
  47427. private _buttonL1;
  47428. private _buttonR1;
  47429. private _buttonLeftStick;
  47430. private _buttonRightStick;
  47431. private _dPadUp;
  47432. private _dPadDown;
  47433. private _dPadLeft;
  47434. private _dPadRight;
  47435. /**
  47436. * Creates a new DualShock gamepad object
  47437. * @param id defines the id of this gamepad
  47438. * @param index defines its index
  47439. * @param gamepad defines the internal HTML gamepad object
  47440. */
  47441. constructor(id: string, index: number, gamepad: any);
  47442. /**
  47443. * Defines the callback to call when left trigger is pressed
  47444. * @param callback defines the callback to use
  47445. */
  47446. onlefttriggerchanged(callback: (value: number) => void): void;
  47447. /**
  47448. * Defines the callback to call when right trigger is pressed
  47449. * @param callback defines the callback to use
  47450. */
  47451. onrighttriggerchanged(callback: (value: number) => void): void;
  47452. /**
  47453. * Gets the left trigger value
  47454. */
  47455. get leftTrigger(): number;
  47456. /**
  47457. * Sets the left trigger value
  47458. */
  47459. set leftTrigger(newValue: number);
  47460. /**
  47461. * Gets the right trigger value
  47462. */
  47463. get rightTrigger(): number;
  47464. /**
  47465. * Sets the right trigger value
  47466. */
  47467. set rightTrigger(newValue: number);
  47468. /**
  47469. * Defines the callback to call when a button is pressed
  47470. * @param callback defines the callback to use
  47471. */
  47472. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47473. /**
  47474. * Defines the callback to call when a button is released
  47475. * @param callback defines the callback to use
  47476. */
  47477. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47478. /**
  47479. * Defines the callback to call when a pad is pressed
  47480. * @param callback defines the callback to use
  47481. */
  47482. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47483. /**
  47484. * Defines the callback to call when a pad is released
  47485. * @param callback defines the callback to use
  47486. */
  47487. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47488. private _setButtonValue;
  47489. private _setDPadValue;
  47490. /**
  47491. * Gets the value of the `Cross` button
  47492. */
  47493. get buttonCross(): number;
  47494. /**
  47495. * Sets the value of the `Cross` button
  47496. */
  47497. set buttonCross(value: number);
  47498. /**
  47499. * Gets the value of the `Circle` button
  47500. */
  47501. get buttonCircle(): number;
  47502. /**
  47503. * Sets the value of the `Circle` button
  47504. */
  47505. set buttonCircle(value: number);
  47506. /**
  47507. * Gets the value of the `Square` button
  47508. */
  47509. get buttonSquare(): number;
  47510. /**
  47511. * Sets the value of the `Square` button
  47512. */
  47513. set buttonSquare(value: number);
  47514. /**
  47515. * Gets the value of the `Triangle` button
  47516. */
  47517. get buttonTriangle(): number;
  47518. /**
  47519. * Sets the value of the `Triangle` button
  47520. */
  47521. set buttonTriangle(value: number);
  47522. /**
  47523. * Gets the value of the `Options` button
  47524. */
  47525. get buttonOptions(): number;
  47526. /**
  47527. * Sets the value of the `Options` button
  47528. */
  47529. set buttonOptions(value: number);
  47530. /**
  47531. * Gets the value of the `Share` button
  47532. */
  47533. get buttonShare(): number;
  47534. /**
  47535. * Sets the value of the `Share` button
  47536. */
  47537. set buttonShare(value: number);
  47538. /**
  47539. * Gets the value of the `L1` button
  47540. */
  47541. get buttonL1(): number;
  47542. /**
  47543. * Sets the value of the `L1` button
  47544. */
  47545. set buttonL1(value: number);
  47546. /**
  47547. * Gets the value of the `R1` button
  47548. */
  47549. get buttonR1(): number;
  47550. /**
  47551. * Sets the value of the `R1` button
  47552. */
  47553. set buttonR1(value: number);
  47554. /**
  47555. * Gets the value of the Left joystick
  47556. */
  47557. get buttonLeftStick(): number;
  47558. /**
  47559. * Sets the value of the Left joystick
  47560. */
  47561. set buttonLeftStick(value: number);
  47562. /**
  47563. * Gets the value of the Right joystick
  47564. */
  47565. get buttonRightStick(): number;
  47566. /**
  47567. * Sets the value of the Right joystick
  47568. */
  47569. set buttonRightStick(value: number);
  47570. /**
  47571. * Gets the value of D-pad up
  47572. */
  47573. get dPadUp(): number;
  47574. /**
  47575. * Sets the value of D-pad up
  47576. */
  47577. set dPadUp(value: number);
  47578. /**
  47579. * Gets the value of D-pad down
  47580. */
  47581. get dPadDown(): number;
  47582. /**
  47583. * Sets the value of D-pad down
  47584. */
  47585. set dPadDown(value: number);
  47586. /**
  47587. * Gets the value of D-pad left
  47588. */
  47589. get dPadLeft(): number;
  47590. /**
  47591. * Sets the value of D-pad left
  47592. */
  47593. set dPadLeft(value: number);
  47594. /**
  47595. * Gets the value of D-pad right
  47596. */
  47597. get dPadRight(): number;
  47598. /**
  47599. * Sets the value of D-pad right
  47600. */
  47601. set dPadRight(value: number);
  47602. /**
  47603. * Force the gamepad to synchronize with device values
  47604. */
  47605. update(): void;
  47606. /**
  47607. * Disposes the gamepad
  47608. */
  47609. dispose(): void;
  47610. }
  47611. }
  47612. declare module "babylonjs/Gamepads/gamepadManager" {
  47613. import { Observable } from "babylonjs/Misc/observable";
  47614. import { Nullable } from "babylonjs/types";
  47615. import { Scene } from "babylonjs/scene";
  47616. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47617. /**
  47618. * Manager for handling gamepads
  47619. */
  47620. export class GamepadManager {
  47621. private _scene?;
  47622. private _babylonGamepads;
  47623. private _oneGamepadConnected;
  47624. /** @hidden */
  47625. _isMonitoring: boolean;
  47626. private _gamepadEventSupported;
  47627. private _gamepadSupport?;
  47628. /**
  47629. * observable to be triggered when the gamepad controller has been connected
  47630. */
  47631. onGamepadConnectedObservable: Observable<Gamepad>;
  47632. /**
  47633. * observable to be triggered when the gamepad controller has been disconnected
  47634. */
  47635. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47636. private _onGamepadConnectedEvent;
  47637. private _onGamepadDisconnectedEvent;
  47638. /**
  47639. * Initializes the gamepad manager
  47640. * @param _scene BabylonJS scene
  47641. */
  47642. constructor(_scene?: Scene | undefined);
  47643. /**
  47644. * The gamepads in the game pad manager
  47645. */
  47646. get gamepads(): Gamepad[];
  47647. /**
  47648. * Get the gamepad controllers based on type
  47649. * @param type The type of gamepad controller
  47650. * @returns Nullable gamepad
  47651. */
  47652. getGamepadByType(type?: number): Nullable<Gamepad>;
  47653. /**
  47654. * Disposes the gamepad manager
  47655. */
  47656. dispose(): void;
  47657. private _addNewGamepad;
  47658. private _startMonitoringGamepads;
  47659. private _stopMonitoringGamepads;
  47660. /** @hidden */
  47661. _checkGamepadsStatus(): void;
  47662. private _updateGamepadObjects;
  47663. }
  47664. }
  47665. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47666. import { Nullable } from "babylonjs/types";
  47667. import { Scene } from "babylonjs/scene";
  47668. import { ISceneComponent } from "babylonjs/sceneComponent";
  47669. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47670. module "babylonjs/scene" {
  47671. interface Scene {
  47672. /** @hidden */
  47673. _gamepadManager: Nullable<GamepadManager>;
  47674. /**
  47675. * Gets the gamepad manager associated with the scene
  47676. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47677. */
  47678. gamepadManager: GamepadManager;
  47679. }
  47680. }
  47681. module "babylonjs/Cameras/freeCameraInputsManager" {
  47682. /**
  47683. * Interface representing a free camera inputs manager
  47684. */
  47685. interface FreeCameraInputsManager {
  47686. /**
  47687. * Adds gamepad input support to the FreeCameraInputsManager.
  47688. * @returns the FreeCameraInputsManager
  47689. */
  47690. addGamepad(): FreeCameraInputsManager;
  47691. }
  47692. }
  47693. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47694. /**
  47695. * Interface representing an arc rotate camera inputs manager
  47696. */
  47697. interface ArcRotateCameraInputsManager {
  47698. /**
  47699. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47700. * @returns the camera inputs manager
  47701. */
  47702. addGamepad(): ArcRotateCameraInputsManager;
  47703. }
  47704. }
  47705. /**
  47706. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47707. */
  47708. export class GamepadSystemSceneComponent implements ISceneComponent {
  47709. /**
  47710. * The component name helpfull to identify the component in the list of scene components.
  47711. */
  47712. readonly name: string;
  47713. /**
  47714. * The scene the component belongs to.
  47715. */
  47716. scene: Scene;
  47717. /**
  47718. * Creates a new instance of the component for the given scene
  47719. * @param scene Defines the scene to register the component in
  47720. */
  47721. constructor(scene: Scene);
  47722. /**
  47723. * Registers the component in a given scene
  47724. */
  47725. register(): void;
  47726. /**
  47727. * Rebuilds the elements related to this component in case of
  47728. * context lost for instance.
  47729. */
  47730. rebuild(): void;
  47731. /**
  47732. * Disposes the component and the associated ressources
  47733. */
  47734. dispose(): void;
  47735. private _beforeCameraUpdate;
  47736. }
  47737. }
  47738. declare module "babylonjs/Cameras/universalCamera" {
  47739. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47740. import { Scene } from "babylonjs/scene";
  47741. import { Vector3 } from "babylonjs/Maths/math.vector";
  47742. import "babylonjs/Gamepads/gamepadSceneComponent";
  47743. /**
  47744. * 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,
  47745. * which still works and will still be found in many Playgrounds.
  47746. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47747. */
  47748. export class UniversalCamera extends TouchCamera {
  47749. /**
  47750. * Defines the gamepad rotation sensiblity.
  47751. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47752. */
  47753. get gamepadAngularSensibility(): number;
  47754. set gamepadAngularSensibility(value: number);
  47755. /**
  47756. * Defines the gamepad move sensiblity.
  47757. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47758. */
  47759. get gamepadMoveSensibility(): number;
  47760. set gamepadMoveSensibility(value: number);
  47761. /**
  47762. * 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,
  47763. * which still works and will still be found in many Playgrounds.
  47764. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47765. * @param name Define the name of the camera in the scene
  47766. * @param position Define the start position of the camera in the scene
  47767. * @param scene Define the scene the camera belongs to
  47768. */
  47769. constructor(name: string, position: Vector3, scene: Scene);
  47770. /**
  47771. * Gets the current object class name.
  47772. * @return the class name
  47773. */
  47774. getClassName(): string;
  47775. }
  47776. }
  47777. declare module "babylonjs/Cameras/gamepadCamera" {
  47778. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47779. import { Scene } from "babylonjs/scene";
  47780. import { Vector3 } from "babylonjs/Maths/math.vector";
  47781. /**
  47782. * This represents a FPS type of camera. This is only here for back compat purpose.
  47783. * Please use the UniversalCamera instead as both are identical.
  47784. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47785. */
  47786. export class GamepadCamera extends UniversalCamera {
  47787. /**
  47788. * Instantiates a new Gamepad Camera
  47789. * This represents a FPS type of camera. This is only here for back compat purpose.
  47790. * Please use the UniversalCamera instead as both are identical.
  47791. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47792. * @param name Define the name of the camera in the scene
  47793. * @param position Define the start position of the camera in the scene
  47794. * @param scene Define the scene the camera belongs to
  47795. */
  47796. constructor(name: string, position: Vector3, scene: Scene);
  47797. /**
  47798. * Gets the current object class name.
  47799. * @return the class name
  47800. */
  47801. getClassName(): string;
  47802. }
  47803. }
  47804. declare module "babylonjs/Shaders/pass.fragment" {
  47805. /** @hidden */
  47806. export var passPixelShader: {
  47807. name: string;
  47808. shader: string;
  47809. };
  47810. }
  47811. declare module "babylonjs/Shaders/passCube.fragment" {
  47812. /** @hidden */
  47813. export var passCubePixelShader: {
  47814. name: string;
  47815. shader: string;
  47816. };
  47817. }
  47818. declare module "babylonjs/PostProcesses/passPostProcess" {
  47819. import { Nullable } from "babylonjs/types";
  47820. import { Camera } from "babylonjs/Cameras/camera";
  47821. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47822. import { Engine } from "babylonjs/Engines/engine";
  47823. import "babylonjs/Shaders/pass.fragment";
  47824. import "babylonjs/Shaders/passCube.fragment";
  47825. import { Scene } from "babylonjs/scene";
  47826. /**
  47827. * PassPostProcess which produces an output the same as it's input
  47828. */
  47829. export class PassPostProcess extends PostProcess {
  47830. /**
  47831. * Gets a string identifying the name of the class
  47832. * @returns "PassPostProcess" string
  47833. */
  47834. getClassName(): string;
  47835. /**
  47836. * Creates the PassPostProcess
  47837. * @param name The name of the effect.
  47838. * @param options The required width/height ratio to downsize to before computing the render pass.
  47839. * @param camera The camera to apply the render pass to.
  47840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47841. * @param engine The engine which the post process will be applied. (default: current engine)
  47842. * @param reusable If the post process can be reused on the same frame. (default: false)
  47843. * @param textureType The type of texture to be used when performing the post processing.
  47844. * @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)
  47845. */
  47846. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47847. /** @hidden */
  47848. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47849. }
  47850. /**
  47851. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47852. */
  47853. export class PassCubePostProcess extends PostProcess {
  47854. private _face;
  47855. /**
  47856. * Gets or sets the cube face to display.
  47857. * * 0 is +X
  47858. * * 1 is -X
  47859. * * 2 is +Y
  47860. * * 3 is -Y
  47861. * * 4 is +Z
  47862. * * 5 is -Z
  47863. */
  47864. get face(): number;
  47865. set face(value: number);
  47866. /**
  47867. * Gets a string identifying the name of the class
  47868. * @returns "PassCubePostProcess" string
  47869. */
  47870. getClassName(): string;
  47871. /**
  47872. * Creates the PassCubePostProcess
  47873. * @param name The name of the effect.
  47874. * @param options The required width/height ratio to downsize to before computing the render pass.
  47875. * @param camera The camera to apply the render pass to.
  47876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47877. * @param engine The engine which the post process will be applied. (default: current engine)
  47878. * @param reusable If the post process can be reused on the same frame. (default: false)
  47879. * @param textureType The type of texture to be used when performing the post processing.
  47880. * @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)
  47881. */
  47882. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47883. /** @hidden */
  47884. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47885. }
  47886. }
  47887. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47888. /** @hidden */
  47889. export var anaglyphPixelShader: {
  47890. name: string;
  47891. shader: string;
  47892. };
  47893. }
  47894. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47895. import { Engine } from "babylonjs/Engines/engine";
  47896. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47897. import { Camera } from "babylonjs/Cameras/camera";
  47898. import "babylonjs/Shaders/anaglyph.fragment";
  47899. /**
  47900. * Postprocess used to generate anaglyphic rendering
  47901. */
  47902. export class AnaglyphPostProcess extends PostProcess {
  47903. private _passedProcess;
  47904. /**
  47905. * Gets a string identifying the name of the class
  47906. * @returns "AnaglyphPostProcess" string
  47907. */
  47908. getClassName(): string;
  47909. /**
  47910. * Creates a new AnaglyphPostProcess
  47911. * @param name defines postprocess name
  47912. * @param options defines creation options or target ratio scale
  47913. * @param rigCameras defines cameras using this postprocess
  47914. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47915. * @param engine defines hosting engine
  47916. * @param reusable defines if the postprocess will be reused multiple times per frame
  47917. */
  47918. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47919. }
  47920. }
  47921. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47922. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47923. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47924. import { Scene } from "babylonjs/scene";
  47925. import { Vector3 } from "babylonjs/Maths/math.vector";
  47926. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47927. /**
  47928. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47929. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47930. */
  47931. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47932. /**
  47933. * Creates a new AnaglyphArcRotateCamera
  47934. * @param name defines camera name
  47935. * @param alpha defines alpha angle (in radians)
  47936. * @param beta defines beta angle (in radians)
  47937. * @param radius defines radius
  47938. * @param target defines camera target
  47939. * @param interaxialDistance defines distance between each color axis
  47940. * @param scene defines the hosting scene
  47941. */
  47942. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47943. /**
  47944. * Gets camera class name
  47945. * @returns AnaglyphArcRotateCamera
  47946. */
  47947. getClassName(): string;
  47948. }
  47949. }
  47950. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47951. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47952. import { Scene } from "babylonjs/scene";
  47953. import { Vector3 } from "babylonjs/Maths/math.vector";
  47954. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47955. /**
  47956. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47957. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47958. */
  47959. export class AnaglyphFreeCamera extends FreeCamera {
  47960. /**
  47961. * Creates a new AnaglyphFreeCamera
  47962. * @param name defines camera name
  47963. * @param position defines initial position
  47964. * @param interaxialDistance defines distance between each color axis
  47965. * @param scene defines the hosting scene
  47966. */
  47967. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47968. /**
  47969. * Gets camera class name
  47970. * @returns AnaglyphFreeCamera
  47971. */
  47972. getClassName(): string;
  47973. }
  47974. }
  47975. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47976. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47977. import { Scene } from "babylonjs/scene";
  47978. import { Vector3 } from "babylonjs/Maths/math.vector";
  47979. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47980. /**
  47981. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47982. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47983. */
  47984. export class AnaglyphGamepadCamera extends GamepadCamera {
  47985. /**
  47986. * Creates a new AnaglyphGamepadCamera
  47987. * @param name defines camera name
  47988. * @param position defines initial position
  47989. * @param interaxialDistance defines distance between each color axis
  47990. * @param scene defines the hosting scene
  47991. */
  47992. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47993. /**
  47994. * Gets camera class name
  47995. * @returns AnaglyphGamepadCamera
  47996. */
  47997. getClassName(): string;
  47998. }
  47999. }
  48000. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  48001. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48002. import { Scene } from "babylonjs/scene";
  48003. import { Vector3 } from "babylonjs/Maths/math.vector";
  48004. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48005. /**
  48006. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  48007. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48008. */
  48009. export class AnaglyphUniversalCamera extends UniversalCamera {
  48010. /**
  48011. * Creates a new AnaglyphUniversalCamera
  48012. * @param name defines camera name
  48013. * @param position defines initial position
  48014. * @param interaxialDistance defines distance between each color axis
  48015. * @param scene defines the hosting scene
  48016. */
  48017. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48018. /**
  48019. * Gets camera class name
  48020. * @returns AnaglyphUniversalCamera
  48021. */
  48022. getClassName(): string;
  48023. }
  48024. }
  48025. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  48026. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  48027. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48028. import { Scene } from "babylonjs/scene";
  48029. import { Vector3 } from "babylonjs/Maths/math.vector";
  48030. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48031. /**
  48032. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  48033. * @see https://doc.babylonjs.com/features/cameras
  48034. */
  48035. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  48036. /**
  48037. * Creates a new StereoscopicArcRotateCamera
  48038. * @param name defines camera name
  48039. * @param alpha defines alpha angle (in radians)
  48040. * @param beta defines beta angle (in radians)
  48041. * @param radius defines radius
  48042. * @param target defines camera target
  48043. * @param interaxialDistance defines distance between each color axis
  48044. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48045. * @param scene defines the hosting scene
  48046. */
  48047. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48048. /**
  48049. * Gets camera class name
  48050. * @returns StereoscopicArcRotateCamera
  48051. */
  48052. getClassName(): string;
  48053. }
  48054. }
  48055. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  48056. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48057. import { Scene } from "babylonjs/scene";
  48058. import { Vector3 } from "babylonjs/Maths/math.vector";
  48059. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48060. /**
  48061. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  48062. * @see https://doc.babylonjs.com/features/cameras
  48063. */
  48064. export class StereoscopicFreeCamera extends FreeCamera {
  48065. /**
  48066. * Creates a new StereoscopicFreeCamera
  48067. * @param name defines camera name
  48068. * @param position defines initial position
  48069. * @param interaxialDistance defines distance between each color axis
  48070. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48071. * @param scene defines the hosting scene
  48072. */
  48073. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48074. /**
  48075. * Gets camera class name
  48076. * @returns StereoscopicFreeCamera
  48077. */
  48078. getClassName(): string;
  48079. }
  48080. }
  48081. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  48082. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48083. import { Scene } from "babylonjs/scene";
  48084. import { Vector3 } from "babylonjs/Maths/math.vector";
  48085. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48086. /**
  48087. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  48088. * @see https://doc.babylonjs.com/features/cameras
  48089. */
  48090. export class StereoscopicGamepadCamera extends GamepadCamera {
  48091. /**
  48092. * Creates a new StereoscopicGamepadCamera
  48093. * @param name defines camera name
  48094. * @param position defines initial position
  48095. * @param interaxialDistance defines distance between each color axis
  48096. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48097. * @param scene defines the hosting scene
  48098. */
  48099. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48100. /**
  48101. * Gets camera class name
  48102. * @returns StereoscopicGamepadCamera
  48103. */
  48104. getClassName(): string;
  48105. }
  48106. }
  48107. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48108. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48109. import { Scene } from "babylonjs/scene";
  48110. import { Vector3 } from "babylonjs/Maths/math.vector";
  48111. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48112. /**
  48113. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48114. * @see https://doc.babylonjs.com/features/cameras
  48115. */
  48116. export class StereoscopicUniversalCamera extends UniversalCamera {
  48117. /**
  48118. * Creates a new StereoscopicUniversalCamera
  48119. * @param name defines camera name
  48120. * @param position defines initial position
  48121. * @param interaxialDistance defines distance between each color axis
  48122. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48123. * @param scene defines the hosting scene
  48124. */
  48125. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48126. /**
  48127. * Gets camera class name
  48128. * @returns StereoscopicUniversalCamera
  48129. */
  48130. getClassName(): string;
  48131. }
  48132. }
  48133. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48134. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48135. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48136. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48137. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48138. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48139. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48140. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48141. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48142. }
  48143. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48144. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48145. import { Scene } from "babylonjs/scene";
  48146. import { Vector3 } from "babylonjs/Maths/math.vector";
  48147. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48148. /**
  48149. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48150. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48151. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48152. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48153. */
  48154. export class VirtualJoysticksCamera extends FreeCamera {
  48155. /**
  48156. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48157. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48158. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48159. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48160. * @param name Define the name of the camera in the scene
  48161. * @param position Define the start position of the camera in the scene
  48162. * @param scene Define the scene the camera belongs to
  48163. */
  48164. constructor(name: string, position: Vector3, scene: Scene);
  48165. /**
  48166. * Gets the current object class name.
  48167. * @return the class name
  48168. */
  48169. getClassName(): string;
  48170. }
  48171. }
  48172. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48173. import { Matrix } from "babylonjs/Maths/math.vector";
  48174. /**
  48175. * This represents all the required metrics to create a VR camera.
  48176. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48177. */
  48178. export class VRCameraMetrics {
  48179. /**
  48180. * Define the horizontal resolution off the screen.
  48181. */
  48182. hResolution: number;
  48183. /**
  48184. * Define the vertical resolution off the screen.
  48185. */
  48186. vResolution: number;
  48187. /**
  48188. * Define the horizontal screen size.
  48189. */
  48190. hScreenSize: number;
  48191. /**
  48192. * Define the vertical screen size.
  48193. */
  48194. vScreenSize: number;
  48195. /**
  48196. * Define the vertical screen center position.
  48197. */
  48198. vScreenCenter: number;
  48199. /**
  48200. * Define the distance of the eyes to the screen.
  48201. */
  48202. eyeToScreenDistance: number;
  48203. /**
  48204. * Define the distance between both lenses
  48205. */
  48206. lensSeparationDistance: number;
  48207. /**
  48208. * Define the distance between both viewer's eyes.
  48209. */
  48210. interpupillaryDistance: number;
  48211. /**
  48212. * Define the distortion factor of the VR postprocess.
  48213. * Please, touch with care.
  48214. */
  48215. distortionK: number[];
  48216. /**
  48217. * Define the chromatic aberration correction factors for the VR post process.
  48218. */
  48219. chromaAbCorrection: number[];
  48220. /**
  48221. * Define the scale factor of the post process.
  48222. * The smaller the better but the slower.
  48223. */
  48224. postProcessScaleFactor: number;
  48225. /**
  48226. * Define an offset for the lens center.
  48227. */
  48228. lensCenterOffset: number;
  48229. /**
  48230. * Define if the current vr camera should compensate the distortion of the lense or not.
  48231. */
  48232. compensateDistortion: boolean;
  48233. /**
  48234. * Defines if multiview should be enabled when rendering (Default: false)
  48235. */
  48236. multiviewEnabled: boolean;
  48237. /**
  48238. * Gets the rendering aspect ratio based on the provided resolutions.
  48239. */
  48240. get aspectRatio(): number;
  48241. /**
  48242. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48243. */
  48244. get aspectRatioFov(): number;
  48245. /**
  48246. * @hidden
  48247. */
  48248. get leftHMatrix(): Matrix;
  48249. /**
  48250. * @hidden
  48251. */
  48252. get rightHMatrix(): Matrix;
  48253. /**
  48254. * @hidden
  48255. */
  48256. get leftPreViewMatrix(): Matrix;
  48257. /**
  48258. * @hidden
  48259. */
  48260. get rightPreViewMatrix(): Matrix;
  48261. /**
  48262. * Get the default VRMetrics based on the most generic setup.
  48263. * @returns the default vr metrics
  48264. */
  48265. static GetDefault(): VRCameraMetrics;
  48266. }
  48267. }
  48268. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48269. /** @hidden */
  48270. export var vrDistortionCorrectionPixelShader: {
  48271. name: string;
  48272. shader: string;
  48273. };
  48274. }
  48275. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48276. import { Camera } from "babylonjs/Cameras/camera";
  48277. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48278. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48279. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48280. /**
  48281. * VRDistortionCorrectionPostProcess used for mobile VR
  48282. */
  48283. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48284. private _isRightEye;
  48285. private _distortionFactors;
  48286. private _postProcessScaleFactor;
  48287. private _lensCenterOffset;
  48288. private _scaleIn;
  48289. private _scaleFactor;
  48290. private _lensCenter;
  48291. /**
  48292. * Gets a string identifying the name of the class
  48293. * @returns "VRDistortionCorrectionPostProcess" string
  48294. */
  48295. getClassName(): string;
  48296. /**
  48297. * Initializes the VRDistortionCorrectionPostProcess
  48298. * @param name The name of the effect.
  48299. * @param camera The camera to apply the render pass to.
  48300. * @param isRightEye If this is for the right eye distortion
  48301. * @param vrMetrics All the required metrics for the VR camera
  48302. */
  48303. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48304. }
  48305. }
  48306. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48307. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48308. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48309. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48310. import { Scene } from "babylonjs/scene";
  48311. import { Vector3 } from "babylonjs/Maths/math.vector";
  48312. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48313. import "babylonjs/Cameras/RigModes/vrRigMode";
  48314. /**
  48315. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48316. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48317. */
  48318. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48319. /**
  48320. * Creates a new VRDeviceOrientationArcRotateCamera
  48321. * @param name defines camera name
  48322. * @param alpha defines the camera rotation along the logitudinal axis
  48323. * @param beta defines the camera rotation along the latitudinal axis
  48324. * @param radius defines the camera distance from its target
  48325. * @param target defines the camera target
  48326. * @param scene defines the scene the camera belongs to
  48327. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48328. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48329. */
  48330. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48331. /**
  48332. * Gets camera class name
  48333. * @returns VRDeviceOrientationArcRotateCamera
  48334. */
  48335. getClassName(): string;
  48336. }
  48337. }
  48338. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48339. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48340. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48341. import { Scene } from "babylonjs/scene";
  48342. import { Vector3 } from "babylonjs/Maths/math.vector";
  48343. import "babylonjs/Cameras/RigModes/vrRigMode";
  48344. /**
  48345. * Camera used to simulate VR rendering (based on FreeCamera)
  48346. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48347. */
  48348. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48349. /**
  48350. * Creates a new VRDeviceOrientationFreeCamera
  48351. * @param name defines camera name
  48352. * @param position defines the start position of the camera
  48353. * @param scene defines the scene the camera belongs to
  48354. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48355. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48356. */
  48357. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48358. /**
  48359. * Gets camera class name
  48360. * @returns VRDeviceOrientationFreeCamera
  48361. */
  48362. getClassName(): string;
  48363. }
  48364. }
  48365. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48366. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48367. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48368. import { Scene } from "babylonjs/scene";
  48369. import { Vector3 } from "babylonjs/Maths/math.vector";
  48370. import "babylonjs/Gamepads/gamepadSceneComponent";
  48371. /**
  48372. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48373. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48374. */
  48375. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48376. /**
  48377. * Creates a new VRDeviceOrientationGamepadCamera
  48378. * @param name defines camera name
  48379. * @param position defines the start position of the camera
  48380. * @param scene defines the scene the camera belongs to
  48381. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48382. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48383. */
  48384. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48385. /**
  48386. * Gets camera class name
  48387. * @returns VRDeviceOrientationGamepadCamera
  48388. */
  48389. getClassName(): string;
  48390. }
  48391. }
  48392. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48393. import { Scene } from "babylonjs/scene";
  48394. import { Texture } from "babylonjs/Materials/Textures/texture";
  48395. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48396. /**
  48397. * A class extending Texture allowing drawing on a texture
  48398. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48399. */
  48400. export class DynamicTexture extends Texture {
  48401. private _generateMipMaps;
  48402. private _canvas;
  48403. private _context;
  48404. /**
  48405. * Creates a DynamicTexture
  48406. * @param name defines the name of the texture
  48407. * @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
  48408. * @param scene defines the scene where you want the texture
  48409. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48410. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48411. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48412. */
  48413. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48414. /**
  48415. * Get the current class name of the texture useful for serialization or dynamic coding.
  48416. * @returns "DynamicTexture"
  48417. */
  48418. getClassName(): string;
  48419. /**
  48420. * Gets the current state of canRescale
  48421. */
  48422. get canRescale(): boolean;
  48423. private _recreate;
  48424. /**
  48425. * Scales the texture
  48426. * @param ratio the scale factor to apply to both width and height
  48427. */
  48428. scale(ratio: number): void;
  48429. /**
  48430. * Resizes the texture
  48431. * @param width the new width
  48432. * @param height the new height
  48433. */
  48434. scaleTo(width: number, height: number): void;
  48435. /**
  48436. * Gets the context of the canvas used by the texture
  48437. * @returns the canvas context of the dynamic texture
  48438. */
  48439. getContext(): CanvasRenderingContext2D;
  48440. /**
  48441. * Clears the texture
  48442. */
  48443. clear(): void;
  48444. /**
  48445. * Updates the texture
  48446. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48447. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48448. */
  48449. update(invertY?: boolean, premulAlpha?: boolean): void;
  48450. /**
  48451. * Draws text onto the texture
  48452. * @param text defines the text to be drawn
  48453. * @param x defines the placement of the text from the left
  48454. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48455. * @param font defines the font to be used with font-style, font-size, font-name
  48456. * @param color defines the color used for the text
  48457. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48458. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48459. * @param update defines whether texture is immediately update (default is true)
  48460. */
  48461. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48462. /**
  48463. * Clones the texture
  48464. * @returns the clone of the texture.
  48465. */
  48466. clone(): DynamicTexture;
  48467. /**
  48468. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48469. * @returns a serialized dynamic texture object
  48470. */
  48471. serialize(): any;
  48472. private _IsCanvasElement;
  48473. /** @hidden */
  48474. _rebuild(): void;
  48475. }
  48476. }
  48477. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48478. import { Scene } from "babylonjs/scene";
  48479. import { Color3 } from "babylonjs/Maths/math.color";
  48480. import { Mesh } from "babylonjs/Meshes/mesh";
  48481. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48482. import { Nullable } from "babylonjs/types";
  48483. /**
  48484. * Class containing static functions to help procedurally build meshes
  48485. */
  48486. export class GroundBuilder {
  48487. /**
  48488. * Creates a ground mesh
  48489. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48490. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48492. * @param name defines the name of the mesh
  48493. * @param options defines the options used to create the mesh
  48494. * @param scene defines the hosting scene
  48495. * @returns the ground mesh
  48496. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48497. */
  48498. static CreateGround(name: string, options: {
  48499. width?: number;
  48500. height?: number;
  48501. subdivisions?: number;
  48502. subdivisionsX?: number;
  48503. subdivisionsY?: number;
  48504. updatable?: boolean;
  48505. }, scene: any): Mesh;
  48506. /**
  48507. * Creates a tiled ground mesh
  48508. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48509. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48510. * * 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
  48511. * * 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
  48512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48513. * @param name defines the name of the mesh
  48514. * @param options defines the options used to create the mesh
  48515. * @param scene defines the hosting scene
  48516. * @returns the tiled ground mesh
  48517. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48518. */
  48519. static CreateTiledGround(name: string, options: {
  48520. xmin: number;
  48521. zmin: number;
  48522. xmax: number;
  48523. zmax: number;
  48524. subdivisions?: {
  48525. w: number;
  48526. h: number;
  48527. };
  48528. precision?: {
  48529. w: number;
  48530. h: number;
  48531. };
  48532. updatable?: boolean;
  48533. }, scene?: Nullable<Scene>): Mesh;
  48534. /**
  48535. * Creates a ground mesh from a height map
  48536. * * The parameter `url` sets the URL of the height map image resource.
  48537. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48538. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48539. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48540. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48541. * * 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.
  48542. * * 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).
  48543. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48545. * @param name defines the name of the mesh
  48546. * @param url defines the url to the height map
  48547. * @param options defines the options used to create the mesh
  48548. * @param scene defines the hosting scene
  48549. * @returns the ground mesh
  48550. * @see https://doc.babylonjs.com/babylon101/height_map
  48551. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48552. */
  48553. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48554. width?: number;
  48555. height?: number;
  48556. subdivisions?: number;
  48557. minHeight?: number;
  48558. maxHeight?: number;
  48559. colorFilter?: Color3;
  48560. alphaFilter?: number;
  48561. updatable?: boolean;
  48562. onReady?: (mesh: GroundMesh) => void;
  48563. }, scene?: Nullable<Scene>): GroundMesh;
  48564. }
  48565. }
  48566. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48567. import { Vector4 } from "babylonjs/Maths/math.vector";
  48568. import { Mesh } from "babylonjs/Meshes/mesh";
  48569. /**
  48570. * Class containing static functions to help procedurally build meshes
  48571. */
  48572. export class TorusBuilder {
  48573. /**
  48574. * Creates a torus mesh
  48575. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48576. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48577. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48581. * @param name defines the name of the mesh
  48582. * @param options defines the options used to create the mesh
  48583. * @param scene defines the hosting scene
  48584. * @returns the torus mesh
  48585. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48586. */
  48587. static CreateTorus(name: string, options: {
  48588. diameter?: number;
  48589. thickness?: number;
  48590. tessellation?: number;
  48591. updatable?: boolean;
  48592. sideOrientation?: number;
  48593. frontUVs?: Vector4;
  48594. backUVs?: Vector4;
  48595. }, scene: any): Mesh;
  48596. }
  48597. }
  48598. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48599. import { Vector4 } from "babylonjs/Maths/math.vector";
  48600. import { Color4 } from "babylonjs/Maths/math.color";
  48601. import { Mesh } from "babylonjs/Meshes/mesh";
  48602. /**
  48603. * Class containing static functions to help procedurally build meshes
  48604. */
  48605. export class CylinderBuilder {
  48606. /**
  48607. * Creates a cylinder or a cone mesh
  48608. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48609. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48610. * * 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.
  48611. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48612. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48613. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48614. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48615. * * 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).
  48616. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48617. * * 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).
  48618. * * 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
  48619. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48620. * * 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
  48621. * * 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.
  48622. * * If `enclose` is false, a ring surface is one element.
  48623. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48624. * * 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
  48625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48626. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48628. * @param name defines the name of the mesh
  48629. * @param options defines the options used to create the mesh
  48630. * @param scene defines the hosting scene
  48631. * @returns the cylinder mesh
  48632. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48633. */
  48634. static CreateCylinder(name: string, options: {
  48635. height?: number;
  48636. diameterTop?: number;
  48637. diameterBottom?: number;
  48638. diameter?: number;
  48639. tessellation?: number;
  48640. subdivisions?: number;
  48641. arc?: number;
  48642. faceColors?: Color4[];
  48643. faceUV?: Vector4[];
  48644. updatable?: boolean;
  48645. hasRings?: boolean;
  48646. enclose?: boolean;
  48647. cap?: number;
  48648. sideOrientation?: number;
  48649. frontUVs?: Vector4;
  48650. backUVs?: Vector4;
  48651. }, scene: any): Mesh;
  48652. }
  48653. }
  48654. declare module "babylonjs/XR/webXRTypes" {
  48655. import { Nullable } from "babylonjs/types";
  48656. import { IDisposable } from "babylonjs/scene";
  48657. /**
  48658. * States of the webXR experience
  48659. */
  48660. export enum WebXRState {
  48661. /**
  48662. * Transitioning to being in XR mode
  48663. */
  48664. ENTERING_XR = 0,
  48665. /**
  48666. * Transitioning to non XR mode
  48667. */
  48668. EXITING_XR = 1,
  48669. /**
  48670. * In XR mode and presenting
  48671. */
  48672. IN_XR = 2,
  48673. /**
  48674. * Not entered XR mode
  48675. */
  48676. NOT_IN_XR = 3
  48677. }
  48678. /**
  48679. * Abstraction of the XR render target
  48680. */
  48681. export interface WebXRRenderTarget extends IDisposable {
  48682. /**
  48683. * xrpresent context of the canvas which can be used to display/mirror xr content
  48684. */
  48685. canvasContext: WebGLRenderingContext;
  48686. /**
  48687. * xr layer for the canvas
  48688. */
  48689. xrLayer: Nullable<XRWebGLLayer>;
  48690. /**
  48691. * Initializes the xr layer for the session
  48692. * @param xrSession xr session
  48693. * @returns a promise that will resolve once the XR Layer has been created
  48694. */
  48695. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48696. }
  48697. }
  48698. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48699. import { Nullable } from "babylonjs/types";
  48700. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48701. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48702. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48703. import { Observable } from "babylonjs/Misc/observable";
  48704. /**
  48705. * COnfiguration object for WebXR output canvas
  48706. */
  48707. export class WebXRManagedOutputCanvasOptions {
  48708. /**
  48709. * An optional canvas in case you wish to create it yourself and provide it here.
  48710. * If not provided, a new canvas will be created
  48711. */
  48712. canvasElement?: HTMLCanvasElement;
  48713. /**
  48714. * Options for this XR Layer output
  48715. */
  48716. canvasOptions?: XRWebGLLayerOptions;
  48717. /**
  48718. * CSS styling for a newly created canvas (if not provided)
  48719. */
  48720. newCanvasCssStyle?: string;
  48721. /**
  48722. * Get the default values of the configuration object
  48723. * @param engine defines the engine to use (can be null)
  48724. * @returns default values of this configuration object
  48725. */
  48726. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48727. }
  48728. /**
  48729. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48730. */
  48731. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48732. private _options;
  48733. private _canvas;
  48734. private _engine;
  48735. private _originalCanvasSize;
  48736. /**
  48737. * Rendering context of the canvas which can be used to display/mirror xr content
  48738. */
  48739. canvasContext: WebGLRenderingContext;
  48740. /**
  48741. * xr layer for the canvas
  48742. */
  48743. xrLayer: Nullable<XRWebGLLayer>;
  48744. /**
  48745. * Obseervers registered here will be triggered when the xr layer was initialized
  48746. */
  48747. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48748. /**
  48749. * Initializes the canvas to be added/removed upon entering/exiting xr
  48750. * @param _xrSessionManager The XR Session manager
  48751. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48752. */
  48753. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48754. /**
  48755. * Disposes of the object
  48756. */
  48757. dispose(): void;
  48758. /**
  48759. * Initializes the xr layer for the session
  48760. * @param xrSession xr session
  48761. * @returns a promise that will resolve once the XR Layer has been created
  48762. */
  48763. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48764. private _addCanvas;
  48765. private _removeCanvas;
  48766. private _setCanvasSize;
  48767. private _setManagedOutputCanvas;
  48768. }
  48769. }
  48770. declare module "babylonjs/XR/webXRSessionManager" {
  48771. import { Observable } from "babylonjs/Misc/observable";
  48772. import { Nullable } from "babylonjs/types";
  48773. import { IDisposable, Scene } from "babylonjs/scene";
  48774. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48775. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48776. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48777. /**
  48778. * Manages an XRSession to work with Babylon's engine
  48779. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48780. */
  48781. export class WebXRSessionManager implements IDisposable {
  48782. /** The scene which the session should be created for */
  48783. scene: Scene;
  48784. private _referenceSpace;
  48785. private _rttProvider;
  48786. private _sessionEnded;
  48787. private _xrNavigator;
  48788. private baseLayer;
  48789. /**
  48790. * The base reference space from which the session started. good if you want to reset your
  48791. * reference space
  48792. */
  48793. baseReferenceSpace: XRReferenceSpace;
  48794. /**
  48795. * Current XR frame
  48796. */
  48797. currentFrame: Nullable<XRFrame>;
  48798. /** WebXR timestamp updated every frame */
  48799. currentTimestamp: number;
  48800. /**
  48801. * Used just in case of a failure to initialize an immersive session.
  48802. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48803. */
  48804. defaultHeightCompensation: number;
  48805. /**
  48806. * Fires every time a new xrFrame arrives which can be used to update the camera
  48807. */
  48808. onXRFrameObservable: Observable<XRFrame>;
  48809. /**
  48810. * Fires when the reference space changed
  48811. */
  48812. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48813. /**
  48814. * Fires when the xr session is ended either by the device or manually done
  48815. */
  48816. onXRSessionEnded: Observable<any>;
  48817. /**
  48818. * Fires when the xr session is ended either by the device or manually done
  48819. */
  48820. onXRSessionInit: Observable<XRSession>;
  48821. /**
  48822. * Underlying xr session
  48823. */
  48824. session: XRSession;
  48825. /**
  48826. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48827. * or get the offset the player is currently at.
  48828. */
  48829. viewerReferenceSpace: XRReferenceSpace;
  48830. /**
  48831. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48832. * @param scene The scene which the session should be created for
  48833. */
  48834. constructor(
  48835. /** The scene which the session should be created for */
  48836. scene: Scene);
  48837. /**
  48838. * The current reference space used in this session. This reference space can constantly change!
  48839. * It is mainly used to offset the camera's position.
  48840. */
  48841. get referenceSpace(): XRReferenceSpace;
  48842. /**
  48843. * Set a new reference space and triggers the observable
  48844. */
  48845. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48846. /**
  48847. * Disposes of the session manager
  48848. */
  48849. dispose(): void;
  48850. /**
  48851. * Stops the xrSession and restores the render loop
  48852. * @returns Promise which resolves after it exits XR
  48853. */
  48854. exitXRAsync(): Promise<void>;
  48855. /**
  48856. * Gets the correct render target texture to be rendered this frame for this eye
  48857. * @param eye the eye for which to get the render target
  48858. * @returns the render target for the specified eye
  48859. */
  48860. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48861. /**
  48862. * Creates a WebXRRenderTarget object for the XR session
  48863. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48864. * @param options optional options to provide when creating a new render target
  48865. * @returns a WebXR render target to which the session can render
  48866. */
  48867. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48868. /**
  48869. * Initializes the manager
  48870. * After initialization enterXR can be called to start an XR session
  48871. * @returns Promise which resolves after it is initialized
  48872. */
  48873. initializeAsync(): Promise<void>;
  48874. /**
  48875. * Initializes an xr session
  48876. * @param xrSessionMode mode to initialize
  48877. * @param xrSessionInit defines optional and required values to pass to the session builder
  48878. * @returns a promise which will resolve once the session has been initialized
  48879. */
  48880. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48881. /**
  48882. * Checks if a session would be supported for the creation options specified
  48883. * @param sessionMode session mode to check if supported eg. immersive-vr
  48884. * @returns A Promise that resolves to true if supported and false if not
  48885. */
  48886. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48887. /**
  48888. * Resets the reference space to the one started the session
  48889. */
  48890. resetReferenceSpace(): void;
  48891. /**
  48892. * Starts rendering to the xr layer
  48893. */
  48894. runXRRenderLoop(): void;
  48895. /**
  48896. * Sets the reference space on the xr session
  48897. * @param referenceSpaceType space to set
  48898. * @returns a promise that will resolve once the reference space has been set
  48899. */
  48900. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48901. /**
  48902. * Updates the render state of the session
  48903. * @param state state to set
  48904. * @returns a promise that resolves once the render state has been updated
  48905. */
  48906. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48907. /**
  48908. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48909. * @param sessionMode defines the session to test
  48910. * @returns a promise with boolean as final value
  48911. */
  48912. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48913. private _createRenderTargetTexture;
  48914. }
  48915. }
  48916. declare module "babylonjs/XR/webXRCamera" {
  48917. import { Vector3 } from "babylonjs/Maths/math.vector";
  48918. import { Scene } from "babylonjs/scene";
  48919. import { Camera } from "babylonjs/Cameras/camera";
  48920. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48921. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48922. import { Observable } from "babylonjs/Misc/observable";
  48923. /**
  48924. * WebXR Camera which holds the views for the xrSession
  48925. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48926. */
  48927. export class WebXRCamera extends FreeCamera {
  48928. private _xrSessionManager;
  48929. private _firstFrame;
  48930. private _referenceQuaternion;
  48931. private _referencedPosition;
  48932. private _xrInvPositionCache;
  48933. private _xrInvQuaternionCache;
  48934. /**
  48935. * Observable raised before camera teleportation
  48936. */
  48937. onBeforeCameraTeleport: Observable<Vector3>;
  48938. /**
  48939. * Observable raised after camera teleportation
  48940. */
  48941. onAfterCameraTeleport: Observable<Vector3>;
  48942. /**
  48943. * Should position compensation execute on first frame.
  48944. * This is used when copying the position from a native (non XR) camera
  48945. */
  48946. compensateOnFirstFrame: boolean;
  48947. /**
  48948. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48949. * @param name the name of the camera
  48950. * @param scene the scene to add the camera to
  48951. * @param _xrSessionManager a constructed xr session manager
  48952. */
  48953. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48954. /**
  48955. * Return the user's height, unrelated to the current ground.
  48956. * This will be the y position of this camera, when ground level is 0.
  48957. */
  48958. get realWorldHeight(): number;
  48959. /** @hidden */
  48960. _updateForDualEyeDebugging(): void;
  48961. /**
  48962. * Sets this camera's transformation based on a non-vr camera
  48963. * @param otherCamera the non-vr camera to copy the transformation from
  48964. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48965. */
  48966. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48967. /**
  48968. * Gets the current instance class name ("WebXRCamera").
  48969. * @returns the class name
  48970. */
  48971. getClassName(): string;
  48972. private _rotate180;
  48973. private _updateFromXRSession;
  48974. private _updateNumberOfRigCameras;
  48975. private _updateReferenceSpace;
  48976. private _updateReferenceSpaceOffset;
  48977. }
  48978. }
  48979. declare module "babylonjs/XR/webXRFeaturesManager" {
  48980. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48981. import { IDisposable } from "babylonjs/scene";
  48982. /**
  48983. * Defining the interface required for a (webxr) feature
  48984. */
  48985. export interface IWebXRFeature extends IDisposable {
  48986. /**
  48987. * Is this feature attached
  48988. */
  48989. attached: boolean;
  48990. /**
  48991. * Should auto-attach be disabled?
  48992. */
  48993. disableAutoAttach: boolean;
  48994. /**
  48995. * Attach the feature to the session
  48996. * Will usually be called by the features manager
  48997. *
  48998. * @param force should attachment be forced (even when already attached)
  48999. * @returns true if successful.
  49000. */
  49001. attach(force?: boolean): boolean;
  49002. /**
  49003. * Detach the feature from the session
  49004. * Will usually be called by the features manager
  49005. *
  49006. * @returns true if successful.
  49007. */
  49008. detach(): boolean;
  49009. /**
  49010. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  49011. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  49012. *
  49013. * @returns whether or not the feature is compatible in this environment
  49014. */
  49015. isCompatible(): boolean;
  49016. /**
  49017. * Was this feature disposed;
  49018. */
  49019. isDisposed: boolean;
  49020. /**
  49021. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  49022. */
  49023. xrNativeFeatureName?: string;
  49024. /**
  49025. * A list of (Babylon WebXR) features this feature depends on
  49026. */
  49027. dependsOn?: string[];
  49028. }
  49029. /**
  49030. * A list of the currently available features without referencing them
  49031. */
  49032. export class WebXRFeatureName {
  49033. /**
  49034. * The name of the anchor system feature
  49035. */
  49036. static readonly ANCHOR_SYSTEM: string;
  49037. /**
  49038. * The name of the background remover feature
  49039. */
  49040. static readonly BACKGROUND_REMOVER: string;
  49041. /**
  49042. * The name of the hit test feature
  49043. */
  49044. static readonly HIT_TEST: string;
  49045. /**
  49046. * physics impostors for xr controllers feature
  49047. */
  49048. static readonly PHYSICS_CONTROLLERS: string;
  49049. /**
  49050. * The name of the plane detection feature
  49051. */
  49052. static readonly PLANE_DETECTION: string;
  49053. /**
  49054. * The name of the pointer selection feature
  49055. */
  49056. static readonly POINTER_SELECTION: string;
  49057. /**
  49058. * The name of the teleportation feature
  49059. */
  49060. static readonly TELEPORTATION: string;
  49061. /**
  49062. * The name of the feature points feature.
  49063. */
  49064. static readonly FEATURE_POINTS: string;
  49065. /**
  49066. * The name of the hand tracking feature.
  49067. */
  49068. static readonly HAND_TRACKING: string;
  49069. }
  49070. /**
  49071. * Defining the constructor of a feature. Used to register the modules.
  49072. */
  49073. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  49074. /**
  49075. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  49076. * It is mainly used in AR sessions.
  49077. *
  49078. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  49079. */
  49080. export class WebXRFeaturesManager implements IDisposable {
  49081. private _xrSessionManager;
  49082. private static readonly _AvailableFeatures;
  49083. private _features;
  49084. /**
  49085. * constructs a new features manages.
  49086. *
  49087. * @param _xrSessionManager an instance of WebXRSessionManager
  49088. */
  49089. constructor(_xrSessionManager: WebXRSessionManager);
  49090. /**
  49091. * Used to register a module. After calling this function a developer can use this feature in the scene.
  49092. * Mainly used internally.
  49093. *
  49094. * @param featureName the name of the feature to register
  49095. * @param constructorFunction the function used to construct the module
  49096. * @param version the (babylon) version of the module
  49097. * @param stable is that a stable version of this module
  49098. */
  49099. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  49100. /**
  49101. * Returns a constructor of a specific feature.
  49102. *
  49103. * @param featureName the name of the feature to construct
  49104. * @param version the version of the feature to load
  49105. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49106. * @param options optional options provided to the module.
  49107. * @returns a function that, when called, will return a new instance of this feature
  49108. */
  49109. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49110. /**
  49111. * Can be used to return the list of features currently registered
  49112. *
  49113. * @returns an Array of available features
  49114. */
  49115. static GetAvailableFeatures(): string[];
  49116. /**
  49117. * Gets the versions available for a specific feature
  49118. * @param featureName the name of the feature
  49119. * @returns an array with the available versions
  49120. */
  49121. static GetAvailableVersions(featureName: string): string[];
  49122. /**
  49123. * Return the latest unstable version of this feature
  49124. * @param featureName the name of the feature to search
  49125. * @returns the version number. if not found will return -1
  49126. */
  49127. static GetLatestVersionOfFeature(featureName: string): number;
  49128. /**
  49129. * Return the latest stable version of this feature
  49130. * @param featureName the name of the feature to search
  49131. * @returns the version number. if not found will return -1
  49132. */
  49133. static GetStableVersionOfFeature(featureName: string): number;
  49134. /**
  49135. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49136. * Can be used during a session to start a feature
  49137. * @param featureName the name of feature to attach
  49138. */
  49139. attachFeature(featureName: string): void;
  49140. /**
  49141. * Can be used inside a session or when the session ends to detach a specific feature
  49142. * @param featureName the name of the feature to detach
  49143. */
  49144. detachFeature(featureName: string): void;
  49145. /**
  49146. * Used to disable an already-enabled feature
  49147. * The feature will be disposed and will be recreated once enabled.
  49148. * @param featureName the feature to disable
  49149. * @returns true if disable was successful
  49150. */
  49151. disableFeature(featureName: string | {
  49152. Name: string;
  49153. }): boolean;
  49154. /**
  49155. * dispose this features manager
  49156. */
  49157. dispose(): void;
  49158. /**
  49159. * 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.
  49160. * 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.
  49161. *
  49162. * @param featureName the name of the feature to load or the class of the feature
  49163. * @param version optional version to load. if not provided the latest version will be enabled
  49164. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49165. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49166. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49167. * @returns a new constructed feature or throws an error if feature not found.
  49168. */
  49169. enableFeature(featureName: string | {
  49170. Name: string;
  49171. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49172. /**
  49173. * get the implementation of an enabled feature.
  49174. * @param featureName the name of the feature to load
  49175. * @returns the feature class, if found
  49176. */
  49177. getEnabledFeature(featureName: string): IWebXRFeature;
  49178. /**
  49179. * Get the list of enabled features
  49180. * @returns an array of enabled features
  49181. */
  49182. getEnabledFeatures(): string[];
  49183. /**
  49184. * This function will exten the session creation configuration object with enabled features.
  49185. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49186. * according to the defined "required" variable, provided during enableFeature call
  49187. * @param xrSessionInit the xr Session init object to extend
  49188. *
  49189. * @returns an extended XRSessionInit object
  49190. */
  49191. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49192. }
  49193. }
  49194. declare module "babylonjs/XR/webXRExperienceHelper" {
  49195. import { Observable } from "babylonjs/Misc/observable";
  49196. import { IDisposable, Scene } from "babylonjs/scene";
  49197. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49198. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49199. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49200. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49201. /**
  49202. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49203. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49204. */
  49205. export class WebXRExperienceHelper implements IDisposable {
  49206. private scene;
  49207. private _nonVRCamera;
  49208. private _originalSceneAutoClear;
  49209. private _supported;
  49210. /**
  49211. * Camera used to render xr content
  49212. */
  49213. camera: WebXRCamera;
  49214. /** A features manager for this xr session */
  49215. featuresManager: WebXRFeaturesManager;
  49216. /**
  49217. * Observers registered here will be triggered after the camera's initial transformation is set
  49218. * This can be used to set a different ground level or an extra rotation.
  49219. *
  49220. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49221. * to the position set after this observable is done executing.
  49222. */
  49223. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49224. /**
  49225. * Fires when the state of the experience helper has changed
  49226. */
  49227. onStateChangedObservable: Observable<WebXRState>;
  49228. /** Session manager used to keep track of xr session */
  49229. sessionManager: WebXRSessionManager;
  49230. /**
  49231. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49232. */
  49233. state: WebXRState;
  49234. /**
  49235. * Creates a WebXRExperienceHelper
  49236. * @param scene The scene the helper should be created in
  49237. */
  49238. private constructor();
  49239. /**
  49240. * Creates the experience helper
  49241. * @param scene the scene to attach the experience helper to
  49242. * @returns a promise for the experience helper
  49243. */
  49244. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49245. /**
  49246. * Disposes of the experience helper
  49247. */
  49248. dispose(): void;
  49249. /**
  49250. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49251. * @param sessionMode options for the XR session
  49252. * @param referenceSpaceType frame of reference of the XR session
  49253. * @param renderTarget the output canvas that will be used to enter XR mode
  49254. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49255. * @returns promise that resolves after xr mode has entered
  49256. */
  49257. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49258. /**
  49259. * Exits XR mode and returns the scene to its original state
  49260. * @returns promise that resolves after xr mode has exited
  49261. */
  49262. exitXRAsync(): Promise<void>;
  49263. private _nonXRToXRCamera;
  49264. private _setState;
  49265. }
  49266. }
  49267. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49268. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49269. import { Observable } from "babylonjs/Misc/observable";
  49270. import { IDisposable } from "babylonjs/scene";
  49271. /**
  49272. * X-Y values for axes in WebXR
  49273. */
  49274. export interface IWebXRMotionControllerAxesValue {
  49275. /**
  49276. * The value of the x axis
  49277. */
  49278. x: number;
  49279. /**
  49280. * The value of the y-axis
  49281. */
  49282. y: number;
  49283. }
  49284. /**
  49285. * changed / previous values for the values of this component
  49286. */
  49287. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49288. /**
  49289. * current (this frame) value
  49290. */
  49291. current: T;
  49292. /**
  49293. * previous (last change) value
  49294. */
  49295. previous: T;
  49296. }
  49297. /**
  49298. * Represents changes in the component between current frame and last values recorded
  49299. */
  49300. export interface IWebXRMotionControllerComponentChanges {
  49301. /**
  49302. * will be populated with previous and current values if axes changed
  49303. */
  49304. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49305. /**
  49306. * will be populated with previous and current values if pressed changed
  49307. */
  49308. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49309. /**
  49310. * will be populated with previous and current values if touched changed
  49311. */
  49312. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49313. /**
  49314. * will be populated with previous and current values if value changed
  49315. */
  49316. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49317. }
  49318. /**
  49319. * This class represents a single component (for example button or thumbstick) of a motion controller
  49320. */
  49321. export class WebXRControllerComponent implements IDisposable {
  49322. /**
  49323. * the id of this component
  49324. */
  49325. id: string;
  49326. /**
  49327. * the type of the component
  49328. */
  49329. type: MotionControllerComponentType;
  49330. private _buttonIndex;
  49331. private _axesIndices;
  49332. private _axes;
  49333. private _changes;
  49334. private _currentValue;
  49335. private _hasChanges;
  49336. private _pressed;
  49337. private _touched;
  49338. /**
  49339. * button component type
  49340. */
  49341. static BUTTON_TYPE: MotionControllerComponentType;
  49342. /**
  49343. * squeeze component type
  49344. */
  49345. static SQUEEZE_TYPE: MotionControllerComponentType;
  49346. /**
  49347. * Thumbstick component type
  49348. */
  49349. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49350. /**
  49351. * Touchpad component type
  49352. */
  49353. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49354. /**
  49355. * trigger component type
  49356. */
  49357. static TRIGGER_TYPE: MotionControllerComponentType;
  49358. /**
  49359. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49360. * the axes data changes
  49361. */
  49362. onAxisValueChangedObservable: Observable<{
  49363. x: number;
  49364. y: number;
  49365. }>;
  49366. /**
  49367. * Observers registered here will be triggered when the state of a button changes
  49368. * State change is either pressed / touched / value
  49369. */
  49370. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49371. /**
  49372. * Creates a new component for a motion controller.
  49373. * It is created by the motion controller itself
  49374. *
  49375. * @param id the id of this component
  49376. * @param type the type of the component
  49377. * @param _buttonIndex index in the buttons array of the gamepad
  49378. * @param _axesIndices indices of the values in the axes array of the gamepad
  49379. */
  49380. constructor(
  49381. /**
  49382. * the id of this component
  49383. */
  49384. id: string,
  49385. /**
  49386. * the type of the component
  49387. */
  49388. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49389. /**
  49390. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49391. */
  49392. get axes(): IWebXRMotionControllerAxesValue;
  49393. /**
  49394. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49395. */
  49396. get changes(): IWebXRMotionControllerComponentChanges;
  49397. /**
  49398. * Return whether or not the component changed the last frame
  49399. */
  49400. get hasChanges(): boolean;
  49401. /**
  49402. * is the button currently pressed
  49403. */
  49404. get pressed(): boolean;
  49405. /**
  49406. * is the button currently touched
  49407. */
  49408. get touched(): boolean;
  49409. /**
  49410. * Get the current value of this component
  49411. */
  49412. get value(): number;
  49413. /**
  49414. * Dispose this component
  49415. */
  49416. dispose(): void;
  49417. /**
  49418. * Are there axes correlating to this component
  49419. * @return true is axes data is available
  49420. */
  49421. isAxes(): boolean;
  49422. /**
  49423. * Is this component a button (hence - pressable)
  49424. * @returns true if can be pressed
  49425. */
  49426. isButton(): boolean;
  49427. /**
  49428. * update this component using the gamepad object it is in. Called on every frame
  49429. * @param nativeController the native gamepad controller object
  49430. */
  49431. update(nativeController: IMinimalMotionControllerObject): void;
  49432. }
  49433. }
  49434. declare module "babylonjs/Loading/sceneLoader" {
  49435. import { Observable } from "babylonjs/Misc/observable";
  49436. import { Nullable } from "babylonjs/types";
  49437. import { Scene } from "babylonjs/scene";
  49438. import { Engine } from "babylonjs/Engines/engine";
  49439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49440. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49441. import { AssetContainer } from "babylonjs/assetContainer";
  49442. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49443. import { Skeleton } from "babylonjs/Bones/skeleton";
  49444. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49445. import { WebRequest } from "babylonjs/Misc/webRequest";
  49446. /**
  49447. * Interface used to represent data loading progression
  49448. */
  49449. export interface ISceneLoaderProgressEvent {
  49450. /**
  49451. * Defines if data length to load can be evaluated
  49452. */
  49453. readonly lengthComputable: boolean;
  49454. /**
  49455. * Defines the loaded data length
  49456. */
  49457. readonly loaded: number;
  49458. /**
  49459. * Defines the data length to load
  49460. */
  49461. readonly total: number;
  49462. }
  49463. /**
  49464. * Interface used by SceneLoader plugins to define supported file extensions
  49465. */
  49466. export interface ISceneLoaderPluginExtensions {
  49467. /**
  49468. * Defines the list of supported extensions
  49469. */
  49470. [extension: string]: {
  49471. isBinary: boolean;
  49472. };
  49473. }
  49474. /**
  49475. * Interface used by SceneLoader plugin factory
  49476. */
  49477. export interface ISceneLoaderPluginFactory {
  49478. /**
  49479. * Defines the name of the factory
  49480. */
  49481. name: string;
  49482. /**
  49483. * Function called to create a new plugin
  49484. * @return the new plugin
  49485. */
  49486. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49487. /**
  49488. * The callback that returns true if the data can be directly loaded.
  49489. * @param data string containing the file data
  49490. * @returns if the data can be loaded directly
  49491. */
  49492. canDirectLoad?(data: string): boolean;
  49493. }
  49494. /**
  49495. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49496. */
  49497. export interface ISceneLoaderPluginBase {
  49498. /**
  49499. * The friendly name of this plugin.
  49500. */
  49501. name: string;
  49502. /**
  49503. * The file extensions supported by this plugin.
  49504. */
  49505. extensions: string | ISceneLoaderPluginExtensions;
  49506. /**
  49507. * The callback called when loading from a url.
  49508. * @param scene scene loading this url
  49509. * @param url url to load
  49510. * @param onSuccess callback called when the file successfully loads
  49511. * @param onProgress callback called while file is loading (if the server supports this mode)
  49512. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49513. * @param onError callback called when the file fails to load
  49514. * @returns a file request object
  49515. */
  49516. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49517. /**
  49518. * The callback called when loading from a file object.
  49519. * @param scene scene loading this file
  49520. * @param file defines the file to load
  49521. * @param onSuccess defines the callback to call when data is loaded
  49522. * @param onProgress defines the callback to call during loading process
  49523. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49524. * @param onError defines the callback to call when an error occurs
  49525. * @returns a file request object
  49526. */
  49527. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49528. /**
  49529. * The callback that returns true if the data can be directly loaded.
  49530. * @param data string containing the file data
  49531. * @returns if the data can be loaded directly
  49532. */
  49533. canDirectLoad?(data: string): boolean;
  49534. /**
  49535. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49536. * @param scene scene loading this data
  49537. * @param data string containing the data
  49538. * @returns data to pass to the plugin
  49539. */
  49540. directLoad?(scene: Scene, data: string): any;
  49541. /**
  49542. * The callback that allows custom handling of the root url based on the response url.
  49543. * @param rootUrl the original root url
  49544. * @param responseURL the response url if available
  49545. * @returns the new root url
  49546. */
  49547. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49548. }
  49549. /**
  49550. * Interface used to define a SceneLoader plugin
  49551. */
  49552. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49553. /**
  49554. * Import meshes into a scene.
  49555. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49556. * @param scene The scene to import into
  49557. * @param data The data to import
  49558. * @param rootUrl The root url for scene and resources
  49559. * @param meshes The meshes array to import into
  49560. * @param particleSystems The particle systems array to import into
  49561. * @param skeletons The skeletons array to import into
  49562. * @param onError The callback when import fails
  49563. * @returns True if successful or false otherwise
  49564. */
  49565. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49566. /**
  49567. * Load into a scene.
  49568. * @param scene The scene to load into
  49569. * @param data The data to import
  49570. * @param rootUrl The root url for scene and resources
  49571. * @param onError The callback when import fails
  49572. * @returns True if successful or false otherwise
  49573. */
  49574. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49575. /**
  49576. * Load into an asset container.
  49577. * @param scene The scene to load into
  49578. * @param data The data to import
  49579. * @param rootUrl The root url for scene and resources
  49580. * @param onError The callback when import fails
  49581. * @returns The loaded asset container
  49582. */
  49583. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49584. }
  49585. /**
  49586. * Interface used to define an async SceneLoader plugin
  49587. */
  49588. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49589. /**
  49590. * Import meshes into a scene.
  49591. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49592. * @param scene The scene to import into
  49593. * @param data The data to import
  49594. * @param rootUrl The root url for scene and resources
  49595. * @param onProgress The callback when the load progresses
  49596. * @param fileName Defines the name of the file to load
  49597. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49598. */
  49599. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49600. meshes: AbstractMesh[];
  49601. particleSystems: IParticleSystem[];
  49602. skeletons: Skeleton[];
  49603. animationGroups: AnimationGroup[];
  49604. }>;
  49605. /**
  49606. * Load into a scene.
  49607. * @param scene The scene to load into
  49608. * @param data The data to import
  49609. * @param rootUrl The root url for scene and resources
  49610. * @param onProgress The callback when the load progresses
  49611. * @param fileName Defines the name of the file to load
  49612. * @returns Nothing
  49613. */
  49614. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49615. /**
  49616. * Load into an asset container.
  49617. * @param scene The scene to load into
  49618. * @param data The data to import
  49619. * @param rootUrl The root url for scene and resources
  49620. * @param onProgress The callback when the load progresses
  49621. * @param fileName Defines the name of the file to load
  49622. * @returns The loaded asset container
  49623. */
  49624. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49625. }
  49626. /**
  49627. * Mode that determines how to handle old animation groups before loading new ones.
  49628. */
  49629. export enum SceneLoaderAnimationGroupLoadingMode {
  49630. /**
  49631. * Reset all old animations to initial state then dispose them.
  49632. */
  49633. Clean = 0,
  49634. /**
  49635. * Stop all old animations.
  49636. */
  49637. Stop = 1,
  49638. /**
  49639. * Restart old animations from first frame.
  49640. */
  49641. Sync = 2,
  49642. /**
  49643. * Old animations remains untouched.
  49644. */
  49645. NoSync = 3
  49646. }
  49647. /**
  49648. * Defines a plugin registered by the SceneLoader
  49649. */
  49650. interface IRegisteredPlugin {
  49651. /**
  49652. * Defines the plugin to use
  49653. */
  49654. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49655. /**
  49656. * Defines if the plugin supports binary data
  49657. */
  49658. isBinary: boolean;
  49659. }
  49660. /**
  49661. * Class used to load scene from various file formats using registered plugins
  49662. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49663. */
  49664. export class SceneLoader {
  49665. /**
  49666. * No logging while loading
  49667. */
  49668. static readonly NO_LOGGING: number;
  49669. /**
  49670. * Minimal logging while loading
  49671. */
  49672. static readonly MINIMAL_LOGGING: number;
  49673. /**
  49674. * Summary logging while loading
  49675. */
  49676. static readonly SUMMARY_LOGGING: number;
  49677. /**
  49678. * Detailled logging while loading
  49679. */
  49680. static readonly DETAILED_LOGGING: number;
  49681. /**
  49682. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49683. */
  49684. static get ForceFullSceneLoadingForIncremental(): boolean;
  49685. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49686. /**
  49687. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49688. */
  49689. static get ShowLoadingScreen(): boolean;
  49690. static set ShowLoadingScreen(value: boolean);
  49691. /**
  49692. * Defines the current logging level (while loading the scene)
  49693. * @ignorenaming
  49694. */
  49695. static get loggingLevel(): number;
  49696. static set loggingLevel(value: number);
  49697. /**
  49698. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49699. */
  49700. static get CleanBoneMatrixWeights(): boolean;
  49701. static set CleanBoneMatrixWeights(value: boolean);
  49702. /**
  49703. * Event raised when a plugin is used to load a scene
  49704. */
  49705. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49706. private static _registeredPlugins;
  49707. private static _showingLoadingScreen;
  49708. /**
  49709. * Gets the default plugin (used to load Babylon files)
  49710. * @returns the .babylon plugin
  49711. */
  49712. static GetDefaultPlugin(): IRegisteredPlugin;
  49713. private static _GetPluginForExtension;
  49714. private static _GetPluginForDirectLoad;
  49715. private static _GetPluginForFilename;
  49716. private static _GetDirectLoad;
  49717. private static _LoadData;
  49718. private static _GetFileInfo;
  49719. /**
  49720. * Gets a plugin that can load the given extension
  49721. * @param extension defines the extension to load
  49722. * @returns a plugin or null if none works
  49723. */
  49724. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49725. /**
  49726. * Gets a boolean indicating that the given extension can be loaded
  49727. * @param extension defines the extension to load
  49728. * @returns true if the extension is supported
  49729. */
  49730. static IsPluginForExtensionAvailable(extension: string): boolean;
  49731. /**
  49732. * Adds a new plugin to the list of registered plugins
  49733. * @param plugin defines the plugin to add
  49734. */
  49735. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49736. /**
  49737. * Import meshes into a scene
  49738. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49739. * @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)
  49740. * @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)
  49741. * @param scene the instance of BABYLON.Scene to append to
  49742. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  49743. * @param onProgress a callback with a progress event for each file being loaded
  49744. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49745. * @param pluginExtension the extension used to determine the plugin
  49746. * @returns The loaded plugin
  49747. */
  49748. 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>;
  49749. /**
  49750. * Import meshes into a scene
  49751. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49752. * @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)
  49753. * @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)
  49754. * @param scene the instance of BABYLON.Scene to append to
  49755. * @param onProgress a callback with a progress event for each file being loaded
  49756. * @param pluginExtension the extension used to determine the plugin
  49757. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49758. */
  49759. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49760. meshes: AbstractMesh[];
  49761. particleSystems: IParticleSystem[];
  49762. skeletons: Skeleton[];
  49763. animationGroups: AnimationGroup[];
  49764. }>;
  49765. /**
  49766. * Load a scene
  49767. * @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)
  49768. * @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)
  49769. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49770. * @param onSuccess a callback with the scene when import succeeds
  49771. * @param onProgress a callback with a progress event for each file being loaded
  49772. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49773. * @param pluginExtension the extension used to determine the plugin
  49774. * @returns The loaded plugin
  49775. */
  49776. 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>;
  49777. /**
  49778. * Load a scene
  49779. * @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)
  49780. * @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)
  49781. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49782. * @param onProgress a callback with a progress event for each file being loaded
  49783. * @param pluginExtension the extension used to determine the plugin
  49784. * @returns The loaded scene
  49785. */
  49786. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49787. /**
  49788. * Append a scene
  49789. * @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)
  49790. * @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)
  49791. * @param scene is the instance of BABYLON.Scene to append to
  49792. * @param onSuccess a callback with the scene when import succeeds
  49793. * @param onProgress a callback with a progress event for each file being loaded
  49794. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49795. * @param pluginExtension the extension used to determine the plugin
  49796. * @returns The loaded plugin
  49797. */
  49798. 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>;
  49799. /**
  49800. * Append a scene
  49801. * @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)
  49802. * @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)
  49803. * @param scene is the instance of BABYLON.Scene to append to
  49804. * @param onProgress a callback with a progress event for each file being loaded
  49805. * @param pluginExtension the extension used to determine the plugin
  49806. * @returns The given scene
  49807. */
  49808. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49809. /**
  49810. * Load a scene into an asset container
  49811. * @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)
  49812. * @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)
  49813. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49814. * @param onSuccess a callback with the scene when import succeeds
  49815. * @param onProgress a callback with a progress event for each file being loaded
  49816. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49817. * @param pluginExtension the extension used to determine the plugin
  49818. * @returns The loaded plugin
  49819. */
  49820. 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>;
  49821. /**
  49822. * Load a scene into an asset container
  49823. * @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)
  49824. * @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)
  49825. * @param scene is the instance of Scene to append to
  49826. * @param onProgress a callback with a progress event for each file being loaded
  49827. * @param pluginExtension the extension used to determine the plugin
  49828. * @returns The loaded asset container
  49829. */
  49830. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49831. /**
  49832. * Import animations from a file into a scene
  49833. * @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)
  49834. * @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)
  49835. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49836. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49837. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49838. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49839. * @param onSuccess a callback with the scene when import succeeds
  49840. * @param onProgress a callback with a progress event for each file being loaded
  49841. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49842. * @param pluginExtension the extension used to determine the plugin
  49843. */
  49844. 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;
  49845. /**
  49846. * Import animations from a file into a scene
  49847. * @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)
  49848. * @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)
  49849. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49850. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49851. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49852. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49853. * @param onSuccess a callback with the scene when import succeeds
  49854. * @param onProgress a callback with a progress event for each file being loaded
  49855. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49856. * @param pluginExtension the extension used to determine the plugin
  49857. * @returns the updated scene with imported animations
  49858. */
  49859. 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>;
  49860. }
  49861. }
  49862. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49863. import { IDisposable, Scene } from "babylonjs/scene";
  49864. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49865. import { Observable } from "babylonjs/Misc/observable";
  49866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49867. import { Nullable } from "babylonjs/types";
  49868. /**
  49869. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49870. */
  49871. export type MotionControllerHandedness = "none" | "left" | "right";
  49872. /**
  49873. * The type of components available in motion controllers.
  49874. * This is not the name of the component.
  49875. */
  49876. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49877. /**
  49878. * The state of a controller component
  49879. */
  49880. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49881. /**
  49882. * The schema of motion controller layout.
  49883. * No object will be initialized using this interface
  49884. * This is used just to define the profile.
  49885. */
  49886. export interface IMotionControllerLayout {
  49887. /**
  49888. * Path to load the assets. Usually relative to the base path
  49889. */
  49890. assetPath: string;
  49891. /**
  49892. * Available components (unsorted)
  49893. */
  49894. components: {
  49895. /**
  49896. * A map of component Ids
  49897. */
  49898. [componentId: string]: {
  49899. /**
  49900. * The type of input the component outputs
  49901. */
  49902. type: MotionControllerComponentType;
  49903. /**
  49904. * The indices of this component in the gamepad object
  49905. */
  49906. gamepadIndices: {
  49907. /**
  49908. * Index of button
  49909. */
  49910. button?: number;
  49911. /**
  49912. * If available, index of x-axis
  49913. */
  49914. xAxis?: number;
  49915. /**
  49916. * If available, index of y-axis
  49917. */
  49918. yAxis?: number;
  49919. };
  49920. /**
  49921. * The mesh's root node name
  49922. */
  49923. rootNodeName: string;
  49924. /**
  49925. * Animation definitions for this model
  49926. */
  49927. visualResponses: {
  49928. [stateKey: string]: {
  49929. /**
  49930. * What property will be animated
  49931. */
  49932. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49933. /**
  49934. * What states influence this visual response
  49935. */
  49936. states: MotionControllerComponentStateType[];
  49937. /**
  49938. * Type of animation - movement or visibility
  49939. */
  49940. valueNodeProperty: "transform" | "visibility";
  49941. /**
  49942. * Base node name to move. Its position will be calculated according to the min and max nodes
  49943. */
  49944. valueNodeName?: string;
  49945. /**
  49946. * Minimum movement node
  49947. */
  49948. minNodeName?: string;
  49949. /**
  49950. * Max movement node
  49951. */
  49952. maxNodeName?: string;
  49953. };
  49954. };
  49955. /**
  49956. * If touch enabled, what is the name of node to display user feedback
  49957. */
  49958. touchPointNodeName?: string;
  49959. };
  49960. };
  49961. /**
  49962. * Is it xr standard mapping or not
  49963. */
  49964. gamepadMapping: "" | "xr-standard";
  49965. /**
  49966. * Base root node of this entire model
  49967. */
  49968. rootNodeName: string;
  49969. /**
  49970. * Defines the main button component id
  49971. */
  49972. selectComponentId: string;
  49973. }
  49974. /**
  49975. * A definition for the layout map in the input profile
  49976. */
  49977. export interface IMotionControllerLayoutMap {
  49978. /**
  49979. * Layouts with handedness type as a key
  49980. */
  49981. [handedness: string]: IMotionControllerLayout;
  49982. }
  49983. /**
  49984. * The XR Input profile schema
  49985. * Profiles can be found here:
  49986. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49987. */
  49988. export interface IMotionControllerProfile {
  49989. /**
  49990. * fallback profiles for this profileId
  49991. */
  49992. fallbackProfileIds: string[];
  49993. /**
  49994. * The layout map, with handedness as key
  49995. */
  49996. layouts: IMotionControllerLayoutMap;
  49997. /**
  49998. * The id of this profile
  49999. * correlates to the profile(s) in the xrInput.profiles array
  50000. */
  50001. profileId: string;
  50002. }
  50003. /**
  50004. * A helper-interface for the 3 meshes needed for controller button animation
  50005. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  50006. */
  50007. export interface IMotionControllerButtonMeshMap {
  50008. /**
  50009. * the mesh that defines the pressed value mesh position.
  50010. * This is used to find the max-position of this button
  50011. */
  50012. pressedMesh: AbstractMesh;
  50013. /**
  50014. * the mesh that defines the unpressed value mesh position.
  50015. * This is used to find the min (or initial) position of this button
  50016. */
  50017. unpressedMesh: AbstractMesh;
  50018. /**
  50019. * The mesh that will be changed when value changes
  50020. */
  50021. valueMesh: AbstractMesh;
  50022. }
  50023. /**
  50024. * A helper-interface for the 3 meshes needed for controller axis animation.
  50025. * This will be expanded when touchpad animations are fully supported
  50026. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  50027. */
  50028. export interface IMotionControllerMeshMap {
  50029. /**
  50030. * the mesh that defines the maximum value mesh position.
  50031. */
  50032. maxMesh?: AbstractMesh;
  50033. /**
  50034. * the mesh that defines the minimum value mesh position.
  50035. */
  50036. minMesh?: AbstractMesh;
  50037. /**
  50038. * The mesh that will be changed when axis value changes
  50039. */
  50040. valueMesh?: AbstractMesh;
  50041. }
  50042. /**
  50043. * The elements needed for change-detection of the gamepad objects in motion controllers
  50044. */
  50045. export interface IMinimalMotionControllerObject {
  50046. /**
  50047. * Available axes of this controller
  50048. */
  50049. axes: number[];
  50050. /**
  50051. * An array of available buttons
  50052. */
  50053. buttons: Array<{
  50054. /**
  50055. * Value of the button/trigger
  50056. */
  50057. value: number;
  50058. /**
  50059. * If the button/trigger is currently touched
  50060. */
  50061. touched: boolean;
  50062. /**
  50063. * If the button/trigger is currently pressed
  50064. */
  50065. pressed: boolean;
  50066. }>;
  50067. /**
  50068. * EXPERIMENTAL haptic support.
  50069. */
  50070. hapticActuators?: Array<{
  50071. pulse: (value: number, duration: number) => Promise<boolean>;
  50072. }>;
  50073. }
  50074. /**
  50075. * An Abstract Motion controller
  50076. * This class receives an xrInput and a profile layout and uses those to initialize the components
  50077. * Each component has an observable to check for changes in value and state
  50078. */
  50079. export abstract class WebXRAbstractMotionController implements IDisposable {
  50080. protected scene: Scene;
  50081. protected layout: IMotionControllerLayout;
  50082. /**
  50083. * The gamepad object correlating to this controller
  50084. */
  50085. gamepadObject: IMinimalMotionControllerObject;
  50086. /**
  50087. * handedness (left/right/none) of this controller
  50088. */
  50089. handedness: MotionControllerHandedness;
  50090. private _initComponent;
  50091. private _modelReady;
  50092. /**
  50093. * A map of components (WebXRControllerComponent) in this motion controller
  50094. * Components have a ComponentType and can also have both button and axis definitions
  50095. */
  50096. readonly components: {
  50097. [id: string]: WebXRControllerComponent;
  50098. };
  50099. /**
  50100. * Disable the model's animation. Can be set at any time.
  50101. */
  50102. disableAnimation: boolean;
  50103. /**
  50104. * Observers registered here will be triggered when the model of this controller is done loading
  50105. */
  50106. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50107. /**
  50108. * The profile id of this motion controller
  50109. */
  50110. abstract profileId: string;
  50111. /**
  50112. * The root mesh of the model. It is null if the model was not yet initialized
  50113. */
  50114. rootMesh: Nullable<AbstractMesh>;
  50115. /**
  50116. * constructs a new abstract motion controller
  50117. * @param scene the scene to which the model of the controller will be added
  50118. * @param layout The profile layout to load
  50119. * @param gamepadObject The gamepad object correlating to this controller
  50120. * @param handedness handedness (left/right/none) of this controller
  50121. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50122. */
  50123. constructor(scene: Scene, layout: IMotionControllerLayout,
  50124. /**
  50125. * The gamepad object correlating to this controller
  50126. */
  50127. gamepadObject: IMinimalMotionControllerObject,
  50128. /**
  50129. * handedness (left/right/none) of this controller
  50130. */
  50131. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50132. /**
  50133. * Dispose this controller, the model mesh and all its components
  50134. */
  50135. dispose(): void;
  50136. /**
  50137. * Returns all components of specific type
  50138. * @param type the type to search for
  50139. * @return an array of components with this type
  50140. */
  50141. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50142. /**
  50143. * get a component based an its component id as defined in layout.components
  50144. * @param id the id of the component
  50145. * @returns the component correlates to the id or undefined if not found
  50146. */
  50147. getComponent(id: string): WebXRControllerComponent;
  50148. /**
  50149. * Get the list of components available in this motion controller
  50150. * @returns an array of strings correlating to available components
  50151. */
  50152. getComponentIds(): string[];
  50153. /**
  50154. * Get the first component of specific type
  50155. * @param type type of component to find
  50156. * @return a controller component or null if not found
  50157. */
  50158. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50159. /**
  50160. * Get the main (Select) component of this controller as defined in the layout
  50161. * @returns the main component of this controller
  50162. */
  50163. getMainComponent(): WebXRControllerComponent;
  50164. /**
  50165. * Loads the model correlating to this controller
  50166. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50167. * @returns A promise fulfilled with the result of the model loading
  50168. */
  50169. loadModel(): Promise<boolean>;
  50170. /**
  50171. * Update this model using the current XRFrame
  50172. * @param xrFrame the current xr frame to use and update the model
  50173. */
  50174. updateFromXRFrame(xrFrame: XRFrame): void;
  50175. /**
  50176. * Backwards compatibility due to a deeply-integrated typo
  50177. */
  50178. get handness(): XREye;
  50179. /**
  50180. * Pulse (vibrate) this controller
  50181. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50182. * Consecutive calls to this function will cancel the last pulse call
  50183. *
  50184. * @param value the strength of the pulse in 0.0...1.0 range
  50185. * @param duration Duration of the pulse in milliseconds
  50186. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50187. * @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
  50188. */
  50189. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50190. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50191. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50192. /**
  50193. * Moves the axis on the controller mesh based on its current state
  50194. * @param axis the index of the axis
  50195. * @param axisValue the value of the axis which determines the meshes new position
  50196. * @hidden
  50197. */
  50198. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50199. /**
  50200. * Update the model itself with the current frame data
  50201. * @param xrFrame the frame to use for updating the model mesh
  50202. */
  50203. protected updateModel(xrFrame: XRFrame): void;
  50204. /**
  50205. * Get the filename and path for this controller's model
  50206. * @returns a map of filename and path
  50207. */
  50208. protected abstract _getFilenameAndPath(): {
  50209. filename: string;
  50210. path: string;
  50211. };
  50212. /**
  50213. * This function is called before the mesh is loaded. It checks for loading constraints.
  50214. * For example, this function can check if the GLB loader is available
  50215. * If this function returns false, the generic controller will be loaded instead
  50216. * @returns Is the client ready to load the mesh
  50217. */
  50218. protected abstract _getModelLoadingConstraints(): boolean;
  50219. /**
  50220. * This function will be called after the model was successfully loaded and can be used
  50221. * for mesh transformations before it is available for the user
  50222. * @param meshes the loaded meshes
  50223. */
  50224. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50225. /**
  50226. * Set the root mesh for this controller. Important for the WebXR controller class
  50227. * @param meshes the loaded meshes
  50228. */
  50229. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50230. /**
  50231. * A function executed each frame that updates the mesh (if needed)
  50232. * @param xrFrame the current xrFrame
  50233. */
  50234. protected abstract _updateModel(xrFrame: XRFrame): void;
  50235. private _getGenericFilenameAndPath;
  50236. private _getGenericParentMesh;
  50237. }
  50238. }
  50239. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50240. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50242. import { Scene } from "babylonjs/scene";
  50243. /**
  50244. * A generic trigger-only motion controller for WebXR
  50245. */
  50246. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50247. /**
  50248. * Static version of the profile id of this controller
  50249. */
  50250. static ProfileId: string;
  50251. profileId: string;
  50252. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50253. protected _getFilenameAndPath(): {
  50254. filename: string;
  50255. path: string;
  50256. };
  50257. protected _getModelLoadingConstraints(): boolean;
  50258. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50259. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50260. protected _updateModel(): void;
  50261. }
  50262. }
  50263. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50264. import { Vector4 } from "babylonjs/Maths/math.vector";
  50265. import { Mesh } from "babylonjs/Meshes/mesh";
  50266. import { Scene } from "babylonjs/scene";
  50267. import { Nullable } from "babylonjs/types";
  50268. /**
  50269. * Class containing static functions to help procedurally build meshes
  50270. */
  50271. export class SphereBuilder {
  50272. /**
  50273. * Creates a sphere mesh
  50274. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50275. * * 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`)
  50276. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50277. * * 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
  50278. * * 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)
  50279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50282. * @param name defines the name of the mesh
  50283. * @param options defines the options used to create the mesh
  50284. * @param scene defines the hosting scene
  50285. * @returns the sphere mesh
  50286. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50287. */
  50288. static CreateSphere(name: string, options: {
  50289. segments?: number;
  50290. diameter?: number;
  50291. diameterX?: number;
  50292. diameterY?: number;
  50293. diameterZ?: number;
  50294. arc?: number;
  50295. slice?: number;
  50296. sideOrientation?: number;
  50297. frontUVs?: Vector4;
  50298. backUVs?: Vector4;
  50299. updatable?: boolean;
  50300. }, scene?: Nullable<Scene>): Mesh;
  50301. }
  50302. }
  50303. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50305. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50306. import { Scene } from "babylonjs/scene";
  50307. /**
  50308. * A profiled motion controller has its profile loaded from an online repository.
  50309. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50310. */
  50311. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50312. private _repositoryUrl;
  50313. private _buttonMeshMapping;
  50314. private _touchDots;
  50315. /**
  50316. * The profile ID of this controller. Will be populated when the controller initializes.
  50317. */
  50318. profileId: string;
  50319. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50320. dispose(): void;
  50321. protected _getFilenameAndPath(): {
  50322. filename: string;
  50323. path: string;
  50324. };
  50325. protected _getModelLoadingConstraints(): boolean;
  50326. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50327. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50328. protected _updateModel(_xrFrame: XRFrame): void;
  50329. }
  50330. }
  50331. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50332. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50333. import { Scene } from "babylonjs/scene";
  50334. /**
  50335. * A construction function type to create a new controller based on an xrInput object
  50336. */
  50337. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50338. /**
  50339. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50340. *
  50341. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50342. * it should be replaced with auto-loaded controllers.
  50343. *
  50344. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50345. */
  50346. export class WebXRMotionControllerManager {
  50347. private static _AvailableControllers;
  50348. private static _Fallbacks;
  50349. private static _ProfileLoadingPromises;
  50350. private static _ProfilesList;
  50351. /**
  50352. * The base URL of the online controller repository. Can be changed at any time.
  50353. */
  50354. static BaseRepositoryUrl: string;
  50355. /**
  50356. * Which repository gets priority - local or online
  50357. */
  50358. static PrioritizeOnlineRepository: boolean;
  50359. /**
  50360. * Use the online repository, or use only locally-defined controllers
  50361. */
  50362. static UseOnlineRepository: boolean;
  50363. /**
  50364. * Clear the cache used for profile loading and reload when requested again
  50365. */
  50366. static ClearProfilesCache(): void;
  50367. /**
  50368. * Register the default fallbacks.
  50369. * This function is called automatically when this file is imported.
  50370. */
  50371. static DefaultFallbacks(): void;
  50372. /**
  50373. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50374. * @param profileId the profile to which a fallback needs to be found
  50375. * @return an array with corresponding fallback profiles
  50376. */
  50377. static FindFallbackWithProfileId(profileId: string): string[];
  50378. /**
  50379. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50380. * The order of search:
  50381. *
  50382. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50383. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50384. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50385. * 4) return the generic trigger controller if none were found
  50386. *
  50387. * @param xrInput the xrInput to which a new controller is initialized
  50388. * @param scene the scene to which the model will be added
  50389. * @param forceProfile force a certain profile for this controller
  50390. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50391. */
  50392. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50393. /**
  50394. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50395. *
  50396. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50397. *
  50398. * @param type the profile type to register
  50399. * @param constructFunction the function to be called when loading this profile
  50400. */
  50401. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50402. /**
  50403. * Register a fallback to a specific profile.
  50404. * @param profileId the profileId that will receive the fallbacks
  50405. * @param fallbacks A list of fallback profiles
  50406. */
  50407. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50408. /**
  50409. * Will update the list of profiles available in the repository
  50410. * @return a promise that resolves to a map of profiles available online
  50411. */
  50412. static UpdateProfilesList(): Promise<{
  50413. [profile: string]: string;
  50414. }>;
  50415. private static _LoadProfileFromRepository;
  50416. private static _LoadProfilesFromAvailableControllers;
  50417. }
  50418. }
  50419. declare module "babylonjs/XR/webXRInputSource" {
  50420. import { Observable } from "babylonjs/Misc/observable";
  50421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50422. import { Ray } from "babylonjs/Culling/ray";
  50423. import { Scene } from "babylonjs/scene";
  50424. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50425. /**
  50426. * Configuration options for the WebXR controller creation
  50427. */
  50428. export interface IWebXRControllerOptions {
  50429. /**
  50430. * Should the controller mesh be animated when a user interacts with it
  50431. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50432. */
  50433. disableMotionControllerAnimation?: boolean;
  50434. /**
  50435. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50436. */
  50437. doNotLoadControllerMesh?: boolean;
  50438. /**
  50439. * Force a specific controller type for this controller.
  50440. * This can be used when creating your own profile or when testing different controllers
  50441. */
  50442. forceControllerProfile?: string;
  50443. /**
  50444. * Defines a rendering group ID for meshes that will be loaded.
  50445. * This is for the default controllers only.
  50446. */
  50447. renderingGroupId?: number;
  50448. }
  50449. /**
  50450. * Represents an XR controller
  50451. */
  50452. export class WebXRInputSource {
  50453. private _scene;
  50454. /** The underlying input source for the controller */
  50455. inputSource: XRInputSource;
  50456. private _options;
  50457. private _tmpVector;
  50458. private _uniqueId;
  50459. private _disposed;
  50460. /**
  50461. * 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
  50462. */
  50463. grip?: AbstractMesh;
  50464. /**
  50465. * If available, this is the gamepad object related to this controller.
  50466. * Using this object it is possible to get click events and trackpad changes of the
  50467. * webxr controller that is currently being used.
  50468. */
  50469. motionController?: WebXRAbstractMotionController;
  50470. /**
  50471. * Event that fires when the controller is removed/disposed.
  50472. * The object provided as event data is this controller, after associated assets were disposed.
  50473. * uniqueId is still available.
  50474. */
  50475. onDisposeObservable: Observable<WebXRInputSource>;
  50476. /**
  50477. * Will be triggered when the mesh associated with the motion controller is done loading.
  50478. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50479. * A shortened version of controller -> motion controller -> on mesh loaded.
  50480. */
  50481. onMeshLoadedObservable: Observable<AbstractMesh>;
  50482. /**
  50483. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50484. */
  50485. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50486. /**
  50487. * Pointer which can be used to select objects or attach a visible laser to
  50488. */
  50489. pointer: AbstractMesh;
  50490. /**
  50491. * Creates the input source object
  50492. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50493. * @param _scene the scene which the controller should be associated to
  50494. * @param inputSource the underlying input source for the controller
  50495. * @param _options options for this controller creation
  50496. */
  50497. constructor(_scene: Scene,
  50498. /** The underlying input source for the controller */
  50499. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50500. /**
  50501. * Get this controllers unique id
  50502. */
  50503. get uniqueId(): string;
  50504. /**
  50505. * Disposes of the object
  50506. */
  50507. dispose(): void;
  50508. /**
  50509. * Gets a world space ray coming from the pointer or grip
  50510. * @param result the resulting ray
  50511. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50512. */
  50513. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50514. /**
  50515. * Updates the controller pose based on the given XRFrame
  50516. * @param xrFrame xr frame to update the pose with
  50517. * @param referenceSpace reference space to use
  50518. */
  50519. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50520. }
  50521. }
  50522. declare module "babylonjs/XR/webXRInput" {
  50523. import { Observable } from "babylonjs/Misc/observable";
  50524. import { IDisposable } from "babylonjs/scene";
  50525. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50526. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50527. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50528. /**
  50529. * The schema for initialization options of the XR Input class
  50530. */
  50531. export interface IWebXRInputOptions {
  50532. /**
  50533. * If set to true no model will be automatically loaded
  50534. */
  50535. doNotLoadControllerMeshes?: boolean;
  50536. /**
  50537. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50538. * If not found, the xr input profile data will be used.
  50539. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50540. */
  50541. forceInputProfile?: string;
  50542. /**
  50543. * Do not send a request to the controller repository to load the profile.
  50544. *
  50545. * Instead, use the controllers available in babylon itself.
  50546. */
  50547. disableOnlineControllerRepository?: boolean;
  50548. /**
  50549. * A custom URL for the controllers repository
  50550. */
  50551. customControllersRepositoryURL?: string;
  50552. /**
  50553. * Should the controller model's components not move according to the user input
  50554. */
  50555. disableControllerAnimation?: boolean;
  50556. /**
  50557. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50558. */
  50559. controllerOptions?: IWebXRControllerOptions;
  50560. }
  50561. /**
  50562. * XR input used to track XR inputs such as controllers/rays
  50563. */
  50564. export class WebXRInput implements IDisposable {
  50565. /**
  50566. * the xr session manager for this session
  50567. */
  50568. xrSessionManager: WebXRSessionManager;
  50569. /**
  50570. * the WebXR camera for this session. Mainly used for teleportation
  50571. */
  50572. xrCamera: WebXRCamera;
  50573. private readonly options;
  50574. /**
  50575. * XR controllers being tracked
  50576. */
  50577. controllers: Array<WebXRInputSource>;
  50578. private _frameObserver;
  50579. private _sessionEndedObserver;
  50580. private _sessionInitObserver;
  50581. /**
  50582. * Event when a controller has been connected/added
  50583. */
  50584. onControllerAddedObservable: Observable<WebXRInputSource>;
  50585. /**
  50586. * Event when a controller has been removed/disconnected
  50587. */
  50588. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50589. /**
  50590. * Initializes the WebXRInput
  50591. * @param xrSessionManager the xr session manager for this session
  50592. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50593. * @param options = initialization options for this xr input
  50594. */
  50595. constructor(
  50596. /**
  50597. * the xr session manager for this session
  50598. */
  50599. xrSessionManager: WebXRSessionManager,
  50600. /**
  50601. * the WebXR camera for this session. Mainly used for teleportation
  50602. */
  50603. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50604. private _onInputSourcesChange;
  50605. private _addAndRemoveControllers;
  50606. /**
  50607. * Disposes of the object
  50608. */
  50609. dispose(): void;
  50610. }
  50611. }
  50612. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50613. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50614. import { Observable, EventState } from "babylonjs/Misc/observable";
  50615. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50616. /**
  50617. * This is the base class for all WebXR features.
  50618. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50619. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50620. */
  50621. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50622. protected _xrSessionManager: WebXRSessionManager;
  50623. private _attached;
  50624. private _removeOnDetach;
  50625. /**
  50626. * Is this feature disposed?
  50627. */
  50628. isDisposed: boolean;
  50629. /**
  50630. * Should auto-attach be disabled?
  50631. */
  50632. disableAutoAttach: boolean;
  50633. /**
  50634. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50635. */
  50636. xrNativeFeatureName: string;
  50637. /**
  50638. * Construct a new (abstract) WebXR feature
  50639. * @param _xrSessionManager the xr session manager for this feature
  50640. */
  50641. constructor(_xrSessionManager: WebXRSessionManager);
  50642. /**
  50643. * Is this feature attached
  50644. */
  50645. get attached(): boolean;
  50646. /**
  50647. * attach this feature
  50648. *
  50649. * @param force should attachment be forced (even when already attached)
  50650. * @returns true if successful, false is failed or already attached
  50651. */
  50652. attach(force?: boolean): boolean;
  50653. /**
  50654. * detach this feature.
  50655. *
  50656. * @returns true if successful, false if failed or already detached
  50657. */
  50658. detach(): boolean;
  50659. /**
  50660. * Dispose this feature and all of the resources attached
  50661. */
  50662. dispose(): void;
  50663. /**
  50664. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50665. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50666. *
  50667. * @returns whether or not the feature is compatible in this environment
  50668. */
  50669. isCompatible(): boolean;
  50670. /**
  50671. * This is used to register callbacks that will automatically be removed when detach is called.
  50672. * @param observable the observable to which the observer will be attached
  50673. * @param callback the callback to register
  50674. */
  50675. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50676. /**
  50677. * Code in this function will be executed on each xrFrame received from the browser.
  50678. * This function will not execute after the feature is detached.
  50679. * @param _xrFrame the current frame
  50680. */
  50681. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50682. }
  50683. }
  50684. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50685. import { IDisposable, Scene } from "babylonjs/scene";
  50686. import { Nullable } from "babylonjs/types";
  50687. import { Observable } from "babylonjs/Misc/observable";
  50688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50689. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50690. import { Camera } from "babylonjs/Cameras/camera";
  50691. /**
  50692. * Renders a layer on top of an existing scene
  50693. */
  50694. export class UtilityLayerRenderer implements IDisposable {
  50695. /** the original scene that will be rendered on top of */
  50696. originalScene: Scene;
  50697. private _pointerCaptures;
  50698. private _lastPointerEvents;
  50699. private static _DefaultUtilityLayer;
  50700. private static _DefaultKeepDepthUtilityLayer;
  50701. private _sharedGizmoLight;
  50702. private _renderCamera;
  50703. /**
  50704. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50705. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50706. * @returns the camera that is used when rendering the utility layer
  50707. */
  50708. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50709. /**
  50710. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50711. * @param cam the camera that should be used when rendering the utility layer
  50712. */
  50713. setRenderCamera(cam: Nullable<Camera>): void;
  50714. /**
  50715. * @hidden
  50716. * Light which used by gizmos to get light shading
  50717. */
  50718. _getSharedGizmoLight(): HemisphericLight;
  50719. /**
  50720. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50721. */
  50722. pickUtilitySceneFirst: boolean;
  50723. /**
  50724. * 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)
  50725. */
  50726. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50727. /**
  50728. * 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)
  50729. */
  50730. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50731. /**
  50732. * The scene that is rendered on top of the original scene
  50733. */
  50734. utilityLayerScene: Scene;
  50735. /**
  50736. * If the utility layer should automatically be rendered on top of existing scene
  50737. */
  50738. shouldRender: boolean;
  50739. /**
  50740. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50741. */
  50742. onlyCheckPointerDownEvents: boolean;
  50743. /**
  50744. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50745. */
  50746. processAllEvents: boolean;
  50747. /**
  50748. * Observable raised when the pointer move from the utility layer scene to the main scene
  50749. */
  50750. onPointerOutObservable: Observable<number>;
  50751. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50752. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50753. private _afterRenderObserver;
  50754. private _sceneDisposeObserver;
  50755. private _originalPointerObserver;
  50756. /**
  50757. * Instantiates a UtilityLayerRenderer
  50758. * @param originalScene the original scene that will be rendered on top of
  50759. * @param handleEvents boolean indicating if the utility layer should handle events
  50760. */
  50761. constructor(
  50762. /** the original scene that will be rendered on top of */
  50763. originalScene: Scene, handleEvents?: boolean);
  50764. private _notifyObservers;
  50765. /**
  50766. * Renders the utility layers scene on top of the original scene
  50767. */
  50768. render(): void;
  50769. /**
  50770. * Disposes of the renderer
  50771. */
  50772. dispose(): void;
  50773. private _updateCamera;
  50774. }
  50775. }
  50776. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50777. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50779. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50780. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50781. import { Scene } from "babylonjs/scene";
  50782. import { Nullable } from "babylonjs/types";
  50783. import { Color3 } from "babylonjs/Maths/math.color";
  50784. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50785. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50786. /**
  50787. * Options interface for the pointer selection module
  50788. */
  50789. export interface IWebXRControllerPointerSelectionOptions {
  50790. /**
  50791. * if provided, this scene will be used to render meshes.
  50792. */
  50793. customUtilityLayerScene?: Scene;
  50794. /**
  50795. * 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)
  50796. * If not disabled, the last picked point will be used to execute a pointer up event
  50797. * If disabled, pointer up event will be triggered right after the pointer down event.
  50798. * Used in screen and gaze target ray mode only
  50799. */
  50800. disablePointerUpOnTouchOut: boolean;
  50801. /**
  50802. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50803. */
  50804. forceGazeMode: boolean;
  50805. /**
  50806. * 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
  50807. * to start a new countdown to the pointer down event.
  50808. * Defaults to 1.
  50809. */
  50810. gazeModePointerMovedFactor?: number;
  50811. /**
  50812. * Different button type to use instead of the main component
  50813. */
  50814. overrideButtonId?: string;
  50815. /**
  50816. * use this rendering group id for the meshes (optional)
  50817. */
  50818. renderingGroupId?: number;
  50819. /**
  50820. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50821. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50822. * 3000 means 3 seconds between pointing at something and selecting it
  50823. */
  50824. timeToSelect?: number;
  50825. /**
  50826. * Should meshes created here be added to a utility layer or the main scene
  50827. */
  50828. useUtilityLayer?: boolean;
  50829. /**
  50830. * Optional WebXR camera to be used for gaze selection
  50831. */
  50832. gazeCamera?: WebXRCamera;
  50833. /**
  50834. * the xr input to use with this pointer selection
  50835. */
  50836. xrInput: WebXRInput;
  50837. }
  50838. /**
  50839. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50840. */
  50841. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50842. private readonly _options;
  50843. private static _idCounter;
  50844. private _attachController;
  50845. private _controllers;
  50846. private _scene;
  50847. private _tmpVectorForPickCompare;
  50848. /**
  50849. * The module's name
  50850. */
  50851. static readonly Name: string;
  50852. /**
  50853. * The (Babylon) version of this module.
  50854. * This is an integer representing the implementation version.
  50855. * This number does not correspond to the WebXR specs version
  50856. */
  50857. static readonly Version: number;
  50858. /**
  50859. * Disable lighting on the laser pointer (so it will always be visible)
  50860. */
  50861. disablePointerLighting: boolean;
  50862. /**
  50863. * Disable lighting on the selection mesh (so it will always be visible)
  50864. */
  50865. disableSelectionMeshLighting: boolean;
  50866. /**
  50867. * Should the laser pointer be displayed
  50868. */
  50869. displayLaserPointer: boolean;
  50870. /**
  50871. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50872. */
  50873. displaySelectionMesh: boolean;
  50874. /**
  50875. * This color will be set to the laser pointer when selection is triggered
  50876. */
  50877. laserPointerPickedColor: Color3;
  50878. /**
  50879. * Default color of the laser pointer
  50880. */
  50881. laserPointerDefaultColor: Color3;
  50882. /**
  50883. * default color of the selection ring
  50884. */
  50885. selectionMeshDefaultColor: Color3;
  50886. /**
  50887. * This color will be applied to the selection ring when selection is triggered
  50888. */
  50889. selectionMeshPickedColor: Color3;
  50890. /**
  50891. * Optional filter to be used for ray selection. This predicate shares behavior with
  50892. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50893. */
  50894. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50895. /**
  50896. * constructs a new background remover module
  50897. * @param _xrSessionManager the session manager for this module
  50898. * @param _options read-only options to be used in this module
  50899. */
  50900. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50901. /**
  50902. * attach this feature
  50903. * Will usually be called by the features manager
  50904. *
  50905. * @returns true if successful.
  50906. */
  50907. attach(): boolean;
  50908. /**
  50909. * detach this feature.
  50910. * Will usually be called by the features manager
  50911. *
  50912. * @returns true if successful.
  50913. */
  50914. detach(): boolean;
  50915. /**
  50916. * Will get the mesh under a specific pointer.
  50917. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50918. * @param controllerId the controllerId to check
  50919. * @returns The mesh under pointer or null if no mesh is under the pointer
  50920. */
  50921. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50922. /**
  50923. * Get the xr controller that correlates to the pointer id in the pointer event
  50924. *
  50925. * @param id the pointer id to search for
  50926. * @returns the controller that correlates to this id or null if not found
  50927. */
  50928. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50929. protected _onXRFrame(_xrFrame: XRFrame): void;
  50930. private _attachGazeMode;
  50931. private _attachScreenRayMode;
  50932. private _attachTrackedPointerRayMode;
  50933. private _convertNormalToDirectionOfRay;
  50934. private _detachController;
  50935. private _generateNewMeshPair;
  50936. private _pickingMoved;
  50937. private _updatePointerDistance;
  50938. /** @hidden */
  50939. get lasterPointerDefaultColor(): Color3;
  50940. }
  50941. }
  50942. declare module "babylonjs/XR/webXREnterExitUI" {
  50943. import { Nullable } from "babylonjs/types";
  50944. import { Observable } from "babylonjs/Misc/observable";
  50945. import { IDisposable, Scene } from "babylonjs/scene";
  50946. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50947. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50948. /**
  50949. * Button which can be used to enter a different mode of XR
  50950. */
  50951. export class WebXREnterExitUIButton {
  50952. /** button element */
  50953. element: HTMLElement;
  50954. /** XR initialization options for the button */
  50955. sessionMode: XRSessionMode;
  50956. /** Reference space type */
  50957. referenceSpaceType: XRReferenceSpaceType;
  50958. /**
  50959. * Creates a WebXREnterExitUIButton
  50960. * @param element button element
  50961. * @param sessionMode XR initialization session mode
  50962. * @param referenceSpaceType the type of reference space to be used
  50963. */
  50964. constructor(
  50965. /** button element */
  50966. element: HTMLElement,
  50967. /** XR initialization options for the button */
  50968. sessionMode: XRSessionMode,
  50969. /** Reference space type */
  50970. referenceSpaceType: XRReferenceSpaceType);
  50971. /**
  50972. * Extendable function which can be used to update the button's visuals when the state changes
  50973. * @param activeButton the current active button in the UI
  50974. */
  50975. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50976. }
  50977. /**
  50978. * Options to create the webXR UI
  50979. */
  50980. export class WebXREnterExitUIOptions {
  50981. /**
  50982. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50983. */
  50984. customButtons?: Array<WebXREnterExitUIButton>;
  50985. /**
  50986. * A reference space type to use when creating the default button.
  50987. * Default is local-floor
  50988. */
  50989. referenceSpaceType?: XRReferenceSpaceType;
  50990. /**
  50991. * Context to enter xr with
  50992. */
  50993. renderTarget?: Nullable<WebXRRenderTarget>;
  50994. /**
  50995. * A session mode to use when creating the default button.
  50996. * Default is immersive-vr
  50997. */
  50998. sessionMode?: XRSessionMode;
  50999. /**
  51000. * A list of optional features to init the session with
  51001. */
  51002. optionalFeatures?: string[];
  51003. /**
  51004. * A list of optional features to init the session with
  51005. */
  51006. requiredFeatures?: string[];
  51007. }
  51008. /**
  51009. * UI to allow the user to enter/exit XR mode
  51010. */
  51011. export class WebXREnterExitUI implements IDisposable {
  51012. private scene;
  51013. /** version of the options passed to this UI */
  51014. options: WebXREnterExitUIOptions;
  51015. private _activeButton;
  51016. private _buttons;
  51017. /**
  51018. * The HTML Div Element to which buttons are added.
  51019. */
  51020. readonly overlay: HTMLDivElement;
  51021. /**
  51022. * Fired every time the active button is changed.
  51023. *
  51024. * When xr is entered via a button that launches xr that button will be the callback parameter
  51025. *
  51026. * When exiting xr the callback parameter will be null)
  51027. */
  51028. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  51029. /**
  51030. *
  51031. * @param scene babylon scene object to use
  51032. * @param options (read-only) version of the options passed to this UI
  51033. */
  51034. private constructor();
  51035. /**
  51036. * Creates UI to allow the user to enter/exit XR mode
  51037. * @param scene the scene to add the ui to
  51038. * @param helper the xr experience helper to enter/exit xr with
  51039. * @param options options to configure the UI
  51040. * @returns the created ui
  51041. */
  51042. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  51043. /**
  51044. * Disposes of the XR UI component
  51045. */
  51046. dispose(): void;
  51047. private _updateButtons;
  51048. }
  51049. }
  51050. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  51051. import { Vector3 } from "babylonjs/Maths/math.vector";
  51052. import { Color4 } from "babylonjs/Maths/math.color";
  51053. import { Nullable } from "babylonjs/types";
  51054. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51055. import { Scene } from "babylonjs/scene";
  51056. /**
  51057. * Class containing static functions to help procedurally build meshes
  51058. */
  51059. export class LinesBuilder {
  51060. /**
  51061. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51062. * * 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
  51063. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51064. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51065. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51066. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51067. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51068. * * 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
  51069. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51072. * @param name defines the name of the new line system
  51073. * @param options defines the options used to create the line system
  51074. * @param scene defines the hosting scene
  51075. * @returns a new line system mesh
  51076. */
  51077. static CreateLineSystem(name: string, options: {
  51078. lines: Vector3[][];
  51079. updatable?: boolean;
  51080. instance?: Nullable<LinesMesh>;
  51081. colors?: Nullable<Color4[][]>;
  51082. useVertexAlpha?: boolean;
  51083. }, scene: Nullable<Scene>): LinesMesh;
  51084. /**
  51085. * Creates a line mesh
  51086. * 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
  51087. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51088. * * The parameter `points` is an array successive Vector3
  51089. * * 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
  51090. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51091. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51092. * * When updating an instance, remember that only point positions can change, not the number of points
  51093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51095. * @param name defines the name of the new line system
  51096. * @param options defines the options used to create the line system
  51097. * @param scene defines the hosting scene
  51098. * @returns a new line mesh
  51099. */
  51100. static CreateLines(name: string, options: {
  51101. points: Vector3[];
  51102. updatable?: boolean;
  51103. instance?: Nullable<LinesMesh>;
  51104. colors?: Color4[];
  51105. useVertexAlpha?: boolean;
  51106. }, scene?: Nullable<Scene>): LinesMesh;
  51107. /**
  51108. * Creates a dashed line mesh
  51109. * * 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
  51110. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51111. * * The parameter `points` is an array successive Vector3
  51112. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51113. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51114. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51115. * * 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
  51116. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51117. * * When updating an instance, remember that only point positions can change, not the number of points
  51118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51119. * @param name defines the name of the mesh
  51120. * @param options defines the options used to create the mesh
  51121. * @param scene defines the hosting scene
  51122. * @returns the dashed line mesh
  51123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51124. */
  51125. static CreateDashedLines(name: string, options: {
  51126. points: Vector3[];
  51127. dashSize?: number;
  51128. gapSize?: number;
  51129. dashNb?: number;
  51130. updatable?: boolean;
  51131. instance?: LinesMesh;
  51132. useVertexAlpha?: boolean;
  51133. }, scene?: Nullable<Scene>): LinesMesh;
  51134. }
  51135. }
  51136. declare module "babylonjs/Misc/timer" {
  51137. import { Observable, Observer } from "babylonjs/Misc/observable";
  51138. import { Nullable } from "babylonjs/types";
  51139. import { IDisposable } from "babylonjs/scene";
  51140. /**
  51141. * Construction options for a timer
  51142. */
  51143. export interface ITimerOptions<T> {
  51144. /**
  51145. * Time-to-end
  51146. */
  51147. timeout: number;
  51148. /**
  51149. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51150. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51151. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51152. */
  51153. contextObservable: Observable<T>;
  51154. /**
  51155. * Optional parameters when adding an observer to the observable
  51156. */
  51157. observableParameters?: {
  51158. mask?: number;
  51159. insertFirst?: boolean;
  51160. scope?: any;
  51161. };
  51162. /**
  51163. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51164. */
  51165. breakCondition?: (data?: ITimerData<T>) => boolean;
  51166. /**
  51167. * Will be triggered when the time condition has met
  51168. */
  51169. onEnded?: (data: ITimerData<any>) => void;
  51170. /**
  51171. * Will be triggered when the break condition has met (prematurely ended)
  51172. */
  51173. onAborted?: (data: ITimerData<any>) => void;
  51174. /**
  51175. * Optional function to execute on each tick (or count)
  51176. */
  51177. onTick?: (data: ITimerData<any>) => void;
  51178. }
  51179. /**
  51180. * An interface defining the data sent by the timer
  51181. */
  51182. export interface ITimerData<T> {
  51183. /**
  51184. * When did it start
  51185. */
  51186. startTime: number;
  51187. /**
  51188. * Time now
  51189. */
  51190. currentTime: number;
  51191. /**
  51192. * Time passed since started
  51193. */
  51194. deltaTime: number;
  51195. /**
  51196. * How much is completed, in [0.0...1.0].
  51197. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51198. */
  51199. completeRate: number;
  51200. /**
  51201. * What the registered observable sent in the last count
  51202. */
  51203. payload: T;
  51204. }
  51205. /**
  51206. * The current state of the timer
  51207. */
  51208. export enum TimerState {
  51209. /**
  51210. * Timer initialized, not yet started
  51211. */
  51212. INIT = 0,
  51213. /**
  51214. * Timer started and counting
  51215. */
  51216. STARTED = 1,
  51217. /**
  51218. * Timer ended (whether aborted or time reached)
  51219. */
  51220. ENDED = 2
  51221. }
  51222. /**
  51223. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51224. *
  51225. * @param options options with which to initialize this timer
  51226. */
  51227. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51228. /**
  51229. * An advanced implementation of a timer class
  51230. */
  51231. export class AdvancedTimer<T = any> implements IDisposable {
  51232. /**
  51233. * Will notify each time the timer calculates the remaining time
  51234. */
  51235. onEachCountObservable: Observable<ITimerData<T>>;
  51236. /**
  51237. * Will trigger when the timer was aborted due to the break condition
  51238. */
  51239. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51240. /**
  51241. * Will trigger when the timer ended successfully
  51242. */
  51243. onTimerEndedObservable: Observable<ITimerData<T>>;
  51244. /**
  51245. * Will trigger when the timer state has changed
  51246. */
  51247. onStateChangedObservable: Observable<TimerState>;
  51248. private _observer;
  51249. private _contextObservable;
  51250. private _observableParameters;
  51251. private _startTime;
  51252. private _timer;
  51253. private _state;
  51254. private _breakCondition;
  51255. private _timeToEnd;
  51256. private _breakOnNextTick;
  51257. /**
  51258. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51259. * @param options construction options for this advanced timer
  51260. */
  51261. constructor(options: ITimerOptions<T>);
  51262. /**
  51263. * set a breaking condition for this timer. Default is to never break during count
  51264. * @param predicate the new break condition. Returns true to break, false otherwise
  51265. */
  51266. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51267. /**
  51268. * Reset ALL associated observables in this advanced timer
  51269. */
  51270. clearObservables(): void;
  51271. /**
  51272. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51273. *
  51274. * @param timeToEnd how much time to measure until timer ended
  51275. */
  51276. start(timeToEnd?: number): void;
  51277. /**
  51278. * Will force a stop on the next tick.
  51279. */
  51280. stop(): void;
  51281. /**
  51282. * Dispose this timer, clearing all resources
  51283. */
  51284. dispose(): void;
  51285. private _setState;
  51286. private _tick;
  51287. private _stop;
  51288. }
  51289. }
  51290. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51291. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51292. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51293. import { Nullable } from "babylonjs/types";
  51294. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51296. import { Vector3 } from "babylonjs/Maths/math.vector";
  51297. import { Material } from "babylonjs/Materials/material";
  51298. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51299. import { Scene } from "babylonjs/scene";
  51300. /**
  51301. * The options container for the teleportation module
  51302. */
  51303. export interface IWebXRTeleportationOptions {
  51304. /**
  51305. * if provided, this scene will be used to render meshes.
  51306. */
  51307. customUtilityLayerScene?: Scene;
  51308. /**
  51309. * Values to configure the default target mesh
  51310. */
  51311. defaultTargetMeshOptions?: {
  51312. /**
  51313. * Fill color of the teleportation area
  51314. */
  51315. teleportationFillColor?: string;
  51316. /**
  51317. * Border color for the teleportation area
  51318. */
  51319. teleportationBorderColor?: string;
  51320. /**
  51321. * Disable the mesh's animation sequence
  51322. */
  51323. disableAnimation?: boolean;
  51324. /**
  51325. * Disable lighting on the material or the ring and arrow
  51326. */
  51327. disableLighting?: boolean;
  51328. /**
  51329. * Override the default material of the torus and arrow
  51330. */
  51331. torusArrowMaterial?: Material;
  51332. };
  51333. /**
  51334. * A list of meshes to use as floor meshes.
  51335. * Meshes can be added and removed after initializing the feature using the
  51336. * addFloorMesh and removeFloorMesh functions
  51337. * If empty, rotation will still work
  51338. */
  51339. floorMeshes?: AbstractMesh[];
  51340. /**
  51341. * use this rendering group id for the meshes (optional)
  51342. */
  51343. renderingGroupId?: number;
  51344. /**
  51345. * Should teleportation move only to snap points
  51346. */
  51347. snapPointsOnly?: boolean;
  51348. /**
  51349. * An array of points to which the teleportation will snap to.
  51350. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51351. */
  51352. snapPositions?: Vector3[];
  51353. /**
  51354. * How close should the teleportation ray be in order to snap to position.
  51355. * Default to 0.8 units (meters)
  51356. */
  51357. snapToPositionRadius?: number;
  51358. /**
  51359. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51360. * If you want to support rotation, make sure your mesh has a direction indicator.
  51361. *
  51362. * When left untouched, the default mesh will be initialized.
  51363. */
  51364. teleportationTargetMesh?: AbstractMesh;
  51365. /**
  51366. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51367. */
  51368. timeToTeleport?: number;
  51369. /**
  51370. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51371. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51372. */
  51373. useMainComponentOnly?: boolean;
  51374. /**
  51375. * Should meshes created here be added to a utility layer or the main scene
  51376. */
  51377. useUtilityLayer?: boolean;
  51378. /**
  51379. * Babylon XR Input class for controller
  51380. */
  51381. xrInput: WebXRInput;
  51382. /**
  51383. * Meshes that the teleportation ray cannot go through
  51384. */
  51385. pickBlockerMeshes?: AbstractMesh[];
  51386. }
  51387. /**
  51388. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51389. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51390. * the input of the attached controllers.
  51391. */
  51392. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51393. private _options;
  51394. private _controllers;
  51395. private _currentTeleportationControllerId;
  51396. private _floorMeshes;
  51397. private _quadraticBezierCurve;
  51398. private _selectionFeature;
  51399. private _snapToPositions;
  51400. private _snappedToPoint;
  51401. private _teleportationRingMaterial?;
  51402. private _tmpRay;
  51403. private _tmpVector;
  51404. private _tmpQuaternion;
  51405. /**
  51406. * The module's name
  51407. */
  51408. static readonly Name: string;
  51409. /**
  51410. * The (Babylon) version of this module.
  51411. * This is an integer representing the implementation version.
  51412. * This number does not correspond to the webxr specs version
  51413. */
  51414. static readonly Version: number;
  51415. /**
  51416. * Is movement backwards enabled
  51417. */
  51418. backwardsMovementEnabled: boolean;
  51419. /**
  51420. * Distance to travel when moving backwards
  51421. */
  51422. backwardsTeleportationDistance: number;
  51423. /**
  51424. * The distance from the user to the inspection point in the direction of the controller
  51425. * A higher number will allow the user to move further
  51426. * defaults to 5 (meters, in xr units)
  51427. */
  51428. parabolicCheckRadius: number;
  51429. /**
  51430. * Should the module support parabolic ray on top of direct ray
  51431. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51432. * Very helpful when moving between floors / different heights
  51433. */
  51434. parabolicRayEnabled: boolean;
  51435. /**
  51436. * How much rotation should be applied when rotating right and left
  51437. */
  51438. rotationAngle: number;
  51439. /**
  51440. * Is rotation enabled when moving forward?
  51441. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51442. */
  51443. rotationEnabled: boolean;
  51444. /**
  51445. * constructs a new anchor system
  51446. * @param _xrSessionManager an instance of WebXRSessionManager
  51447. * @param _options configuration object for this feature
  51448. */
  51449. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51450. /**
  51451. * Get the snapPointsOnly flag
  51452. */
  51453. get snapPointsOnly(): boolean;
  51454. /**
  51455. * Sets the snapPointsOnly flag
  51456. * @param snapToPoints should teleportation be exclusively to snap points
  51457. */
  51458. set snapPointsOnly(snapToPoints: boolean);
  51459. /**
  51460. * Add a new mesh to the floor meshes array
  51461. * @param mesh the mesh to use as floor mesh
  51462. */
  51463. addFloorMesh(mesh: AbstractMesh): void;
  51464. /**
  51465. * Add a new snap-to point to fix teleportation to this position
  51466. * @param newSnapPoint The new Snap-To point
  51467. */
  51468. addSnapPoint(newSnapPoint: Vector3): void;
  51469. attach(): boolean;
  51470. detach(): boolean;
  51471. dispose(): void;
  51472. /**
  51473. * Remove a mesh from the floor meshes array
  51474. * @param mesh the mesh to remove
  51475. */
  51476. removeFloorMesh(mesh: AbstractMesh): void;
  51477. /**
  51478. * Remove a mesh from the floor meshes array using its name
  51479. * @param name the mesh name to remove
  51480. */
  51481. removeFloorMeshByName(name: string): void;
  51482. /**
  51483. * 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
  51484. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51485. * @returns was the point found and removed or not
  51486. */
  51487. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51488. /**
  51489. * This function sets a selection feature that will be disabled when
  51490. * the forward ray is shown and will be reattached when hidden.
  51491. * This is used to remove the selection rays when moving.
  51492. * @param selectionFeature the feature to disable when forward movement is enabled
  51493. */
  51494. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51495. protected _onXRFrame(_xrFrame: XRFrame): void;
  51496. private _attachController;
  51497. private _createDefaultTargetMesh;
  51498. private _detachController;
  51499. private _findClosestSnapPointWithRadius;
  51500. private _setTargetMeshPosition;
  51501. private _setTargetMeshVisibility;
  51502. private _showParabolicPath;
  51503. private _teleportForward;
  51504. }
  51505. }
  51506. declare module "babylonjs/XR/webXRDefaultExperience" {
  51507. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51508. import { Scene } from "babylonjs/scene";
  51509. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51510. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51511. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51512. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51514. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51515. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51516. /**
  51517. * Options for the default xr helper
  51518. */
  51519. export class WebXRDefaultExperienceOptions {
  51520. /**
  51521. * Enable or disable default UI to enter XR
  51522. */
  51523. disableDefaultUI?: boolean;
  51524. /**
  51525. * Should teleportation not initialize. defaults to false.
  51526. */
  51527. disableTeleportation?: boolean;
  51528. /**
  51529. * Floor meshes that will be used for teleport
  51530. */
  51531. floorMeshes?: Array<AbstractMesh>;
  51532. /**
  51533. * If set to true, the first frame will not be used to reset position
  51534. * The first frame is mainly used when copying transformation from the old camera
  51535. * Mainly used in AR
  51536. */
  51537. ignoreNativeCameraTransformation?: boolean;
  51538. /**
  51539. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51540. */
  51541. inputOptions?: IWebXRInputOptions;
  51542. /**
  51543. * optional configuration for the output canvas
  51544. */
  51545. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51546. /**
  51547. * optional UI options. This can be used among other to change session mode and reference space type
  51548. */
  51549. uiOptions?: WebXREnterExitUIOptions;
  51550. /**
  51551. * When loading teleportation and pointer select, use stable versions instead of latest.
  51552. */
  51553. useStablePlugins?: boolean;
  51554. /**
  51555. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51556. */
  51557. renderingGroupId?: number;
  51558. /**
  51559. * A list of optional features to init the session with
  51560. * If set to true, all features we support will be added
  51561. */
  51562. optionalFeatures?: boolean | string[];
  51563. }
  51564. /**
  51565. * Default experience which provides a similar setup to the previous webVRExperience
  51566. */
  51567. export class WebXRDefaultExperience {
  51568. /**
  51569. * Base experience
  51570. */
  51571. baseExperience: WebXRExperienceHelper;
  51572. /**
  51573. * Enables ui for entering/exiting xr
  51574. */
  51575. enterExitUI: WebXREnterExitUI;
  51576. /**
  51577. * Input experience extension
  51578. */
  51579. input: WebXRInput;
  51580. /**
  51581. * Enables laser pointer and selection
  51582. */
  51583. pointerSelection: WebXRControllerPointerSelection;
  51584. /**
  51585. * Default target xr should render to
  51586. */
  51587. renderTarget: WebXRRenderTarget;
  51588. /**
  51589. * Enables teleportation
  51590. */
  51591. teleportation: WebXRMotionControllerTeleportation;
  51592. private constructor();
  51593. /**
  51594. * Creates the default xr experience
  51595. * @param scene scene
  51596. * @param options options for basic configuration
  51597. * @returns resulting WebXRDefaultExperience
  51598. */
  51599. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51600. /**
  51601. * DIsposes of the experience helper
  51602. */
  51603. dispose(): void;
  51604. }
  51605. }
  51606. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51607. import { Observable } from "babylonjs/Misc/observable";
  51608. import { Nullable } from "babylonjs/types";
  51609. import { Camera } from "babylonjs/Cameras/camera";
  51610. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51611. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51612. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51613. import { Scene } from "babylonjs/scene";
  51614. import { Vector3 } from "babylonjs/Maths/math.vector";
  51615. import { Color3 } from "babylonjs/Maths/math.color";
  51616. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51618. import { Mesh } from "babylonjs/Meshes/mesh";
  51619. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51620. import { EasingFunction } from "babylonjs/Animations/easing";
  51621. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51622. import "babylonjs/Meshes/Builders/groundBuilder";
  51623. import "babylonjs/Meshes/Builders/torusBuilder";
  51624. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51625. import "babylonjs/Gamepads/gamepadSceneComponent";
  51626. import "babylonjs/Animations/animatable";
  51627. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51628. /**
  51629. * Options to modify the vr teleportation behavior.
  51630. */
  51631. export interface VRTeleportationOptions {
  51632. /**
  51633. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51634. */
  51635. floorMeshName?: string;
  51636. /**
  51637. * A list of meshes to be used as the teleportation floor. (default: empty)
  51638. */
  51639. floorMeshes?: Mesh[];
  51640. /**
  51641. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51642. */
  51643. teleportationMode?: number;
  51644. /**
  51645. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51646. */
  51647. teleportationTime?: number;
  51648. /**
  51649. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51650. */
  51651. teleportationSpeed?: number;
  51652. /**
  51653. * The easing function used in the animation or null for Linear. (default CircleEase)
  51654. */
  51655. easingFunction?: EasingFunction;
  51656. }
  51657. /**
  51658. * Options to modify the vr experience helper's behavior.
  51659. */
  51660. export interface VRExperienceHelperOptions extends WebVROptions {
  51661. /**
  51662. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51663. */
  51664. createDeviceOrientationCamera?: boolean;
  51665. /**
  51666. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51667. */
  51668. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51669. /**
  51670. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51671. */
  51672. laserToggle?: boolean;
  51673. /**
  51674. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51675. */
  51676. floorMeshes?: Mesh[];
  51677. /**
  51678. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51679. */
  51680. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51681. /**
  51682. * Defines if WebXR should be used instead of WebVR (if available)
  51683. */
  51684. useXR?: boolean;
  51685. }
  51686. /**
  51687. * Event containing information after VR has been entered
  51688. */
  51689. export class OnAfterEnteringVRObservableEvent {
  51690. /**
  51691. * If entering vr was successful
  51692. */
  51693. success: boolean;
  51694. }
  51695. /**
  51696. * Helps to quickly add VR support to an existing scene.
  51697. * See https://doc.babylonjs.com/how_to/webvr_helper
  51698. */
  51699. export class VRExperienceHelper {
  51700. /** Options to modify the vr experience helper's behavior. */
  51701. webVROptions: VRExperienceHelperOptions;
  51702. private _scene;
  51703. private _position;
  51704. private _btnVR;
  51705. private _btnVRDisplayed;
  51706. private _webVRsupported;
  51707. private _webVRready;
  51708. private _webVRrequesting;
  51709. private _webVRpresenting;
  51710. private _hasEnteredVR;
  51711. private _fullscreenVRpresenting;
  51712. private _inputElement;
  51713. private _webVRCamera;
  51714. private _vrDeviceOrientationCamera;
  51715. private _deviceOrientationCamera;
  51716. private _existingCamera;
  51717. private _onKeyDown;
  51718. private _onVrDisplayPresentChange;
  51719. private _onVRDisplayChanged;
  51720. private _onVRRequestPresentStart;
  51721. private _onVRRequestPresentComplete;
  51722. /**
  51723. * 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)
  51724. */
  51725. enableGazeEvenWhenNoPointerLock: boolean;
  51726. /**
  51727. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51728. */
  51729. exitVROnDoubleTap: boolean;
  51730. /**
  51731. * Observable raised right before entering VR.
  51732. */
  51733. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51734. /**
  51735. * Observable raised when entering VR has completed.
  51736. */
  51737. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51738. /**
  51739. * Observable raised when exiting VR.
  51740. */
  51741. onExitingVRObservable: Observable<VRExperienceHelper>;
  51742. /**
  51743. * Observable raised when controller mesh is loaded.
  51744. */
  51745. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51746. /** Return this.onEnteringVRObservable
  51747. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51748. */
  51749. get onEnteringVR(): Observable<VRExperienceHelper>;
  51750. /** Return this.onExitingVRObservable
  51751. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51752. */
  51753. get onExitingVR(): Observable<VRExperienceHelper>;
  51754. /** Return this.onControllerMeshLoadedObservable
  51755. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51756. */
  51757. get onControllerMeshLoaded(): Observable<WebVRController>;
  51758. private _rayLength;
  51759. private _useCustomVRButton;
  51760. private _teleportationRequested;
  51761. private _teleportActive;
  51762. private _floorMeshName;
  51763. private _floorMeshesCollection;
  51764. private _teleportationMode;
  51765. private _teleportationTime;
  51766. private _teleportationSpeed;
  51767. private _teleportationEasing;
  51768. private _rotationAllowed;
  51769. private _teleportBackwardsVector;
  51770. private _teleportationTarget;
  51771. private _isDefaultTeleportationTarget;
  51772. private _postProcessMove;
  51773. private _teleportationFillColor;
  51774. private _teleportationBorderColor;
  51775. private _rotationAngle;
  51776. private _haloCenter;
  51777. private _cameraGazer;
  51778. private _padSensibilityUp;
  51779. private _padSensibilityDown;
  51780. private _leftController;
  51781. private _rightController;
  51782. private _gazeColor;
  51783. private _laserColor;
  51784. private _pickedLaserColor;
  51785. private _pickedGazeColor;
  51786. /**
  51787. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51788. */
  51789. onNewMeshSelected: Observable<AbstractMesh>;
  51790. /**
  51791. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51792. * This observable will provide the mesh and the controller used to select the mesh
  51793. */
  51794. onMeshSelectedWithController: Observable<{
  51795. mesh: AbstractMesh;
  51796. controller: WebVRController;
  51797. }>;
  51798. /**
  51799. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51800. */
  51801. onNewMeshPicked: Observable<PickingInfo>;
  51802. private _circleEase;
  51803. /**
  51804. * Observable raised before camera teleportation
  51805. */
  51806. onBeforeCameraTeleport: Observable<Vector3>;
  51807. /**
  51808. * Observable raised after camera teleportation
  51809. */
  51810. onAfterCameraTeleport: Observable<Vector3>;
  51811. /**
  51812. * Observable raised when current selected mesh gets unselected
  51813. */
  51814. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51815. private _raySelectionPredicate;
  51816. /**
  51817. * To be optionaly changed by user to define custom ray selection
  51818. */
  51819. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51820. /**
  51821. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51822. */
  51823. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51824. /**
  51825. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51826. */
  51827. teleportationEnabled: boolean;
  51828. private _defaultHeight;
  51829. private _teleportationInitialized;
  51830. private _interactionsEnabled;
  51831. private _interactionsRequested;
  51832. private _displayGaze;
  51833. private _displayLaserPointer;
  51834. /**
  51835. * The mesh used to display where the user is going to teleport.
  51836. */
  51837. get teleportationTarget(): Mesh;
  51838. /**
  51839. * Sets the mesh to be used to display where the user is going to teleport.
  51840. */
  51841. set teleportationTarget(value: Mesh);
  51842. /**
  51843. * 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
  51844. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51845. * See https://doc.babylonjs.com/resources/baking_transformations
  51846. */
  51847. get gazeTrackerMesh(): Mesh;
  51848. set gazeTrackerMesh(value: Mesh);
  51849. /**
  51850. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51851. */
  51852. updateGazeTrackerScale: boolean;
  51853. /**
  51854. * If the gaze trackers color should be updated when selecting meshes
  51855. */
  51856. updateGazeTrackerColor: boolean;
  51857. /**
  51858. * If the controller laser color should be updated when selecting meshes
  51859. */
  51860. updateControllerLaserColor: boolean;
  51861. /**
  51862. * The gaze tracking mesh corresponding to the left controller
  51863. */
  51864. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51865. /**
  51866. * The gaze tracking mesh corresponding to the right controller
  51867. */
  51868. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51869. /**
  51870. * If the ray of the gaze should be displayed.
  51871. */
  51872. get displayGaze(): boolean;
  51873. /**
  51874. * Sets if the ray of the gaze should be displayed.
  51875. */
  51876. set displayGaze(value: boolean);
  51877. /**
  51878. * If the ray of the LaserPointer should be displayed.
  51879. */
  51880. get displayLaserPointer(): boolean;
  51881. /**
  51882. * Sets if the ray of the LaserPointer should be displayed.
  51883. */
  51884. set displayLaserPointer(value: boolean);
  51885. /**
  51886. * The deviceOrientationCamera used as the camera when not in VR.
  51887. */
  51888. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51889. /**
  51890. * Based on the current WebVR support, returns the current VR camera used.
  51891. */
  51892. get currentVRCamera(): Nullable<Camera>;
  51893. /**
  51894. * The webVRCamera which is used when in VR.
  51895. */
  51896. get webVRCamera(): WebVRFreeCamera;
  51897. /**
  51898. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51899. */
  51900. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51901. /**
  51902. * The html button that is used to trigger entering into VR.
  51903. */
  51904. get vrButton(): Nullable<HTMLButtonElement>;
  51905. private get _teleportationRequestInitiated();
  51906. /**
  51907. * Defines whether or not Pointer lock should be requested when switching to
  51908. * full screen.
  51909. */
  51910. requestPointerLockOnFullScreen: boolean;
  51911. /**
  51912. * If asking to force XR, this will be populated with the default xr experience
  51913. */
  51914. xr: WebXRDefaultExperience;
  51915. /**
  51916. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51917. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51918. */
  51919. xrTestDone: boolean;
  51920. /**
  51921. * Instantiates a VRExperienceHelper.
  51922. * Helps to quickly add VR support to an existing scene.
  51923. * @param scene The scene the VRExperienceHelper belongs to.
  51924. * @param webVROptions Options to modify the vr experience helper's behavior.
  51925. */
  51926. constructor(scene: Scene,
  51927. /** Options to modify the vr experience helper's behavior. */
  51928. webVROptions?: VRExperienceHelperOptions);
  51929. private completeVRInit;
  51930. private _onDefaultMeshLoaded;
  51931. private _onResize;
  51932. private _onFullscreenChange;
  51933. /**
  51934. * Gets a value indicating if we are currently in VR mode.
  51935. */
  51936. get isInVRMode(): boolean;
  51937. private onVrDisplayPresentChange;
  51938. private onVRDisplayChanged;
  51939. private moveButtonToBottomRight;
  51940. private displayVRButton;
  51941. private updateButtonVisibility;
  51942. private _cachedAngularSensibility;
  51943. /**
  51944. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51945. * Otherwise, will use the fullscreen API.
  51946. */
  51947. enterVR(): void;
  51948. /**
  51949. * Attempt to exit VR, or fullscreen.
  51950. */
  51951. exitVR(): void;
  51952. /**
  51953. * The position of the vr experience helper.
  51954. */
  51955. get position(): Vector3;
  51956. /**
  51957. * Sets the position of the vr experience helper.
  51958. */
  51959. set position(value: Vector3);
  51960. /**
  51961. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51962. */
  51963. enableInteractions(): void;
  51964. private get _noControllerIsActive();
  51965. private beforeRender;
  51966. private _isTeleportationFloor;
  51967. /**
  51968. * Adds a floor mesh to be used for teleportation.
  51969. * @param floorMesh the mesh to be used for teleportation.
  51970. */
  51971. addFloorMesh(floorMesh: Mesh): void;
  51972. /**
  51973. * Removes a floor mesh from being used for teleportation.
  51974. * @param floorMesh the mesh to be removed.
  51975. */
  51976. removeFloorMesh(floorMesh: Mesh): void;
  51977. /**
  51978. * Enables interactions and teleportation using the VR controllers and gaze.
  51979. * @param vrTeleportationOptions options to modify teleportation behavior.
  51980. */
  51981. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51982. private _onNewGamepadConnected;
  51983. private _tryEnableInteractionOnController;
  51984. private _onNewGamepadDisconnected;
  51985. private _enableInteractionOnController;
  51986. private _checkTeleportWithRay;
  51987. private _checkRotate;
  51988. private _checkTeleportBackwards;
  51989. private _enableTeleportationOnController;
  51990. private _createTeleportationCircles;
  51991. private _displayTeleportationTarget;
  51992. private _hideTeleportationTarget;
  51993. private _rotateCamera;
  51994. private _moveTeleportationSelectorTo;
  51995. private _workingVector;
  51996. private _workingQuaternion;
  51997. private _workingMatrix;
  51998. /**
  51999. * Time Constant Teleportation Mode
  52000. */
  52001. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52002. /**
  52003. * Speed Constant Teleportation Mode
  52004. */
  52005. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52006. /**
  52007. * Teleports the users feet to the desired location
  52008. * @param location The location where the user's feet should be placed
  52009. */
  52010. teleportCamera(location: Vector3): void;
  52011. private _convertNormalToDirectionOfRay;
  52012. private _castRayAndSelectObject;
  52013. private _notifySelectedMeshUnselected;
  52014. /**
  52015. * Permanently set new colors for the laser pointer
  52016. * @param color the new laser color
  52017. * @param pickedColor the new laser color when picked mesh detected
  52018. */
  52019. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52020. /**
  52021. * Set lighting enabled / disabled on the laser pointer of both controllers
  52022. * @param enabled should the lighting be enabled on the laser pointer
  52023. */
  52024. setLaserLightingState(enabled?: boolean): void;
  52025. /**
  52026. * Permanently set new colors for the gaze pointer
  52027. * @param color the new gaze color
  52028. * @param pickedColor the new gaze color when picked mesh detected
  52029. */
  52030. setGazeColor(color: Color3, pickedColor?: Color3): void;
  52031. /**
  52032. * Sets the color of the laser ray from the vr controllers.
  52033. * @param color new color for the ray.
  52034. */
  52035. changeLaserColor(color: Color3): void;
  52036. /**
  52037. * Sets the color of the ray from the vr headsets gaze.
  52038. * @param color new color for the ray.
  52039. */
  52040. changeGazeColor(color: Color3): void;
  52041. /**
  52042. * Exits VR and disposes of the vr experience helper
  52043. */
  52044. dispose(): void;
  52045. /**
  52046. * Gets the name of the VRExperienceHelper class
  52047. * @returns "VRExperienceHelper"
  52048. */
  52049. getClassName(): string;
  52050. }
  52051. }
  52052. declare module "babylonjs/Cameras/VR/index" {
  52053. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  52054. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  52055. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52056. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  52057. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  52058. export * from "babylonjs/Cameras/VR/webVRCamera";
  52059. }
  52060. declare module "babylonjs/Cameras/RigModes/index" {
  52061. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  52062. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  52063. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  52064. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  52065. }
  52066. declare module "babylonjs/Cameras/index" {
  52067. export * from "babylonjs/Cameras/Inputs/index";
  52068. export * from "babylonjs/Cameras/cameraInputsManager";
  52069. export * from "babylonjs/Cameras/camera";
  52070. export * from "babylonjs/Cameras/targetCamera";
  52071. export * from "babylonjs/Cameras/freeCamera";
  52072. export * from "babylonjs/Cameras/freeCameraInputsManager";
  52073. export * from "babylonjs/Cameras/touchCamera";
  52074. export * from "babylonjs/Cameras/arcRotateCamera";
  52075. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  52076. export * from "babylonjs/Cameras/deviceOrientationCamera";
  52077. export * from "babylonjs/Cameras/flyCamera";
  52078. export * from "babylonjs/Cameras/flyCameraInputsManager";
  52079. export * from "babylonjs/Cameras/followCamera";
  52080. export * from "babylonjs/Cameras/followCameraInputsManager";
  52081. export * from "babylonjs/Cameras/gamepadCamera";
  52082. export * from "babylonjs/Cameras/Stereoscopic/index";
  52083. export * from "babylonjs/Cameras/universalCamera";
  52084. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  52085. export * from "babylonjs/Cameras/VR/index";
  52086. export * from "babylonjs/Cameras/RigModes/index";
  52087. }
  52088. declare module "babylonjs/Collisions/index" {
  52089. export * from "babylonjs/Collisions/collider";
  52090. export * from "babylonjs/Collisions/collisionCoordinator";
  52091. export * from "babylonjs/Collisions/pickingInfo";
  52092. export * from "babylonjs/Collisions/intersectionInfo";
  52093. export * from "babylonjs/Collisions/meshCollisionData";
  52094. }
  52095. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  52096. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  52097. import { Vector3 } from "babylonjs/Maths/math.vector";
  52098. import { Ray } from "babylonjs/Culling/ray";
  52099. import { Plane } from "babylonjs/Maths/math.plane";
  52100. /**
  52101. * Contains an array of blocks representing the octree
  52102. */
  52103. export interface IOctreeContainer<T> {
  52104. /**
  52105. * Blocks within the octree
  52106. */
  52107. blocks: Array<OctreeBlock<T>>;
  52108. }
  52109. /**
  52110. * Class used to store a cell in an octree
  52111. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52112. */
  52113. export class OctreeBlock<T> {
  52114. /**
  52115. * Gets the content of the current block
  52116. */
  52117. entries: T[];
  52118. /**
  52119. * Gets the list of block children
  52120. */
  52121. blocks: Array<OctreeBlock<T>>;
  52122. private _depth;
  52123. private _maxDepth;
  52124. private _capacity;
  52125. private _minPoint;
  52126. private _maxPoint;
  52127. private _boundingVectors;
  52128. private _creationFunc;
  52129. /**
  52130. * Creates a new block
  52131. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52132. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52133. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52134. * @param depth defines the current depth of this block in the octree
  52135. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52136. * @param creationFunc defines a callback to call when an element is added to the block
  52137. */
  52138. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52139. /**
  52140. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52141. */
  52142. get capacity(): number;
  52143. /**
  52144. * Gets the minimum vector (in world space) of the block's bounding box
  52145. */
  52146. get minPoint(): Vector3;
  52147. /**
  52148. * Gets the maximum vector (in world space) of the block's bounding box
  52149. */
  52150. get maxPoint(): Vector3;
  52151. /**
  52152. * Add a new element to this block
  52153. * @param entry defines the element to add
  52154. */
  52155. addEntry(entry: T): void;
  52156. /**
  52157. * Remove an element from this block
  52158. * @param entry defines the element to remove
  52159. */
  52160. removeEntry(entry: T): void;
  52161. /**
  52162. * Add an array of elements to this block
  52163. * @param entries defines the array of elements to add
  52164. */
  52165. addEntries(entries: T[]): void;
  52166. /**
  52167. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52168. * @param frustumPlanes defines the frustum planes to test
  52169. * @param selection defines the array to store current content if selection is positive
  52170. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52171. */
  52172. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52173. /**
  52174. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52175. * @param sphereCenter defines the bounding sphere center
  52176. * @param sphereRadius defines the bounding sphere radius
  52177. * @param selection defines the array to store current content if selection is positive
  52178. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52179. */
  52180. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52181. /**
  52182. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52183. * @param ray defines the ray to test with
  52184. * @param selection defines the array to store current content if selection is positive
  52185. */
  52186. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52187. /**
  52188. * Subdivide the content into child blocks (this block will then be empty)
  52189. */
  52190. createInnerBlocks(): void;
  52191. /**
  52192. * @hidden
  52193. */
  52194. 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;
  52195. }
  52196. }
  52197. declare module "babylonjs/Culling/Octrees/octree" {
  52198. import { SmartArray } from "babylonjs/Misc/smartArray";
  52199. import { Vector3 } from "babylonjs/Maths/math.vector";
  52200. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52202. import { Ray } from "babylonjs/Culling/ray";
  52203. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52204. import { Plane } from "babylonjs/Maths/math.plane";
  52205. /**
  52206. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52207. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52208. */
  52209. export class Octree<T> {
  52210. /** 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.) */
  52211. maxDepth: number;
  52212. /**
  52213. * Blocks within the octree containing objects
  52214. */
  52215. blocks: Array<OctreeBlock<T>>;
  52216. /**
  52217. * Content stored in the octree
  52218. */
  52219. dynamicContent: T[];
  52220. private _maxBlockCapacity;
  52221. private _selectionContent;
  52222. private _creationFunc;
  52223. /**
  52224. * Creates a octree
  52225. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52226. * @param creationFunc function to be used to instatiate the octree
  52227. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52228. * @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.)
  52229. */
  52230. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52231. /** 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.) */
  52232. maxDepth?: number);
  52233. /**
  52234. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52235. * @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);
  52236. * @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);
  52237. * @param entries meshes to be added to the octree blocks
  52238. */
  52239. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52240. /**
  52241. * Adds a mesh to the octree
  52242. * @param entry Mesh to add to the octree
  52243. */
  52244. addMesh(entry: T): void;
  52245. /**
  52246. * Remove an element from the octree
  52247. * @param entry defines the element to remove
  52248. */
  52249. removeMesh(entry: T): void;
  52250. /**
  52251. * Selects an array of meshes within the frustum
  52252. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52253. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52254. * @returns array of meshes within the frustum
  52255. */
  52256. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52257. /**
  52258. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52259. * @param sphereCenter defines the bounding sphere center
  52260. * @param sphereRadius defines the bounding sphere radius
  52261. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52262. * @returns an array of objects that intersect the sphere
  52263. */
  52264. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52265. /**
  52266. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52267. * @param ray defines the ray to test with
  52268. * @returns array of intersected objects
  52269. */
  52270. intersectsRay(ray: Ray): SmartArray<T>;
  52271. /**
  52272. * Adds a mesh into the octree block if it intersects the block
  52273. */
  52274. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52275. /**
  52276. * Adds a submesh into the octree block if it intersects the block
  52277. */
  52278. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52279. }
  52280. }
  52281. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52282. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52283. import { Scene } from "babylonjs/scene";
  52284. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52286. import { Ray } from "babylonjs/Culling/ray";
  52287. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52288. import { Collider } from "babylonjs/Collisions/collider";
  52289. module "babylonjs/scene" {
  52290. interface Scene {
  52291. /**
  52292. * @hidden
  52293. * Backing Filed
  52294. */
  52295. _selectionOctree: Octree<AbstractMesh>;
  52296. /**
  52297. * Gets the octree used to boost mesh selection (picking)
  52298. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52299. */
  52300. selectionOctree: Octree<AbstractMesh>;
  52301. /**
  52302. * Creates or updates the octree used to boost selection (picking)
  52303. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52304. * @param maxCapacity defines the maximum capacity per leaf
  52305. * @param maxDepth defines the maximum depth of the octree
  52306. * @returns an octree of AbstractMesh
  52307. */
  52308. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52309. }
  52310. }
  52311. module "babylonjs/Meshes/abstractMesh" {
  52312. interface AbstractMesh {
  52313. /**
  52314. * @hidden
  52315. * Backing Field
  52316. */
  52317. _submeshesOctree: Octree<SubMesh>;
  52318. /**
  52319. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52320. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52321. * @param maxCapacity defines the maximum size of each block (64 by default)
  52322. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52323. * @returns the new octree
  52324. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52325. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52326. */
  52327. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52328. }
  52329. }
  52330. /**
  52331. * Defines the octree scene component responsible to manage any octrees
  52332. * in a given scene.
  52333. */
  52334. export class OctreeSceneComponent {
  52335. /**
  52336. * The component name help to identify the component in the list of scene components.
  52337. */
  52338. readonly name: string;
  52339. /**
  52340. * The scene the component belongs to.
  52341. */
  52342. scene: Scene;
  52343. /**
  52344. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52345. */
  52346. readonly checksIsEnabled: boolean;
  52347. /**
  52348. * Creates a new instance of the component for the given scene
  52349. * @param scene Defines the scene to register the component in
  52350. */
  52351. constructor(scene: Scene);
  52352. /**
  52353. * Registers the component in a given scene
  52354. */
  52355. register(): void;
  52356. /**
  52357. * Return the list of active meshes
  52358. * @returns the list of active meshes
  52359. */
  52360. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52361. /**
  52362. * Return the list of active sub meshes
  52363. * @param mesh The mesh to get the candidates sub meshes from
  52364. * @returns the list of active sub meshes
  52365. */
  52366. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52367. private _tempRay;
  52368. /**
  52369. * Return the list of sub meshes intersecting with a given local ray
  52370. * @param mesh defines the mesh to find the submesh for
  52371. * @param localRay defines the ray in local space
  52372. * @returns the list of intersecting sub meshes
  52373. */
  52374. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52375. /**
  52376. * Return the list of sub meshes colliding with a collider
  52377. * @param mesh defines the mesh to find the submesh for
  52378. * @param collider defines the collider to evaluate the collision against
  52379. * @returns the list of colliding sub meshes
  52380. */
  52381. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52382. /**
  52383. * Rebuilds the elements related to this component in case of
  52384. * context lost for instance.
  52385. */
  52386. rebuild(): void;
  52387. /**
  52388. * Disposes the component and the associated ressources.
  52389. */
  52390. dispose(): void;
  52391. }
  52392. }
  52393. declare module "babylonjs/Culling/Octrees/index" {
  52394. export * from "babylonjs/Culling/Octrees/octree";
  52395. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52396. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52397. }
  52398. declare module "babylonjs/Culling/index" {
  52399. export * from "babylonjs/Culling/boundingBox";
  52400. export * from "babylonjs/Culling/boundingInfo";
  52401. export * from "babylonjs/Culling/boundingSphere";
  52402. export * from "babylonjs/Culling/Octrees/index";
  52403. export * from "babylonjs/Culling/ray";
  52404. }
  52405. declare module "babylonjs/Gizmos/gizmo" {
  52406. import { Nullable } from "babylonjs/types";
  52407. import { IDisposable } from "babylonjs/scene";
  52408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52409. import { Mesh } from "babylonjs/Meshes/mesh";
  52410. import { Node } from "babylonjs/node";
  52411. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52412. /**
  52413. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52414. */
  52415. export class Gizmo implements IDisposable {
  52416. /** The utility layer the gizmo will be added to */
  52417. gizmoLayer: UtilityLayerRenderer;
  52418. /**
  52419. * The root mesh of the gizmo
  52420. */
  52421. _rootMesh: Mesh;
  52422. private _attachedMesh;
  52423. private _attachedNode;
  52424. /**
  52425. * Ratio for the scale of the gizmo (Default: 1)
  52426. */
  52427. protected _scaleRatio: number;
  52428. /**
  52429. * Ratio for the scale of the gizmo (Default: 1)
  52430. */
  52431. set scaleRatio(value: number);
  52432. get scaleRatio(): number;
  52433. /**
  52434. * If a custom mesh has been set (Default: false)
  52435. */
  52436. protected _customMeshSet: boolean;
  52437. /**
  52438. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52439. * * When set, interactions will be enabled
  52440. */
  52441. get attachedMesh(): Nullable<AbstractMesh>;
  52442. set attachedMesh(value: Nullable<AbstractMesh>);
  52443. /**
  52444. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52445. * * When set, interactions will be enabled
  52446. */
  52447. get attachedNode(): Nullable<Node>;
  52448. set attachedNode(value: Nullable<Node>);
  52449. /**
  52450. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52451. * @param mesh The mesh to replace the default mesh of the gizmo
  52452. */
  52453. setCustomMesh(mesh: Mesh): void;
  52454. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52455. /**
  52456. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52457. */
  52458. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52459. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52460. /**
  52461. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52462. */
  52463. updateGizmoPositionToMatchAttachedMesh: boolean;
  52464. /**
  52465. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52466. */
  52467. updateScale: boolean;
  52468. protected _interactionsEnabled: boolean;
  52469. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52470. private _beforeRenderObserver;
  52471. private _tempQuaternion;
  52472. private _tempVector;
  52473. private _tempVector2;
  52474. private _tempMatrix1;
  52475. private _tempMatrix2;
  52476. private _rightHandtoLeftHandMatrix;
  52477. /**
  52478. * Creates a gizmo
  52479. * @param gizmoLayer The utility layer the gizmo will be added to
  52480. */
  52481. constructor(
  52482. /** The utility layer the gizmo will be added to */
  52483. gizmoLayer?: UtilityLayerRenderer);
  52484. /**
  52485. * Updates the gizmo to match the attached mesh's position/rotation
  52486. */
  52487. protected _update(): void;
  52488. /**
  52489. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52490. * @param value Node, TransformNode or mesh
  52491. */
  52492. protected _matrixChanged(): void;
  52493. /**
  52494. * Disposes of the gizmo
  52495. */
  52496. dispose(): void;
  52497. }
  52498. }
  52499. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52500. import { Observable } from "babylonjs/Misc/observable";
  52501. import { Nullable } from "babylonjs/types";
  52502. import { Vector3 } from "babylonjs/Maths/math.vector";
  52503. import { Color3 } from "babylonjs/Maths/math.color";
  52504. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52505. import { Node } from "babylonjs/node";
  52506. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52507. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52508. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52509. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52510. import { Scene } from "babylonjs/scene";
  52511. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52512. /**
  52513. * Single plane drag gizmo
  52514. */
  52515. export class PlaneDragGizmo extends Gizmo {
  52516. /**
  52517. * Drag behavior responsible for the gizmos dragging interactions
  52518. */
  52519. dragBehavior: PointerDragBehavior;
  52520. private _pointerObserver;
  52521. /**
  52522. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52523. */
  52524. snapDistance: number;
  52525. /**
  52526. * Event that fires each time the gizmo snaps to a new location.
  52527. * * snapDistance is the the change in distance
  52528. */
  52529. onSnapObservable: Observable<{
  52530. snapDistance: number;
  52531. }>;
  52532. private _plane;
  52533. private _coloredMaterial;
  52534. private _hoverMaterial;
  52535. private _isEnabled;
  52536. private _parent;
  52537. /** @hidden */
  52538. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52539. /** @hidden */
  52540. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52541. /**
  52542. * Creates a PlaneDragGizmo
  52543. * @param gizmoLayer The utility layer the gizmo will be added to
  52544. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52545. * @param color The color of the gizmo
  52546. */
  52547. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52548. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52549. /**
  52550. * If the gizmo is enabled
  52551. */
  52552. set isEnabled(value: boolean);
  52553. get isEnabled(): boolean;
  52554. /**
  52555. * Disposes of the gizmo
  52556. */
  52557. dispose(): void;
  52558. }
  52559. }
  52560. declare module "babylonjs/Gizmos/positionGizmo" {
  52561. import { Observable } from "babylonjs/Misc/observable";
  52562. import { Nullable } from "babylonjs/types";
  52563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52564. import { Node } from "babylonjs/node";
  52565. import { Mesh } from "babylonjs/Meshes/mesh";
  52566. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52567. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52568. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52569. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52570. /**
  52571. * Gizmo that enables dragging a mesh along 3 axis
  52572. */
  52573. export class PositionGizmo extends Gizmo {
  52574. /**
  52575. * Internal gizmo used for interactions on the x axis
  52576. */
  52577. xGizmo: AxisDragGizmo;
  52578. /**
  52579. * Internal gizmo used for interactions on the y axis
  52580. */
  52581. yGizmo: AxisDragGizmo;
  52582. /**
  52583. * Internal gizmo used for interactions on the z axis
  52584. */
  52585. zGizmo: AxisDragGizmo;
  52586. /**
  52587. * Internal gizmo used for interactions on the yz plane
  52588. */
  52589. xPlaneGizmo: PlaneDragGizmo;
  52590. /**
  52591. * Internal gizmo used for interactions on the xz plane
  52592. */
  52593. yPlaneGizmo: PlaneDragGizmo;
  52594. /**
  52595. * Internal gizmo used for interactions on the xy plane
  52596. */
  52597. zPlaneGizmo: PlaneDragGizmo;
  52598. /**
  52599. * private variables
  52600. */
  52601. private _meshAttached;
  52602. private _nodeAttached;
  52603. private _snapDistance;
  52604. /** Fires an event when any of it's sub gizmos are dragged */
  52605. onDragStartObservable: Observable<unknown>;
  52606. /** Fires an event when any of it's sub gizmos are released from dragging */
  52607. onDragEndObservable: Observable<unknown>;
  52608. /**
  52609. * If set to true, planar drag is enabled
  52610. */
  52611. private _planarGizmoEnabled;
  52612. get attachedMesh(): Nullable<AbstractMesh>;
  52613. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52614. get attachedNode(): Nullable<Node>;
  52615. set attachedNode(node: Nullable<Node>);
  52616. /**
  52617. * Creates a PositionGizmo
  52618. * @param gizmoLayer The utility layer the gizmo will be added to
  52619. @param thickness display gizmo axis thickness
  52620. */
  52621. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52622. /**
  52623. * If the planar drag gizmo is enabled
  52624. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52625. */
  52626. set planarGizmoEnabled(value: boolean);
  52627. get planarGizmoEnabled(): boolean;
  52628. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52629. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52630. /**
  52631. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52632. */
  52633. set snapDistance(value: number);
  52634. get snapDistance(): number;
  52635. /**
  52636. * Ratio for the scale of the gizmo (Default: 1)
  52637. */
  52638. set scaleRatio(value: number);
  52639. get scaleRatio(): number;
  52640. /**
  52641. * Disposes of the gizmo
  52642. */
  52643. dispose(): void;
  52644. /**
  52645. * CustomMeshes are not supported by this gizmo
  52646. * @param mesh The mesh to replace the default mesh of the gizmo
  52647. */
  52648. setCustomMesh(mesh: Mesh): void;
  52649. }
  52650. }
  52651. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52652. import { Observable } from "babylonjs/Misc/observable";
  52653. import { Nullable } from "babylonjs/types";
  52654. import { Vector3 } from "babylonjs/Maths/math.vector";
  52655. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52656. import { Node } from "babylonjs/node";
  52657. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52658. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52659. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52660. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52661. import { Scene } from "babylonjs/scene";
  52662. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52663. import { Color3 } from "babylonjs/Maths/math.color";
  52664. /**
  52665. * Single axis drag gizmo
  52666. */
  52667. export class AxisDragGizmo extends Gizmo {
  52668. /**
  52669. * Drag behavior responsible for the gizmos dragging interactions
  52670. */
  52671. dragBehavior: PointerDragBehavior;
  52672. private _pointerObserver;
  52673. /**
  52674. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52675. */
  52676. snapDistance: number;
  52677. /**
  52678. * Event that fires each time the gizmo snaps to a new location.
  52679. * * snapDistance is the the change in distance
  52680. */
  52681. onSnapObservable: Observable<{
  52682. snapDistance: number;
  52683. }>;
  52684. private _isEnabled;
  52685. private _parent;
  52686. private _arrow;
  52687. private _coloredMaterial;
  52688. private _hoverMaterial;
  52689. /** @hidden */
  52690. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52691. /** @hidden */
  52692. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52693. /**
  52694. * Creates an AxisDragGizmo
  52695. * @param gizmoLayer The utility layer the gizmo will be added to
  52696. * @param dragAxis The axis which the gizmo will be able to drag on
  52697. * @param color The color of the gizmo
  52698. * @param thickness display gizmo axis thickness
  52699. */
  52700. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52701. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52702. /**
  52703. * If the gizmo is enabled
  52704. */
  52705. set isEnabled(value: boolean);
  52706. get isEnabled(): boolean;
  52707. /**
  52708. * Disposes of the gizmo
  52709. */
  52710. dispose(): void;
  52711. }
  52712. }
  52713. declare module "babylonjs/Debug/axesViewer" {
  52714. import { Vector3 } from "babylonjs/Maths/math.vector";
  52715. import { Nullable } from "babylonjs/types";
  52716. import { Scene } from "babylonjs/scene";
  52717. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52718. /**
  52719. * The Axes viewer will show 3 axes in a specific point in space
  52720. */
  52721. export class AxesViewer {
  52722. private _xAxis;
  52723. private _yAxis;
  52724. private _zAxis;
  52725. private _scaleLinesFactor;
  52726. private _instanced;
  52727. /**
  52728. * Gets the hosting scene
  52729. */
  52730. scene: Nullable<Scene>;
  52731. /**
  52732. * Gets or sets a number used to scale line length
  52733. */
  52734. scaleLines: number;
  52735. /** Gets the node hierarchy used to render x-axis */
  52736. get xAxis(): TransformNode;
  52737. /** Gets the node hierarchy used to render y-axis */
  52738. get yAxis(): TransformNode;
  52739. /** Gets the node hierarchy used to render z-axis */
  52740. get zAxis(): TransformNode;
  52741. /**
  52742. * Creates a new AxesViewer
  52743. * @param scene defines the hosting scene
  52744. * @param scaleLines defines a number used to scale line length (1 by default)
  52745. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52746. * @param xAxis defines the node hierarchy used to render the x-axis
  52747. * @param yAxis defines the node hierarchy used to render the y-axis
  52748. * @param zAxis defines the node hierarchy used to render the z-axis
  52749. */
  52750. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52751. /**
  52752. * Force the viewer to update
  52753. * @param position defines the position of the viewer
  52754. * @param xaxis defines the x axis of the viewer
  52755. * @param yaxis defines the y axis of the viewer
  52756. * @param zaxis defines the z axis of the viewer
  52757. */
  52758. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52759. /**
  52760. * Creates an instance of this axes viewer.
  52761. * @returns a new axes viewer with instanced meshes
  52762. */
  52763. createInstance(): AxesViewer;
  52764. /** Releases resources */
  52765. dispose(): void;
  52766. private static _SetRenderingGroupId;
  52767. }
  52768. }
  52769. declare module "babylonjs/Debug/boneAxesViewer" {
  52770. import { Nullable } from "babylonjs/types";
  52771. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52772. import { Vector3 } from "babylonjs/Maths/math.vector";
  52773. import { Mesh } from "babylonjs/Meshes/mesh";
  52774. import { Bone } from "babylonjs/Bones/bone";
  52775. import { Scene } from "babylonjs/scene";
  52776. /**
  52777. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52778. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52779. */
  52780. export class BoneAxesViewer extends AxesViewer {
  52781. /**
  52782. * Gets or sets the target mesh where to display the axes viewer
  52783. */
  52784. mesh: Nullable<Mesh>;
  52785. /**
  52786. * Gets or sets the target bone where to display the axes viewer
  52787. */
  52788. bone: Nullable<Bone>;
  52789. /** Gets current position */
  52790. pos: Vector3;
  52791. /** Gets direction of X axis */
  52792. xaxis: Vector3;
  52793. /** Gets direction of Y axis */
  52794. yaxis: Vector3;
  52795. /** Gets direction of Z axis */
  52796. zaxis: Vector3;
  52797. /**
  52798. * Creates a new BoneAxesViewer
  52799. * @param scene defines the hosting scene
  52800. * @param bone defines the target bone
  52801. * @param mesh defines the target mesh
  52802. * @param scaleLines defines a scaling factor for line length (1 by default)
  52803. */
  52804. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52805. /**
  52806. * Force the viewer to update
  52807. */
  52808. update(): void;
  52809. /** Releases resources */
  52810. dispose(): void;
  52811. }
  52812. }
  52813. declare module "babylonjs/Debug/debugLayer" {
  52814. import { Scene } from "babylonjs/scene";
  52815. /**
  52816. * Interface used to define scene explorer extensibility option
  52817. */
  52818. export interface IExplorerExtensibilityOption {
  52819. /**
  52820. * Define the option label
  52821. */
  52822. label: string;
  52823. /**
  52824. * Defines the action to execute on click
  52825. */
  52826. action: (entity: any) => void;
  52827. }
  52828. /**
  52829. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52830. */
  52831. export interface IExplorerExtensibilityGroup {
  52832. /**
  52833. * Defines a predicate to test if a given type mut be extended
  52834. */
  52835. predicate: (entity: any) => boolean;
  52836. /**
  52837. * Gets the list of options added to a type
  52838. */
  52839. entries: IExplorerExtensibilityOption[];
  52840. }
  52841. /**
  52842. * Interface used to define the options to use to create the Inspector
  52843. */
  52844. export interface IInspectorOptions {
  52845. /**
  52846. * Display in overlay mode (default: false)
  52847. */
  52848. overlay?: boolean;
  52849. /**
  52850. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52851. */
  52852. globalRoot?: HTMLElement;
  52853. /**
  52854. * Display the Scene explorer
  52855. */
  52856. showExplorer?: boolean;
  52857. /**
  52858. * Display the property inspector
  52859. */
  52860. showInspector?: boolean;
  52861. /**
  52862. * Display in embed mode (both panes on the right)
  52863. */
  52864. embedMode?: boolean;
  52865. /**
  52866. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52867. */
  52868. handleResize?: boolean;
  52869. /**
  52870. * Allow the panes to popup (default: true)
  52871. */
  52872. enablePopup?: boolean;
  52873. /**
  52874. * Allow the panes to be closed by users (default: true)
  52875. */
  52876. enableClose?: boolean;
  52877. /**
  52878. * Optional list of extensibility entries
  52879. */
  52880. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52881. /**
  52882. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52883. */
  52884. inspectorURL?: string;
  52885. /**
  52886. * Optional initial tab (default to DebugLayerTab.Properties)
  52887. */
  52888. initialTab?: DebugLayerTab;
  52889. }
  52890. module "babylonjs/scene" {
  52891. interface Scene {
  52892. /**
  52893. * @hidden
  52894. * Backing field
  52895. */
  52896. _debugLayer: DebugLayer;
  52897. /**
  52898. * Gets the debug layer (aka Inspector) associated with the scene
  52899. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52900. */
  52901. debugLayer: DebugLayer;
  52902. }
  52903. }
  52904. /**
  52905. * Enum of inspector action tab
  52906. */
  52907. export enum DebugLayerTab {
  52908. /**
  52909. * Properties tag (default)
  52910. */
  52911. Properties = 0,
  52912. /**
  52913. * Debug tab
  52914. */
  52915. Debug = 1,
  52916. /**
  52917. * Statistics tab
  52918. */
  52919. Statistics = 2,
  52920. /**
  52921. * Tools tab
  52922. */
  52923. Tools = 3,
  52924. /**
  52925. * Settings tab
  52926. */
  52927. Settings = 4
  52928. }
  52929. /**
  52930. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52931. * what is happening in your scene
  52932. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52933. */
  52934. export class DebugLayer {
  52935. /**
  52936. * Define the url to get the inspector script from.
  52937. * By default it uses the babylonjs CDN.
  52938. * @ignoreNaming
  52939. */
  52940. static InspectorURL: string;
  52941. private _scene;
  52942. private BJSINSPECTOR;
  52943. private _onPropertyChangedObservable?;
  52944. /**
  52945. * Observable triggered when a property is changed through the inspector.
  52946. */
  52947. get onPropertyChangedObservable(): any;
  52948. /**
  52949. * Instantiates a new debug layer.
  52950. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52951. * what is happening in your scene
  52952. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52953. * @param scene Defines the scene to inspect
  52954. */
  52955. constructor(scene: Scene);
  52956. /** Creates the inspector window. */
  52957. private _createInspector;
  52958. /**
  52959. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52960. * @param entity defines the entity to select
  52961. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52962. */
  52963. select(entity: any, lineContainerTitles?: string | string[]): void;
  52964. /** Get the inspector from bundle or global */
  52965. private _getGlobalInspector;
  52966. /**
  52967. * Get if the inspector is visible or not.
  52968. * @returns true if visible otherwise, false
  52969. */
  52970. isVisible(): boolean;
  52971. /**
  52972. * Hide the inspector and close its window.
  52973. */
  52974. hide(): void;
  52975. /**
  52976. * Update the scene in the inspector
  52977. */
  52978. setAsActiveScene(): void;
  52979. /**
  52980. * Launch the debugLayer.
  52981. * @param config Define the configuration of the inspector
  52982. * @return a promise fulfilled when the debug layer is visible
  52983. */
  52984. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52985. }
  52986. }
  52987. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52988. import { Nullable } from "babylonjs/types";
  52989. import { Scene } from "babylonjs/scene";
  52990. import { Vector4 } from "babylonjs/Maths/math.vector";
  52991. import { Color4 } from "babylonjs/Maths/math.color";
  52992. import { Mesh } from "babylonjs/Meshes/mesh";
  52993. /**
  52994. * Class containing static functions to help procedurally build meshes
  52995. */
  52996. export class BoxBuilder {
  52997. /**
  52998. * Creates a box mesh
  52999. * * The parameter `size` sets the size (float) of each box side (default 1)
  53000. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53001. * * 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)
  53002. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53004. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53006. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53007. * @param name defines the name of the mesh
  53008. * @param options defines the options used to create the mesh
  53009. * @param scene defines the hosting scene
  53010. * @returns the box mesh
  53011. */
  53012. static CreateBox(name: string, options: {
  53013. size?: number;
  53014. width?: number;
  53015. height?: number;
  53016. depth?: number;
  53017. faceUV?: Vector4[];
  53018. faceColors?: Color4[];
  53019. sideOrientation?: number;
  53020. frontUVs?: Vector4;
  53021. backUVs?: Vector4;
  53022. wrap?: boolean;
  53023. topBaseAt?: number;
  53024. bottomBaseAt?: number;
  53025. updatable?: boolean;
  53026. }, scene?: Nullable<Scene>): Mesh;
  53027. }
  53028. }
  53029. declare module "babylonjs/Debug/physicsViewer" {
  53030. import { Nullable } from "babylonjs/types";
  53031. import { Scene } from "babylonjs/scene";
  53032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53033. import { Mesh } from "babylonjs/Meshes/mesh";
  53034. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53035. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53036. /**
  53037. * Used to show the physics impostor around the specific mesh
  53038. */
  53039. export class PhysicsViewer {
  53040. /** @hidden */
  53041. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53042. /** @hidden */
  53043. protected _meshes: Array<Nullable<AbstractMesh>>;
  53044. /** @hidden */
  53045. protected _scene: Nullable<Scene>;
  53046. /** @hidden */
  53047. protected _numMeshes: number;
  53048. /** @hidden */
  53049. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53050. private _renderFunction;
  53051. private _utilityLayer;
  53052. private _debugBoxMesh;
  53053. private _debugSphereMesh;
  53054. private _debugCylinderMesh;
  53055. private _debugMaterial;
  53056. private _debugMeshMeshes;
  53057. /**
  53058. * Creates a new PhysicsViewer
  53059. * @param scene defines the hosting scene
  53060. */
  53061. constructor(scene: Scene);
  53062. /** @hidden */
  53063. protected _updateDebugMeshes(): void;
  53064. /**
  53065. * Renders a specified physic impostor
  53066. * @param impostor defines the impostor to render
  53067. * @param targetMesh defines the mesh represented by the impostor
  53068. * @returns the new debug mesh used to render the impostor
  53069. */
  53070. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53071. /**
  53072. * Hides a specified physic impostor
  53073. * @param impostor defines the impostor to hide
  53074. */
  53075. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53076. private _getDebugMaterial;
  53077. private _getDebugBoxMesh;
  53078. private _getDebugSphereMesh;
  53079. private _getDebugCylinderMesh;
  53080. private _getDebugMeshMesh;
  53081. private _getDebugMesh;
  53082. /** Releases all resources */
  53083. dispose(): void;
  53084. }
  53085. }
  53086. declare module "babylonjs/Debug/rayHelper" {
  53087. import { Nullable } from "babylonjs/types";
  53088. import { Ray } from "babylonjs/Culling/ray";
  53089. import { Vector3 } from "babylonjs/Maths/math.vector";
  53090. import { Color3 } from "babylonjs/Maths/math.color";
  53091. import { Scene } from "babylonjs/scene";
  53092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53093. import "babylonjs/Meshes/Builders/linesBuilder";
  53094. /**
  53095. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53096. * in order to better appreciate the issue one might have.
  53097. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53098. */
  53099. export class RayHelper {
  53100. /**
  53101. * Defines the ray we are currently tryin to visualize.
  53102. */
  53103. ray: Nullable<Ray>;
  53104. private _renderPoints;
  53105. private _renderLine;
  53106. private _renderFunction;
  53107. private _scene;
  53108. private _onAfterRenderObserver;
  53109. private _onAfterStepObserver;
  53110. private _attachedToMesh;
  53111. private _meshSpaceDirection;
  53112. private _meshSpaceOrigin;
  53113. /**
  53114. * Helper function to create a colored helper in a scene in one line.
  53115. * @param ray Defines the ray we are currently tryin to visualize
  53116. * @param scene Defines the scene the ray is used in
  53117. * @param color Defines the color we want to see the ray in
  53118. * @returns The newly created ray helper.
  53119. */
  53120. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53121. /**
  53122. * Instantiate a new ray helper.
  53123. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53124. * in order to better appreciate the issue one might have.
  53125. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53126. * @param ray Defines the ray we are currently tryin to visualize
  53127. */
  53128. constructor(ray: Ray);
  53129. /**
  53130. * Shows the ray we are willing to debug.
  53131. * @param scene Defines the scene the ray needs to be rendered in
  53132. * @param color Defines the color the ray needs to be rendered in
  53133. */
  53134. show(scene: Scene, color?: Color3): void;
  53135. /**
  53136. * Hides the ray we are debugging.
  53137. */
  53138. hide(): void;
  53139. private _render;
  53140. /**
  53141. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53142. * @param mesh Defines the mesh we want the helper attached to
  53143. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53144. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53145. * @param length Defines the length of the ray
  53146. */
  53147. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53148. /**
  53149. * Detach the ray helper from the mesh it has previously been attached to.
  53150. */
  53151. detachFromMesh(): void;
  53152. private _updateToMesh;
  53153. /**
  53154. * Dispose the helper and release its associated resources.
  53155. */
  53156. dispose(): void;
  53157. }
  53158. }
  53159. declare module "babylonjs/Debug/ISkeletonViewer" {
  53160. import { Skeleton } from "babylonjs/Bones/skeleton";
  53161. import { Color3 } from "babylonjs/Maths/math.color";
  53162. /**
  53163. * Defines the options associated with the creation of a SkeletonViewer.
  53164. */
  53165. export interface ISkeletonViewerOptions {
  53166. /** Should the system pause animations before building the Viewer? */
  53167. pauseAnimations: boolean;
  53168. /** Should the system return the skeleton to rest before building? */
  53169. returnToRest: boolean;
  53170. /** public Display Mode of the Viewer */
  53171. displayMode: number;
  53172. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53173. displayOptions: ISkeletonViewerDisplayOptions;
  53174. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53175. computeBonesUsingShaders: boolean;
  53176. /** Flag ignore non weighted bones */
  53177. useAllBones: boolean;
  53178. }
  53179. /**
  53180. * Defines how to display the various bone meshes for the viewer.
  53181. */
  53182. export interface ISkeletonViewerDisplayOptions {
  53183. /** How far down to start tapering the bone spurs */
  53184. midStep?: number;
  53185. /** How big is the midStep? */
  53186. midStepFactor?: number;
  53187. /** Base for the Sphere Size */
  53188. sphereBaseSize?: number;
  53189. /** The ratio of the sphere to the longest bone in units */
  53190. sphereScaleUnit?: number;
  53191. /** Ratio for the Sphere Size */
  53192. sphereFactor?: number;
  53193. }
  53194. /**
  53195. * Defines the constructor options for the BoneWeight Shader.
  53196. */
  53197. export interface IBoneWeightShaderOptions {
  53198. /** Skeleton to Map */
  53199. skeleton: Skeleton;
  53200. /** Colors for Uninfluenced bones */
  53201. colorBase?: Color3;
  53202. /** Colors for 0.0-0.25 Weight bones */
  53203. colorZero?: Color3;
  53204. /** Color for 0.25-0.5 Weight Influence */
  53205. colorQuarter?: Color3;
  53206. /** Color for 0.5-0.75 Weight Influence */
  53207. colorHalf?: Color3;
  53208. /** Color for 0.75-1 Weight Influence */
  53209. colorFull?: Color3;
  53210. /** Color for Zero Weight Influence */
  53211. targetBoneIndex?: number;
  53212. }
  53213. /**
  53214. * Simple structure of the gradient steps for the Color Map.
  53215. */
  53216. export interface ISkeletonMapShaderColorMapKnot {
  53217. /** Color of the Knot */
  53218. color: Color3;
  53219. /** Location of the Knot */
  53220. location: number;
  53221. }
  53222. /**
  53223. * Defines the constructor options for the SkeletonMap Shader.
  53224. */
  53225. export interface ISkeletonMapShaderOptions {
  53226. /** Skeleton to Map */
  53227. skeleton: Skeleton;
  53228. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53229. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53230. }
  53231. }
  53232. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53233. import { Nullable } from "babylonjs/types";
  53234. import { Scene } from "babylonjs/scene";
  53235. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53236. import { Color4 } from "babylonjs/Maths/math.color";
  53237. import { Mesh } from "babylonjs/Meshes/mesh";
  53238. /**
  53239. * Class containing static functions to help procedurally build meshes
  53240. */
  53241. export class RibbonBuilder {
  53242. /**
  53243. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53244. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53245. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53246. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53247. * * 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
  53248. * * 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
  53249. * * 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
  53250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53252. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53253. * * 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
  53254. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53255. * * 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
  53256. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53258. * @param name defines the name of the mesh
  53259. * @param options defines the options used to create the mesh
  53260. * @param scene defines the hosting scene
  53261. * @returns the ribbon mesh
  53262. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53264. */
  53265. static CreateRibbon(name: string, options: {
  53266. pathArray: Vector3[][];
  53267. closeArray?: boolean;
  53268. closePath?: boolean;
  53269. offset?: number;
  53270. updatable?: boolean;
  53271. sideOrientation?: number;
  53272. frontUVs?: Vector4;
  53273. backUVs?: Vector4;
  53274. instance?: Mesh;
  53275. invertUV?: boolean;
  53276. uvs?: Vector2[];
  53277. colors?: Color4[];
  53278. }, scene?: Nullable<Scene>): Mesh;
  53279. }
  53280. }
  53281. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53282. import { Nullable } from "babylonjs/types";
  53283. import { Scene } from "babylonjs/scene";
  53284. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53285. import { Mesh } from "babylonjs/Meshes/mesh";
  53286. /**
  53287. * Class containing static functions to help procedurally build meshes
  53288. */
  53289. export class ShapeBuilder {
  53290. /**
  53291. * 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.
  53292. * * 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.
  53293. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53294. * * 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.
  53295. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53296. * * 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
  53297. * * 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
  53298. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53301. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53303. * @param name defines the name of the mesh
  53304. * @param options defines the options used to create the mesh
  53305. * @param scene defines the hosting scene
  53306. * @returns the extruded shape mesh
  53307. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53309. */
  53310. static ExtrudeShape(name: string, options: {
  53311. shape: Vector3[];
  53312. path: Vector3[];
  53313. scale?: number;
  53314. rotation?: number;
  53315. cap?: number;
  53316. updatable?: boolean;
  53317. sideOrientation?: number;
  53318. frontUVs?: Vector4;
  53319. backUVs?: Vector4;
  53320. instance?: Mesh;
  53321. invertUV?: boolean;
  53322. }, scene?: Nullable<Scene>): Mesh;
  53323. /**
  53324. * Creates an custom extruded shape mesh.
  53325. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53326. * * 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.
  53327. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53328. * * 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
  53329. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53330. * * 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
  53331. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53332. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53333. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53334. * * 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
  53335. * * 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
  53336. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53341. * @param name defines the name of the mesh
  53342. * @param options defines the options used to create the mesh
  53343. * @param scene defines the hosting scene
  53344. * @returns the custom extruded shape mesh
  53345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53346. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53348. */
  53349. static ExtrudeShapeCustom(name: string, options: {
  53350. shape: Vector3[];
  53351. path: Vector3[];
  53352. scaleFunction?: any;
  53353. rotationFunction?: any;
  53354. ribbonCloseArray?: boolean;
  53355. ribbonClosePath?: boolean;
  53356. cap?: number;
  53357. updatable?: boolean;
  53358. sideOrientation?: number;
  53359. frontUVs?: Vector4;
  53360. backUVs?: Vector4;
  53361. instance?: Mesh;
  53362. invertUV?: boolean;
  53363. }, scene?: Nullable<Scene>): Mesh;
  53364. private static _ExtrudeShapeGeneric;
  53365. }
  53366. }
  53367. declare module "babylonjs/Debug/skeletonViewer" {
  53368. import { Color3 } from "babylonjs/Maths/math.color";
  53369. import { Scene } from "babylonjs/scene";
  53370. import { Nullable } from "babylonjs/types";
  53371. import { Skeleton } from "babylonjs/Bones/skeleton";
  53372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53373. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53374. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53375. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53376. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53377. /**
  53378. * Class used to render a debug view of a given skeleton
  53379. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53380. */
  53381. export class SkeletonViewer {
  53382. /** defines the skeleton to render */
  53383. skeleton: Skeleton;
  53384. /** defines the mesh attached to the skeleton */
  53385. mesh: AbstractMesh;
  53386. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53387. autoUpdateBonesMatrices: boolean;
  53388. /** defines the rendering group id to use with the viewer */
  53389. renderingGroupId: number;
  53390. /** is the options for the viewer */
  53391. options: Partial<ISkeletonViewerOptions>;
  53392. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53393. static readonly DISPLAY_LINES: number;
  53394. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53395. static readonly DISPLAY_SPHERES: number;
  53396. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53397. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53398. /** public static method to create a BoneWeight Shader
  53399. * @param options The constructor options
  53400. * @param scene The scene that the shader is scoped to
  53401. * @returns The created ShaderMaterial
  53402. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53403. */
  53404. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53405. /** public static method to create a BoneWeight Shader
  53406. * @param options The constructor options
  53407. * @param scene The scene that the shader is scoped to
  53408. * @returns The created ShaderMaterial
  53409. */
  53410. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53411. /** private static method to create a BoneWeight Shader
  53412. * @param size The size of the buffer to create (usually the bone count)
  53413. * @param colorMap The gradient data to generate
  53414. * @param scene The scene that the shader is scoped to
  53415. * @returns an Array of floats from the color gradient values
  53416. */
  53417. private static _CreateBoneMapColorBuffer;
  53418. /** If SkeletonViewer scene scope. */
  53419. private _scene;
  53420. /** Gets or sets the color used to render the skeleton */
  53421. color: Color3;
  53422. /** Array of the points of the skeleton fo the line view. */
  53423. private _debugLines;
  53424. /** The SkeletonViewers Mesh. */
  53425. private _debugMesh;
  53426. /** If SkeletonViewer is enabled. */
  53427. private _isEnabled;
  53428. /** If SkeletonViewer is ready. */
  53429. private _ready;
  53430. /** SkeletonViewer render observable. */
  53431. private _obs;
  53432. /** The Utility Layer to render the gizmos in. */
  53433. private _utilityLayer;
  53434. private _boneIndices;
  53435. /** Gets the Scene. */
  53436. get scene(): Scene;
  53437. /** Gets the utilityLayer. */
  53438. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53439. /** Checks Ready Status. */
  53440. get isReady(): Boolean;
  53441. /** Sets Ready Status. */
  53442. set ready(value: boolean);
  53443. /** Gets the debugMesh */
  53444. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53445. /** Sets the debugMesh */
  53446. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53447. /** Gets the displayMode */
  53448. get displayMode(): number;
  53449. /** Sets the displayMode */
  53450. set displayMode(value: number);
  53451. /**
  53452. * Creates a new SkeletonViewer
  53453. * @param skeleton defines the skeleton to render
  53454. * @param mesh defines the mesh attached to the skeleton
  53455. * @param scene defines the hosting scene
  53456. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53457. * @param renderingGroupId defines the rendering group id to use with the viewer
  53458. * @param options All of the extra constructor options for the SkeletonViewer
  53459. */
  53460. constructor(
  53461. /** defines the skeleton to render */
  53462. skeleton: Skeleton,
  53463. /** defines the mesh attached to the skeleton */
  53464. mesh: AbstractMesh,
  53465. /** The Scene scope*/
  53466. scene: Scene,
  53467. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53468. autoUpdateBonesMatrices?: boolean,
  53469. /** defines the rendering group id to use with the viewer */
  53470. renderingGroupId?: number,
  53471. /** is the options for the viewer */
  53472. options?: Partial<ISkeletonViewerOptions>);
  53473. /** The Dynamic bindings for the update functions */
  53474. private _bindObs;
  53475. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53476. update(): void;
  53477. /** Gets or sets a boolean indicating if the viewer is enabled */
  53478. set isEnabled(value: boolean);
  53479. get isEnabled(): boolean;
  53480. private _getBonePosition;
  53481. private _getLinesForBonesWithLength;
  53482. private _getLinesForBonesNoLength;
  53483. /** function to revert the mesh and scene back to the initial state. */
  53484. private _revert;
  53485. /** function to build and bind sphere joint points and spur bone representations. */
  53486. private _buildSpheresAndSpurs;
  53487. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53488. private _displayLinesUpdate;
  53489. /** Changes the displayMode of the skeleton viewer
  53490. * @param mode The displayMode numerical value
  53491. */
  53492. changeDisplayMode(mode: number): void;
  53493. /** Changes the displayMode of the skeleton viewer
  53494. * @param option String of the option name
  53495. * @param value The numerical option value
  53496. */
  53497. changeDisplayOptions(option: string, value: number): void;
  53498. /** Release associated resources */
  53499. dispose(): void;
  53500. }
  53501. }
  53502. declare module "babylonjs/Debug/index" {
  53503. export * from "babylonjs/Debug/axesViewer";
  53504. export * from "babylonjs/Debug/boneAxesViewer";
  53505. export * from "babylonjs/Debug/debugLayer";
  53506. export * from "babylonjs/Debug/physicsViewer";
  53507. export * from "babylonjs/Debug/rayHelper";
  53508. export * from "babylonjs/Debug/skeletonViewer";
  53509. export * from "babylonjs/Debug/ISkeletonViewer";
  53510. }
  53511. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53512. /**
  53513. * Enum for Device Types
  53514. */
  53515. export enum DeviceType {
  53516. /** Generic */
  53517. Generic = 0,
  53518. /** Keyboard */
  53519. Keyboard = 1,
  53520. /** Mouse */
  53521. Mouse = 2,
  53522. /** Touch Pointers */
  53523. Touch = 3,
  53524. /** PS4 Dual Shock */
  53525. DualShock = 4,
  53526. /** Xbox */
  53527. Xbox = 5,
  53528. /** Switch Controller */
  53529. Switch = 6
  53530. }
  53531. /**
  53532. * Enum for All Pointers (Touch/Mouse)
  53533. */
  53534. export enum PointerInput {
  53535. /** Horizontal Axis */
  53536. Horizontal = 0,
  53537. /** Vertical Axis */
  53538. Vertical = 1,
  53539. /** Left Click or Touch */
  53540. LeftClick = 2,
  53541. /** Middle Click */
  53542. MiddleClick = 3,
  53543. /** Right Click */
  53544. RightClick = 4,
  53545. /** Browser Back */
  53546. BrowserBack = 5,
  53547. /** Browser Forward */
  53548. BrowserForward = 6
  53549. }
  53550. /**
  53551. * Enum for Dual Shock Gamepad
  53552. */
  53553. export enum DualShockInput {
  53554. /** Cross */
  53555. Cross = 0,
  53556. /** Circle */
  53557. Circle = 1,
  53558. /** Square */
  53559. Square = 2,
  53560. /** Triangle */
  53561. Triangle = 3,
  53562. /** L1 */
  53563. L1 = 4,
  53564. /** R1 */
  53565. R1 = 5,
  53566. /** L2 */
  53567. L2 = 6,
  53568. /** R2 */
  53569. R2 = 7,
  53570. /** Share */
  53571. Share = 8,
  53572. /** Options */
  53573. Options = 9,
  53574. /** L3 */
  53575. L3 = 10,
  53576. /** R3 */
  53577. R3 = 11,
  53578. /** DPadUp */
  53579. DPadUp = 12,
  53580. /** DPadDown */
  53581. DPadDown = 13,
  53582. /** DPadLeft */
  53583. DPadLeft = 14,
  53584. /** DRight */
  53585. DPadRight = 15,
  53586. /** Home */
  53587. Home = 16,
  53588. /** TouchPad */
  53589. TouchPad = 17,
  53590. /** LStickXAxis */
  53591. LStickXAxis = 18,
  53592. /** LStickYAxis */
  53593. LStickYAxis = 19,
  53594. /** RStickXAxis */
  53595. RStickXAxis = 20,
  53596. /** RStickYAxis */
  53597. RStickYAxis = 21
  53598. }
  53599. /**
  53600. * Enum for Xbox Gamepad
  53601. */
  53602. export enum XboxInput {
  53603. /** A */
  53604. A = 0,
  53605. /** B */
  53606. B = 1,
  53607. /** X */
  53608. X = 2,
  53609. /** Y */
  53610. Y = 3,
  53611. /** LB */
  53612. LB = 4,
  53613. /** RB */
  53614. RB = 5,
  53615. /** LT */
  53616. LT = 6,
  53617. /** RT */
  53618. RT = 7,
  53619. /** Back */
  53620. Back = 8,
  53621. /** Start */
  53622. Start = 9,
  53623. /** LS */
  53624. LS = 10,
  53625. /** RS */
  53626. RS = 11,
  53627. /** DPadUp */
  53628. DPadUp = 12,
  53629. /** DPadDown */
  53630. DPadDown = 13,
  53631. /** DPadLeft */
  53632. DPadLeft = 14,
  53633. /** DRight */
  53634. DPadRight = 15,
  53635. /** Home */
  53636. Home = 16,
  53637. /** LStickXAxis */
  53638. LStickXAxis = 17,
  53639. /** LStickYAxis */
  53640. LStickYAxis = 18,
  53641. /** RStickXAxis */
  53642. RStickXAxis = 19,
  53643. /** RStickYAxis */
  53644. RStickYAxis = 20
  53645. }
  53646. /**
  53647. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53648. */
  53649. export enum SwitchInput {
  53650. /** B */
  53651. B = 0,
  53652. /** A */
  53653. A = 1,
  53654. /** Y */
  53655. Y = 2,
  53656. /** X */
  53657. X = 3,
  53658. /** L */
  53659. L = 4,
  53660. /** R */
  53661. R = 5,
  53662. /** ZL */
  53663. ZL = 6,
  53664. /** ZR */
  53665. ZR = 7,
  53666. /** Minus */
  53667. Minus = 8,
  53668. /** Plus */
  53669. Plus = 9,
  53670. /** LS */
  53671. LS = 10,
  53672. /** RS */
  53673. RS = 11,
  53674. /** DPadUp */
  53675. DPadUp = 12,
  53676. /** DPadDown */
  53677. DPadDown = 13,
  53678. /** DPadLeft */
  53679. DPadLeft = 14,
  53680. /** DRight */
  53681. DPadRight = 15,
  53682. /** Home */
  53683. Home = 16,
  53684. /** Capture */
  53685. Capture = 17,
  53686. /** LStickXAxis */
  53687. LStickXAxis = 18,
  53688. /** LStickYAxis */
  53689. LStickYAxis = 19,
  53690. /** RStickXAxis */
  53691. RStickXAxis = 20,
  53692. /** RStickYAxis */
  53693. RStickYAxis = 21
  53694. }
  53695. }
  53696. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53697. import { Engine } from "babylonjs/Engines/engine";
  53698. import { IDisposable } from "babylonjs/scene";
  53699. import { Nullable } from "babylonjs/types";
  53700. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53701. /**
  53702. * This class will take all inputs from Keyboard, Pointer, and
  53703. * any Gamepads and provide a polling system that all devices
  53704. * will use. This class assumes that there will only be one
  53705. * pointer device and one keyboard.
  53706. */
  53707. export class DeviceInputSystem implements IDisposable {
  53708. /**
  53709. * Callback to be triggered when a device is connected
  53710. */
  53711. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53712. /**
  53713. * Callback to be triggered when a device is disconnected
  53714. */
  53715. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53716. /**
  53717. * Callback to be triggered when event driven input is updated
  53718. */
  53719. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53720. private _inputs;
  53721. private _gamepads;
  53722. private _keyboardActive;
  53723. private _pointerActive;
  53724. private _elementToAttachTo;
  53725. private _keyboardDownEvent;
  53726. private _keyboardUpEvent;
  53727. private _pointerMoveEvent;
  53728. private _pointerDownEvent;
  53729. private _pointerUpEvent;
  53730. private _gamepadConnectedEvent;
  53731. private _gamepadDisconnectedEvent;
  53732. private static _MAX_KEYCODES;
  53733. private static _MAX_POINTER_INPUTS;
  53734. private constructor();
  53735. /**
  53736. * Creates a new DeviceInputSystem instance
  53737. * @param engine Engine to pull input element from
  53738. * @returns The new instance
  53739. */
  53740. static Create(engine: Engine): DeviceInputSystem;
  53741. /**
  53742. * Checks for current device input value, given an id and input index
  53743. * @param deviceName Id of connected device
  53744. * @param inputIndex Index of device input
  53745. * @returns Current value of input
  53746. */
  53747. /**
  53748. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53749. * @param deviceType Enum specifiying device type
  53750. * @param deviceSlot "Slot" or index that device is referenced in
  53751. * @param inputIndex Id of input to be checked
  53752. * @returns Current value of input
  53753. */
  53754. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53755. /**
  53756. * Dispose of all the eventlisteners
  53757. */
  53758. dispose(): void;
  53759. /**
  53760. * Add device and inputs to device array
  53761. * @param deviceType Enum specifiying device type
  53762. * @param deviceSlot "Slot" or index that device is referenced in
  53763. * @param numberOfInputs Number of input entries to create for given device
  53764. */
  53765. private _registerDevice;
  53766. /**
  53767. * Given a specific device name, remove that device from the device map
  53768. * @param deviceType Enum specifiying device type
  53769. * @param deviceSlot "Slot" or index that device is referenced in
  53770. */
  53771. private _unregisterDevice;
  53772. /**
  53773. * Handle all actions that come from keyboard interaction
  53774. */
  53775. private _handleKeyActions;
  53776. /**
  53777. * Handle all actions that come from pointer interaction
  53778. */
  53779. private _handlePointerActions;
  53780. /**
  53781. * Handle all actions that come from gamepad interaction
  53782. */
  53783. private _handleGamepadActions;
  53784. /**
  53785. * Update all non-event based devices with each frame
  53786. * @param deviceType Enum specifiying device type
  53787. * @param deviceSlot "Slot" or index that device is referenced in
  53788. * @param inputIndex Id of input to be checked
  53789. */
  53790. private _updateDevice;
  53791. /**
  53792. * Gets DeviceType from the device name
  53793. * @param deviceName Name of Device from DeviceInputSystem
  53794. * @returns DeviceType enum value
  53795. */
  53796. private _getGamepadDeviceType;
  53797. }
  53798. }
  53799. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53800. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53801. /**
  53802. * Type to handle enforcement of inputs
  53803. */
  53804. 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;
  53805. }
  53806. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53807. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53808. import { Engine } from "babylonjs/Engines/engine";
  53809. import { IDisposable } from "babylonjs/scene";
  53810. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53811. import { Nullable } from "babylonjs/types";
  53812. import { Observable } from "babylonjs/Misc/observable";
  53813. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53814. /**
  53815. * Class that handles all input for a specific device
  53816. */
  53817. export class DeviceSource<T extends DeviceType> {
  53818. /** Type of device */
  53819. readonly deviceType: DeviceType;
  53820. /** "Slot" or index that device is referenced in */
  53821. readonly deviceSlot: number;
  53822. /**
  53823. * Observable to handle device input changes per device
  53824. */
  53825. readonly onInputChangedObservable: Observable<{
  53826. inputIndex: DeviceInput<T>;
  53827. previousState: Nullable<number>;
  53828. currentState: Nullable<number>;
  53829. }>;
  53830. private readonly _deviceInputSystem;
  53831. /**
  53832. * Default Constructor
  53833. * @param deviceInputSystem Reference to DeviceInputSystem
  53834. * @param deviceType Type of device
  53835. * @param deviceSlot "Slot" or index that device is referenced in
  53836. */
  53837. constructor(deviceInputSystem: DeviceInputSystem,
  53838. /** Type of device */
  53839. deviceType: DeviceType,
  53840. /** "Slot" or index that device is referenced in */
  53841. deviceSlot?: number);
  53842. /**
  53843. * Get input for specific input
  53844. * @param inputIndex index of specific input on device
  53845. * @returns Input value from DeviceInputSystem
  53846. */
  53847. getInput(inputIndex: DeviceInput<T>): number;
  53848. }
  53849. /**
  53850. * Class to keep track of devices
  53851. */
  53852. export class DeviceSourceManager implements IDisposable {
  53853. /**
  53854. * Observable to be triggered when before a device is connected
  53855. */
  53856. readonly onBeforeDeviceConnectedObservable: Observable<{
  53857. deviceType: DeviceType;
  53858. deviceSlot: number;
  53859. }>;
  53860. /**
  53861. * Observable to be triggered when before a device is disconnected
  53862. */
  53863. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53864. deviceType: DeviceType;
  53865. deviceSlot: number;
  53866. }>;
  53867. /**
  53868. * Observable to be triggered when after a device is connected
  53869. */
  53870. readonly onAfterDeviceConnectedObservable: Observable<{
  53871. deviceType: DeviceType;
  53872. deviceSlot: number;
  53873. }>;
  53874. /**
  53875. * Observable to be triggered when after a device is disconnected
  53876. */
  53877. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53878. deviceType: DeviceType;
  53879. deviceSlot: number;
  53880. }>;
  53881. private readonly _devices;
  53882. private readonly _firstDevice;
  53883. private readonly _deviceInputSystem;
  53884. /**
  53885. * Default Constructor
  53886. * @param engine engine to pull input element from
  53887. */
  53888. constructor(engine: Engine);
  53889. /**
  53890. * Gets a DeviceSource, given a type and slot
  53891. * @param deviceType Enum specifying device type
  53892. * @param deviceSlot "Slot" or index that device is referenced in
  53893. * @returns DeviceSource object
  53894. */
  53895. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53896. /**
  53897. * Gets an array of DeviceSource objects for a given device type
  53898. * @param deviceType Enum specifying device type
  53899. * @returns Array of DeviceSource objects
  53900. */
  53901. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53902. /**
  53903. * Dispose of DeviceInputSystem and other parts
  53904. */
  53905. dispose(): void;
  53906. /**
  53907. * Function to add device name to device list
  53908. * @param deviceType Enum specifying device type
  53909. * @param deviceSlot "Slot" or index that device is referenced in
  53910. */
  53911. private _addDevice;
  53912. /**
  53913. * Function to remove device name to device list
  53914. * @param deviceType Enum specifying device type
  53915. * @param deviceSlot "Slot" or index that device is referenced in
  53916. */
  53917. private _removeDevice;
  53918. /**
  53919. * Updates array storing first connected device of each type
  53920. * @param type Type of Device
  53921. */
  53922. private _updateFirstDevices;
  53923. }
  53924. }
  53925. declare module "babylonjs/DeviceInput/index" {
  53926. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53927. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53928. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53929. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53930. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53931. }
  53932. declare module "babylonjs/Engines/nullEngine" {
  53933. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53934. import { Engine } from "babylonjs/Engines/engine";
  53935. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53936. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53937. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53938. import { Effect } from "babylonjs/Materials/effect";
  53939. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53940. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53941. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53942. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53943. /**
  53944. * Options to create the null engine
  53945. */
  53946. export class NullEngineOptions {
  53947. /**
  53948. * Render width (Default: 512)
  53949. */
  53950. renderWidth: number;
  53951. /**
  53952. * Render height (Default: 256)
  53953. */
  53954. renderHeight: number;
  53955. /**
  53956. * Texture size (Default: 512)
  53957. */
  53958. textureSize: number;
  53959. /**
  53960. * If delta time between frames should be constant
  53961. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53962. */
  53963. deterministicLockstep: boolean;
  53964. /**
  53965. * Maximum about of steps between frames (Default: 4)
  53966. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53967. */
  53968. lockstepMaxSteps: number;
  53969. /**
  53970. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53971. */
  53972. useHighPrecisionMatrix?: boolean;
  53973. }
  53974. /**
  53975. * The null engine class provides support for headless version of babylon.js.
  53976. * This can be used in server side scenario or for testing purposes
  53977. */
  53978. export class NullEngine extends Engine {
  53979. private _options;
  53980. /**
  53981. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53982. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53983. * @returns true if engine is in deterministic lock step mode
  53984. */
  53985. isDeterministicLockStep(): boolean;
  53986. /**
  53987. * Gets the max steps when engine is running in deterministic lock step
  53988. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53989. * @returns the max steps
  53990. */
  53991. getLockstepMaxSteps(): number;
  53992. /**
  53993. * Gets the current hardware scaling level.
  53994. * By default the hardware scaling level is computed from the window device ratio.
  53995. * 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.
  53996. * @returns a number indicating the current hardware scaling level
  53997. */
  53998. getHardwareScalingLevel(): number;
  53999. constructor(options?: NullEngineOptions);
  54000. /**
  54001. * Creates a vertex buffer
  54002. * @param vertices the data for the vertex buffer
  54003. * @returns the new WebGL static buffer
  54004. */
  54005. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54006. /**
  54007. * Creates a new index buffer
  54008. * @param indices defines the content of the index buffer
  54009. * @param updatable defines if the index buffer must be updatable
  54010. * @returns a new webGL buffer
  54011. */
  54012. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54013. /**
  54014. * Clear the current render buffer or the current render target (if any is set up)
  54015. * @param color defines the color to use
  54016. * @param backBuffer defines if the back buffer must be cleared
  54017. * @param depth defines if the depth buffer must be cleared
  54018. * @param stencil defines if the stencil buffer must be cleared
  54019. */
  54020. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54021. /**
  54022. * Gets the current render width
  54023. * @param useScreen defines if screen size must be used (or the current render target if any)
  54024. * @returns a number defining the current render width
  54025. */
  54026. getRenderWidth(useScreen?: boolean): number;
  54027. /**
  54028. * Gets the current render height
  54029. * @param useScreen defines if screen size must be used (or the current render target if any)
  54030. * @returns a number defining the current render height
  54031. */
  54032. getRenderHeight(useScreen?: boolean): number;
  54033. /**
  54034. * Set the WebGL's viewport
  54035. * @param viewport defines the viewport element to be used
  54036. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54037. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54038. */
  54039. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54040. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54041. /**
  54042. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54043. * @param pipelineContext defines the pipeline context to use
  54044. * @param uniformsNames defines the list of uniform names
  54045. * @returns an array of webGL uniform locations
  54046. */
  54047. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54048. /**
  54049. * Gets the lsit of active attributes for a given webGL program
  54050. * @param pipelineContext defines the pipeline context to use
  54051. * @param attributesNames defines the list of attribute names to get
  54052. * @returns an array of indices indicating the offset of each attribute
  54053. */
  54054. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54055. /**
  54056. * Binds an effect to the webGL context
  54057. * @param effect defines the effect to bind
  54058. */
  54059. bindSamplers(effect: Effect): void;
  54060. /**
  54061. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54062. * @param effect defines the effect to activate
  54063. */
  54064. enableEffect(effect: Effect): void;
  54065. /**
  54066. * Set various states to the webGL context
  54067. * @param culling defines backface culling state
  54068. * @param zOffset defines the value to apply to zOffset (0 by default)
  54069. * @param force defines if states must be applied even if cache is up to date
  54070. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54071. */
  54072. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54073. /**
  54074. * Set the value of an uniform to an array of int32
  54075. * @param uniform defines the webGL uniform location where to store the value
  54076. * @param array defines the array of int32 to store
  54077. * @returns true if value was set
  54078. */
  54079. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54080. /**
  54081. * Set the value of an uniform to an array of int32 (stored as vec2)
  54082. * @param uniform defines the webGL uniform location where to store the value
  54083. * @param array defines the array of int32 to store
  54084. * @returns true if value was set
  54085. */
  54086. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54087. /**
  54088. * Set the value of an uniform to an array of int32 (stored as vec3)
  54089. * @param uniform defines the webGL uniform location where to store the value
  54090. * @param array defines the array of int32 to store
  54091. * @returns true if value was set
  54092. */
  54093. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54094. /**
  54095. * Set the value of an uniform to an array of int32 (stored as vec4)
  54096. * @param uniform defines the webGL uniform location where to store the value
  54097. * @param array defines the array of int32 to store
  54098. * @returns true if value was set
  54099. */
  54100. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54101. /**
  54102. * Set the value of an uniform to an array of float32
  54103. * @param uniform defines the webGL uniform location where to store the value
  54104. * @param array defines the array of float32 to store
  54105. * @returns true if value was set
  54106. */
  54107. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54108. /**
  54109. * Set the value of an uniform to an array of float32 (stored as vec2)
  54110. * @param uniform defines the webGL uniform location where to store the value
  54111. * @param array defines the array of float32 to store
  54112. * @returns true if value was set
  54113. */
  54114. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54115. /**
  54116. * Set the value of an uniform to an array of float32 (stored as vec3)
  54117. * @param uniform defines the webGL uniform location where to store the value
  54118. * @param array defines the array of float32 to store
  54119. * @returns true if value was set
  54120. */
  54121. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54122. /**
  54123. * Set the value of an uniform to an array of float32 (stored as vec4)
  54124. * @param uniform defines the webGL uniform location where to store the value
  54125. * @param array defines the array of float32 to store
  54126. * @returns true if value was set
  54127. */
  54128. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54129. /**
  54130. * Set the value of an uniform to an array of number
  54131. * @param uniform defines the webGL uniform location where to store the value
  54132. * @param array defines the array of number to store
  54133. * @returns true if value was set
  54134. */
  54135. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  54136. /**
  54137. * Set the value of an uniform to an array of number (stored as vec2)
  54138. * @param uniform defines the webGL uniform location where to store the value
  54139. * @param array defines the array of number to store
  54140. * @returns true if value was set
  54141. */
  54142. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  54143. /**
  54144. * Set the value of an uniform to an array of number (stored as vec3)
  54145. * @param uniform defines the webGL uniform location where to store the value
  54146. * @param array defines the array of number to store
  54147. * @returns true if value was set
  54148. */
  54149. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  54150. /**
  54151. * Set the value of an uniform to an array of number (stored as vec4)
  54152. * @param uniform defines the webGL uniform location where to store the value
  54153. * @param array defines the array of number to store
  54154. * @returns true if value was set
  54155. */
  54156. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  54157. /**
  54158. * Set the value of an uniform to an array of float32 (stored as matrices)
  54159. * @param uniform defines the webGL uniform location where to store the value
  54160. * @param matrices defines the array of float32 to store
  54161. * @returns true if value was set
  54162. */
  54163. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  54164. /**
  54165. * Set the value of an uniform to a matrix (3x3)
  54166. * @param uniform defines the webGL uniform location where to store the value
  54167. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54168. * @returns true if value was set
  54169. */
  54170. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54171. /**
  54172. * Set the value of an uniform to a matrix (2x2)
  54173. * @param uniform defines the webGL uniform location where to store the value
  54174. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54175. * @returns true if value was set
  54176. */
  54177. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54178. /**
  54179. * Set the value of an uniform to a number (float)
  54180. * @param uniform defines the webGL uniform location where to store the value
  54181. * @param value defines the float number to store
  54182. * @returns true if value was set
  54183. */
  54184. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  54185. /**
  54186. * Set the value of an uniform to a vec2
  54187. * @param uniform defines the webGL uniform location where to store the value
  54188. * @param x defines the 1st component of the value
  54189. * @param y defines the 2nd component of the value
  54190. * @returns true if value was set
  54191. */
  54192. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  54193. /**
  54194. * Set the value of an uniform to a vec3
  54195. * @param uniform defines the webGL uniform location where to store the value
  54196. * @param x defines the 1st component of the value
  54197. * @param y defines the 2nd component of the value
  54198. * @param z defines the 3rd component of the value
  54199. * @returns true if value was set
  54200. */
  54201. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  54202. /**
  54203. * Set the value of an uniform to a boolean
  54204. * @param uniform defines the webGL uniform location where to store the value
  54205. * @param bool defines the boolean to store
  54206. * @returns true if value was set
  54207. */
  54208. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  54209. /**
  54210. * Set the value of an uniform to a vec4
  54211. * @param uniform defines the webGL uniform location where to store the value
  54212. * @param x defines the 1st component of the value
  54213. * @param y defines the 2nd component of the value
  54214. * @param z defines the 3rd component of the value
  54215. * @param w defines the 4th component of the value
  54216. * @returns true if value was set
  54217. */
  54218. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  54219. /**
  54220. * Sets the current alpha mode
  54221. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54222. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54223. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54224. */
  54225. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54226. /**
  54227. * Bind webGl buffers directly to the webGL context
  54228. * @param vertexBuffers defines the vertex buffer to bind
  54229. * @param indexBuffer defines the index buffer to bind
  54230. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54231. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54232. * @param effect defines the effect associated with the vertex buffer
  54233. */
  54234. bindBuffers(vertexBuffers: {
  54235. [key: string]: VertexBuffer;
  54236. }, indexBuffer: DataBuffer, effect: Effect): void;
  54237. /**
  54238. * Force the entire cache to be cleared
  54239. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54240. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54241. */
  54242. wipeCaches(bruteForce?: boolean): void;
  54243. /**
  54244. * Send a draw order
  54245. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54246. * @param indexStart defines the starting index
  54247. * @param indexCount defines the number of index to draw
  54248. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54249. */
  54250. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54251. /**
  54252. * Draw a list of indexed primitives
  54253. * @param fillMode defines the primitive to use
  54254. * @param indexStart defines the starting index
  54255. * @param indexCount defines the number of index to draw
  54256. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54257. */
  54258. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54259. /**
  54260. * Draw a list of unindexed primitives
  54261. * @param fillMode defines the primitive to use
  54262. * @param verticesStart defines the index of first vertex to draw
  54263. * @param verticesCount defines the count of vertices to draw
  54264. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54265. */
  54266. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54267. /** @hidden */
  54268. _createTexture(): WebGLTexture;
  54269. /** @hidden */
  54270. _releaseTexture(texture: InternalTexture): void;
  54271. /**
  54272. * Usually called from Texture.ts.
  54273. * Passed information to create a WebGLTexture
  54274. * @param urlArg defines a value which contains one of the following:
  54275. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54276. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54277. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54278. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54279. * @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)
  54280. * @param scene needed for loading to the correct scene
  54281. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54282. * @param onLoad optional callback to be called upon successful completion
  54283. * @param onError optional callback to be called upon failure
  54284. * @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
  54285. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54286. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54287. * @param forcedExtension defines the extension to use to pick the right loader
  54288. * @param mimeType defines an optional mime type
  54289. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54290. */
  54291. 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;
  54292. /**
  54293. * Creates a new render target texture
  54294. * @param size defines the size of the texture
  54295. * @param options defines the options used to create the texture
  54296. * @returns a new render target texture stored in an InternalTexture
  54297. */
  54298. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54299. /**
  54300. * Update the sampling mode of a given texture
  54301. * @param samplingMode defines the required sampling mode
  54302. * @param texture defines the texture to update
  54303. */
  54304. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54305. /**
  54306. * Binds the frame buffer to the specified texture.
  54307. * @param texture The texture to render to or null for the default canvas
  54308. * @param faceIndex The face of the texture to render to in case of cube texture
  54309. * @param requiredWidth The width of the target to render to
  54310. * @param requiredHeight The height of the target to render to
  54311. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54312. * @param lodLevel defines le lod level to bind to the frame buffer
  54313. */
  54314. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54315. /**
  54316. * Unbind the current render target texture from the webGL context
  54317. * @param texture defines the render target texture to unbind
  54318. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54319. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54320. */
  54321. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54322. /**
  54323. * Creates a dynamic vertex buffer
  54324. * @param vertices the data for the dynamic vertex buffer
  54325. * @returns the new WebGL dynamic buffer
  54326. */
  54327. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54328. /**
  54329. * Update the content of a dynamic texture
  54330. * @param texture defines the texture to update
  54331. * @param canvas defines the canvas containing the source
  54332. * @param invertY defines if data must be stored with Y axis inverted
  54333. * @param premulAlpha defines if alpha is stored as premultiplied
  54334. * @param format defines the format of the data
  54335. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54336. */
  54337. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54338. /**
  54339. * Gets a boolean indicating if all created effects are ready
  54340. * @returns true if all effects are ready
  54341. */
  54342. areAllEffectsReady(): boolean;
  54343. /**
  54344. * @hidden
  54345. * Get the current error code of the webGL context
  54346. * @returns the error code
  54347. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54348. */
  54349. getError(): number;
  54350. /** @hidden */
  54351. _getUnpackAlignement(): number;
  54352. /** @hidden */
  54353. _unpackFlipY(value: boolean): void;
  54354. /**
  54355. * Update a dynamic index buffer
  54356. * @param indexBuffer defines the target index buffer
  54357. * @param indices defines the data to update
  54358. * @param offset defines the offset in the target index buffer where update should start
  54359. */
  54360. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54361. /**
  54362. * Updates a dynamic vertex buffer.
  54363. * @param vertexBuffer the vertex buffer to update
  54364. * @param vertices the data used to update the vertex buffer
  54365. * @param byteOffset the byte offset of the data (optional)
  54366. * @param byteLength the byte length of the data (optional)
  54367. */
  54368. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54369. /** @hidden */
  54370. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54371. /** @hidden */
  54372. _bindTexture(channel: number, texture: InternalTexture): void;
  54373. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54374. /**
  54375. * 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
  54376. */
  54377. releaseEffects(): void;
  54378. displayLoadingUI(): void;
  54379. hideLoadingUI(): void;
  54380. /** @hidden */
  54381. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54382. /** @hidden */
  54383. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54384. /** @hidden */
  54385. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54386. /** @hidden */
  54387. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54388. }
  54389. }
  54390. declare module "babylonjs/Instrumentation/timeToken" {
  54391. import { Nullable } from "babylonjs/types";
  54392. /**
  54393. * @hidden
  54394. **/
  54395. export class _TimeToken {
  54396. _startTimeQuery: Nullable<WebGLQuery>;
  54397. _endTimeQuery: Nullable<WebGLQuery>;
  54398. _timeElapsedQuery: Nullable<WebGLQuery>;
  54399. _timeElapsedQueryEnded: boolean;
  54400. }
  54401. }
  54402. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54403. import { Nullable, int } from "babylonjs/types";
  54404. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54405. /** @hidden */
  54406. export class _OcclusionDataStorage {
  54407. /** @hidden */
  54408. occlusionInternalRetryCounter: number;
  54409. /** @hidden */
  54410. isOcclusionQueryInProgress: boolean;
  54411. /** @hidden */
  54412. isOccluded: boolean;
  54413. /** @hidden */
  54414. occlusionRetryCount: number;
  54415. /** @hidden */
  54416. occlusionType: number;
  54417. /** @hidden */
  54418. occlusionQueryAlgorithmType: number;
  54419. }
  54420. module "babylonjs/Engines/engine" {
  54421. interface Engine {
  54422. /**
  54423. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54424. * @return the new query
  54425. */
  54426. createQuery(): WebGLQuery;
  54427. /**
  54428. * Delete and release a webGL query
  54429. * @param query defines the query to delete
  54430. * @return the current engine
  54431. */
  54432. deleteQuery(query: WebGLQuery): Engine;
  54433. /**
  54434. * Check if a given query has resolved and got its value
  54435. * @param query defines the query to check
  54436. * @returns true if the query got its value
  54437. */
  54438. isQueryResultAvailable(query: WebGLQuery): boolean;
  54439. /**
  54440. * Gets the value of a given query
  54441. * @param query defines the query to check
  54442. * @returns the value of the query
  54443. */
  54444. getQueryResult(query: WebGLQuery): number;
  54445. /**
  54446. * Initiates an occlusion query
  54447. * @param algorithmType defines the algorithm to use
  54448. * @param query defines the query to use
  54449. * @returns the current engine
  54450. * @see https://doc.babylonjs.com/features/occlusionquery
  54451. */
  54452. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54453. /**
  54454. * Ends an occlusion query
  54455. * @see https://doc.babylonjs.com/features/occlusionquery
  54456. * @param algorithmType defines the algorithm to use
  54457. * @returns the current engine
  54458. */
  54459. endOcclusionQuery(algorithmType: number): Engine;
  54460. /**
  54461. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54462. * Please note that only one query can be issued at a time
  54463. * @returns a time token used to track the time span
  54464. */
  54465. startTimeQuery(): Nullable<_TimeToken>;
  54466. /**
  54467. * Ends a time query
  54468. * @param token defines the token used to measure the time span
  54469. * @returns the time spent (in ns)
  54470. */
  54471. endTimeQuery(token: _TimeToken): int;
  54472. /** @hidden */
  54473. _currentNonTimestampToken: Nullable<_TimeToken>;
  54474. /** @hidden */
  54475. _createTimeQuery(): WebGLQuery;
  54476. /** @hidden */
  54477. _deleteTimeQuery(query: WebGLQuery): void;
  54478. /** @hidden */
  54479. _getGlAlgorithmType(algorithmType: number): number;
  54480. /** @hidden */
  54481. _getTimeQueryResult(query: WebGLQuery): any;
  54482. /** @hidden */
  54483. _getTimeQueryAvailability(query: WebGLQuery): any;
  54484. }
  54485. }
  54486. module "babylonjs/Meshes/abstractMesh" {
  54487. interface AbstractMesh {
  54488. /**
  54489. * Backing filed
  54490. * @hidden
  54491. */
  54492. __occlusionDataStorage: _OcclusionDataStorage;
  54493. /**
  54494. * Access property
  54495. * @hidden
  54496. */
  54497. _occlusionDataStorage: _OcclusionDataStorage;
  54498. /**
  54499. * 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.
  54500. * The default value is -1 which means don't break the query and wait till the result
  54501. * @see https://doc.babylonjs.com/features/occlusionquery
  54502. */
  54503. occlusionRetryCount: number;
  54504. /**
  54505. * 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:
  54506. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54507. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54508. * * 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.
  54509. * @see https://doc.babylonjs.com/features/occlusionquery
  54510. */
  54511. occlusionType: number;
  54512. /**
  54513. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54514. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54515. * * 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.
  54516. * @see https://doc.babylonjs.com/features/occlusionquery
  54517. */
  54518. occlusionQueryAlgorithmType: number;
  54519. /**
  54520. * 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
  54521. * @see https://doc.babylonjs.com/features/occlusionquery
  54522. */
  54523. isOccluded: boolean;
  54524. /**
  54525. * Flag to check the progress status of the query
  54526. * @see https://doc.babylonjs.com/features/occlusionquery
  54527. */
  54528. isOcclusionQueryInProgress: boolean;
  54529. }
  54530. }
  54531. }
  54532. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54533. import { Nullable } from "babylonjs/types";
  54534. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54535. /** @hidden */
  54536. export var _forceTransformFeedbackToBundle: boolean;
  54537. module "babylonjs/Engines/engine" {
  54538. interface Engine {
  54539. /**
  54540. * Creates a webGL transform feedback object
  54541. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54542. * @returns the webGL transform feedback object
  54543. */
  54544. createTransformFeedback(): WebGLTransformFeedback;
  54545. /**
  54546. * Delete a webGL transform feedback object
  54547. * @param value defines the webGL transform feedback object to delete
  54548. */
  54549. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54550. /**
  54551. * Bind a webGL transform feedback object to the webgl context
  54552. * @param value defines the webGL transform feedback object to bind
  54553. */
  54554. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54555. /**
  54556. * Begins a transform feedback operation
  54557. * @param usePoints defines if points or triangles must be used
  54558. */
  54559. beginTransformFeedback(usePoints: boolean): void;
  54560. /**
  54561. * Ends a transform feedback operation
  54562. */
  54563. endTransformFeedback(): void;
  54564. /**
  54565. * Specify the varyings to use with transform feedback
  54566. * @param program defines the associated webGL program
  54567. * @param value defines the list of strings representing the varying names
  54568. */
  54569. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54570. /**
  54571. * Bind a webGL buffer for a transform feedback operation
  54572. * @param value defines the webGL buffer to bind
  54573. */
  54574. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54575. }
  54576. }
  54577. }
  54578. declare module "babylonjs/Engines/Extensions/engine.views" {
  54579. import { Camera } from "babylonjs/Cameras/camera";
  54580. import { Nullable } from "babylonjs/types";
  54581. /**
  54582. * Class used to define an additional view for the engine
  54583. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54584. */
  54585. export class EngineView {
  54586. /** Defines the canvas where to render the view */
  54587. target: HTMLCanvasElement;
  54588. /** Defines an optional camera used to render the view (will use active camera else) */
  54589. camera?: Camera;
  54590. }
  54591. module "babylonjs/Engines/engine" {
  54592. interface Engine {
  54593. /**
  54594. * Gets or sets the HTML element to use for attaching events
  54595. */
  54596. inputElement: Nullable<HTMLElement>;
  54597. /**
  54598. * Gets the current engine view
  54599. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54600. */
  54601. activeView: Nullable<EngineView>;
  54602. /** Gets or sets the list of views */
  54603. views: EngineView[];
  54604. /**
  54605. * Register a new child canvas
  54606. * @param canvas defines the canvas to register
  54607. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54608. * @returns the associated view
  54609. */
  54610. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54611. /**
  54612. * Remove a registered child canvas
  54613. * @param canvas defines the canvas to remove
  54614. * @returns the current engine
  54615. */
  54616. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54617. }
  54618. }
  54619. }
  54620. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54621. import { Nullable } from "babylonjs/types";
  54622. module "babylonjs/Engines/engine" {
  54623. interface Engine {
  54624. /** @hidden */
  54625. _excludedCompressedTextures: string[];
  54626. /** @hidden */
  54627. _textureFormatInUse: string;
  54628. /**
  54629. * Gets the list of texture formats supported
  54630. */
  54631. readonly texturesSupported: Array<string>;
  54632. /**
  54633. * Gets the texture format in use
  54634. */
  54635. readonly textureFormatInUse: Nullable<string>;
  54636. /**
  54637. * Set the compressed texture extensions or file names to skip.
  54638. *
  54639. * @param skippedFiles defines the list of those texture files you want to skip
  54640. * Example: [".dds", ".env", "myfile.png"]
  54641. */
  54642. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54643. /**
  54644. * Set the compressed texture format to use, based on the formats you have, and the formats
  54645. * supported by the hardware / browser.
  54646. *
  54647. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54648. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54649. * to API arguments needed to compressed textures. This puts the burden on the container
  54650. * generator to house the arcane code for determining these for current & future formats.
  54651. *
  54652. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54653. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54654. *
  54655. * Note: The result of this call is not taken into account when a texture is base64.
  54656. *
  54657. * @param formatsAvailable defines the list of those format families you have created
  54658. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54659. *
  54660. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54661. * @returns The extension selected.
  54662. */
  54663. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54664. }
  54665. }
  54666. }
  54667. declare module "babylonjs/Engines/Extensions/index" {
  54668. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54669. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54670. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54671. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54672. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54673. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54674. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54675. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54676. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54677. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54678. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54679. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54680. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54681. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54682. export * from "babylonjs/Engines/Extensions/engine.views";
  54683. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54684. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54685. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54686. }
  54687. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54688. import { Nullable } from "babylonjs/types";
  54689. /**
  54690. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54691. */
  54692. export interface CubeMapInfo {
  54693. /**
  54694. * The pixel array for the front face.
  54695. * This is stored in format, left to right, up to down format.
  54696. */
  54697. front: Nullable<ArrayBufferView>;
  54698. /**
  54699. * The pixel array for the back face.
  54700. * This is stored in format, left to right, up to down format.
  54701. */
  54702. back: Nullable<ArrayBufferView>;
  54703. /**
  54704. * The pixel array for the left face.
  54705. * This is stored in format, left to right, up to down format.
  54706. */
  54707. left: Nullable<ArrayBufferView>;
  54708. /**
  54709. * The pixel array for the right face.
  54710. * This is stored in format, left to right, up to down format.
  54711. */
  54712. right: Nullable<ArrayBufferView>;
  54713. /**
  54714. * The pixel array for the up face.
  54715. * This is stored in format, left to right, up to down format.
  54716. */
  54717. up: Nullable<ArrayBufferView>;
  54718. /**
  54719. * The pixel array for the down face.
  54720. * This is stored in format, left to right, up to down format.
  54721. */
  54722. down: Nullable<ArrayBufferView>;
  54723. /**
  54724. * The size of the cubemap stored.
  54725. *
  54726. * Each faces will be size * size pixels.
  54727. */
  54728. size: number;
  54729. /**
  54730. * The format of the texture.
  54731. *
  54732. * RGBA, RGB.
  54733. */
  54734. format: number;
  54735. /**
  54736. * The type of the texture data.
  54737. *
  54738. * UNSIGNED_INT, FLOAT.
  54739. */
  54740. type: number;
  54741. /**
  54742. * Specifies whether the texture is in gamma space.
  54743. */
  54744. gammaSpace: boolean;
  54745. }
  54746. /**
  54747. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54748. */
  54749. export class PanoramaToCubeMapTools {
  54750. private static FACE_LEFT;
  54751. private static FACE_RIGHT;
  54752. private static FACE_FRONT;
  54753. private static FACE_BACK;
  54754. private static FACE_DOWN;
  54755. private static FACE_UP;
  54756. /**
  54757. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54758. *
  54759. * @param float32Array The source data.
  54760. * @param inputWidth The width of the input panorama.
  54761. * @param inputHeight The height of the input panorama.
  54762. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54763. * @return The cubemap data
  54764. */
  54765. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54766. private static CreateCubemapTexture;
  54767. private static CalcProjectionSpherical;
  54768. }
  54769. }
  54770. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54771. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54772. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54773. import { Nullable } from "babylonjs/types";
  54774. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54775. /**
  54776. * Helper class dealing with the extraction of spherical polynomial dataArray
  54777. * from a cube map.
  54778. */
  54779. export class CubeMapToSphericalPolynomialTools {
  54780. private static FileFaces;
  54781. /**
  54782. * Converts a texture to the according Spherical Polynomial data.
  54783. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54784. *
  54785. * @param texture The texture to extract the information from.
  54786. * @return The Spherical Polynomial data.
  54787. */
  54788. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54789. /**
  54790. * Converts a cubemap to the according Spherical Polynomial data.
  54791. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54792. *
  54793. * @param cubeInfo The Cube map to extract the information from.
  54794. * @return The Spherical Polynomial data.
  54795. */
  54796. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54797. }
  54798. }
  54799. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54800. import { Nullable } from "babylonjs/types";
  54801. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54802. module "babylonjs/Materials/Textures/baseTexture" {
  54803. interface BaseTexture {
  54804. /**
  54805. * Get the polynomial representation of the texture data.
  54806. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54807. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54808. */
  54809. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54810. }
  54811. }
  54812. }
  54813. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54814. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54815. /** @hidden */
  54816. export var rgbdEncodePixelShader: {
  54817. name: string;
  54818. shader: string;
  54819. };
  54820. }
  54821. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54822. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54823. /** @hidden */
  54824. export var rgbdDecodePixelShader: {
  54825. name: string;
  54826. shader: string;
  54827. };
  54828. }
  54829. declare module "babylonjs/Misc/environmentTextureTools" {
  54830. import { Nullable } from "babylonjs/types";
  54831. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54832. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54833. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54834. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54835. import "babylonjs/Engines/Extensions/engine.readTexture";
  54836. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54837. import "babylonjs/Shaders/rgbdEncode.fragment";
  54838. import "babylonjs/Shaders/rgbdDecode.fragment";
  54839. /**
  54840. * Raw texture data and descriptor sufficient for WebGL texture upload
  54841. */
  54842. export interface EnvironmentTextureInfo {
  54843. /**
  54844. * Version of the environment map
  54845. */
  54846. version: number;
  54847. /**
  54848. * Width of image
  54849. */
  54850. width: number;
  54851. /**
  54852. * Irradiance information stored in the file.
  54853. */
  54854. irradiance: any;
  54855. /**
  54856. * Specular information stored in the file.
  54857. */
  54858. specular: any;
  54859. }
  54860. /**
  54861. * Defines One Image in the file. It requires only the position in the file
  54862. * as well as the length.
  54863. */
  54864. interface BufferImageData {
  54865. /**
  54866. * Length of the image data.
  54867. */
  54868. length: number;
  54869. /**
  54870. * Position of the data from the null terminator delimiting the end of the JSON.
  54871. */
  54872. position: number;
  54873. }
  54874. /**
  54875. * Defines the specular data enclosed in the file.
  54876. * This corresponds to the version 1 of the data.
  54877. */
  54878. export interface EnvironmentTextureSpecularInfoV1 {
  54879. /**
  54880. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54881. */
  54882. specularDataPosition?: number;
  54883. /**
  54884. * This contains all the images data needed to reconstruct the cubemap.
  54885. */
  54886. mipmaps: Array<BufferImageData>;
  54887. /**
  54888. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54889. */
  54890. lodGenerationScale: number;
  54891. }
  54892. /**
  54893. * Sets of helpers addressing the serialization and deserialization of environment texture
  54894. * stored in a BabylonJS env file.
  54895. * Those files are usually stored as .env files.
  54896. */
  54897. export class EnvironmentTextureTools {
  54898. /**
  54899. * Magic number identifying the env file.
  54900. */
  54901. private static _MagicBytes;
  54902. /**
  54903. * Gets the environment info from an env file.
  54904. * @param data The array buffer containing the .env bytes.
  54905. * @returns the environment file info (the json header) if successfully parsed.
  54906. */
  54907. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54908. /**
  54909. * Creates an environment texture from a loaded cube texture.
  54910. * @param texture defines the cube texture to convert in env file
  54911. * @return a promise containing the environment data if succesfull.
  54912. */
  54913. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54914. /**
  54915. * Creates a JSON representation of the spherical data.
  54916. * @param texture defines the texture containing the polynomials
  54917. * @return the JSON representation of the spherical info
  54918. */
  54919. private static _CreateEnvTextureIrradiance;
  54920. /**
  54921. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54922. * @param data the image data
  54923. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54924. * @return the views described by info providing access to the underlying buffer
  54925. */
  54926. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54927. /**
  54928. * Uploads the texture info contained in the env file to the GPU.
  54929. * @param texture defines the internal texture to upload to
  54930. * @param data defines the data to load
  54931. * @param info defines the texture info retrieved through the GetEnvInfo method
  54932. * @returns a promise
  54933. */
  54934. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54935. private static _OnImageReadyAsync;
  54936. /**
  54937. * Uploads the levels of image data to the GPU.
  54938. * @param texture defines the internal texture to upload to
  54939. * @param imageData defines the array buffer views of image data [mipmap][face]
  54940. * @returns a promise
  54941. */
  54942. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54943. /**
  54944. * Uploads spherical polynomials information to the texture.
  54945. * @param texture defines the texture we are trying to upload the information to
  54946. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54947. */
  54948. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54949. /** @hidden */
  54950. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54951. }
  54952. }
  54953. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54954. /**
  54955. * Class used to inline functions in shader code
  54956. */
  54957. export class ShaderCodeInliner {
  54958. private static readonly _RegexpFindFunctionNameAndType;
  54959. private _sourceCode;
  54960. private _functionDescr;
  54961. private _numMaxIterations;
  54962. /** Gets or sets the token used to mark the functions to inline */
  54963. inlineToken: string;
  54964. /** Gets or sets the debug mode */
  54965. debug: boolean;
  54966. /** Gets the code after the inlining process */
  54967. get code(): string;
  54968. /**
  54969. * Initializes the inliner
  54970. * @param sourceCode shader code source to inline
  54971. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54972. */
  54973. constructor(sourceCode: string, numMaxIterations?: number);
  54974. /**
  54975. * Start the processing of the shader code
  54976. */
  54977. processCode(): void;
  54978. private _collectFunctions;
  54979. private _processInlining;
  54980. private _extractBetweenMarkers;
  54981. private _skipWhitespaces;
  54982. private _removeComments;
  54983. private _replaceFunctionCallsByCode;
  54984. private _findBackward;
  54985. private _escapeRegExp;
  54986. private _replaceNames;
  54987. }
  54988. }
  54989. declare module "babylonjs/Engines/nativeEngine" {
  54990. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54991. import { Engine } from "babylonjs/Engines/engine";
  54992. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54993. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54995. import { Effect } from "babylonjs/Materials/effect";
  54996. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54997. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54998. import { IColor4Like } from "babylonjs/Maths/math.like";
  54999. import { Scene } from "babylonjs/scene";
  55000. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  55001. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  55002. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  55003. /**
  55004. * Container for accessors for natively-stored mesh data buffers.
  55005. */
  55006. class NativeDataBuffer extends DataBuffer {
  55007. /**
  55008. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55009. */
  55010. nativeIndexBuffer?: any;
  55011. /**
  55012. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55013. */
  55014. nativeVertexBuffer?: any;
  55015. }
  55016. /** @hidden */
  55017. class NativeTexture extends InternalTexture {
  55018. getInternalTexture(): InternalTexture;
  55019. getViewCount(): number;
  55020. }
  55021. /** @hidden */
  55022. export class NativeEngine extends Engine {
  55023. private readonly _native;
  55024. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55025. private readonly INVALID_HANDLE;
  55026. private _boundBuffersVertexArray;
  55027. getHardwareScalingLevel(): number;
  55028. constructor();
  55029. dispose(): void;
  55030. /**
  55031. * Can be used to override the current requestAnimationFrame requester.
  55032. * @hidden
  55033. */
  55034. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55035. /**
  55036. * Override default engine behavior.
  55037. * @param color
  55038. * @param backBuffer
  55039. * @param depth
  55040. * @param stencil
  55041. */
  55042. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55043. /**
  55044. * Gets host document
  55045. * @returns the host document object
  55046. */
  55047. getHostDocument(): Nullable<Document>;
  55048. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55049. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55050. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55051. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55052. [key: string]: VertexBuffer;
  55053. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55054. bindBuffers(vertexBuffers: {
  55055. [key: string]: VertexBuffer;
  55056. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55057. recordVertexArrayObject(vertexBuffers: {
  55058. [key: string]: VertexBuffer;
  55059. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55060. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55061. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55062. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55063. /**
  55064. * Draw a list of indexed primitives
  55065. * @param fillMode defines the primitive to use
  55066. * @param indexStart defines the starting index
  55067. * @param indexCount defines the number of index to draw
  55068. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55069. */
  55070. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55071. /**
  55072. * Draw a list of unindexed primitives
  55073. * @param fillMode defines the primitive to use
  55074. * @param verticesStart defines the index of first vertex to draw
  55075. * @param verticesCount defines the count of vertices to draw
  55076. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55077. */
  55078. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55079. createPipelineContext(): IPipelineContext;
  55080. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55081. /** @hidden */
  55082. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55083. /** @hidden */
  55084. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55085. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55086. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55087. protected _setProgram(program: WebGLProgram): void;
  55088. _releaseEffect(effect: Effect): void;
  55089. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55090. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55091. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55092. bindSamplers(effect: Effect): void;
  55093. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55094. getRenderWidth(useScreen?: boolean): number;
  55095. getRenderHeight(useScreen?: boolean): number;
  55096. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55097. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55098. /**
  55099. * Set the z offset to apply to current rendering
  55100. * @param value defines the offset to apply
  55101. */
  55102. setZOffset(value: number): void;
  55103. /**
  55104. * Gets the current value of the zOffset
  55105. * @returns the current zOffset state
  55106. */
  55107. getZOffset(): number;
  55108. /**
  55109. * Enable or disable depth buffering
  55110. * @param enable defines the state to set
  55111. */
  55112. setDepthBuffer(enable: boolean): void;
  55113. /**
  55114. * Gets a boolean indicating if depth writing is enabled
  55115. * @returns the current depth writing state
  55116. */
  55117. getDepthWrite(): boolean;
  55118. /**
  55119. * Enable or disable depth writing
  55120. * @param enable defines the state to set
  55121. */
  55122. setDepthWrite(enable: boolean): void;
  55123. /**
  55124. * Enable or disable color writing
  55125. * @param enable defines the state to set
  55126. */
  55127. setColorWrite(enable: boolean): void;
  55128. /**
  55129. * Gets a boolean indicating if color writing is enabled
  55130. * @returns the current color writing state
  55131. */
  55132. getColorWrite(): boolean;
  55133. /**
  55134. * Sets alpha constants used by some alpha blending modes
  55135. * @param r defines the red component
  55136. * @param g defines the green component
  55137. * @param b defines the blue component
  55138. * @param a defines the alpha component
  55139. */
  55140. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55141. /**
  55142. * Sets the current alpha mode
  55143. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55144. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55145. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55146. */
  55147. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55148. /**
  55149. * Gets the current alpha mode
  55150. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55151. * @returns the current alpha mode
  55152. */
  55153. getAlphaMode(): number;
  55154. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55155. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55156. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55157. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55158. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55159. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55160. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55161. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55162. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55163. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55164. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55165. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55166. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55167. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55168. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55169. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55170. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55171. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55172. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55173. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55174. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55175. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55176. wipeCaches(bruteForce?: boolean): void;
  55177. _createTexture(): WebGLTexture;
  55178. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55179. /**
  55180. * Usually called from Texture.ts.
  55181. * Passed information to create a WebGLTexture
  55182. * @param url defines a value which contains one of the following:
  55183. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55184. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55185. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55186. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55187. * @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)
  55188. * @param scene needed for loading to the correct scene
  55189. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55190. * @param onLoad optional callback to be called upon successful completion
  55191. * @param onError optional callback to be called upon failure
  55192. * @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
  55193. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55194. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55195. * @param forcedExtension defines the extension to use to pick the right loader
  55196. * @param mimeType defines an optional mime type
  55197. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55198. */
  55199. 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;
  55200. /**
  55201. * Creates a cube texture
  55202. * @param rootUrl defines the url where the files to load is located
  55203. * @param scene defines the current scene
  55204. * @param files defines the list of files to load (1 per face)
  55205. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55206. * @param onLoad defines an optional callback raised when the texture is loaded
  55207. * @param onError defines an optional callback raised if there is an issue to load the texture
  55208. * @param format defines the format of the data
  55209. * @param forcedExtension defines the extension to use to pick the right loader
  55210. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55211. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55212. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55213. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55214. * @returns the cube texture as an InternalTexture
  55215. */
  55216. 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;
  55217. private _getSamplingFilter;
  55218. private static _GetNativeTextureFormat;
  55219. createRenderTargetTexture(size: number | {
  55220. width: number;
  55221. height: number;
  55222. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55223. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55224. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55225. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55226. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55227. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55228. /**
  55229. * Updates a dynamic vertex buffer.
  55230. * @param vertexBuffer the vertex buffer to update
  55231. * @param data the data used to update the vertex buffer
  55232. * @param byteOffset the byte offset of the data (optional)
  55233. * @param byteLength the byte length of the data (optional)
  55234. */
  55235. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55236. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55237. private _updateAnisotropicLevel;
  55238. private _getAddressMode;
  55239. /** @hidden */
  55240. _bindTexture(channel: number, texture: InternalTexture): void;
  55241. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55242. releaseEffects(): void;
  55243. /** @hidden */
  55244. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55245. /** @hidden */
  55246. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55247. /** @hidden */
  55248. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55249. /** @hidden */
  55250. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55251. }
  55252. }
  55253. declare module "babylonjs/Engines/index" {
  55254. export * from "babylonjs/Engines/constants";
  55255. export * from "babylonjs/Engines/engineCapabilities";
  55256. export * from "babylonjs/Engines/instancingAttributeInfo";
  55257. export * from "babylonjs/Engines/thinEngine";
  55258. export * from "babylonjs/Engines/engine";
  55259. export * from "babylonjs/Engines/engineStore";
  55260. export * from "babylonjs/Engines/nullEngine";
  55261. export * from "babylonjs/Engines/Extensions/index";
  55262. export * from "babylonjs/Engines/IPipelineContext";
  55263. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55264. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55265. export * from "babylonjs/Engines/nativeEngine";
  55266. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55267. export * from "babylonjs/Engines/performanceConfigurator";
  55268. }
  55269. declare module "babylonjs/Events/clipboardEvents" {
  55270. /**
  55271. * Gather the list of clipboard event types as constants.
  55272. */
  55273. export class ClipboardEventTypes {
  55274. /**
  55275. * The clipboard event is fired when a copy command is active (pressed).
  55276. */
  55277. static readonly COPY: number;
  55278. /**
  55279. * The clipboard event is fired when a cut command is active (pressed).
  55280. */
  55281. static readonly CUT: number;
  55282. /**
  55283. * The clipboard event is fired when a paste command is active (pressed).
  55284. */
  55285. static readonly PASTE: number;
  55286. }
  55287. /**
  55288. * This class is used to store clipboard related info for the onClipboardObservable event.
  55289. */
  55290. export class ClipboardInfo {
  55291. /**
  55292. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55293. */
  55294. type: number;
  55295. /**
  55296. * Defines the related dom event
  55297. */
  55298. event: ClipboardEvent;
  55299. /**
  55300. *Creates an instance of ClipboardInfo.
  55301. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55302. * @param event Defines the related dom event
  55303. */
  55304. constructor(
  55305. /**
  55306. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55307. */
  55308. type: number,
  55309. /**
  55310. * Defines the related dom event
  55311. */
  55312. event: ClipboardEvent);
  55313. /**
  55314. * Get the clipboard event's type from the keycode.
  55315. * @param keyCode Defines the keyCode for the current keyboard event.
  55316. * @return {number}
  55317. */
  55318. static GetTypeFromCharacter(keyCode: number): number;
  55319. }
  55320. }
  55321. declare module "babylonjs/Events/index" {
  55322. export * from "babylonjs/Events/keyboardEvents";
  55323. export * from "babylonjs/Events/pointerEvents";
  55324. export * from "babylonjs/Events/clipboardEvents";
  55325. }
  55326. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55327. import { Scene } from "babylonjs/scene";
  55328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55329. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55330. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55331. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55332. /**
  55333. * Google Daydream controller
  55334. */
  55335. export class DaydreamController extends WebVRController {
  55336. /**
  55337. * Base Url for the controller model.
  55338. */
  55339. static MODEL_BASE_URL: string;
  55340. /**
  55341. * File name for the controller model.
  55342. */
  55343. static MODEL_FILENAME: string;
  55344. /**
  55345. * Gamepad Id prefix used to identify Daydream Controller.
  55346. */
  55347. static readonly GAMEPAD_ID_PREFIX: string;
  55348. /**
  55349. * Creates a new DaydreamController from a gamepad
  55350. * @param vrGamepad the gamepad that the controller should be created from
  55351. */
  55352. constructor(vrGamepad: any);
  55353. /**
  55354. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55355. * @param scene scene in which to add meshes
  55356. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55357. */
  55358. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55359. /**
  55360. * Called once for each button that changed state since the last frame
  55361. * @param buttonIdx Which button index changed
  55362. * @param state New state of the button
  55363. * @param changes Which properties on the state changed since last frame
  55364. */
  55365. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55366. }
  55367. }
  55368. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55369. import { Scene } from "babylonjs/scene";
  55370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55371. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55372. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55373. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55374. /**
  55375. * Gear VR Controller
  55376. */
  55377. export class GearVRController extends WebVRController {
  55378. /**
  55379. * Base Url for the controller model.
  55380. */
  55381. static MODEL_BASE_URL: string;
  55382. /**
  55383. * File name for the controller model.
  55384. */
  55385. static MODEL_FILENAME: string;
  55386. /**
  55387. * Gamepad Id prefix used to identify this controller.
  55388. */
  55389. static readonly GAMEPAD_ID_PREFIX: string;
  55390. private readonly _buttonIndexToObservableNameMap;
  55391. /**
  55392. * Creates a new GearVRController from a gamepad
  55393. * @param vrGamepad the gamepad that the controller should be created from
  55394. */
  55395. constructor(vrGamepad: any);
  55396. /**
  55397. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55398. * @param scene scene in which to add meshes
  55399. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55400. */
  55401. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55402. /**
  55403. * Called once for each button that changed state since the last frame
  55404. * @param buttonIdx Which button index changed
  55405. * @param state New state of the button
  55406. * @param changes Which properties on the state changed since last frame
  55407. */
  55408. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55409. }
  55410. }
  55411. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55412. import { Scene } from "babylonjs/scene";
  55413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55414. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55415. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55416. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55417. /**
  55418. * Generic Controller
  55419. */
  55420. export class GenericController extends WebVRController {
  55421. /**
  55422. * Base Url for the controller model.
  55423. */
  55424. static readonly MODEL_BASE_URL: string;
  55425. /**
  55426. * File name for the controller model.
  55427. */
  55428. static readonly MODEL_FILENAME: string;
  55429. /**
  55430. * Creates a new GenericController from a gamepad
  55431. * @param vrGamepad the gamepad that the controller should be created from
  55432. */
  55433. constructor(vrGamepad: any);
  55434. /**
  55435. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55436. * @param scene scene in which to add meshes
  55437. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55438. */
  55439. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55440. /**
  55441. * Called once for each button that changed state since the last frame
  55442. * @param buttonIdx Which button index changed
  55443. * @param state New state of the button
  55444. * @param changes Which properties on the state changed since last frame
  55445. */
  55446. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55447. }
  55448. }
  55449. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55450. import { Observable } from "babylonjs/Misc/observable";
  55451. import { Scene } from "babylonjs/scene";
  55452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55453. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55454. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55455. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55456. /**
  55457. * Oculus Touch Controller
  55458. */
  55459. export class OculusTouchController extends WebVRController {
  55460. /**
  55461. * Base Url for the controller model.
  55462. */
  55463. static MODEL_BASE_URL: string;
  55464. /**
  55465. * File name for the left controller model.
  55466. */
  55467. static MODEL_LEFT_FILENAME: string;
  55468. /**
  55469. * File name for the right controller model.
  55470. */
  55471. static MODEL_RIGHT_FILENAME: string;
  55472. /**
  55473. * Base Url for the Quest controller model.
  55474. */
  55475. static QUEST_MODEL_BASE_URL: string;
  55476. /**
  55477. * @hidden
  55478. * If the controllers are running on a device that needs the updated Quest controller models
  55479. */
  55480. static _IsQuest: boolean;
  55481. /**
  55482. * Fired when the secondary trigger on this controller is modified
  55483. */
  55484. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55485. /**
  55486. * Fired when the thumb rest on this controller is modified
  55487. */
  55488. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55489. /**
  55490. * Creates a new OculusTouchController from a gamepad
  55491. * @param vrGamepad the gamepad that the controller should be created from
  55492. */
  55493. constructor(vrGamepad: any);
  55494. /**
  55495. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55496. * @param scene scene in which to add meshes
  55497. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55498. */
  55499. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55500. /**
  55501. * Fired when the A button on this controller is modified
  55502. */
  55503. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55504. /**
  55505. * Fired when the B button on this controller is modified
  55506. */
  55507. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55508. /**
  55509. * Fired when the X button on this controller is modified
  55510. */
  55511. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55512. /**
  55513. * Fired when the Y button on this controller is modified
  55514. */
  55515. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55516. /**
  55517. * Called once for each button that changed state since the last frame
  55518. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55519. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55520. * 2) secondary trigger (same)
  55521. * 3) A (right) X (left), touch, pressed = value
  55522. * 4) B / Y
  55523. * 5) thumb rest
  55524. * @param buttonIdx Which button index changed
  55525. * @param state New state of the button
  55526. * @param changes Which properties on the state changed since last frame
  55527. */
  55528. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55529. }
  55530. }
  55531. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55532. import { Scene } from "babylonjs/scene";
  55533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55534. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55535. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55536. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55537. import { Observable } from "babylonjs/Misc/observable";
  55538. /**
  55539. * Vive Controller
  55540. */
  55541. export class ViveController extends WebVRController {
  55542. /**
  55543. * Base Url for the controller model.
  55544. */
  55545. static MODEL_BASE_URL: string;
  55546. /**
  55547. * File name for the controller model.
  55548. */
  55549. static MODEL_FILENAME: string;
  55550. /**
  55551. * Creates a new ViveController from a gamepad
  55552. * @param vrGamepad the gamepad that the controller should be created from
  55553. */
  55554. constructor(vrGamepad: any);
  55555. /**
  55556. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55557. * @param scene scene in which to add meshes
  55558. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55559. */
  55560. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55561. /**
  55562. * Fired when the left button on this controller is modified
  55563. */
  55564. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55565. /**
  55566. * Fired when the right button on this controller is modified
  55567. */
  55568. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55569. /**
  55570. * Fired when the menu button on this controller is modified
  55571. */
  55572. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55573. /**
  55574. * Called once for each button that changed state since the last frame
  55575. * Vive mapping:
  55576. * 0: touchpad
  55577. * 1: trigger
  55578. * 2: left AND right buttons
  55579. * 3: menu button
  55580. * @param buttonIdx Which button index changed
  55581. * @param state New state of the button
  55582. * @param changes Which properties on the state changed since last frame
  55583. */
  55584. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55585. }
  55586. }
  55587. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55588. import { Observable } from "babylonjs/Misc/observable";
  55589. import { Scene } from "babylonjs/scene";
  55590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55591. import { Ray } from "babylonjs/Culling/ray";
  55592. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55593. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55594. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55595. /**
  55596. * Defines the WindowsMotionController object that the state of the windows motion controller
  55597. */
  55598. export class WindowsMotionController extends WebVRController {
  55599. /**
  55600. * The base url used to load the left and right controller models
  55601. */
  55602. static MODEL_BASE_URL: string;
  55603. /**
  55604. * The name of the left controller model file
  55605. */
  55606. static MODEL_LEFT_FILENAME: string;
  55607. /**
  55608. * The name of the right controller model file
  55609. */
  55610. static MODEL_RIGHT_FILENAME: string;
  55611. /**
  55612. * The controller name prefix for this controller type
  55613. */
  55614. static readonly GAMEPAD_ID_PREFIX: string;
  55615. /**
  55616. * The controller id pattern for this controller type
  55617. */
  55618. private static readonly GAMEPAD_ID_PATTERN;
  55619. private _loadedMeshInfo;
  55620. protected readonly _mapping: {
  55621. buttons: string[];
  55622. buttonMeshNames: {
  55623. trigger: string;
  55624. menu: string;
  55625. grip: string;
  55626. thumbstick: string;
  55627. trackpad: string;
  55628. };
  55629. buttonObservableNames: {
  55630. trigger: string;
  55631. menu: string;
  55632. grip: string;
  55633. thumbstick: string;
  55634. trackpad: string;
  55635. };
  55636. axisMeshNames: string[];
  55637. pointingPoseMeshName: string;
  55638. };
  55639. /**
  55640. * Fired when the trackpad on this controller is clicked
  55641. */
  55642. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55643. /**
  55644. * Fired when the trackpad on this controller is modified
  55645. */
  55646. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55647. /**
  55648. * The current x and y values of this controller's trackpad
  55649. */
  55650. trackpad: StickValues;
  55651. /**
  55652. * Creates a new WindowsMotionController from a gamepad
  55653. * @param vrGamepad the gamepad that the controller should be created from
  55654. */
  55655. constructor(vrGamepad: any);
  55656. /**
  55657. * Fired when the trigger on this controller is modified
  55658. */
  55659. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55660. /**
  55661. * Fired when the menu button on this controller is modified
  55662. */
  55663. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55664. /**
  55665. * Fired when the grip button on this controller is modified
  55666. */
  55667. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55668. /**
  55669. * Fired when the thumbstick button on this controller is modified
  55670. */
  55671. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55672. /**
  55673. * Fired when the touchpad button on this controller is modified
  55674. */
  55675. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55676. /**
  55677. * Fired when the touchpad values on this controller are modified
  55678. */
  55679. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55680. protected _updateTrackpad(): void;
  55681. /**
  55682. * Called once per frame by the engine.
  55683. */
  55684. update(): void;
  55685. /**
  55686. * Called once for each button that changed state since the last frame
  55687. * @param buttonIdx Which button index changed
  55688. * @param state New state of the button
  55689. * @param changes Which properties on the state changed since last frame
  55690. */
  55691. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55692. /**
  55693. * Moves the buttons on the controller mesh based on their current state
  55694. * @param buttonName the name of the button to move
  55695. * @param buttonValue the value of the button which determines the buttons new position
  55696. */
  55697. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55698. /**
  55699. * Moves the axis on the controller mesh based on its current state
  55700. * @param axis the index of the axis
  55701. * @param axisValue the value of the axis which determines the meshes new position
  55702. * @hidden
  55703. */
  55704. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55705. /**
  55706. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55707. * @param scene scene in which to add meshes
  55708. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55709. */
  55710. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55711. /**
  55712. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55713. * can be transformed by button presses and axes values, based on this._mapping.
  55714. *
  55715. * @param scene scene in which the meshes exist
  55716. * @param meshes list of meshes that make up the controller model to process
  55717. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55718. */
  55719. private processModel;
  55720. private createMeshInfo;
  55721. /**
  55722. * Gets the ray of the controller in the direction the controller is pointing
  55723. * @param length the length the resulting ray should be
  55724. * @returns a ray in the direction the controller is pointing
  55725. */
  55726. getForwardRay(length?: number): Ray;
  55727. /**
  55728. * Disposes of the controller
  55729. */
  55730. dispose(): void;
  55731. }
  55732. /**
  55733. * This class represents a new windows motion controller in XR.
  55734. */
  55735. export class XRWindowsMotionController extends WindowsMotionController {
  55736. /**
  55737. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55738. */
  55739. protected readonly _mapping: {
  55740. buttons: string[];
  55741. buttonMeshNames: {
  55742. trigger: string;
  55743. menu: string;
  55744. grip: string;
  55745. thumbstick: string;
  55746. trackpad: string;
  55747. };
  55748. buttonObservableNames: {
  55749. trigger: string;
  55750. menu: string;
  55751. grip: string;
  55752. thumbstick: string;
  55753. trackpad: string;
  55754. };
  55755. axisMeshNames: string[];
  55756. pointingPoseMeshName: string;
  55757. };
  55758. /**
  55759. * Construct a new XR-Based windows motion controller
  55760. *
  55761. * @param gamepadInfo the gamepad object from the browser
  55762. */
  55763. constructor(gamepadInfo: any);
  55764. /**
  55765. * holds the thumbstick values (X,Y)
  55766. */
  55767. thumbstickValues: StickValues;
  55768. /**
  55769. * Fired when the thumbstick on this controller is clicked
  55770. */
  55771. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55772. /**
  55773. * Fired when the thumbstick on this controller is modified
  55774. */
  55775. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55776. /**
  55777. * Fired when the touchpad button on this controller is modified
  55778. */
  55779. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55780. /**
  55781. * Fired when the touchpad values on this controller are modified
  55782. */
  55783. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55784. /**
  55785. * Fired when the thumbstick button on this controller is modified
  55786. * here to prevent breaking changes
  55787. */
  55788. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55789. /**
  55790. * updating the thumbstick(!) and not the trackpad.
  55791. * This is named this way due to the difference between WebVR and XR and to avoid
  55792. * changing the parent class.
  55793. */
  55794. protected _updateTrackpad(): void;
  55795. /**
  55796. * Disposes the class with joy
  55797. */
  55798. dispose(): void;
  55799. }
  55800. }
  55801. declare module "babylonjs/Gamepads/Controllers/index" {
  55802. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55803. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55804. export * from "babylonjs/Gamepads/Controllers/genericController";
  55805. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55806. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55807. export * from "babylonjs/Gamepads/Controllers/viveController";
  55808. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55809. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55810. }
  55811. declare module "babylonjs/Gamepads/index" {
  55812. export * from "babylonjs/Gamepads/Controllers/index";
  55813. export * from "babylonjs/Gamepads/gamepad";
  55814. export * from "babylonjs/Gamepads/gamepadManager";
  55815. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55816. export * from "babylonjs/Gamepads/xboxGamepad";
  55817. export * from "babylonjs/Gamepads/dualShockGamepad";
  55818. }
  55819. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55820. import { Scene } from "babylonjs/scene";
  55821. import { Vector4 } from "babylonjs/Maths/math.vector";
  55822. import { Color4 } from "babylonjs/Maths/math.color";
  55823. import { Mesh } from "babylonjs/Meshes/mesh";
  55824. import { Nullable } from "babylonjs/types";
  55825. /**
  55826. * Class containing static functions to help procedurally build meshes
  55827. */
  55828. export class PolyhedronBuilder {
  55829. /**
  55830. * Creates a polyhedron mesh
  55831. * * 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
  55832. * * The parameter `size` (positive float, default 1) sets the polygon size
  55833. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55834. * * 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`
  55835. * * 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
  55836. * * 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)`)
  55837. * * 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
  55838. * * 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
  55839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55842. * @param name defines the name of the mesh
  55843. * @param options defines the options used to create the mesh
  55844. * @param scene defines the hosting scene
  55845. * @returns the polyhedron mesh
  55846. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55847. */
  55848. static CreatePolyhedron(name: string, options: {
  55849. type?: number;
  55850. size?: number;
  55851. sizeX?: number;
  55852. sizeY?: number;
  55853. sizeZ?: number;
  55854. custom?: any;
  55855. faceUV?: Vector4[];
  55856. faceColors?: Color4[];
  55857. flat?: boolean;
  55858. updatable?: boolean;
  55859. sideOrientation?: number;
  55860. frontUVs?: Vector4;
  55861. backUVs?: Vector4;
  55862. }, scene?: Nullable<Scene>): Mesh;
  55863. }
  55864. }
  55865. declare module "babylonjs/Gizmos/scaleGizmo" {
  55866. import { Observable } from "babylonjs/Misc/observable";
  55867. import { Nullable } from "babylonjs/types";
  55868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55869. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55870. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55871. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55872. import { Node } from "babylonjs/node";
  55873. /**
  55874. * Gizmo that enables scaling a mesh along 3 axis
  55875. */
  55876. export class ScaleGizmo extends Gizmo {
  55877. /**
  55878. * Internal gizmo used for interactions on the x axis
  55879. */
  55880. xGizmo: AxisScaleGizmo;
  55881. /**
  55882. * Internal gizmo used for interactions on the y axis
  55883. */
  55884. yGizmo: AxisScaleGizmo;
  55885. /**
  55886. * Internal gizmo used for interactions on the z axis
  55887. */
  55888. zGizmo: AxisScaleGizmo;
  55889. /**
  55890. * Internal gizmo used to scale all axis equally
  55891. */
  55892. uniformScaleGizmo: AxisScaleGizmo;
  55893. private _meshAttached;
  55894. private _nodeAttached;
  55895. private _snapDistance;
  55896. private _uniformScalingMesh;
  55897. private _octahedron;
  55898. private _sensitivity;
  55899. /** Fires an event when any of it's sub gizmos are dragged */
  55900. onDragStartObservable: Observable<unknown>;
  55901. /** Fires an event when any of it's sub gizmos are released from dragging */
  55902. onDragEndObservable: Observable<unknown>;
  55903. get attachedMesh(): Nullable<AbstractMesh>;
  55904. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55905. get attachedNode(): Nullable<Node>;
  55906. set attachedNode(node: Nullable<Node>);
  55907. /**
  55908. * Creates a ScaleGizmo
  55909. * @param gizmoLayer The utility layer the gizmo will be added to
  55910. * @param thickness display gizmo axis thickness
  55911. */
  55912. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55913. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55914. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55915. /**
  55916. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55917. */
  55918. set snapDistance(value: number);
  55919. get snapDistance(): number;
  55920. /**
  55921. * Ratio for the scale of the gizmo (Default: 1)
  55922. */
  55923. set scaleRatio(value: number);
  55924. get scaleRatio(): number;
  55925. /**
  55926. * Sensitivity factor for dragging (Default: 1)
  55927. */
  55928. set sensitivity(value: number);
  55929. get sensitivity(): number;
  55930. /**
  55931. * Disposes of the gizmo
  55932. */
  55933. dispose(): void;
  55934. }
  55935. }
  55936. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55937. import { Observable } from "babylonjs/Misc/observable";
  55938. import { Nullable } from "babylonjs/types";
  55939. import { Vector3 } from "babylonjs/Maths/math.vector";
  55940. import { Node } from "babylonjs/node";
  55941. import { Mesh } from "babylonjs/Meshes/mesh";
  55942. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55943. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55944. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55945. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55946. import { Color3 } from "babylonjs/Maths/math.color";
  55947. /**
  55948. * Single axis scale gizmo
  55949. */
  55950. export class AxisScaleGizmo extends Gizmo {
  55951. /**
  55952. * Drag behavior responsible for the gizmos dragging interactions
  55953. */
  55954. dragBehavior: PointerDragBehavior;
  55955. private _pointerObserver;
  55956. /**
  55957. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55958. */
  55959. snapDistance: number;
  55960. /**
  55961. * Event that fires each time the gizmo snaps to a new location.
  55962. * * snapDistance is the the change in distance
  55963. */
  55964. onSnapObservable: Observable<{
  55965. snapDistance: number;
  55966. }>;
  55967. /**
  55968. * If the scaling operation should be done on all axis (default: false)
  55969. */
  55970. uniformScaling: boolean;
  55971. /**
  55972. * Custom sensitivity value for the drag strength
  55973. */
  55974. sensitivity: number;
  55975. private _isEnabled;
  55976. private _parent;
  55977. private _arrow;
  55978. private _coloredMaterial;
  55979. private _hoverMaterial;
  55980. /**
  55981. * Creates an AxisScaleGizmo
  55982. * @param gizmoLayer The utility layer the gizmo will be added to
  55983. * @param dragAxis The axis which the gizmo will be able to scale on
  55984. * @param color The color of the gizmo
  55985. * @param thickness display gizmo axis thickness
  55986. */
  55987. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55988. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55989. /**
  55990. * If the gizmo is enabled
  55991. */
  55992. set isEnabled(value: boolean);
  55993. get isEnabled(): boolean;
  55994. /**
  55995. * Disposes of the gizmo
  55996. */
  55997. dispose(): void;
  55998. /**
  55999. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56000. * @param mesh The mesh to replace the default mesh of the gizmo
  56001. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56002. */
  56003. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56004. }
  56005. }
  56006. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56007. import { Observable } from "babylonjs/Misc/observable";
  56008. import { Nullable } from "babylonjs/types";
  56009. import { Vector3 } from "babylonjs/Maths/math.vector";
  56010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56011. import { Mesh } from "babylonjs/Meshes/mesh";
  56012. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56013. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56014. import { Color3 } from "babylonjs/Maths/math.color";
  56015. import "babylonjs/Meshes/Builders/boxBuilder";
  56016. /**
  56017. * Bounding box gizmo
  56018. */
  56019. export class BoundingBoxGizmo extends Gizmo {
  56020. private _lineBoundingBox;
  56021. private _rotateSpheresParent;
  56022. private _scaleBoxesParent;
  56023. private _boundingDimensions;
  56024. private _renderObserver;
  56025. private _pointerObserver;
  56026. private _scaleDragSpeed;
  56027. private _tmpQuaternion;
  56028. private _tmpVector;
  56029. private _tmpRotationMatrix;
  56030. /**
  56031. * 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)
  56032. */
  56033. ignoreChildren: boolean;
  56034. /**
  56035. * 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)
  56036. */
  56037. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56038. /**
  56039. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56040. */
  56041. rotationSphereSize: number;
  56042. /**
  56043. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56044. */
  56045. scaleBoxSize: number;
  56046. /**
  56047. * 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)
  56048. */
  56049. fixedDragMeshScreenSize: boolean;
  56050. /**
  56051. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56052. */
  56053. fixedDragMeshScreenSizeDistanceFactor: number;
  56054. /**
  56055. * Fired when a rotation sphere or scale box is dragged
  56056. */
  56057. onDragStartObservable: Observable<{}>;
  56058. /**
  56059. * Fired when a scale box is dragged
  56060. */
  56061. onScaleBoxDragObservable: Observable<{}>;
  56062. /**
  56063. * Fired when a scale box drag is ended
  56064. */
  56065. onScaleBoxDragEndObservable: Observable<{}>;
  56066. /**
  56067. * Fired when a rotation sphere is dragged
  56068. */
  56069. onRotationSphereDragObservable: Observable<{}>;
  56070. /**
  56071. * Fired when a rotation sphere drag is ended
  56072. */
  56073. onRotationSphereDragEndObservable: Observable<{}>;
  56074. /**
  56075. * 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)
  56076. */
  56077. scalePivot: Nullable<Vector3>;
  56078. /**
  56079. * Mesh used as a pivot to rotate the attached node
  56080. */
  56081. private _anchorMesh;
  56082. private _existingMeshScale;
  56083. private _dragMesh;
  56084. private pointerDragBehavior;
  56085. private coloredMaterial;
  56086. private hoverColoredMaterial;
  56087. /**
  56088. * Sets the color of the bounding box gizmo
  56089. * @param color the color to set
  56090. */
  56091. setColor(color: Color3): void;
  56092. /**
  56093. * Creates an BoundingBoxGizmo
  56094. * @param gizmoLayer The utility layer the gizmo will be added to
  56095. * @param color The color of the gizmo
  56096. */
  56097. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56098. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56099. private _selectNode;
  56100. /**
  56101. * Updates the bounding box information for the Gizmo
  56102. */
  56103. updateBoundingBox(): void;
  56104. private _updateRotationSpheres;
  56105. private _updateScaleBoxes;
  56106. /**
  56107. * Enables rotation on the specified axis and disables rotation on the others
  56108. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56109. */
  56110. setEnabledRotationAxis(axis: string): void;
  56111. /**
  56112. * Enables/disables scaling
  56113. * @param enable if scaling should be enabled
  56114. * @param homogeneousScaling defines if scaling should only be homogeneous
  56115. */
  56116. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56117. private _updateDummy;
  56118. /**
  56119. * Enables a pointer drag behavior on the bounding box of the gizmo
  56120. */
  56121. enableDragBehavior(): void;
  56122. /**
  56123. * Disposes of the gizmo
  56124. */
  56125. dispose(): void;
  56126. /**
  56127. * 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)
  56128. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56129. * @returns the bounding box mesh with the passed in mesh as a child
  56130. */
  56131. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56132. /**
  56133. * CustomMeshes are not supported by this gizmo
  56134. * @param mesh The mesh to replace the default mesh of the gizmo
  56135. */
  56136. setCustomMesh(mesh: Mesh): void;
  56137. }
  56138. }
  56139. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56140. import { Observable } from "babylonjs/Misc/observable";
  56141. import { Nullable } from "babylonjs/types";
  56142. import { Vector3 } from "babylonjs/Maths/math.vector";
  56143. import { Color3 } from "babylonjs/Maths/math.color";
  56144. import { Node } from "babylonjs/node";
  56145. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56146. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56147. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56148. import "babylonjs/Meshes/Builders/linesBuilder";
  56149. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56150. /**
  56151. * Single plane rotation gizmo
  56152. */
  56153. export class PlaneRotationGizmo extends Gizmo {
  56154. /**
  56155. * Drag behavior responsible for the gizmos dragging interactions
  56156. */
  56157. dragBehavior: PointerDragBehavior;
  56158. private _pointerObserver;
  56159. /**
  56160. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56161. */
  56162. snapDistance: number;
  56163. /**
  56164. * Event that fires each time the gizmo snaps to a new location.
  56165. * * snapDistance is the the change in distance
  56166. */
  56167. onSnapObservable: Observable<{
  56168. snapDistance: number;
  56169. }>;
  56170. private _isEnabled;
  56171. private _parent;
  56172. /**
  56173. * Creates a PlaneRotationGizmo
  56174. * @param gizmoLayer The utility layer the gizmo will be added to
  56175. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56176. * @param color The color of the gizmo
  56177. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56178. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56179. * @param thickness display gizmo axis thickness
  56180. */
  56181. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56182. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56183. /**
  56184. * If the gizmo is enabled
  56185. */
  56186. set isEnabled(value: boolean);
  56187. get isEnabled(): boolean;
  56188. /**
  56189. * Disposes of the gizmo
  56190. */
  56191. dispose(): void;
  56192. }
  56193. }
  56194. declare module "babylonjs/Gizmos/rotationGizmo" {
  56195. import { Observable } from "babylonjs/Misc/observable";
  56196. import { Nullable } from "babylonjs/types";
  56197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56198. import { Mesh } from "babylonjs/Meshes/mesh";
  56199. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56200. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56201. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56202. import { Node } from "babylonjs/node";
  56203. /**
  56204. * Gizmo that enables rotating a mesh along 3 axis
  56205. */
  56206. export class RotationGizmo extends Gizmo {
  56207. /**
  56208. * Internal gizmo used for interactions on the x axis
  56209. */
  56210. xGizmo: PlaneRotationGizmo;
  56211. /**
  56212. * Internal gizmo used for interactions on the y axis
  56213. */
  56214. yGizmo: PlaneRotationGizmo;
  56215. /**
  56216. * Internal gizmo used for interactions on the z axis
  56217. */
  56218. zGizmo: PlaneRotationGizmo;
  56219. /** Fires an event when any of it's sub gizmos are dragged */
  56220. onDragStartObservable: Observable<unknown>;
  56221. /** Fires an event when any of it's sub gizmos are released from dragging */
  56222. onDragEndObservable: Observable<unknown>;
  56223. private _meshAttached;
  56224. private _nodeAttached;
  56225. get attachedMesh(): Nullable<AbstractMesh>;
  56226. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56227. get attachedNode(): Nullable<Node>;
  56228. set attachedNode(node: Nullable<Node>);
  56229. /**
  56230. * Creates a RotationGizmo
  56231. * @param gizmoLayer The utility layer the gizmo will be added to
  56232. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56233. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56234. * @param thickness display gizmo axis thickness
  56235. */
  56236. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56237. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56238. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56239. /**
  56240. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56241. */
  56242. set snapDistance(value: number);
  56243. get snapDistance(): number;
  56244. /**
  56245. * Ratio for the scale of the gizmo (Default: 1)
  56246. */
  56247. set scaleRatio(value: number);
  56248. get scaleRatio(): number;
  56249. /**
  56250. * Disposes of the gizmo
  56251. */
  56252. dispose(): void;
  56253. /**
  56254. * CustomMeshes are not supported by this gizmo
  56255. * @param mesh The mesh to replace the default mesh of the gizmo
  56256. */
  56257. setCustomMesh(mesh: Mesh): void;
  56258. }
  56259. }
  56260. declare module "babylonjs/Gizmos/gizmoManager" {
  56261. import { Observable } from "babylonjs/Misc/observable";
  56262. import { Nullable } from "babylonjs/types";
  56263. import { Scene, IDisposable } from "babylonjs/scene";
  56264. import { Node } from "babylonjs/node";
  56265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56266. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56267. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56268. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56269. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56270. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56271. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56272. /**
  56273. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56274. */
  56275. export class GizmoManager implements IDisposable {
  56276. private scene;
  56277. /**
  56278. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56279. */
  56280. gizmos: {
  56281. positionGizmo: Nullable<PositionGizmo>;
  56282. rotationGizmo: Nullable<RotationGizmo>;
  56283. scaleGizmo: Nullable<ScaleGizmo>;
  56284. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56285. };
  56286. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56287. clearGizmoOnEmptyPointerEvent: boolean;
  56288. /** Fires an event when the manager is attached to a mesh */
  56289. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56290. /** Fires an event when the manager is attached to a node */
  56291. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56292. private _gizmosEnabled;
  56293. private _pointerObserver;
  56294. private _attachedMesh;
  56295. private _attachedNode;
  56296. private _boundingBoxColor;
  56297. private _defaultUtilityLayer;
  56298. private _defaultKeepDepthUtilityLayer;
  56299. private _thickness;
  56300. /**
  56301. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56302. */
  56303. boundingBoxDragBehavior: SixDofDragBehavior;
  56304. /**
  56305. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56306. */
  56307. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56308. /**
  56309. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56310. */
  56311. attachableNodes: Nullable<Array<Node>>;
  56312. /**
  56313. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56314. */
  56315. usePointerToAttachGizmos: boolean;
  56316. /**
  56317. * Utility layer that the bounding box gizmo belongs to
  56318. */
  56319. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56320. /**
  56321. * Utility layer that all gizmos besides bounding box belong to
  56322. */
  56323. get utilityLayer(): UtilityLayerRenderer;
  56324. /**
  56325. * Instatiates a gizmo manager
  56326. * @param scene the scene to overlay the gizmos on top of
  56327. * @param thickness display gizmo axis thickness
  56328. */
  56329. constructor(scene: Scene, thickness?: number);
  56330. /**
  56331. * Attaches a set of gizmos to the specified mesh
  56332. * @param mesh The mesh the gizmo's should be attached to
  56333. */
  56334. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56335. /**
  56336. * Attaches a set of gizmos to the specified node
  56337. * @param node The node the gizmo's should be attached to
  56338. */
  56339. attachToNode(node: Nullable<Node>): void;
  56340. /**
  56341. * If the position gizmo is enabled
  56342. */
  56343. set positionGizmoEnabled(value: boolean);
  56344. get positionGizmoEnabled(): boolean;
  56345. /**
  56346. * If the rotation gizmo is enabled
  56347. */
  56348. set rotationGizmoEnabled(value: boolean);
  56349. get rotationGizmoEnabled(): boolean;
  56350. /**
  56351. * If the scale gizmo is enabled
  56352. */
  56353. set scaleGizmoEnabled(value: boolean);
  56354. get scaleGizmoEnabled(): boolean;
  56355. /**
  56356. * If the boundingBox gizmo is enabled
  56357. */
  56358. set boundingBoxGizmoEnabled(value: boolean);
  56359. get boundingBoxGizmoEnabled(): boolean;
  56360. /**
  56361. * Disposes of the gizmo manager
  56362. */
  56363. dispose(): void;
  56364. }
  56365. }
  56366. declare module "babylonjs/Lights/directionalLight" {
  56367. import { Camera } from "babylonjs/Cameras/camera";
  56368. import { Scene } from "babylonjs/scene";
  56369. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56371. import { Light } from "babylonjs/Lights/light";
  56372. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56373. import { Effect } from "babylonjs/Materials/effect";
  56374. /**
  56375. * A directional light is defined by a direction (what a surprise!).
  56376. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56377. * 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.
  56378. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56379. */
  56380. export class DirectionalLight extends ShadowLight {
  56381. private _shadowFrustumSize;
  56382. /**
  56383. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56384. */
  56385. get shadowFrustumSize(): number;
  56386. /**
  56387. * Specifies a fix frustum size for the shadow generation.
  56388. */
  56389. set shadowFrustumSize(value: number);
  56390. private _shadowOrthoScale;
  56391. /**
  56392. * Gets the shadow projection scale against the optimal computed one.
  56393. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56394. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56395. */
  56396. get shadowOrthoScale(): number;
  56397. /**
  56398. * Sets the shadow projection scale against the optimal computed one.
  56399. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56400. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56401. */
  56402. set shadowOrthoScale(value: number);
  56403. /**
  56404. * Automatically compute the projection matrix to best fit (including all the casters)
  56405. * on each frame.
  56406. */
  56407. autoUpdateExtends: boolean;
  56408. /**
  56409. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56410. * on each frame. autoUpdateExtends must be set to true for this to work
  56411. */
  56412. autoCalcShadowZBounds: boolean;
  56413. private _orthoLeft;
  56414. private _orthoRight;
  56415. private _orthoTop;
  56416. private _orthoBottom;
  56417. /**
  56418. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56419. * The directional light is emitted from everywhere in the given direction.
  56420. * It can cast shadows.
  56421. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56422. * @param name The friendly name of the light
  56423. * @param direction The direction of the light
  56424. * @param scene The scene the light belongs to
  56425. */
  56426. constructor(name: string, direction: Vector3, scene: Scene);
  56427. /**
  56428. * Returns the string "DirectionalLight".
  56429. * @return The class name
  56430. */
  56431. getClassName(): string;
  56432. /**
  56433. * Returns the integer 1.
  56434. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56435. */
  56436. getTypeID(): number;
  56437. /**
  56438. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56439. * Returns the DirectionalLight Shadow projection matrix.
  56440. */
  56441. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56442. /**
  56443. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56444. * Returns the DirectionalLight Shadow projection matrix.
  56445. */
  56446. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56447. /**
  56448. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56449. * Returns the DirectionalLight Shadow projection matrix.
  56450. */
  56451. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56452. protected _buildUniformLayout(): void;
  56453. /**
  56454. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56455. * @param effect The effect to update
  56456. * @param lightIndex The index of the light in the effect to update
  56457. * @returns The directional light
  56458. */
  56459. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56460. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56461. /**
  56462. * Gets the minZ used for shadow according to both the scene and the light.
  56463. *
  56464. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56465. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56466. * @param activeCamera The camera we are returning the min for
  56467. * @returns the depth min z
  56468. */
  56469. getDepthMinZ(activeCamera: Camera): number;
  56470. /**
  56471. * Gets the maxZ used for shadow according to both the scene and the light.
  56472. *
  56473. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56474. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56475. * @param activeCamera The camera we are returning the max for
  56476. * @returns the depth max z
  56477. */
  56478. getDepthMaxZ(activeCamera: Camera): number;
  56479. /**
  56480. * Prepares the list of defines specific to the light type.
  56481. * @param defines the list of defines
  56482. * @param lightIndex defines the index of the light for the effect
  56483. */
  56484. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56485. }
  56486. }
  56487. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56488. import { Mesh } from "babylonjs/Meshes/mesh";
  56489. /**
  56490. * Class containing static functions to help procedurally build meshes
  56491. */
  56492. export class HemisphereBuilder {
  56493. /**
  56494. * Creates a hemisphere mesh
  56495. * @param name defines the name of the mesh
  56496. * @param options defines the options used to create the mesh
  56497. * @param scene defines the hosting scene
  56498. * @returns the hemisphere mesh
  56499. */
  56500. static CreateHemisphere(name: string, options: {
  56501. segments?: number;
  56502. diameter?: number;
  56503. sideOrientation?: number;
  56504. }, scene: any): Mesh;
  56505. }
  56506. }
  56507. declare module "babylonjs/Lights/spotLight" {
  56508. import { Nullable } from "babylonjs/types";
  56509. import { Scene } from "babylonjs/scene";
  56510. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56512. import { Effect } from "babylonjs/Materials/effect";
  56513. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56514. import { Light } from "babylonjs/Lights/light";
  56515. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56516. /**
  56517. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56518. * These values define a cone of light starting from the position, emitting toward the direction.
  56519. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56520. * and the exponent defines the speed of the decay of the light with distance (reach).
  56521. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56522. */
  56523. export class SpotLight extends ShadowLight {
  56524. private _angle;
  56525. private _innerAngle;
  56526. private _cosHalfAngle;
  56527. private _lightAngleScale;
  56528. private _lightAngleOffset;
  56529. /**
  56530. * Gets the cone angle of the spot light in Radians.
  56531. */
  56532. get angle(): number;
  56533. /**
  56534. * Sets the cone angle of the spot light in Radians.
  56535. */
  56536. set angle(value: number);
  56537. /**
  56538. * Only used in gltf falloff mode, this defines the angle where
  56539. * the directional falloff will start before cutting at angle which could be seen
  56540. * as outer angle.
  56541. */
  56542. get innerAngle(): number;
  56543. /**
  56544. * Only used in gltf falloff mode, this defines the angle where
  56545. * the directional falloff will start before cutting at angle which could be seen
  56546. * as outer angle.
  56547. */
  56548. set innerAngle(value: number);
  56549. private _shadowAngleScale;
  56550. /**
  56551. * Allows scaling the angle of the light for shadow generation only.
  56552. */
  56553. get shadowAngleScale(): number;
  56554. /**
  56555. * Allows scaling the angle of the light for shadow generation only.
  56556. */
  56557. set shadowAngleScale(value: number);
  56558. /**
  56559. * The light decay speed with the distance from the emission spot.
  56560. */
  56561. exponent: number;
  56562. private _projectionTextureMatrix;
  56563. /**
  56564. * Allows reading the projecton texture
  56565. */
  56566. get projectionTextureMatrix(): Matrix;
  56567. protected _projectionTextureLightNear: number;
  56568. /**
  56569. * Gets the near clip of the Spotlight for texture projection.
  56570. */
  56571. get projectionTextureLightNear(): number;
  56572. /**
  56573. * Sets the near clip of the Spotlight for texture projection.
  56574. */
  56575. set projectionTextureLightNear(value: number);
  56576. protected _projectionTextureLightFar: number;
  56577. /**
  56578. * Gets the far clip of the Spotlight for texture projection.
  56579. */
  56580. get projectionTextureLightFar(): number;
  56581. /**
  56582. * Sets the far clip of the Spotlight for texture projection.
  56583. */
  56584. set projectionTextureLightFar(value: number);
  56585. protected _projectionTextureUpDirection: Vector3;
  56586. /**
  56587. * Gets the Up vector of the Spotlight for texture projection.
  56588. */
  56589. get projectionTextureUpDirection(): Vector3;
  56590. /**
  56591. * Sets the Up vector of the Spotlight for texture projection.
  56592. */
  56593. set projectionTextureUpDirection(value: Vector3);
  56594. private _projectionTexture;
  56595. /**
  56596. * Gets the projection texture of the light.
  56597. */
  56598. get projectionTexture(): Nullable<BaseTexture>;
  56599. /**
  56600. * Sets the projection texture of the light.
  56601. */
  56602. set projectionTexture(value: Nullable<BaseTexture>);
  56603. private _projectionTextureViewLightDirty;
  56604. private _projectionTextureProjectionLightDirty;
  56605. private _projectionTextureDirty;
  56606. private _projectionTextureViewTargetVector;
  56607. private _projectionTextureViewLightMatrix;
  56608. private _projectionTextureProjectionLightMatrix;
  56609. private _projectionTextureScalingMatrix;
  56610. /**
  56611. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56612. * It can cast shadows.
  56613. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56614. * @param name The light friendly name
  56615. * @param position The position of the spot light in the scene
  56616. * @param direction The direction of the light in the scene
  56617. * @param angle The cone angle of the light in Radians
  56618. * @param exponent The light decay speed with the distance from the emission spot
  56619. * @param scene The scene the lights belongs to
  56620. */
  56621. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56622. /**
  56623. * Returns the string "SpotLight".
  56624. * @returns the class name
  56625. */
  56626. getClassName(): string;
  56627. /**
  56628. * Returns the integer 2.
  56629. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56630. */
  56631. getTypeID(): number;
  56632. /**
  56633. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56634. */
  56635. protected _setDirection(value: Vector3): void;
  56636. /**
  56637. * Overrides the position setter to recompute the projection texture view light Matrix.
  56638. */
  56639. protected _setPosition(value: Vector3): void;
  56640. /**
  56641. * 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.
  56642. * Returns the SpotLight.
  56643. */
  56644. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56645. protected _computeProjectionTextureViewLightMatrix(): void;
  56646. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56647. /**
  56648. * Main function for light texture projection matrix computing.
  56649. */
  56650. protected _computeProjectionTextureMatrix(): void;
  56651. protected _buildUniformLayout(): void;
  56652. private _computeAngleValues;
  56653. /**
  56654. * Sets the passed Effect "effect" with the Light textures.
  56655. * @param effect The effect to update
  56656. * @param lightIndex The index of the light in the effect to update
  56657. * @returns The light
  56658. */
  56659. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56660. /**
  56661. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56662. * @param effect The effect to update
  56663. * @param lightIndex The index of the light in the effect to update
  56664. * @returns The spot light
  56665. */
  56666. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56667. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56668. /**
  56669. * Disposes the light and the associated resources.
  56670. */
  56671. dispose(): void;
  56672. /**
  56673. * Prepares the list of defines specific to the light type.
  56674. * @param defines the list of defines
  56675. * @param lightIndex defines the index of the light for the effect
  56676. */
  56677. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56678. }
  56679. }
  56680. declare module "babylonjs/Gizmos/lightGizmo" {
  56681. import { Nullable } from "babylonjs/types";
  56682. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56683. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56684. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56685. import { Light } from "babylonjs/Lights/light";
  56686. import { Observable } from "babylonjs/Misc/observable";
  56687. /**
  56688. * Gizmo that enables viewing a light
  56689. */
  56690. export class LightGizmo extends Gizmo {
  56691. private _lightMesh;
  56692. private _material;
  56693. private _cachedPosition;
  56694. private _cachedForward;
  56695. private _attachedMeshParent;
  56696. private _pointerObserver;
  56697. /**
  56698. * Event that fires each time the gizmo is clicked
  56699. */
  56700. onClickedObservable: Observable<Light>;
  56701. /**
  56702. * Creates a LightGizmo
  56703. * @param gizmoLayer The utility layer the gizmo will be added to
  56704. */
  56705. constructor(gizmoLayer?: UtilityLayerRenderer);
  56706. private _light;
  56707. /**
  56708. * The light that the gizmo is attached to
  56709. */
  56710. set light(light: Nullable<Light>);
  56711. get light(): Nullable<Light>;
  56712. /**
  56713. * Gets the material used to render the light gizmo
  56714. */
  56715. get material(): StandardMaterial;
  56716. /**
  56717. * @hidden
  56718. * Updates the gizmo to match the attached mesh's position/rotation
  56719. */
  56720. protected _update(): void;
  56721. private static _Scale;
  56722. /**
  56723. * Creates the lines for a light mesh
  56724. */
  56725. private static _CreateLightLines;
  56726. /**
  56727. * Disposes of the light gizmo
  56728. */
  56729. dispose(): void;
  56730. private static _CreateHemisphericLightMesh;
  56731. private static _CreatePointLightMesh;
  56732. private static _CreateSpotLightMesh;
  56733. private static _CreateDirectionalLightMesh;
  56734. }
  56735. }
  56736. declare module "babylonjs/Gizmos/cameraGizmo" {
  56737. import { Nullable } from "babylonjs/types";
  56738. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56739. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56740. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56741. import { Camera } from "babylonjs/Cameras/camera";
  56742. import { Observable } from "babylonjs/Misc/observable";
  56743. /**
  56744. * Gizmo that enables viewing a camera
  56745. */
  56746. export class CameraGizmo extends Gizmo {
  56747. private _cameraMesh;
  56748. private _cameraLinesMesh;
  56749. private _material;
  56750. private _pointerObserver;
  56751. /**
  56752. * Event that fires each time the gizmo is clicked
  56753. */
  56754. onClickedObservable: Observable<Camera>;
  56755. /**
  56756. * Creates a CameraGizmo
  56757. * @param gizmoLayer The utility layer the gizmo will be added to
  56758. */
  56759. constructor(gizmoLayer?: UtilityLayerRenderer);
  56760. private _camera;
  56761. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56762. get displayFrustum(): boolean;
  56763. set displayFrustum(value: boolean);
  56764. /**
  56765. * The camera that the gizmo is attached to
  56766. */
  56767. set camera(camera: Nullable<Camera>);
  56768. get camera(): Nullable<Camera>;
  56769. /**
  56770. * Gets the material used to render the camera gizmo
  56771. */
  56772. get material(): StandardMaterial;
  56773. /**
  56774. * @hidden
  56775. * Updates the gizmo to match the attached mesh's position/rotation
  56776. */
  56777. protected _update(): void;
  56778. private static _Scale;
  56779. private _invProjection;
  56780. /**
  56781. * Disposes of the camera gizmo
  56782. */
  56783. dispose(): void;
  56784. private static _CreateCameraMesh;
  56785. private static _CreateCameraFrustum;
  56786. }
  56787. }
  56788. declare module "babylonjs/Gizmos/index" {
  56789. export * from "babylonjs/Gizmos/axisDragGizmo";
  56790. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56791. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56792. export * from "babylonjs/Gizmos/gizmo";
  56793. export * from "babylonjs/Gizmos/gizmoManager";
  56794. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56795. export * from "babylonjs/Gizmos/positionGizmo";
  56796. export * from "babylonjs/Gizmos/rotationGizmo";
  56797. export * from "babylonjs/Gizmos/scaleGizmo";
  56798. export * from "babylonjs/Gizmos/lightGizmo";
  56799. export * from "babylonjs/Gizmos/cameraGizmo";
  56800. export * from "babylonjs/Gizmos/planeDragGizmo";
  56801. }
  56802. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56803. /** @hidden */
  56804. export var backgroundFragmentDeclaration: {
  56805. name: string;
  56806. shader: string;
  56807. };
  56808. }
  56809. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56810. /** @hidden */
  56811. export var backgroundUboDeclaration: {
  56812. name: string;
  56813. shader: string;
  56814. };
  56815. }
  56816. declare module "babylonjs/Shaders/background.fragment" {
  56817. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56818. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56819. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56820. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56821. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56822. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56823. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56824. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56825. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56826. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56827. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56828. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56829. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56830. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56831. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56832. /** @hidden */
  56833. export var backgroundPixelShader: {
  56834. name: string;
  56835. shader: string;
  56836. };
  56837. }
  56838. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56839. /** @hidden */
  56840. export var backgroundVertexDeclaration: {
  56841. name: string;
  56842. shader: string;
  56843. };
  56844. }
  56845. declare module "babylonjs/Shaders/background.vertex" {
  56846. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56847. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56848. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56849. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56850. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56851. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56852. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56853. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56854. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56855. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56856. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56857. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56858. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56859. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56860. /** @hidden */
  56861. export var backgroundVertexShader: {
  56862. name: string;
  56863. shader: string;
  56864. };
  56865. }
  56866. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56867. import { Nullable, int, float } from "babylonjs/types";
  56868. import { Scene } from "babylonjs/scene";
  56869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56870. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56872. import { Mesh } from "babylonjs/Meshes/mesh";
  56873. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56874. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56875. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56876. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56877. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56878. import { Color3 } from "babylonjs/Maths/math.color";
  56879. import "babylonjs/Shaders/background.fragment";
  56880. import "babylonjs/Shaders/background.vertex";
  56881. /**
  56882. * Background material used to create an efficient environement around your scene.
  56883. */
  56884. export class BackgroundMaterial extends PushMaterial {
  56885. /**
  56886. * Standard reflectance value at parallel view angle.
  56887. */
  56888. static StandardReflectance0: number;
  56889. /**
  56890. * Standard reflectance value at grazing angle.
  56891. */
  56892. static StandardReflectance90: number;
  56893. protected _primaryColor: Color3;
  56894. /**
  56895. * Key light Color (multiply against the environement texture)
  56896. */
  56897. primaryColor: Color3;
  56898. protected __perceptualColor: Nullable<Color3>;
  56899. /**
  56900. * Experimental Internal Use Only.
  56901. *
  56902. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56903. * This acts as a helper to set the primary color to a more "human friendly" value.
  56904. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56905. * output color as close as possible from the chosen value.
  56906. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56907. * part of lighting setup.)
  56908. */
  56909. get _perceptualColor(): Nullable<Color3>;
  56910. set _perceptualColor(value: Nullable<Color3>);
  56911. protected _primaryColorShadowLevel: float;
  56912. /**
  56913. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56914. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56915. */
  56916. get primaryColorShadowLevel(): float;
  56917. set primaryColorShadowLevel(value: float);
  56918. protected _primaryColorHighlightLevel: float;
  56919. /**
  56920. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56921. * The primary color is used at the level chosen to define what the white area would look.
  56922. */
  56923. get primaryColorHighlightLevel(): float;
  56924. set primaryColorHighlightLevel(value: float);
  56925. protected _reflectionTexture: Nullable<BaseTexture>;
  56926. /**
  56927. * Reflection Texture used in the material.
  56928. * Should be author in a specific way for the best result (refer to the documentation).
  56929. */
  56930. reflectionTexture: Nullable<BaseTexture>;
  56931. protected _reflectionBlur: float;
  56932. /**
  56933. * Reflection Texture level of blur.
  56934. *
  56935. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56936. * texture twice.
  56937. */
  56938. reflectionBlur: float;
  56939. protected _diffuseTexture: Nullable<BaseTexture>;
  56940. /**
  56941. * Diffuse Texture used in the material.
  56942. * Should be author in a specific way for the best result (refer to the documentation).
  56943. */
  56944. diffuseTexture: Nullable<BaseTexture>;
  56945. protected _shadowLights: Nullable<IShadowLight[]>;
  56946. /**
  56947. * Specify the list of lights casting shadow on the material.
  56948. * All scene shadow lights will be included if null.
  56949. */
  56950. shadowLights: Nullable<IShadowLight[]>;
  56951. protected _shadowLevel: float;
  56952. /**
  56953. * Helps adjusting the shadow to a softer level if required.
  56954. * 0 means black shadows and 1 means no shadows.
  56955. */
  56956. shadowLevel: float;
  56957. protected _sceneCenter: Vector3;
  56958. /**
  56959. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56960. * It is usually zero but might be interesting to modify according to your setup.
  56961. */
  56962. sceneCenter: Vector3;
  56963. protected _opacityFresnel: boolean;
  56964. /**
  56965. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56966. * This helps ensuring a nice transition when the camera goes under the ground.
  56967. */
  56968. opacityFresnel: boolean;
  56969. protected _reflectionFresnel: boolean;
  56970. /**
  56971. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56972. * This helps adding a mirror texture on the ground.
  56973. */
  56974. reflectionFresnel: boolean;
  56975. protected _reflectionFalloffDistance: number;
  56976. /**
  56977. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56978. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56979. */
  56980. reflectionFalloffDistance: number;
  56981. protected _reflectionAmount: number;
  56982. /**
  56983. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56984. */
  56985. reflectionAmount: number;
  56986. protected _reflectionReflectance0: number;
  56987. /**
  56988. * This specifies the weight of the reflection at grazing angle.
  56989. */
  56990. reflectionReflectance0: number;
  56991. protected _reflectionReflectance90: number;
  56992. /**
  56993. * This specifies the weight of the reflection at a perpendicular point of view.
  56994. */
  56995. reflectionReflectance90: number;
  56996. /**
  56997. * Sets the reflection reflectance fresnel values according to the default standard
  56998. * empirically know to work well :-)
  56999. */
  57000. set reflectionStandardFresnelWeight(value: number);
  57001. protected _useRGBColor: boolean;
  57002. /**
  57003. * Helps to directly use the maps channels instead of their level.
  57004. */
  57005. useRGBColor: boolean;
  57006. protected _enableNoise: boolean;
  57007. /**
  57008. * This helps reducing the banding effect that could occur on the background.
  57009. */
  57010. enableNoise: boolean;
  57011. /**
  57012. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57013. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57014. * Recommended to be keep at 1.0 except for special cases.
  57015. */
  57016. get fovMultiplier(): number;
  57017. set fovMultiplier(value: number);
  57018. private _fovMultiplier;
  57019. /**
  57020. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57021. */
  57022. useEquirectangularFOV: boolean;
  57023. private _maxSimultaneousLights;
  57024. /**
  57025. * Number of Simultaneous lights allowed on the material.
  57026. */
  57027. maxSimultaneousLights: int;
  57028. private _shadowOnly;
  57029. /**
  57030. * Make the material only render shadows
  57031. */
  57032. shadowOnly: boolean;
  57033. /**
  57034. * Default configuration related to image processing available in the Background Material.
  57035. */
  57036. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57037. /**
  57038. * Keep track of the image processing observer to allow dispose and replace.
  57039. */
  57040. private _imageProcessingObserver;
  57041. /**
  57042. * Attaches a new image processing configuration to the PBR Material.
  57043. * @param configuration (if null the scene configuration will be use)
  57044. */
  57045. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57046. /**
  57047. * Gets the image processing configuration used either in this material.
  57048. */
  57049. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57050. /**
  57051. * Sets the Default image processing configuration used either in the this material.
  57052. *
  57053. * If sets to null, the scene one is in use.
  57054. */
  57055. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57056. /**
  57057. * Gets wether the color curves effect is enabled.
  57058. */
  57059. get cameraColorCurvesEnabled(): boolean;
  57060. /**
  57061. * Sets wether the color curves effect is enabled.
  57062. */
  57063. set cameraColorCurvesEnabled(value: boolean);
  57064. /**
  57065. * Gets wether the color grading effect is enabled.
  57066. */
  57067. get cameraColorGradingEnabled(): boolean;
  57068. /**
  57069. * Gets wether the color grading effect is enabled.
  57070. */
  57071. set cameraColorGradingEnabled(value: boolean);
  57072. /**
  57073. * Gets wether tonemapping is enabled or not.
  57074. */
  57075. get cameraToneMappingEnabled(): boolean;
  57076. /**
  57077. * Sets wether tonemapping is enabled or not
  57078. */
  57079. set cameraToneMappingEnabled(value: boolean);
  57080. /**
  57081. * The camera exposure used on this material.
  57082. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57083. * This corresponds to a photographic exposure.
  57084. */
  57085. get cameraExposure(): float;
  57086. /**
  57087. * The camera exposure used on this material.
  57088. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57089. * This corresponds to a photographic exposure.
  57090. */
  57091. set cameraExposure(value: float);
  57092. /**
  57093. * Gets The camera contrast used on this material.
  57094. */
  57095. get cameraContrast(): float;
  57096. /**
  57097. * Sets The camera contrast used on this material.
  57098. */
  57099. set cameraContrast(value: float);
  57100. /**
  57101. * Gets the Color Grading 2D Lookup Texture.
  57102. */
  57103. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57104. /**
  57105. * Sets the Color Grading 2D Lookup Texture.
  57106. */
  57107. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57108. /**
  57109. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57110. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57111. * 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;
  57112. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57113. */
  57114. get cameraColorCurves(): Nullable<ColorCurves>;
  57115. /**
  57116. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57117. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57118. * 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;
  57119. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57120. */
  57121. set cameraColorCurves(value: Nullable<ColorCurves>);
  57122. /**
  57123. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57124. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57125. */
  57126. switchToBGR: boolean;
  57127. private _renderTargets;
  57128. private _reflectionControls;
  57129. private _white;
  57130. private _primaryShadowColor;
  57131. private _primaryHighlightColor;
  57132. /**
  57133. * Instantiates a Background Material in the given scene
  57134. * @param name The friendly name of the material
  57135. * @param scene The scene to add the material to
  57136. */
  57137. constructor(name: string, scene: Scene);
  57138. /**
  57139. * Gets a boolean indicating that current material needs to register RTT
  57140. */
  57141. get hasRenderTargetTextures(): boolean;
  57142. /**
  57143. * The entire material has been created in order to prevent overdraw.
  57144. * @returns false
  57145. */
  57146. needAlphaTesting(): boolean;
  57147. /**
  57148. * The entire material has been created in order to prevent overdraw.
  57149. * @returns true if blending is enable
  57150. */
  57151. needAlphaBlending(): boolean;
  57152. /**
  57153. * Checks wether the material is ready to be rendered for a given mesh.
  57154. * @param mesh The mesh to render
  57155. * @param subMesh The submesh to check against
  57156. * @param useInstances Specify wether or not the material is used with instances
  57157. * @returns true if all the dependencies are ready (Textures, Effects...)
  57158. */
  57159. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57160. /**
  57161. * Compute the primary color according to the chosen perceptual color.
  57162. */
  57163. private _computePrimaryColorFromPerceptualColor;
  57164. /**
  57165. * Compute the highlights and shadow colors according to their chosen levels.
  57166. */
  57167. private _computePrimaryColors;
  57168. /**
  57169. * Build the uniform buffer used in the material.
  57170. */
  57171. buildUniformLayout(): void;
  57172. /**
  57173. * Unbind the material.
  57174. */
  57175. unbind(): void;
  57176. /**
  57177. * Bind only the world matrix to the material.
  57178. * @param world The world matrix to bind.
  57179. */
  57180. bindOnlyWorldMatrix(world: Matrix): void;
  57181. /**
  57182. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57183. * @param world The world matrix to bind.
  57184. * @param subMesh The submesh to bind for.
  57185. */
  57186. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57187. /**
  57188. * Checks to see if a texture is used in the material.
  57189. * @param texture - Base texture to use.
  57190. * @returns - Boolean specifying if a texture is used in the material.
  57191. */
  57192. hasTexture(texture: BaseTexture): boolean;
  57193. /**
  57194. * Dispose the material.
  57195. * @param forceDisposeEffect Force disposal of the associated effect.
  57196. * @param forceDisposeTextures Force disposal of the associated textures.
  57197. */
  57198. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57199. /**
  57200. * Clones the material.
  57201. * @param name The cloned name.
  57202. * @returns The cloned material.
  57203. */
  57204. clone(name: string): BackgroundMaterial;
  57205. /**
  57206. * Serializes the current material to its JSON representation.
  57207. * @returns The JSON representation.
  57208. */
  57209. serialize(): any;
  57210. /**
  57211. * Gets the class name of the material
  57212. * @returns "BackgroundMaterial"
  57213. */
  57214. getClassName(): string;
  57215. /**
  57216. * Parse a JSON input to create back a background material.
  57217. * @param source The JSON data to parse
  57218. * @param scene The scene to create the parsed material in
  57219. * @param rootUrl The root url of the assets the material depends upon
  57220. * @returns the instantiated BackgroundMaterial.
  57221. */
  57222. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57223. }
  57224. }
  57225. declare module "babylonjs/Helpers/environmentHelper" {
  57226. import { Observable } from "babylonjs/Misc/observable";
  57227. import { Nullable } from "babylonjs/types";
  57228. import { Scene } from "babylonjs/scene";
  57229. import { Vector3 } from "babylonjs/Maths/math.vector";
  57230. import { Color3 } from "babylonjs/Maths/math.color";
  57231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57232. import { Mesh } from "babylonjs/Meshes/mesh";
  57233. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57234. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57235. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57236. import "babylonjs/Meshes/Builders/planeBuilder";
  57237. import "babylonjs/Meshes/Builders/boxBuilder";
  57238. /**
  57239. * Represents the different options available during the creation of
  57240. * a Environment helper.
  57241. *
  57242. * This can control the default ground, skybox and image processing setup of your scene.
  57243. */
  57244. export interface IEnvironmentHelperOptions {
  57245. /**
  57246. * Specifies whether or not to create a ground.
  57247. * True by default.
  57248. */
  57249. createGround: boolean;
  57250. /**
  57251. * Specifies the ground size.
  57252. * 15 by default.
  57253. */
  57254. groundSize: number;
  57255. /**
  57256. * The texture used on the ground for the main color.
  57257. * Comes from the BabylonJS CDN by default.
  57258. *
  57259. * Remarks: Can be either a texture or a url.
  57260. */
  57261. groundTexture: string | BaseTexture;
  57262. /**
  57263. * The color mixed in the ground texture by default.
  57264. * BabylonJS clearColor by default.
  57265. */
  57266. groundColor: Color3;
  57267. /**
  57268. * Specifies the ground opacity.
  57269. * 1 by default.
  57270. */
  57271. groundOpacity: number;
  57272. /**
  57273. * Enables the ground to receive shadows.
  57274. * True by default.
  57275. */
  57276. enableGroundShadow: boolean;
  57277. /**
  57278. * Helps preventing the shadow to be fully black on the ground.
  57279. * 0.5 by default.
  57280. */
  57281. groundShadowLevel: number;
  57282. /**
  57283. * Creates a mirror texture attach to the ground.
  57284. * false by default.
  57285. */
  57286. enableGroundMirror: boolean;
  57287. /**
  57288. * Specifies the ground mirror size ratio.
  57289. * 0.3 by default as the default kernel is 64.
  57290. */
  57291. groundMirrorSizeRatio: number;
  57292. /**
  57293. * Specifies the ground mirror blur kernel size.
  57294. * 64 by default.
  57295. */
  57296. groundMirrorBlurKernel: number;
  57297. /**
  57298. * Specifies the ground mirror visibility amount.
  57299. * 1 by default
  57300. */
  57301. groundMirrorAmount: number;
  57302. /**
  57303. * Specifies the ground mirror reflectance weight.
  57304. * This uses the standard weight of the background material to setup the fresnel effect
  57305. * of the mirror.
  57306. * 1 by default.
  57307. */
  57308. groundMirrorFresnelWeight: number;
  57309. /**
  57310. * Specifies the ground mirror Falloff distance.
  57311. * This can helps reducing the size of the reflection.
  57312. * 0 by Default.
  57313. */
  57314. groundMirrorFallOffDistance: number;
  57315. /**
  57316. * Specifies the ground mirror texture type.
  57317. * Unsigned Int by Default.
  57318. */
  57319. groundMirrorTextureType: number;
  57320. /**
  57321. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57322. * the shown objects.
  57323. */
  57324. groundYBias: number;
  57325. /**
  57326. * Specifies whether or not to create a skybox.
  57327. * True by default.
  57328. */
  57329. createSkybox: boolean;
  57330. /**
  57331. * Specifies the skybox size.
  57332. * 20 by default.
  57333. */
  57334. skyboxSize: number;
  57335. /**
  57336. * The texture used on the skybox for the main color.
  57337. * Comes from the BabylonJS CDN by default.
  57338. *
  57339. * Remarks: Can be either a texture or a url.
  57340. */
  57341. skyboxTexture: string | BaseTexture;
  57342. /**
  57343. * The color mixed in the skybox texture by default.
  57344. * BabylonJS clearColor by default.
  57345. */
  57346. skyboxColor: Color3;
  57347. /**
  57348. * The background rotation around the Y axis of the scene.
  57349. * This helps aligning the key lights of your scene with the background.
  57350. * 0 by default.
  57351. */
  57352. backgroundYRotation: number;
  57353. /**
  57354. * Compute automatically the size of the elements to best fit with the scene.
  57355. */
  57356. sizeAuto: boolean;
  57357. /**
  57358. * Default position of the rootMesh if autoSize is not true.
  57359. */
  57360. rootPosition: Vector3;
  57361. /**
  57362. * Sets up the image processing in the scene.
  57363. * true by default.
  57364. */
  57365. setupImageProcessing: boolean;
  57366. /**
  57367. * The texture used as your environment texture in the scene.
  57368. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57369. *
  57370. * Remarks: Can be either a texture or a url.
  57371. */
  57372. environmentTexture: string | BaseTexture;
  57373. /**
  57374. * The value of the exposure to apply to the scene.
  57375. * 0.6 by default if setupImageProcessing is true.
  57376. */
  57377. cameraExposure: number;
  57378. /**
  57379. * The value of the contrast to apply to the scene.
  57380. * 1.6 by default if setupImageProcessing is true.
  57381. */
  57382. cameraContrast: number;
  57383. /**
  57384. * Specifies whether or not tonemapping should be enabled in the scene.
  57385. * true by default if setupImageProcessing is true.
  57386. */
  57387. toneMappingEnabled: boolean;
  57388. }
  57389. /**
  57390. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57391. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57392. * It also helps with the default setup of your imageProcessing configuration.
  57393. */
  57394. export class EnvironmentHelper {
  57395. /**
  57396. * Default ground texture URL.
  57397. */
  57398. private static _groundTextureCDNUrl;
  57399. /**
  57400. * Default skybox texture URL.
  57401. */
  57402. private static _skyboxTextureCDNUrl;
  57403. /**
  57404. * Default environment texture URL.
  57405. */
  57406. private static _environmentTextureCDNUrl;
  57407. /**
  57408. * Creates the default options for the helper.
  57409. */
  57410. private static _getDefaultOptions;
  57411. private _rootMesh;
  57412. /**
  57413. * Gets the root mesh created by the helper.
  57414. */
  57415. get rootMesh(): Mesh;
  57416. private _skybox;
  57417. /**
  57418. * Gets the skybox created by the helper.
  57419. */
  57420. get skybox(): Nullable<Mesh>;
  57421. private _skyboxTexture;
  57422. /**
  57423. * Gets the skybox texture created by the helper.
  57424. */
  57425. get skyboxTexture(): Nullable<BaseTexture>;
  57426. private _skyboxMaterial;
  57427. /**
  57428. * Gets the skybox material created by the helper.
  57429. */
  57430. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57431. private _ground;
  57432. /**
  57433. * Gets the ground mesh created by the helper.
  57434. */
  57435. get ground(): Nullable<Mesh>;
  57436. private _groundTexture;
  57437. /**
  57438. * Gets the ground texture created by the helper.
  57439. */
  57440. get groundTexture(): Nullable<BaseTexture>;
  57441. private _groundMirror;
  57442. /**
  57443. * Gets the ground mirror created by the helper.
  57444. */
  57445. get groundMirror(): Nullable<MirrorTexture>;
  57446. /**
  57447. * Gets the ground mirror render list to helps pushing the meshes
  57448. * you wish in the ground reflection.
  57449. */
  57450. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57451. private _groundMaterial;
  57452. /**
  57453. * Gets the ground material created by the helper.
  57454. */
  57455. get groundMaterial(): Nullable<BackgroundMaterial>;
  57456. /**
  57457. * Stores the creation options.
  57458. */
  57459. private readonly _scene;
  57460. private _options;
  57461. /**
  57462. * This observable will be notified with any error during the creation of the environment,
  57463. * mainly texture creation errors.
  57464. */
  57465. onErrorObservable: Observable<{
  57466. message?: string;
  57467. exception?: any;
  57468. }>;
  57469. /**
  57470. * constructor
  57471. * @param options Defines the options we want to customize the helper
  57472. * @param scene The scene to add the material to
  57473. */
  57474. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57475. /**
  57476. * Updates the background according to the new options
  57477. * @param options
  57478. */
  57479. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57480. /**
  57481. * Sets the primary color of all the available elements.
  57482. * @param color the main color to affect to the ground and the background
  57483. */
  57484. setMainColor(color: Color3): void;
  57485. /**
  57486. * Setup the image processing according to the specified options.
  57487. */
  57488. private _setupImageProcessing;
  57489. /**
  57490. * Setup the environment texture according to the specified options.
  57491. */
  57492. private _setupEnvironmentTexture;
  57493. /**
  57494. * Setup the background according to the specified options.
  57495. */
  57496. private _setupBackground;
  57497. /**
  57498. * Get the scene sizes according to the setup.
  57499. */
  57500. private _getSceneSize;
  57501. /**
  57502. * Setup the ground according to the specified options.
  57503. */
  57504. private _setupGround;
  57505. /**
  57506. * Setup the ground material according to the specified options.
  57507. */
  57508. private _setupGroundMaterial;
  57509. /**
  57510. * Setup the ground diffuse texture according to the specified options.
  57511. */
  57512. private _setupGroundDiffuseTexture;
  57513. /**
  57514. * Setup the ground mirror texture according to the specified options.
  57515. */
  57516. private _setupGroundMirrorTexture;
  57517. /**
  57518. * Setup the ground to receive the mirror texture.
  57519. */
  57520. private _setupMirrorInGroundMaterial;
  57521. /**
  57522. * Setup the skybox according to the specified options.
  57523. */
  57524. private _setupSkybox;
  57525. /**
  57526. * Setup the skybox material according to the specified options.
  57527. */
  57528. private _setupSkyboxMaterial;
  57529. /**
  57530. * Setup the skybox reflection texture according to the specified options.
  57531. */
  57532. private _setupSkyboxReflectionTexture;
  57533. private _errorHandler;
  57534. /**
  57535. * Dispose all the elements created by the Helper.
  57536. */
  57537. dispose(): void;
  57538. }
  57539. }
  57540. declare module "babylonjs/Helpers/textureDome" {
  57541. import { Scene } from "babylonjs/scene";
  57542. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57543. import { Mesh } from "babylonjs/Meshes/mesh";
  57544. import { Texture } from "babylonjs/Materials/Textures/texture";
  57545. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57546. import "babylonjs/Meshes/Builders/sphereBuilder";
  57547. import { Nullable } from "babylonjs/types";
  57548. import { Observable } from "babylonjs/Misc/observable";
  57549. /**
  57550. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57551. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57552. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57553. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57554. */
  57555. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57556. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57557. /**
  57558. * Define the source as a Monoscopic panoramic 360/180.
  57559. */
  57560. static readonly MODE_MONOSCOPIC: number;
  57561. /**
  57562. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57563. */
  57564. static readonly MODE_TOPBOTTOM: number;
  57565. /**
  57566. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57567. */
  57568. static readonly MODE_SIDEBYSIDE: number;
  57569. private _halfDome;
  57570. protected _useDirectMapping: boolean;
  57571. /**
  57572. * The texture being displayed on the sphere
  57573. */
  57574. protected _texture: T;
  57575. /**
  57576. * Gets the texture being displayed on the sphere
  57577. */
  57578. get texture(): T;
  57579. /**
  57580. * Sets the texture being displayed on the sphere
  57581. */
  57582. set texture(newTexture: T);
  57583. /**
  57584. * The skybox material
  57585. */
  57586. protected _material: BackgroundMaterial;
  57587. /**
  57588. * The surface used for the dome
  57589. */
  57590. protected _mesh: Mesh;
  57591. /**
  57592. * Gets the mesh used for the dome.
  57593. */
  57594. get mesh(): Mesh;
  57595. /**
  57596. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57597. */
  57598. private _halfDomeMask;
  57599. /**
  57600. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57601. * Also see the options.resolution property.
  57602. */
  57603. get fovMultiplier(): number;
  57604. set fovMultiplier(value: number);
  57605. protected _textureMode: number;
  57606. /**
  57607. * Gets or set the current texture mode for the texture. It can be:
  57608. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57609. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57610. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57611. */
  57612. get textureMode(): number;
  57613. /**
  57614. * Sets the current texture mode for the texture. It can be:
  57615. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57616. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57617. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57618. */
  57619. set textureMode(value: number);
  57620. /**
  57621. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57622. */
  57623. get halfDome(): boolean;
  57624. /**
  57625. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57626. */
  57627. set halfDome(enabled: boolean);
  57628. /**
  57629. * Oberserver used in Stereoscopic VR Mode.
  57630. */
  57631. private _onBeforeCameraRenderObserver;
  57632. /**
  57633. * Observable raised when an error occured while loading the 360 image
  57634. */
  57635. onLoadErrorObservable: Observable<string>;
  57636. /**
  57637. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57638. * @param name Element's name, child elements will append suffixes for their own names.
  57639. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57640. * @param options An object containing optional or exposed sub element properties
  57641. */
  57642. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57643. resolution?: number;
  57644. clickToPlay?: boolean;
  57645. autoPlay?: boolean;
  57646. loop?: boolean;
  57647. size?: number;
  57648. poster?: string;
  57649. faceForward?: boolean;
  57650. useDirectMapping?: boolean;
  57651. halfDomeMode?: boolean;
  57652. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57653. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57654. protected _changeTextureMode(value: number): void;
  57655. /**
  57656. * Releases resources associated with this node.
  57657. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57658. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57659. */
  57660. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57661. }
  57662. }
  57663. declare module "babylonjs/Helpers/photoDome" {
  57664. import { Scene } from "babylonjs/scene";
  57665. import { Texture } from "babylonjs/Materials/Textures/texture";
  57666. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57667. /**
  57668. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57669. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57670. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57671. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57672. */
  57673. export class PhotoDome extends TextureDome<Texture> {
  57674. /**
  57675. * Define the image as a Monoscopic panoramic 360 image.
  57676. */
  57677. static readonly MODE_MONOSCOPIC: number;
  57678. /**
  57679. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57680. */
  57681. static readonly MODE_TOPBOTTOM: number;
  57682. /**
  57683. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57684. */
  57685. static readonly MODE_SIDEBYSIDE: number;
  57686. /**
  57687. * Gets or sets the texture being displayed on the sphere
  57688. */
  57689. get photoTexture(): Texture;
  57690. /**
  57691. * sets the texture being displayed on the sphere
  57692. */
  57693. set photoTexture(value: Texture);
  57694. /**
  57695. * Gets the current video mode for the video. It can be:
  57696. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57697. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57698. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57699. */
  57700. get imageMode(): number;
  57701. /**
  57702. * Sets the current video mode for the video. It can be:
  57703. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57704. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57705. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57706. */
  57707. set imageMode(value: number);
  57708. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57709. }
  57710. }
  57711. declare module "babylonjs/Misc/rgbdTextureTools" {
  57712. import "babylonjs/Shaders/rgbdDecode.fragment";
  57713. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57714. import { Texture } from "babylonjs/Materials/Textures/texture";
  57715. /**
  57716. * Class used to host RGBD texture specific utilities
  57717. */
  57718. export class RGBDTextureTools {
  57719. /**
  57720. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57721. * @param texture the texture to expand.
  57722. */
  57723. static ExpandRGBDTexture(texture: Texture): void;
  57724. }
  57725. }
  57726. declare module "babylonjs/Misc/brdfTextureTools" {
  57727. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57728. import { Scene } from "babylonjs/scene";
  57729. /**
  57730. * Class used to host texture specific utilities
  57731. */
  57732. export class BRDFTextureTools {
  57733. /**
  57734. * Prevents texture cache collision
  57735. */
  57736. private static _instanceNumber;
  57737. /**
  57738. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57739. * @param scene defines the hosting scene
  57740. * @returns the environment BRDF texture
  57741. */
  57742. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57743. private static _environmentBRDFBase64Texture;
  57744. }
  57745. }
  57746. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57747. import { Nullable } from "babylonjs/types";
  57748. import { Color3 } from "babylonjs/Maths/math.color";
  57749. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57750. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57751. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57752. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57753. import { Engine } from "babylonjs/Engines/engine";
  57754. import { Scene } from "babylonjs/scene";
  57755. /**
  57756. * @hidden
  57757. */
  57758. export interface IMaterialClearCoatDefines {
  57759. CLEARCOAT: boolean;
  57760. CLEARCOAT_DEFAULTIOR: boolean;
  57761. CLEARCOAT_TEXTURE: boolean;
  57762. CLEARCOAT_TEXTUREDIRECTUV: number;
  57763. CLEARCOAT_BUMP: boolean;
  57764. CLEARCOAT_BUMPDIRECTUV: number;
  57765. CLEARCOAT_TINT: boolean;
  57766. CLEARCOAT_TINT_TEXTURE: boolean;
  57767. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57768. /** @hidden */
  57769. _areTexturesDirty: boolean;
  57770. }
  57771. /**
  57772. * Define the code related to the clear coat parameters of the pbr material.
  57773. */
  57774. export class PBRClearCoatConfiguration {
  57775. /**
  57776. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57777. * The default fits with a polyurethane material.
  57778. */
  57779. private static readonly _DefaultIndexOfRefraction;
  57780. private _isEnabled;
  57781. /**
  57782. * Defines if the clear coat is enabled in the material.
  57783. */
  57784. isEnabled: boolean;
  57785. /**
  57786. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57787. */
  57788. intensity: number;
  57789. /**
  57790. * Defines the clear coat layer roughness.
  57791. */
  57792. roughness: number;
  57793. private _indexOfRefraction;
  57794. /**
  57795. * Defines the index of refraction of the clear coat.
  57796. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57797. * The default fits with a polyurethane material.
  57798. * Changing the default value is more performance intensive.
  57799. */
  57800. indexOfRefraction: number;
  57801. private _texture;
  57802. /**
  57803. * Stores the clear coat values in a texture.
  57804. */
  57805. texture: Nullable<BaseTexture>;
  57806. private _bumpTexture;
  57807. /**
  57808. * Define the clear coat specific bump texture.
  57809. */
  57810. bumpTexture: Nullable<BaseTexture>;
  57811. private _isTintEnabled;
  57812. /**
  57813. * Defines if the clear coat tint is enabled in the material.
  57814. */
  57815. isTintEnabled: boolean;
  57816. /**
  57817. * Defines the clear coat tint of the material.
  57818. * This is only use if tint is enabled
  57819. */
  57820. tintColor: Color3;
  57821. /**
  57822. * Defines the distance at which the tint color should be found in the
  57823. * clear coat media.
  57824. * This is only use if tint is enabled
  57825. */
  57826. tintColorAtDistance: number;
  57827. /**
  57828. * Defines the clear coat layer thickness.
  57829. * This is only use if tint is enabled
  57830. */
  57831. tintThickness: number;
  57832. private _tintTexture;
  57833. /**
  57834. * Stores the clear tint values in a texture.
  57835. * rgb is tint
  57836. * a is a thickness factor
  57837. */
  57838. tintTexture: Nullable<BaseTexture>;
  57839. /** @hidden */
  57840. private _internalMarkAllSubMeshesAsTexturesDirty;
  57841. /** @hidden */
  57842. _markAllSubMeshesAsTexturesDirty(): void;
  57843. /**
  57844. * Instantiate a new istance of clear coat configuration.
  57845. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57846. */
  57847. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57848. /**
  57849. * Gets wehter the submesh is ready to be used or not.
  57850. * @param defines the list of "defines" to update.
  57851. * @param scene defines the scene the material belongs to.
  57852. * @param engine defines the engine the material belongs to.
  57853. * @param disableBumpMap defines wether the material disables bump or not.
  57854. * @returns - boolean indicating that the submesh is ready or not.
  57855. */
  57856. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57857. /**
  57858. * Checks to see if a texture is used in the material.
  57859. * @param defines the list of "defines" to update.
  57860. * @param scene defines the scene to the material belongs to.
  57861. */
  57862. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57863. /**
  57864. * Binds the material data.
  57865. * @param uniformBuffer defines the Uniform buffer to fill in.
  57866. * @param scene defines the scene the material belongs to.
  57867. * @param engine defines the engine the material belongs to.
  57868. * @param disableBumpMap defines wether the material disables bump or not.
  57869. * @param isFrozen defines wether the material is frozen or not.
  57870. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57871. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57872. */
  57873. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57874. /**
  57875. * Checks to see if a texture is used in the material.
  57876. * @param texture - Base texture to use.
  57877. * @returns - Boolean specifying if a texture is used in the material.
  57878. */
  57879. hasTexture(texture: BaseTexture): boolean;
  57880. /**
  57881. * Returns an array of the actively used textures.
  57882. * @param activeTextures Array of BaseTextures
  57883. */
  57884. getActiveTextures(activeTextures: BaseTexture[]): void;
  57885. /**
  57886. * Returns the animatable textures.
  57887. * @param animatables Array of animatable textures.
  57888. */
  57889. getAnimatables(animatables: IAnimatable[]): void;
  57890. /**
  57891. * Disposes the resources of the material.
  57892. * @param forceDisposeTextures - Forces the disposal of all textures.
  57893. */
  57894. dispose(forceDisposeTextures?: boolean): void;
  57895. /**
  57896. * Get the current class name of the texture useful for serialization or dynamic coding.
  57897. * @returns "PBRClearCoatConfiguration"
  57898. */
  57899. getClassName(): string;
  57900. /**
  57901. * Add fallbacks to the effect fallbacks list.
  57902. * @param defines defines the Base texture to use.
  57903. * @param fallbacks defines the current fallback list.
  57904. * @param currentRank defines the current fallback rank.
  57905. * @returns the new fallback rank.
  57906. */
  57907. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57908. /**
  57909. * Add the required uniforms to the current list.
  57910. * @param uniforms defines the current uniform list.
  57911. */
  57912. static AddUniforms(uniforms: string[]): void;
  57913. /**
  57914. * Add the required samplers to the current list.
  57915. * @param samplers defines the current sampler list.
  57916. */
  57917. static AddSamplers(samplers: string[]): void;
  57918. /**
  57919. * Add the required uniforms to the current buffer.
  57920. * @param uniformBuffer defines the current uniform buffer.
  57921. */
  57922. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57923. /**
  57924. * Makes a duplicate of the current configuration into another one.
  57925. * @param clearCoatConfiguration define the config where to copy the info
  57926. */
  57927. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57928. /**
  57929. * Serializes this clear coat configuration.
  57930. * @returns - An object with the serialized config.
  57931. */
  57932. serialize(): any;
  57933. /**
  57934. * Parses a anisotropy Configuration from a serialized object.
  57935. * @param source - Serialized object.
  57936. * @param scene Defines the scene we are parsing for
  57937. * @param rootUrl Defines the rootUrl to load from
  57938. */
  57939. parse(source: any, scene: Scene, rootUrl: string): void;
  57940. }
  57941. }
  57942. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57943. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57945. import { Vector2 } from "babylonjs/Maths/math.vector";
  57946. import { Scene } from "babylonjs/scene";
  57947. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57948. import { Nullable } from "babylonjs/types";
  57949. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57950. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57951. /**
  57952. * @hidden
  57953. */
  57954. export interface IMaterialAnisotropicDefines {
  57955. ANISOTROPIC: boolean;
  57956. ANISOTROPIC_TEXTURE: boolean;
  57957. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57958. MAINUV1: boolean;
  57959. _areTexturesDirty: boolean;
  57960. _needUVs: boolean;
  57961. }
  57962. /**
  57963. * Define the code related to the anisotropic parameters of the pbr material.
  57964. */
  57965. export class PBRAnisotropicConfiguration {
  57966. private _isEnabled;
  57967. /**
  57968. * Defines if the anisotropy is enabled in the material.
  57969. */
  57970. isEnabled: boolean;
  57971. /**
  57972. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57973. */
  57974. intensity: number;
  57975. /**
  57976. * Defines if the effect is along the tangents, bitangents or in between.
  57977. * By default, the effect is "strectching" the highlights along the tangents.
  57978. */
  57979. direction: Vector2;
  57980. private _texture;
  57981. /**
  57982. * Stores the anisotropy values in a texture.
  57983. * rg is direction (like normal from -1 to 1)
  57984. * b is a intensity
  57985. */
  57986. texture: Nullable<BaseTexture>;
  57987. /** @hidden */
  57988. private _internalMarkAllSubMeshesAsTexturesDirty;
  57989. /** @hidden */
  57990. _markAllSubMeshesAsTexturesDirty(): void;
  57991. /**
  57992. * Instantiate a new istance of anisotropy configuration.
  57993. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57994. */
  57995. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57996. /**
  57997. * Specifies that the submesh is ready to be used.
  57998. * @param defines the list of "defines" to update.
  57999. * @param scene defines the scene the material belongs to.
  58000. * @returns - boolean indicating that the submesh is ready or not.
  58001. */
  58002. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  58003. /**
  58004. * Checks to see if a texture is used in the material.
  58005. * @param defines the list of "defines" to update.
  58006. * @param mesh the mesh we are preparing the defines for.
  58007. * @param scene defines the scene the material belongs to.
  58008. */
  58009. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  58010. /**
  58011. * Binds the material data.
  58012. * @param uniformBuffer defines the Uniform buffer to fill in.
  58013. * @param scene defines the scene the material belongs to.
  58014. * @param isFrozen defines wether the material is frozen or not.
  58015. */
  58016. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58017. /**
  58018. * Checks to see if a texture is used in the material.
  58019. * @param texture - Base texture to use.
  58020. * @returns - Boolean specifying if a texture is used in the material.
  58021. */
  58022. hasTexture(texture: BaseTexture): boolean;
  58023. /**
  58024. * Returns an array of the actively used textures.
  58025. * @param activeTextures Array of BaseTextures
  58026. */
  58027. getActiveTextures(activeTextures: BaseTexture[]): void;
  58028. /**
  58029. * Returns the animatable textures.
  58030. * @param animatables Array of animatable textures.
  58031. */
  58032. getAnimatables(animatables: IAnimatable[]): void;
  58033. /**
  58034. * Disposes the resources of the material.
  58035. * @param forceDisposeTextures - Forces the disposal of all textures.
  58036. */
  58037. dispose(forceDisposeTextures?: boolean): void;
  58038. /**
  58039. * Get the current class name of the texture useful for serialization or dynamic coding.
  58040. * @returns "PBRAnisotropicConfiguration"
  58041. */
  58042. getClassName(): string;
  58043. /**
  58044. * Add fallbacks to the effect fallbacks list.
  58045. * @param defines defines the Base texture to use.
  58046. * @param fallbacks defines the current fallback list.
  58047. * @param currentRank defines the current fallback rank.
  58048. * @returns the new fallback rank.
  58049. */
  58050. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58051. /**
  58052. * Add the required uniforms to the current list.
  58053. * @param uniforms defines the current uniform list.
  58054. */
  58055. static AddUniforms(uniforms: string[]): void;
  58056. /**
  58057. * Add the required uniforms to the current buffer.
  58058. * @param uniformBuffer defines the current uniform buffer.
  58059. */
  58060. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58061. /**
  58062. * Add the required samplers to the current list.
  58063. * @param samplers defines the current sampler list.
  58064. */
  58065. static AddSamplers(samplers: string[]): void;
  58066. /**
  58067. * Makes a duplicate of the current configuration into another one.
  58068. * @param anisotropicConfiguration define the config where to copy the info
  58069. */
  58070. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  58071. /**
  58072. * Serializes this anisotropy configuration.
  58073. * @returns - An object with the serialized config.
  58074. */
  58075. serialize(): any;
  58076. /**
  58077. * Parses a anisotropy Configuration from a serialized object.
  58078. * @param source - Serialized object.
  58079. * @param scene Defines the scene we are parsing for
  58080. * @param rootUrl Defines the rootUrl to load from
  58081. */
  58082. parse(source: any, scene: Scene, rootUrl: string): void;
  58083. }
  58084. }
  58085. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  58086. import { Scene } from "babylonjs/scene";
  58087. /**
  58088. * @hidden
  58089. */
  58090. export interface IMaterialBRDFDefines {
  58091. BRDF_V_HEIGHT_CORRELATED: boolean;
  58092. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58093. SPHERICAL_HARMONICS: boolean;
  58094. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58095. /** @hidden */
  58096. _areMiscDirty: boolean;
  58097. }
  58098. /**
  58099. * Define the code related to the BRDF parameters of the pbr material.
  58100. */
  58101. export class PBRBRDFConfiguration {
  58102. /**
  58103. * Default value used for the energy conservation.
  58104. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58105. */
  58106. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  58107. /**
  58108. * Default value used for the Smith Visibility Height Correlated mode.
  58109. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58110. */
  58111. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  58112. /**
  58113. * Default value used for the IBL diffuse part.
  58114. * This can help switching back to the polynomials mode globally which is a tiny bit
  58115. * less GPU intensive at the drawback of a lower quality.
  58116. */
  58117. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  58118. /**
  58119. * Default value used for activating energy conservation for the specular workflow.
  58120. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58121. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58122. */
  58123. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  58124. private _useEnergyConservation;
  58125. /**
  58126. * Defines if the material uses energy conservation.
  58127. */
  58128. useEnergyConservation: boolean;
  58129. private _useSmithVisibilityHeightCorrelated;
  58130. /**
  58131. * LEGACY Mode set to false
  58132. * Defines if the material uses height smith correlated visibility term.
  58133. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58134. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58135. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58136. * Not relying on height correlated will also disable energy conservation.
  58137. */
  58138. useSmithVisibilityHeightCorrelated: boolean;
  58139. private _useSphericalHarmonics;
  58140. /**
  58141. * LEGACY Mode set to false
  58142. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58143. * diffuse part of the IBL.
  58144. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58145. * to the ground truth.
  58146. */
  58147. useSphericalHarmonics: boolean;
  58148. private _useSpecularGlossinessInputEnergyConservation;
  58149. /**
  58150. * Defines if the material uses energy conservation, when the specular workflow is active.
  58151. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58152. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58153. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58154. */
  58155. useSpecularGlossinessInputEnergyConservation: boolean;
  58156. /** @hidden */
  58157. private _internalMarkAllSubMeshesAsMiscDirty;
  58158. /** @hidden */
  58159. _markAllSubMeshesAsMiscDirty(): void;
  58160. /**
  58161. * Instantiate a new istance of clear coat configuration.
  58162. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58163. */
  58164. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58165. /**
  58166. * Checks to see if a texture is used in the material.
  58167. * @param defines the list of "defines" to update.
  58168. */
  58169. prepareDefines(defines: IMaterialBRDFDefines): void;
  58170. /**
  58171. * Get the current class name of the texture useful for serialization or dynamic coding.
  58172. * @returns "PBRClearCoatConfiguration"
  58173. */
  58174. getClassName(): string;
  58175. /**
  58176. * Makes a duplicate of the current configuration into another one.
  58177. * @param brdfConfiguration define the config where to copy the info
  58178. */
  58179. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58180. /**
  58181. * Serializes this BRDF configuration.
  58182. * @returns - An object with the serialized config.
  58183. */
  58184. serialize(): any;
  58185. /**
  58186. * Parses a anisotropy Configuration from a serialized object.
  58187. * @param source - Serialized object.
  58188. * @param scene Defines the scene we are parsing for
  58189. * @param rootUrl Defines the rootUrl to load from
  58190. */
  58191. parse(source: any, scene: Scene, rootUrl: string): void;
  58192. }
  58193. }
  58194. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58195. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58196. import { Color3 } from "babylonjs/Maths/math.color";
  58197. import { Scene } from "babylonjs/scene";
  58198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58199. import { Nullable } from "babylonjs/types";
  58200. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58201. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58202. /**
  58203. * @hidden
  58204. */
  58205. export interface IMaterialSheenDefines {
  58206. SHEEN: boolean;
  58207. SHEEN_TEXTURE: boolean;
  58208. SHEEN_TEXTUREDIRECTUV: number;
  58209. SHEEN_LINKWITHALBEDO: boolean;
  58210. SHEEN_ROUGHNESS: boolean;
  58211. SHEEN_ALBEDOSCALING: boolean;
  58212. /** @hidden */
  58213. _areTexturesDirty: boolean;
  58214. }
  58215. /**
  58216. * Define the code related to the Sheen parameters of the pbr material.
  58217. */
  58218. export class PBRSheenConfiguration {
  58219. private _isEnabled;
  58220. /**
  58221. * Defines if the material uses sheen.
  58222. */
  58223. isEnabled: boolean;
  58224. private _linkSheenWithAlbedo;
  58225. /**
  58226. * Defines if the sheen is linked to the sheen color.
  58227. */
  58228. linkSheenWithAlbedo: boolean;
  58229. /**
  58230. * Defines the sheen intensity.
  58231. */
  58232. intensity: number;
  58233. /**
  58234. * Defines the sheen color.
  58235. */
  58236. color: Color3;
  58237. private _texture;
  58238. /**
  58239. * Stores the sheen tint values in a texture.
  58240. * rgb is tint
  58241. * a is a intensity or roughness if roughness has been defined
  58242. */
  58243. texture: Nullable<BaseTexture>;
  58244. private _roughness;
  58245. /**
  58246. * Defines the sheen roughness.
  58247. * It is not taken into account if linkSheenWithAlbedo is true.
  58248. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58249. */
  58250. roughness: Nullable<number>;
  58251. private _albedoScaling;
  58252. /**
  58253. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58254. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58255. * making it easier to setup and tweak the effect
  58256. */
  58257. albedoScaling: boolean;
  58258. /** @hidden */
  58259. private _internalMarkAllSubMeshesAsTexturesDirty;
  58260. /** @hidden */
  58261. _markAllSubMeshesAsTexturesDirty(): void;
  58262. /**
  58263. * Instantiate a new istance of clear coat configuration.
  58264. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58265. */
  58266. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58267. /**
  58268. * Specifies that the submesh is ready to be used.
  58269. * @param defines the list of "defines" to update.
  58270. * @param scene defines the scene the material belongs to.
  58271. * @returns - boolean indicating that the submesh is ready or not.
  58272. */
  58273. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58274. /**
  58275. * Checks to see if a texture is used in the material.
  58276. * @param defines the list of "defines" to update.
  58277. * @param scene defines the scene the material belongs to.
  58278. */
  58279. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58280. /**
  58281. * Binds the material data.
  58282. * @param uniformBuffer defines the Uniform buffer to fill in.
  58283. * @param scene defines the scene the material belongs to.
  58284. * @param isFrozen defines wether the material is frozen or not.
  58285. */
  58286. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58287. /**
  58288. * Checks to see if a texture is used in the material.
  58289. * @param texture - Base texture to use.
  58290. * @returns - Boolean specifying if a texture is used in the material.
  58291. */
  58292. hasTexture(texture: BaseTexture): boolean;
  58293. /**
  58294. * Returns an array of the actively used textures.
  58295. * @param activeTextures Array of BaseTextures
  58296. */
  58297. getActiveTextures(activeTextures: BaseTexture[]): void;
  58298. /**
  58299. * Returns the animatable textures.
  58300. * @param animatables Array of animatable textures.
  58301. */
  58302. getAnimatables(animatables: IAnimatable[]): void;
  58303. /**
  58304. * Disposes the resources of the material.
  58305. * @param forceDisposeTextures - Forces the disposal of all textures.
  58306. */
  58307. dispose(forceDisposeTextures?: boolean): void;
  58308. /**
  58309. * Get the current class name of the texture useful for serialization or dynamic coding.
  58310. * @returns "PBRSheenConfiguration"
  58311. */
  58312. getClassName(): string;
  58313. /**
  58314. * Add fallbacks to the effect fallbacks list.
  58315. * @param defines defines the Base texture to use.
  58316. * @param fallbacks defines the current fallback list.
  58317. * @param currentRank defines the current fallback rank.
  58318. * @returns the new fallback rank.
  58319. */
  58320. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58321. /**
  58322. * Add the required uniforms to the current list.
  58323. * @param uniforms defines the current uniform list.
  58324. */
  58325. static AddUniforms(uniforms: string[]): void;
  58326. /**
  58327. * Add the required uniforms to the current buffer.
  58328. * @param uniformBuffer defines the current uniform buffer.
  58329. */
  58330. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58331. /**
  58332. * Add the required samplers to the current list.
  58333. * @param samplers defines the current sampler list.
  58334. */
  58335. static AddSamplers(samplers: string[]): void;
  58336. /**
  58337. * Makes a duplicate of the current configuration into another one.
  58338. * @param sheenConfiguration define the config where to copy the info
  58339. */
  58340. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58341. /**
  58342. * Serializes this BRDF configuration.
  58343. * @returns - An object with the serialized config.
  58344. */
  58345. serialize(): any;
  58346. /**
  58347. * Parses a anisotropy Configuration from a serialized object.
  58348. * @param source - Serialized object.
  58349. * @param scene Defines the scene we are parsing for
  58350. * @param rootUrl Defines the rootUrl to load from
  58351. */
  58352. parse(source: any, scene: Scene, rootUrl: string): void;
  58353. }
  58354. }
  58355. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58356. import { Nullable } from "babylonjs/types";
  58357. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58358. import { Color3 } from "babylonjs/Maths/math.color";
  58359. import { SmartArray } from "babylonjs/Misc/smartArray";
  58360. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58361. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58362. import { Effect } from "babylonjs/Materials/effect";
  58363. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58364. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58365. import { Engine } from "babylonjs/Engines/engine";
  58366. import { Scene } from "babylonjs/scene";
  58367. /**
  58368. * @hidden
  58369. */
  58370. export interface IMaterialSubSurfaceDefines {
  58371. SUBSURFACE: boolean;
  58372. SS_REFRACTION: boolean;
  58373. SS_TRANSLUCENCY: boolean;
  58374. SS_SCATTERING: boolean;
  58375. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58376. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58377. SS_REFRACTIONMAP_3D: boolean;
  58378. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58379. SS_LODINREFRACTIONALPHA: boolean;
  58380. SS_GAMMAREFRACTION: boolean;
  58381. SS_RGBDREFRACTION: boolean;
  58382. SS_LINEARSPECULARREFRACTION: boolean;
  58383. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58384. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58385. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58386. /** @hidden */
  58387. _areTexturesDirty: boolean;
  58388. }
  58389. /**
  58390. * Define the code related to the sub surface parameters of the pbr material.
  58391. */
  58392. export class PBRSubSurfaceConfiguration {
  58393. private _isRefractionEnabled;
  58394. /**
  58395. * Defines if the refraction is enabled in the material.
  58396. */
  58397. isRefractionEnabled: boolean;
  58398. private _isTranslucencyEnabled;
  58399. /**
  58400. * Defines if the translucency is enabled in the material.
  58401. */
  58402. isTranslucencyEnabled: boolean;
  58403. private _isScatteringEnabled;
  58404. /**
  58405. * Defines if the sub surface scattering is enabled in the material.
  58406. */
  58407. isScatteringEnabled: boolean;
  58408. private _scatteringDiffusionProfileIndex;
  58409. /**
  58410. * Diffusion profile for subsurface scattering.
  58411. * Useful for better scattering in the skins or foliages.
  58412. */
  58413. get scatteringDiffusionProfile(): Nullable<Color3>;
  58414. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58415. /**
  58416. * Defines the refraction intensity of the material.
  58417. * The refraction when enabled replaces the Diffuse part of the material.
  58418. * The intensity helps transitionning between diffuse and refraction.
  58419. */
  58420. refractionIntensity: number;
  58421. /**
  58422. * Defines the translucency intensity of the material.
  58423. * When translucency has been enabled, this defines how much of the "translucency"
  58424. * is addded to the diffuse part of the material.
  58425. */
  58426. translucencyIntensity: number;
  58427. /**
  58428. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58429. */
  58430. useAlbedoToTintRefraction: boolean;
  58431. private _thicknessTexture;
  58432. /**
  58433. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58434. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58435. * 0 would mean minimumThickness
  58436. * 1 would mean maximumThickness
  58437. * The other channels might be use as a mask to vary the different effects intensity.
  58438. */
  58439. thicknessTexture: Nullable<BaseTexture>;
  58440. private _refractionTexture;
  58441. /**
  58442. * Defines the texture to use for refraction.
  58443. */
  58444. refractionTexture: Nullable<BaseTexture>;
  58445. private _indexOfRefraction;
  58446. /**
  58447. * Index of refraction of the material base layer.
  58448. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58449. *
  58450. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58451. *
  58452. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58453. */
  58454. indexOfRefraction: number;
  58455. private _volumeIndexOfRefraction;
  58456. /**
  58457. * Index of refraction of the material's volume.
  58458. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58459. *
  58460. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58461. * the volume will use the same IOR as the surface.
  58462. */
  58463. get volumeIndexOfRefraction(): number;
  58464. set volumeIndexOfRefraction(value: number);
  58465. private _invertRefractionY;
  58466. /**
  58467. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58468. */
  58469. invertRefractionY: boolean;
  58470. private _linkRefractionWithTransparency;
  58471. /**
  58472. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58473. * Materials half opaque for instance using refraction could benefit from this control.
  58474. */
  58475. linkRefractionWithTransparency: boolean;
  58476. /**
  58477. * Defines the minimum thickness stored in the thickness map.
  58478. * If no thickness map is defined, this value will be used to simulate thickness.
  58479. */
  58480. minimumThickness: number;
  58481. /**
  58482. * Defines the maximum thickness stored in the thickness map.
  58483. */
  58484. maximumThickness: number;
  58485. /**
  58486. * Defines the volume tint of the material.
  58487. * This is used for both translucency and scattering.
  58488. */
  58489. tintColor: Color3;
  58490. /**
  58491. * Defines the distance at which the tint color should be found in the media.
  58492. * This is used for refraction only.
  58493. */
  58494. tintColorAtDistance: number;
  58495. /**
  58496. * Defines how far each channel transmit through the media.
  58497. * It is defined as a color to simplify it selection.
  58498. */
  58499. diffusionDistance: Color3;
  58500. private _useMaskFromThicknessTexture;
  58501. /**
  58502. * Stores the intensity of the different subsurface effects in the thickness texture.
  58503. * * the green channel is the translucency intensity.
  58504. * * the blue channel is the scattering intensity.
  58505. * * the alpha channel is the refraction intensity.
  58506. */
  58507. useMaskFromThicknessTexture: boolean;
  58508. private _scene;
  58509. /** @hidden */
  58510. private _internalMarkAllSubMeshesAsTexturesDirty;
  58511. private _internalMarkScenePrePassDirty;
  58512. /** @hidden */
  58513. _markAllSubMeshesAsTexturesDirty(): void;
  58514. /** @hidden */
  58515. _markScenePrePassDirty(): void;
  58516. /**
  58517. * Instantiate a new istance of sub surface configuration.
  58518. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58519. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58520. * @param scene The scene
  58521. */
  58522. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58523. /**
  58524. * Gets wehter the submesh is ready to be used or not.
  58525. * @param defines the list of "defines" to update.
  58526. * @param scene defines the scene the material belongs to.
  58527. * @returns - boolean indicating that the submesh is ready or not.
  58528. */
  58529. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58530. /**
  58531. * Checks to see if a texture is used in the material.
  58532. * @param defines the list of "defines" to update.
  58533. * @param scene defines the scene to the material belongs to.
  58534. */
  58535. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58536. /**
  58537. * Binds the material data.
  58538. * @param uniformBuffer defines the Uniform buffer to fill in.
  58539. * @param scene defines the scene the material belongs to.
  58540. * @param engine defines the engine the material belongs to.
  58541. * @param isFrozen defines whether the material is frozen or not.
  58542. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58543. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58544. */
  58545. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58546. /**
  58547. * Unbinds the material from the mesh.
  58548. * @param activeEffect defines the effect that should be unbound from.
  58549. * @returns true if unbound, otherwise false
  58550. */
  58551. unbind(activeEffect: Effect): boolean;
  58552. /**
  58553. * Returns the texture used for refraction or null if none is used.
  58554. * @param scene defines the scene the material belongs to.
  58555. * @returns - Refraction texture if present. If no refraction texture and refraction
  58556. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58557. */
  58558. private _getRefractionTexture;
  58559. /**
  58560. * Returns true if alpha blending should be disabled.
  58561. */
  58562. get disableAlphaBlending(): boolean;
  58563. /**
  58564. * Fills the list of render target textures.
  58565. * @param renderTargets the list of render targets to update
  58566. */
  58567. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58568. /**
  58569. * Checks to see if a texture is used in the material.
  58570. * @param texture - Base texture to use.
  58571. * @returns - Boolean specifying if a texture is used in the material.
  58572. */
  58573. hasTexture(texture: BaseTexture): boolean;
  58574. /**
  58575. * Gets a boolean indicating that current material needs to register RTT
  58576. * @returns true if this uses a render target otherwise false.
  58577. */
  58578. hasRenderTargetTextures(): boolean;
  58579. /**
  58580. * Returns an array of the actively used textures.
  58581. * @param activeTextures Array of BaseTextures
  58582. */
  58583. getActiveTextures(activeTextures: BaseTexture[]): void;
  58584. /**
  58585. * Returns the animatable textures.
  58586. * @param animatables Array of animatable textures.
  58587. */
  58588. getAnimatables(animatables: IAnimatable[]): void;
  58589. /**
  58590. * Disposes the resources of the material.
  58591. * @param forceDisposeTextures - Forces the disposal of all textures.
  58592. */
  58593. dispose(forceDisposeTextures?: boolean): void;
  58594. /**
  58595. * Get the current class name of the texture useful for serialization or dynamic coding.
  58596. * @returns "PBRSubSurfaceConfiguration"
  58597. */
  58598. getClassName(): string;
  58599. /**
  58600. * Add fallbacks to the effect fallbacks list.
  58601. * @param defines defines the Base texture to use.
  58602. * @param fallbacks defines the current fallback list.
  58603. * @param currentRank defines the current fallback rank.
  58604. * @returns the new fallback rank.
  58605. */
  58606. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58607. /**
  58608. * Add the required uniforms to the current list.
  58609. * @param uniforms defines the current uniform list.
  58610. */
  58611. static AddUniforms(uniforms: string[]): void;
  58612. /**
  58613. * Add the required samplers to the current list.
  58614. * @param samplers defines the current sampler list.
  58615. */
  58616. static AddSamplers(samplers: string[]): void;
  58617. /**
  58618. * Add the required uniforms to the current buffer.
  58619. * @param uniformBuffer defines the current uniform buffer.
  58620. */
  58621. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58622. /**
  58623. * Makes a duplicate of the current configuration into another one.
  58624. * @param configuration define the config where to copy the info
  58625. */
  58626. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58627. /**
  58628. * Serializes this Sub Surface configuration.
  58629. * @returns - An object with the serialized config.
  58630. */
  58631. serialize(): any;
  58632. /**
  58633. * Parses a anisotropy Configuration from a serialized object.
  58634. * @param source - Serialized object.
  58635. * @param scene Defines the scene we are parsing for
  58636. * @param rootUrl Defines the rootUrl to load from
  58637. */
  58638. parse(source: any, scene: Scene, rootUrl: string): void;
  58639. }
  58640. }
  58641. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58642. /** @hidden */
  58643. export var pbrFragmentDeclaration: {
  58644. name: string;
  58645. shader: string;
  58646. };
  58647. }
  58648. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58649. /** @hidden */
  58650. export var pbrUboDeclaration: {
  58651. name: string;
  58652. shader: string;
  58653. };
  58654. }
  58655. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58656. /** @hidden */
  58657. export var pbrFragmentExtraDeclaration: {
  58658. name: string;
  58659. shader: string;
  58660. };
  58661. }
  58662. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58663. /** @hidden */
  58664. export var pbrFragmentSamplersDeclaration: {
  58665. name: string;
  58666. shader: string;
  58667. };
  58668. }
  58669. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  58670. /** @hidden */
  58671. export var subSurfaceScatteringFunctions: {
  58672. name: string;
  58673. shader: string;
  58674. };
  58675. }
  58676. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58677. /** @hidden */
  58678. export var importanceSampling: {
  58679. name: string;
  58680. shader: string;
  58681. };
  58682. }
  58683. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58684. /** @hidden */
  58685. export var pbrHelperFunctions: {
  58686. name: string;
  58687. shader: string;
  58688. };
  58689. }
  58690. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58691. /** @hidden */
  58692. export var harmonicsFunctions: {
  58693. name: string;
  58694. shader: string;
  58695. };
  58696. }
  58697. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58698. /** @hidden */
  58699. export var pbrDirectLightingSetupFunctions: {
  58700. name: string;
  58701. shader: string;
  58702. };
  58703. }
  58704. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58705. /** @hidden */
  58706. export var pbrDirectLightingFalloffFunctions: {
  58707. name: string;
  58708. shader: string;
  58709. };
  58710. }
  58711. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58712. /** @hidden */
  58713. export var pbrBRDFFunctions: {
  58714. name: string;
  58715. shader: string;
  58716. };
  58717. }
  58718. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58719. /** @hidden */
  58720. export var hdrFilteringFunctions: {
  58721. name: string;
  58722. shader: string;
  58723. };
  58724. }
  58725. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58726. /** @hidden */
  58727. export var pbrDirectLightingFunctions: {
  58728. name: string;
  58729. shader: string;
  58730. };
  58731. }
  58732. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58733. /** @hidden */
  58734. export var pbrIBLFunctions: {
  58735. name: string;
  58736. shader: string;
  58737. };
  58738. }
  58739. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58740. /** @hidden */
  58741. export var pbrBlockAlbedoOpacity: {
  58742. name: string;
  58743. shader: string;
  58744. };
  58745. }
  58746. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58747. /** @hidden */
  58748. export var pbrBlockReflectivity: {
  58749. name: string;
  58750. shader: string;
  58751. };
  58752. }
  58753. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58754. /** @hidden */
  58755. export var pbrBlockAmbientOcclusion: {
  58756. name: string;
  58757. shader: string;
  58758. };
  58759. }
  58760. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58761. /** @hidden */
  58762. export var pbrBlockAlphaFresnel: {
  58763. name: string;
  58764. shader: string;
  58765. };
  58766. }
  58767. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58768. /** @hidden */
  58769. export var pbrBlockAnisotropic: {
  58770. name: string;
  58771. shader: string;
  58772. };
  58773. }
  58774. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58775. /** @hidden */
  58776. export var pbrBlockReflection: {
  58777. name: string;
  58778. shader: string;
  58779. };
  58780. }
  58781. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58782. /** @hidden */
  58783. export var pbrBlockSheen: {
  58784. name: string;
  58785. shader: string;
  58786. };
  58787. }
  58788. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58789. /** @hidden */
  58790. export var pbrBlockClearcoat: {
  58791. name: string;
  58792. shader: string;
  58793. };
  58794. }
  58795. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58796. /** @hidden */
  58797. export var pbrBlockSubSurface: {
  58798. name: string;
  58799. shader: string;
  58800. };
  58801. }
  58802. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58803. /** @hidden */
  58804. export var pbrBlockNormalGeometric: {
  58805. name: string;
  58806. shader: string;
  58807. };
  58808. }
  58809. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58810. /** @hidden */
  58811. export var pbrBlockNormalFinal: {
  58812. name: string;
  58813. shader: string;
  58814. };
  58815. }
  58816. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58817. /** @hidden */
  58818. export var pbrBlockLightmapInit: {
  58819. name: string;
  58820. shader: string;
  58821. };
  58822. }
  58823. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58824. /** @hidden */
  58825. export var pbrBlockGeometryInfo: {
  58826. name: string;
  58827. shader: string;
  58828. };
  58829. }
  58830. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58831. /** @hidden */
  58832. export var pbrBlockReflectance0: {
  58833. name: string;
  58834. shader: string;
  58835. };
  58836. }
  58837. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58838. /** @hidden */
  58839. export var pbrBlockReflectance: {
  58840. name: string;
  58841. shader: string;
  58842. };
  58843. }
  58844. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58845. /** @hidden */
  58846. export var pbrBlockDirectLighting: {
  58847. name: string;
  58848. shader: string;
  58849. };
  58850. }
  58851. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58852. /** @hidden */
  58853. export var pbrBlockFinalLitComponents: {
  58854. name: string;
  58855. shader: string;
  58856. };
  58857. }
  58858. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58859. /** @hidden */
  58860. export var pbrBlockFinalUnlitComponents: {
  58861. name: string;
  58862. shader: string;
  58863. };
  58864. }
  58865. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58866. /** @hidden */
  58867. export var pbrBlockFinalColorComposition: {
  58868. name: string;
  58869. shader: string;
  58870. };
  58871. }
  58872. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58873. /** @hidden */
  58874. export var pbrBlockImageProcessing: {
  58875. name: string;
  58876. shader: string;
  58877. };
  58878. }
  58879. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58880. /** @hidden */
  58881. export var pbrDebug: {
  58882. name: string;
  58883. shader: string;
  58884. };
  58885. }
  58886. declare module "babylonjs/Shaders/pbr.fragment" {
  58887. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58888. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58889. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58890. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58891. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58892. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58893. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58894. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58895. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58896. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58897. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58898. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58899. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58900. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58901. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58902. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58903. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58904. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58905. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58906. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58907. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58908. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58909. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58910. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58911. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58912. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58913. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58914. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58915. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58916. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58917. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58918. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58919. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58920. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58921. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58922. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58923. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58924. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58925. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58926. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58927. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58928. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58929. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58930. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58931. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58932. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58933. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58934. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58935. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58936. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58937. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58938. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58939. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58940. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58941. /** @hidden */
  58942. export var pbrPixelShader: {
  58943. name: string;
  58944. shader: string;
  58945. };
  58946. }
  58947. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58948. /** @hidden */
  58949. export var pbrVertexDeclaration: {
  58950. name: string;
  58951. shader: string;
  58952. };
  58953. }
  58954. declare module "babylonjs/Shaders/pbr.vertex" {
  58955. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58956. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58957. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58958. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58959. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58960. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58961. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58962. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58963. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58964. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58965. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58966. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58967. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58968. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58969. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58970. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58971. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58972. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58973. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58974. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58975. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58976. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58977. /** @hidden */
  58978. export var pbrVertexShader: {
  58979. name: string;
  58980. shader: string;
  58981. };
  58982. }
  58983. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58984. import { Nullable } from "babylonjs/types";
  58985. import { Scene } from "babylonjs/scene";
  58986. import { Matrix } from "babylonjs/Maths/math.vector";
  58987. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58989. import { Mesh } from "babylonjs/Meshes/mesh";
  58990. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58991. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58992. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58993. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58994. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58995. import { Color3 } from "babylonjs/Maths/math.color";
  58996. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58997. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58998. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58999. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59000. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59001. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59002. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59003. import "babylonjs/Shaders/pbr.fragment";
  59004. import "babylonjs/Shaders/pbr.vertex";
  59005. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  59006. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  59007. /**
  59008. * Manages the defines for the PBR Material.
  59009. * @hidden
  59010. */
  59011. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  59012. PBR: boolean;
  59013. NUM_SAMPLES: string;
  59014. REALTIME_FILTERING: boolean;
  59015. MAINUV1: boolean;
  59016. MAINUV2: boolean;
  59017. UV1: boolean;
  59018. UV2: boolean;
  59019. ALBEDO: boolean;
  59020. GAMMAALBEDO: boolean;
  59021. ALBEDODIRECTUV: number;
  59022. VERTEXCOLOR: boolean;
  59023. DETAIL: boolean;
  59024. DETAILDIRECTUV: number;
  59025. DETAIL_NORMALBLENDMETHOD: number;
  59026. AMBIENT: boolean;
  59027. AMBIENTDIRECTUV: number;
  59028. AMBIENTINGRAYSCALE: boolean;
  59029. OPACITY: boolean;
  59030. VERTEXALPHA: boolean;
  59031. OPACITYDIRECTUV: number;
  59032. OPACITYRGB: boolean;
  59033. ALPHATEST: boolean;
  59034. DEPTHPREPASS: boolean;
  59035. ALPHABLEND: boolean;
  59036. ALPHAFROMALBEDO: boolean;
  59037. ALPHATESTVALUE: string;
  59038. SPECULAROVERALPHA: boolean;
  59039. RADIANCEOVERALPHA: boolean;
  59040. ALPHAFRESNEL: boolean;
  59041. LINEARALPHAFRESNEL: boolean;
  59042. PREMULTIPLYALPHA: boolean;
  59043. EMISSIVE: boolean;
  59044. EMISSIVEDIRECTUV: number;
  59045. REFLECTIVITY: boolean;
  59046. REFLECTIVITYDIRECTUV: number;
  59047. SPECULARTERM: boolean;
  59048. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  59049. MICROSURFACEAUTOMATIC: boolean;
  59050. LODBASEDMICROSFURACE: boolean;
  59051. MICROSURFACEMAP: boolean;
  59052. MICROSURFACEMAPDIRECTUV: number;
  59053. METALLICWORKFLOW: boolean;
  59054. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  59055. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  59056. METALLNESSSTOREINMETALMAPBLUE: boolean;
  59057. AOSTOREINMETALMAPRED: boolean;
  59058. METALLIC_REFLECTANCE: boolean;
  59059. METALLIC_REFLECTANCEDIRECTUV: number;
  59060. ENVIRONMENTBRDF: boolean;
  59061. ENVIRONMENTBRDF_RGBD: boolean;
  59062. NORMAL: boolean;
  59063. TANGENT: boolean;
  59064. BUMP: boolean;
  59065. BUMPDIRECTUV: number;
  59066. OBJECTSPACE_NORMALMAP: boolean;
  59067. PARALLAX: boolean;
  59068. PARALLAXOCCLUSION: boolean;
  59069. NORMALXYSCALE: boolean;
  59070. LIGHTMAP: boolean;
  59071. LIGHTMAPDIRECTUV: number;
  59072. USELIGHTMAPASSHADOWMAP: boolean;
  59073. GAMMALIGHTMAP: boolean;
  59074. RGBDLIGHTMAP: boolean;
  59075. REFLECTION: boolean;
  59076. REFLECTIONMAP_3D: boolean;
  59077. REFLECTIONMAP_SPHERICAL: boolean;
  59078. REFLECTIONMAP_PLANAR: boolean;
  59079. REFLECTIONMAP_CUBIC: boolean;
  59080. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  59081. REFLECTIONMAP_PROJECTION: boolean;
  59082. REFLECTIONMAP_SKYBOX: boolean;
  59083. REFLECTIONMAP_EXPLICIT: boolean;
  59084. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  59085. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  59086. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  59087. INVERTCUBICMAP: boolean;
  59088. USESPHERICALFROMREFLECTIONMAP: boolean;
  59089. USEIRRADIANCEMAP: boolean;
  59090. SPHERICAL_HARMONICS: boolean;
  59091. USESPHERICALINVERTEX: boolean;
  59092. REFLECTIONMAP_OPPOSITEZ: boolean;
  59093. LODINREFLECTIONALPHA: boolean;
  59094. GAMMAREFLECTION: boolean;
  59095. RGBDREFLECTION: boolean;
  59096. LINEARSPECULARREFLECTION: boolean;
  59097. RADIANCEOCCLUSION: boolean;
  59098. HORIZONOCCLUSION: boolean;
  59099. INSTANCES: boolean;
  59100. THIN_INSTANCES: boolean;
  59101. PREPASS: boolean;
  59102. PREPASS_IRRADIANCE: boolean;
  59103. PREPASS_IRRADIANCE_INDEX: number;
  59104. PREPASS_ALBEDO: boolean;
  59105. PREPASS_ALBEDO_INDEX: number;
  59106. PREPASS_DEPTHNORMAL: boolean;
  59107. PREPASS_DEPTHNORMAL_INDEX: number;
  59108. SCENE_MRT_COUNT: number;
  59109. NUM_BONE_INFLUENCERS: number;
  59110. BonesPerMesh: number;
  59111. BONETEXTURE: boolean;
  59112. NONUNIFORMSCALING: boolean;
  59113. MORPHTARGETS: boolean;
  59114. MORPHTARGETS_NORMAL: boolean;
  59115. MORPHTARGETS_TANGENT: boolean;
  59116. MORPHTARGETS_UV: boolean;
  59117. NUM_MORPH_INFLUENCERS: number;
  59118. IMAGEPROCESSING: boolean;
  59119. VIGNETTE: boolean;
  59120. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59121. VIGNETTEBLENDMODEOPAQUE: boolean;
  59122. TONEMAPPING: boolean;
  59123. TONEMAPPING_ACES: boolean;
  59124. CONTRAST: boolean;
  59125. COLORCURVES: boolean;
  59126. COLORGRADING: boolean;
  59127. COLORGRADING3D: boolean;
  59128. SAMPLER3DGREENDEPTH: boolean;
  59129. SAMPLER3DBGRMAP: boolean;
  59130. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59131. EXPOSURE: boolean;
  59132. MULTIVIEW: boolean;
  59133. USEPHYSICALLIGHTFALLOFF: boolean;
  59134. USEGLTFLIGHTFALLOFF: boolean;
  59135. TWOSIDEDLIGHTING: boolean;
  59136. SHADOWFLOAT: boolean;
  59137. CLIPPLANE: boolean;
  59138. CLIPPLANE2: boolean;
  59139. CLIPPLANE3: boolean;
  59140. CLIPPLANE4: boolean;
  59141. CLIPPLANE5: boolean;
  59142. CLIPPLANE6: boolean;
  59143. POINTSIZE: boolean;
  59144. FOG: boolean;
  59145. LOGARITHMICDEPTH: boolean;
  59146. FORCENORMALFORWARD: boolean;
  59147. SPECULARAA: boolean;
  59148. CLEARCOAT: boolean;
  59149. CLEARCOAT_DEFAULTIOR: boolean;
  59150. CLEARCOAT_TEXTURE: boolean;
  59151. CLEARCOAT_TEXTUREDIRECTUV: number;
  59152. CLEARCOAT_BUMP: boolean;
  59153. CLEARCOAT_BUMPDIRECTUV: number;
  59154. CLEARCOAT_TINT: boolean;
  59155. CLEARCOAT_TINT_TEXTURE: boolean;
  59156. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59157. ANISOTROPIC: boolean;
  59158. ANISOTROPIC_TEXTURE: boolean;
  59159. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59160. BRDF_V_HEIGHT_CORRELATED: boolean;
  59161. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59162. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59163. SHEEN: boolean;
  59164. SHEEN_TEXTURE: boolean;
  59165. SHEEN_TEXTUREDIRECTUV: number;
  59166. SHEEN_LINKWITHALBEDO: boolean;
  59167. SHEEN_ROUGHNESS: boolean;
  59168. SHEEN_ALBEDOSCALING: boolean;
  59169. SUBSURFACE: boolean;
  59170. SS_REFRACTION: boolean;
  59171. SS_TRANSLUCENCY: boolean;
  59172. SS_SCATTERING: boolean;
  59173. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59174. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59175. SS_REFRACTIONMAP_3D: boolean;
  59176. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59177. SS_LODINREFRACTIONALPHA: boolean;
  59178. SS_GAMMAREFRACTION: boolean;
  59179. SS_RGBDREFRACTION: boolean;
  59180. SS_LINEARSPECULARREFRACTION: boolean;
  59181. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59182. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59183. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59184. UNLIT: boolean;
  59185. DEBUGMODE: number;
  59186. /**
  59187. * Initializes the PBR Material defines.
  59188. */
  59189. constructor();
  59190. /**
  59191. * Resets the PBR Material defines.
  59192. */
  59193. reset(): void;
  59194. }
  59195. /**
  59196. * The Physically based material base class of BJS.
  59197. *
  59198. * This offers the main features of a standard PBR material.
  59199. * For more information, please refer to the documentation :
  59200. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59201. */
  59202. export abstract class PBRBaseMaterial extends PushMaterial {
  59203. /**
  59204. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59205. */
  59206. static readonly PBRMATERIAL_OPAQUE: number;
  59207. /**
  59208. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59209. */
  59210. static readonly PBRMATERIAL_ALPHATEST: number;
  59211. /**
  59212. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59213. */
  59214. static readonly PBRMATERIAL_ALPHABLEND: number;
  59215. /**
  59216. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59217. * They are also discarded below the alpha cutoff threshold to improve performances.
  59218. */
  59219. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59220. /**
  59221. * Defines the default value of how much AO map is occluding the analytical lights
  59222. * (point spot...).
  59223. */
  59224. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59225. /**
  59226. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59227. */
  59228. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59229. /**
  59230. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59231. * to enhance interoperability with other engines.
  59232. */
  59233. static readonly LIGHTFALLOFF_GLTF: number;
  59234. /**
  59235. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59236. * to enhance interoperability with other materials.
  59237. */
  59238. static readonly LIGHTFALLOFF_STANDARD: number;
  59239. /**
  59240. * Intensity of the direct lights e.g. the four lights available in your scene.
  59241. * This impacts both the direct diffuse and specular highlights.
  59242. */
  59243. protected _directIntensity: number;
  59244. /**
  59245. * Intensity of the emissive part of the material.
  59246. * This helps controlling the emissive effect without modifying the emissive color.
  59247. */
  59248. protected _emissiveIntensity: number;
  59249. /**
  59250. * Intensity of the environment e.g. how much the environment will light the object
  59251. * either through harmonics for rough material or through the refelction for shiny ones.
  59252. */
  59253. protected _environmentIntensity: number;
  59254. /**
  59255. * This is a special control allowing the reduction of the specular highlights coming from the
  59256. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59257. */
  59258. protected _specularIntensity: number;
  59259. /**
  59260. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59261. */
  59262. private _lightingInfos;
  59263. /**
  59264. * Debug Control allowing disabling the bump map on this material.
  59265. */
  59266. protected _disableBumpMap: boolean;
  59267. /**
  59268. * AKA Diffuse Texture in standard nomenclature.
  59269. */
  59270. protected _albedoTexture: Nullable<BaseTexture>;
  59271. /**
  59272. * AKA Occlusion Texture in other nomenclature.
  59273. */
  59274. protected _ambientTexture: Nullable<BaseTexture>;
  59275. /**
  59276. * AKA Occlusion Texture Intensity in other nomenclature.
  59277. */
  59278. protected _ambientTextureStrength: number;
  59279. /**
  59280. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59281. * 1 means it completely occludes it
  59282. * 0 mean it has no impact
  59283. */
  59284. protected _ambientTextureImpactOnAnalyticalLights: number;
  59285. /**
  59286. * Stores the alpha values in a texture.
  59287. */
  59288. protected _opacityTexture: Nullable<BaseTexture>;
  59289. /**
  59290. * Stores the reflection values in a texture.
  59291. */
  59292. protected _reflectionTexture: Nullable<BaseTexture>;
  59293. /**
  59294. * Stores the emissive values in a texture.
  59295. */
  59296. protected _emissiveTexture: Nullable<BaseTexture>;
  59297. /**
  59298. * AKA Specular texture in other nomenclature.
  59299. */
  59300. protected _reflectivityTexture: Nullable<BaseTexture>;
  59301. /**
  59302. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59303. */
  59304. protected _metallicTexture: Nullable<BaseTexture>;
  59305. /**
  59306. * Specifies the metallic scalar of the metallic/roughness workflow.
  59307. * Can also be used to scale the metalness values of the metallic texture.
  59308. */
  59309. protected _metallic: Nullable<number>;
  59310. /**
  59311. * Specifies the roughness scalar of the metallic/roughness workflow.
  59312. * Can also be used to scale the roughness values of the metallic texture.
  59313. */
  59314. protected _roughness: Nullable<number>;
  59315. /**
  59316. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59317. * By default the indexOfrefraction is used to compute F0;
  59318. *
  59319. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59320. *
  59321. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59322. * F90 = metallicReflectanceColor;
  59323. */
  59324. protected _metallicF0Factor: number;
  59325. /**
  59326. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59327. * By default the F90 is always 1;
  59328. *
  59329. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59330. *
  59331. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59332. * F90 = metallicReflectanceColor;
  59333. */
  59334. protected _metallicReflectanceColor: Color3;
  59335. /**
  59336. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59337. * This is multiply against the scalar values defined in the material.
  59338. */
  59339. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59340. /**
  59341. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59342. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59343. */
  59344. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59345. /**
  59346. * Stores surface normal data used to displace a mesh in a texture.
  59347. */
  59348. protected _bumpTexture: Nullable<BaseTexture>;
  59349. /**
  59350. * Stores the pre-calculated light information of a mesh in a texture.
  59351. */
  59352. protected _lightmapTexture: Nullable<BaseTexture>;
  59353. /**
  59354. * The color of a material in ambient lighting.
  59355. */
  59356. protected _ambientColor: Color3;
  59357. /**
  59358. * AKA Diffuse Color in other nomenclature.
  59359. */
  59360. protected _albedoColor: Color3;
  59361. /**
  59362. * AKA Specular Color in other nomenclature.
  59363. */
  59364. protected _reflectivityColor: Color3;
  59365. /**
  59366. * The color applied when light is reflected from a material.
  59367. */
  59368. protected _reflectionColor: Color3;
  59369. /**
  59370. * The color applied when light is emitted from a material.
  59371. */
  59372. protected _emissiveColor: Color3;
  59373. /**
  59374. * AKA Glossiness in other nomenclature.
  59375. */
  59376. protected _microSurface: number;
  59377. /**
  59378. * Specifies that the material will use the light map as a show map.
  59379. */
  59380. protected _useLightmapAsShadowmap: boolean;
  59381. /**
  59382. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59383. * makes the reflect vector face the model (under horizon).
  59384. */
  59385. protected _useHorizonOcclusion: boolean;
  59386. /**
  59387. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59388. * too much the area relying on ambient texture to define their ambient occlusion.
  59389. */
  59390. protected _useRadianceOcclusion: boolean;
  59391. /**
  59392. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59393. */
  59394. protected _useAlphaFromAlbedoTexture: boolean;
  59395. /**
  59396. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59397. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59398. */
  59399. protected _useSpecularOverAlpha: boolean;
  59400. /**
  59401. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59402. */
  59403. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59404. /**
  59405. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59406. */
  59407. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59408. /**
  59409. * Specifies if the metallic texture contains the roughness information in its green channel.
  59410. */
  59411. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59412. /**
  59413. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59414. */
  59415. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59416. /**
  59417. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59418. */
  59419. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59420. /**
  59421. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59422. */
  59423. protected _useAmbientInGrayScale: boolean;
  59424. /**
  59425. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59426. * The material will try to infer what glossiness each pixel should be.
  59427. */
  59428. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59429. /**
  59430. * Defines the falloff type used in this material.
  59431. * It by default is Physical.
  59432. */
  59433. protected _lightFalloff: number;
  59434. /**
  59435. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59436. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59437. */
  59438. protected _useRadianceOverAlpha: boolean;
  59439. /**
  59440. * Allows using an object space normal map (instead of tangent space).
  59441. */
  59442. protected _useObjectSpaceNormalMap: boolean;
  59443. /**
  59444. * Allows using the bump map in parallax mode.
  59445. */
  59446. protected _useParallax: boolean;
  59447. /**
  59448. * Allows using the bump map in parallax occlusion mode.
  59449. */
  59450. protected _useParallaxOcclusion: boolean;
  59451. /**
  59452. * Controls the scale bias of the parallax mode.
  59453. */
  59454. protected _parallaxScaleBias: number;
  59455. /**
  59456. * If sets to true, disables all the lights affecting the material.
  59457. */
  59458. protected _disableLighting: boolean;
  59459. /**
  59460. * Number of Simultaneous lights allowed on the material.
  59461. */
  59462. protected _maxSimultaneousLights: number;
  59463. /**
  59464. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59465. */
  59466. protected _invertNormalMapX: boolean;
  59467. /**
  59468. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59469. */
  59470. protected _invertNormalMapY: boolean;
  59471. /**
  59472. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59473. */
  59474. protected _twoSidedLighting: boolean;
  59475. /**
  59476. * Defines the alpha limits in alpha test mode.
  59477. */
  59478. protected _alphaCutOff: number;
  59479. /**
  59480. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59481. */
  59482. protected _forceAlphaTest: boolean;
  59483. /**
  59484. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59485. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59486. */
  59487. protected _useAlphaFresnel: boolean;
  59488. /**
  59489. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59490. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59491. */
  59492. protected _useLinearAlphaFresnel: boolean;
  59493. /**
  59494. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59495. * from cos thetav and roughness:
  59496. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59497. */
  59498. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59499. /**
  59500. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59501. */
  59502. protected _forceIrradianceInFragment: boolean;
  59503. private _realTimeFiltering;
  59504. /**
  59505. * Enables realtime filtering on the texture.
  59506. */
  59507. get realTimeFiltering(): boolean;
  59508. set realTimeFiltering(b: boolean);
  59509. private _realTimeFilteringQuality;
  59510. /**
  59511. * Quality switch for realtime filtering
  59512. */
  59513. get realTimeFilteringQuality(): number;
  59514. set realTimeFilteringQuality(n: number);
  59515. /**
  59516. * Can this material render to several textures at once
  59517. */
  59518. get canRenderToMRT(): boolean;
  59519. /**
  59520. * Force normal to face away from face.
  59521. */
  59522. protected _forceNormalForward: boolean;
  59523. /**
  59524. * Enables specular anti aliasing in the PBR shader.
  59525. * It will both interacts on the Geometry for analytical and IBL lighting.
  59526. * It also prefilter the roughness map based on the bump values.
  59527. */
  59528. protected _enableSpecularAntiAliasing: boolean;
  59529. /**
  59530. * Default configuration related to image processing available in the PBR Material.
  59531. */
  59532. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59533. /**
  59534. * Keep track of the image processing observer to allow dispose and replace.
  59535. */
  59536. private _imageProcessingObserver;
  59537. /**
  59538. * Attaches a new image processing configuration to the PBR Material.
  59539. * @param configuration
  59540. */
  59541. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59542. /**
  59543. * Stores the available render targets.
  59544. */
  59545. private _renderTargets;
  59546. /**
  59547. * Sets the global ambient color for the material used in lighting calculations.
  59548. */
  59549. private _globalAmbientColor;
  59550. /**
  59551. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59552. */
  59553. private _useLogarithmicDepth;
  59554. /**
  59555. * If set to true, no lighting calculations will be applied.
  59556. */
  59557. private _unlit;
  59558. private _debugMode;
  59559. /**
  59560. * @hidden
  59561. * This is reserved for the inspector.
  59562. * Defines the material debug mode.
  59563. * It helps seeing only some components of the material while troubleshooting.
  59564. */
  59565. debugMode: number;
  59566. /**
  59567. * @hidden
  59568. * This is reserved for the inspector.
  59569. * Specify from where on screen the debug mode should start.
  59570. * The value goes from -1 (full screen) to 1 (not visible)
  59571. * It helps with side by side comparison against the final render
  59572. * This defaults to -1
  59573. */
  59574. private debugLimit;
  59575. /**
  59576. * @hidden
  59577. * This is reserved for the inspector.
  59578. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59579. * You can use the factor to better multiply the final value.
  59580. */
  59581. private debugFactor;
  59582. /**
  59583. * Defines the clear coat layer parameters for the material.
  59584. */
  59585. readonly clearCoat: PBRClearCoatConfiguration;
  59586. /**
  59587. * Defines the anisotropic parameters for the material.
  59588. */
  59589. readonly anisotropy: PBRAnisotropicConfiguration;
  59590. /**
  59591. * Defines the BRDF parameters for the material.
  59592. */
  59593. readonly brdf: PBRBRDFConfiguration;
  59594. /**
  59595. * Defines the Sheen parameters for the material.
  59596. */
  59597. readonly sheen: PBRSheenConfiguration;
  59598. /**
  59599. * Defines the SubSurface parameters for the material.
  59600. */
  59601. readonly subSurface: PBRSubSurfaceConfiguration;
  59602. /**
  59603. * Defines the detail map parameters for the material.
  59604. */
  59605. readonly detailMap: DetailMapConfiguration;
  59606. protected _rebuildInParallel: boolean;
  59607. /**
  59608. * Instantiates a new PBRMaterial instance.
  59609. *
  59610. * @param name The material name
  59611. * @param scene The scene the material will be use in.
  59612. */
  59613. constructor(name: string, scene: Scene);
  59614. /**
  59615. * Gets a boolean indicating that current material needs to register RTT
  59616. */
  59617. get hasRenderTargetTextures(): boolean;
  59618. /**
  59619. * Gets the name of the material class.
  59620. */
  59621. getClassName(): string;
  59622. /**
  59623. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59624. */
  59625. get useLogarithmicDepth(): boolean;
  59626. /**
  59627. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59628. */
  59629. set useLogarithmicDepth(value: boolean);
  59630. /**
  59631. * Returns true if alpha blending should be disabled.
  59632. */
  59633. protected get _disableAlphaBlending(): boolean;
  59634. /**
  59635. * Specifies whether or not this material should be rendered in alpha blend mode.
  59636. */
  59637. needAlphaBlending(): boolean;
  59638. /**
  59639. * Specifies whether or not this material should be rendered in alpha test mode.
  59640. */
  59641. needAlphaTesting(): boolean;
  59642. /**
  59643. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59644. */
  59645. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59646. /**
  59647. * Gets the texture used for the alpha test.
  59648. */
  59649. getAlphaTestTexture(): Nullable<BaseTexture>;
  59650. /**
  59651. * Specifies that the submesh is ready to be used.
  59652. * @param mesh - BJS mesh.
  59653. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59654. * @param useInstances - Specifies that instances should be used.
  59655. * @returns - boolean indicating that the submesh is ready or not.
  59656. */
  59657. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59658. /**
  59659. * Specifies if the material uses metallic roughness workflow.
  59660. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59661. */
  59662. isMetallicWorkflow(): boolean;
  59663. private _prepareEffect;
  59664. private _prepareDefines;
  59665. /**
  59666. * Force shader compilation
  59667. */
  59668. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59669. /**
  59670. * Initializes the uniform buffer layout for the shader.
  59671. */
  59672. buildUniformLayout(): void;
  59673. /**
  59674. * Unbinds the material from the mesh
  59675. */
  59676. unbind(): void;
  59677. /**
  59678. * Binds the submesh data.
  59679. * @param world - The world matrix.
  59680. * @param mesh - The BJS mesh.
  59681. * @param subMesh - A submesh of the BJS mesh.
  59682. */
  59683. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59684. /**
  59685. * Returns the animatable textures.
  59686. * @returns - Array of animatable textures.
  59687. */
  59688. getAnimatables(): IAnimatable[];
  59689. /**
  59690. * Returns the texture used for reflections.
  59691. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59692. */
  59693. private _getReflectionTexture;
  59694. /**
  59695. * Returns an array of the actively used textures.
  59696. * @returns - Array of BaseTextures
  59697. */
  59698. getActiveTextures(): BaseTexture[];
  59699. /**
  59700. * Checks to see if a texture is used in the material.
  59701. * @param texture - Base texture to use.
  59702. * @returns - Boolean specifying if a texture is used in the material.
  59703. */
  59704. hasTexture(texture: BaseTexture): boolean;
  59705. /**
  59706. * Sets the required values to the prepass renderer.
  59707. * @param prePassRenderer defines the prepass renderer to setup
  59708. */
  59709. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59710. /**
  59711. * Disposes the resources of the material.
  59712. * @param forceDisposeEffect - Forces the disposal of effects.
  59713. * @param forceDisposeTextures - Forces the disposal of all textures.
  59714. */
  59715. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59716. }
  59717. }
  59718. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59719. import { Nullable } from "babylonjs/types";
  59720. import { Scene } from "babylonjs/scene";
  59721. import { Color3 } from "babylonjs/Maths/math.color";
  59722. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59723. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59725. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59726. /**
  59727. * The Physically based material of BJS.
  59728. *
  59729. * This offers the main features of a standard PBR material.
  59730. * For more information, please refer to the documentation :
  59731. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59732. */
  59733. export class PBRMaterial extends PBRBaseMaterial {
  59734. /**
  59735. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59736. */
  59737. static readonly PBRMATERIAL_OPAQUE: number;
  59738. /**
  59739. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59740. */
  59741. static readonly PBRMATERIAL_ALPHATEST: number;
  59742. /**
  59743. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59744. */
  59745. static readonly PBRMATERIAL_ALPHABLEND: number;
  59746. /**
  59747. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59748. * They are also discarded below the alpha cutoff threshold to improve performances.
  59749. */
  59750. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59751. /**
  59752. * Defines the default value of how much AO map is occluding the analytical lights
  59753. * (point spot...).
  59754. */
  59755. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59756. /**
  59757. * Intensity of the direct lights e.g. the four lights available in your scene.
  59758. * This impacts both the direct diffuse and specular highlights.
  59759. */
  59760. directIntensity: number;
  59761. /**
  59762. * Intensity of the emissive part of the material.
  59763. * This helps controlling the emissive effect without modifying the emissive color.
  59764. */
  59765. emissiveIntensity: number;
  59766. /**
  59767. * Intensity of the environment e.g. how much the environment will light the object
  59768. * either through harmonics for rough material or through the refelction for shiny ones.
  59769. */
  59770. environmentIntensity: number;
  59771. /**
  59772. * This is a special control allowing the reduction of the specular highlights coming from the
  59773. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59774. */
  59775. specularIntensity: number;
  59776. /**
  59777. * Debug Control allowing disabling the bump map on this material.
  59778. */
  59779. disableBumpMap: boolean;
  59780. /**
  59781. * AKA Diffuse Texture in standard nomenclature.
  59782. */
  59783. albedoTexture: BaseTexture;
  59784. /**
  59785. * AKA Occlusion Texture in other nomenclature.
  59786. */
  59787. ambientTexture: BaseTexture;
  59788. /**
  59789. * AKA Occlusion Texture Intensity in other nomenclature.
  59790. */
  59791. ambientTextureStrength: number;
  59792. /**
  59793. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59794. * 1 means it completely occludes it
  59795. * 0 mean it has no impact
  59796. */
  59797. ambientTextureImpactOnAnalyticalLights: number;
  59798. /**
  59799. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59800. */
  59801. opacityTexture: BaseTexture;
  59802. /**
  59803. * Stores the reflection values in a texture.
  59804. */
  59805. reflectionTexture: Nullable<BaseTexture>;
  59806. /**
  59807. * Stores the emissive values in a texture.
  59808. */
  59809. emissiveTexture: BaseTexture;
  59810. /**
  59811. * AKA Specular texture in other nomenclature.
  59812. */
  59813. reflectivityTexture: BaseTexture;
  59814. /**
  59815. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59816. */
  59817. metallicTexture: BaseTexture;
  59818. /**
  59819. * Specifies the metallic scalar of the metallic/roughness workflow.
  59820. * Can also be used to scale the metalness values of the metallic texture.
  59821. */
  59822. metallic: Nullable<number>;
  59823. /**
  59824. * Specifies the roughness scalar of the metallic/roughness workflow.
  59825. * Can also be used to scale the roughness values of the metallic texture.
  59826. */
  59827. roughness: Nullable<number>;
  59828. /**
  59829. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59830. * By default the indexOfrefraction is used to compute F0;
  59831. *
  59832. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59833. *
  59834. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59835. * F90 = metallicReflectanceColor;
  59836. */
  59837. metallicF0Factor: number;
  59838. /**
  59839. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59840. * By default the F90 is always 1;
  59841. *
  59842. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59843. *
  59844. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59845. * F90 = metallicReflectanceColor;
  59846. */
  59847. metallicReflectanceColor: Color3;
  59848. /**
  59849. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59850. * This is multiply against the scalar values defined in the material.
  59851. */
  59852. metallicReflectanceTexture: Nullable<BaseTexture>;
  59853. /**
  59854. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59855. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59856. */
  59857. microSurfaceTexture: BaseTexture;
  59858. /**
  59859. * Stores surface normal data used to displace a mesh in a texture.
  59860. */
  59861. bumpTexture: BaseTexture;
  59862. /**
  59863. * Stores the pre-calculated light information of a mesh in a texture.
  59864. */
  59865. lightmapTexture: BaseTexture;
  59866. /**
  59867. * Stores the refracted light information in a texture.
  59868. */
  59869. get refractionTexture(): Nullable<BaseTexture>;
  59870. set refractionTexture(value: Nullable<BaseTexture>);
  59871. /**
  59872. * The color of a material in ambient lighting.
  59873. */
  59874. ambientColor: Color3;
  59875. /**
  59876. * AKA Diffuse Color in other nomenclature.
  59877. */
  59878. albedoColor: Color3;
  59879. /**
  59880. * AKA Specular Color in other nomenclature.
  59881. */
  59882. reflectivityColor: Color3;
  59883. /**
  59884. * The color reflected from the material.
  59885. */
  59886. reflectionColor: Color3;
  59887. /**
  59888. * The color emitted from the material.
  59889. */
  59890. emissiveColor: Color3;
  59891. /**
  59892. * AKA Glossiness in other nomenclature.
  59893. */
  59894. microSurface: number;
  59895. /**
  59896. * Index of refraction of the material base layer.
  59897. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59898. *
  59899. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59900. *
  59901. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59902. */
  59903. get indexOfRefraction(): number;
  59904. set indexOfRefraction(value: number);
  59905. /**
  59906. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59907. */
  59908. get invertRefractionY(): boolean;
  59909. set invertRefractionY(value: boolean);
  59910. /**
  59911. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59912. * Materials half opaque for instance using refraction could benefit from this control.
  59913. */
  59914. get linkRefractionWithTransparency(): boolean;
  59915. set linkRefractionWithTransparency(value: boolean);
  59916. /**
  59917. * If true, the light map contains occlusion information instead of lighting info.
  59918. */
  59919. useLightmapAsShadowmap: boolean;
  59920. /**
  59921. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59922. */
  59923. useAlphaFromAlbedoTexture: boolean;
  59924. /**
  59925. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59926. */
  59927. forceAlphaTest: boolean;
  59928. /**
  59929. * Defines the alpha limits in alpha test mode.
  59930. */
  59931. alphaCutOff: number;
  59932. /**
  59933. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59934. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59935. */
  59936. useSpecularOverAlpha: boolean;
  59937. /**
  59938. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59939. */
  59940. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59941. /**
  59942. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59943. */
  59944. useRoughnessFromMetallicTextureAlpha: boolean;
  59945. /**
  59946. * Specifies if the metallic texture contains the roughness information in its green channel.
  59947. */
  59948. useRoughnessFromMetallicTextureGreen: boolean;
  59949. /**
  59950. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59951. */
  59952. useMetallnessFromMetallicTextureBlue: boolean;
  59953. /**
  59954. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59955. */
  59956. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59957. /**
  59958. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59959. */
  59960. useAmbientInGrayScale: boolean;
  59961. /**
  59962. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59963. * The material will try to infer what glossiness each pixel should be.
  59964. */
  59965. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59966. /**
  59967. * BJS is using an harcoded light falloff based on a manually sets up range.
  59968. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59969. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59970. */
  59971. get usePhysicalLightFalloff(): boolean;
  59972. /**
  59973. * BJS is using an harcoded light falloff based on a manually sets up range.
  59974. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59975. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59976. */
  59977. set usePhysicalLightFalloff(value: boolean);
  59978. /**
  59979. * In order to support the falloff compatibility with gltf, a special mode has been added
  59980. * to reproduce the gltf light falloff.
  59981. */
  59982. get useGLTFLightFalloff(): boolean;
  59983. /**
  59984. * In order to support the falloff compatibility with gltf, a special mode has been added
  59985. * to reproduce the gltf light falloff.
  59986. */
  59987. set useGLTFLightFalloff(value: boolean);
  59988. /**
  59989. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59990. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59991. */
  59992. useRadianceOverAlpha: boolean;
  59993. /**
  59994. * Allows using an object space normal map (instead of tangent space).
  59995. */
  59996. useObjectSpaceNormalMap: boolean;
  59997. /**
  59998. * Allows using the bump map in parallax mode.
  59999. */
  60000. useParallax: boolean;
  60001. /**
  60002. * Allows using the bump map in parallax occlusion mode.
  60003. */
  60004. useParallaxOcclusion: boolean;
  60005. /**
  60006. * Controls the scale bias of the parallax mode.
  60007. */
  60008. parallaxScaleBias: number;
  60009. /**
  60010. * If sets to true, disables all the lights affecting the material.
  60011. */
  60012. disableLighting: boolean;
  60013. /**
  60014. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  60015. */
  60016. forceIrradianceInFragment: boolean;
  60017. /**
  60018. * Number of Simultaneous lights allowed on the material.
  60019. */
  60020. maxSimultaneousLights: number;
  60021. /**
  60022. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60023. */
  60024. invertNormalMapX: boolean;
  60025. /**
  60026. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60027. */
  60028. invertNormalMapY: boolean;
  60029. /**
  60030. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60031. */
  60032. twoSidedLighting: boolean;
  60033. /**
  60034. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60035. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  60036. */
  60037. useAlphaFresnel: boolean;
  60038. /**
  60039. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60040. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  60041. */
  60042. useLinearAlphaFresnel: boolean;
  60043. /**
  60044. * Let user defines the brdf lookup texture used for IBL.
  60045. * A default 8bit version is embedded but you could point at :
  60046. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  60047. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  60048. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  60049. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  60050. */
  60051. environmentBRDFTexture: Nullable<BaseTexture>;
  60052. /**
  60053. * Force normal to face away from face.
  60054. */
  60055. forceNormalForward: boolean;
  60056. /**
  60057. * Enables specular anti aliasing in the PBR shader.
  60058. * It will both interacts on the Geometry for analytical and IBL lighting.
  60059. * It also prefilter the roughness map based on the bump values.
  60060. */
  60061. enableSpecularAntiAliasing: boolean;
  60062. /**
  60063. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  60064. * makes the reflect vector face the model (under horizon).
  60065. */
  60066. useHorizonOcclusion: boolean;
  60067. /**
  60068. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  60069. * too much the area relying on ambient texture to define their ambient occlusion.
  60070. */
  60071. useRadianceOcclusion: boolean;
  60072. /**
  60073. * If set to true, no lighting calculations will be applied.
  60074. */
  60075. unlit: boolean;
  60076. /**
  60077. * Gets the image processing configuration used either in this material.
  60078. */
  60079. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60080. /**
  60081. * Sets the Default image processing configuration used either in the this material.
  60082. *
  60083. * If sets to null, the scene one is in use.
  60084. */
  60085. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60086. /**
  60087. * Gets wether the color curves effect is enabled.
  60088. */
  60089. get cameraColorCurvesEnabled(): boolean;
  60090. /**
  60091. * Sets wether the color curves effect is enabled.
  60092. */
  60093. set cameraColorCurvesEnabled(value: boolean);
  60094. /**
  60095. * Gets wether the color grading effect is enabled.
  60096. */
  60097. get cameraColorGradingEnabled(): boolean;
  60098. /**
  60099. * Gets wether the color grading effect is enabled.
  60100. */
  60101. set cameraColorGradingEnabled(value: boolean);
  60102. /**
  60103. * Gets wether tonemapping is enabled or not.
  60104. */
  60105. get cameraToneMappingEnabled(): boolean;
  60106. /**
  60107. * Sets wether tonemapping is enabled or not
  60108. */
  60109. set cameraToneMappingEnabled(value: boolean);
  60110. /**
  60111. * The camera exposure used on this material.
  60112. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60113. * This corresponds to a photographic exposure.
  60114. */
  60115. get cameraExposure(): number;
  60116. /**
  60117. * The camera exposure used on this material.
  60118. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60119. * This corresponds to a photographic exposure.
  60120. */
  60121. set cameraExposure(value: number);
  60122. /**
  60123. * Gets The camera contrast used on this material.
  60124. */
  60125. get cameraContrast(): number;
  60126. /**
  60127. * Sets The camera contrast used on this material.
  60128. */
  60129. set cameraContrast(value: number);
  60130. /**
  60131. * Gets the Color Grading 2D Lookup Texture.
  60132. */
  60133. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60134. /**
  60135. * Sets the Color Grading 2D Lookup Texture.
  60136. */
  60137. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60138. /**
  60139. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60140. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60141. * 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;
  60142. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60143. */
  60144. get cameraColorCurves(): Nullable<ColorCurves>;
  60145. /**
  60146. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60147. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60148. * 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;
  60149. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60150. */
  60151. set cameraColorCurves(value: Nullable<ColorCurves>);
  60152. /**
  60153. * Instantiates a new PBRMaterial instance.
  60154. *
  60155. * @param name The material name
  60156. * @param scene The scene the material will be use in.
  60157. */
  60158. constructor(name: string, scene: Scene);
  60159. /**
  60160. * Returns the name of this material class.
  60161. */
  60162. getClassName(): string;
  60163. /**
  60164. * Makes a duplicate of the current material.
  60165. * @param name - name to use for the new material.
  60166. */
  60167. clone(name: string): PBRMaterial;
  60168. /**
  60169. * Serializes this PBR Material.
  60170. * @returns - An object with the serialized material.
  60171. */
  60172. serialize(): any;
  60173. /**
  60174. * Parses a PBR Material from a serialized object.
  60175. * @param source - Serialized object.
  60176. * @param scene - BJS scene instance.
  60177. * @param rootUrl - url for the scene object
  60178. * @returns - PBRMaterial
  60179. */
  60180. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60181. }
  60182. }
  60183. declare module "babylonjs/Misc/dds" {
  60184. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60185. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60186. import { Nullable } from "babylonjs/types";
  60187. import { Scene } from "babylonjs/scene";
  60188. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60189. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60190. /**
  60191. * Direct draw surface info
  60192. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60193. */
  60194. export interface DDSInfo {
  60195. /**
  60196. * Width of the texture
  60197. */
  60198. width: number;
  60199. /**
  60200. * Width of the texture
  60201. */
  60202. height: number;
  60203. /**
  60204. * Number of Mipmaps for the texture
  60205. * @see https://en.wikipedia.org/wiki/Mipmap
  60206. */
  60207. mipmapCount: number;
  60208. /**
  60209. * If the textures format is a known fourCC format
  60210. * @see https://www.fourcc.org/
  60211. */
  60212. isFourCC: boolean;
  60213. /**
  60214. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60215. */
  60216. isRGB: boolean;
  60217. /**
  60218. * If the texture is a lumincance format
  60219. */
  60220. isLuminance: boolean;
  60221. /**
  60222. * If this is a cube texture
  60223. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60224. */
  60225. isCube: boolean;
  60226. /**
  60227. * If the texture is a compressed format eg. FOURCC_DXT1
  60228. */
  60229. isCompressed: boolean;
  60230. /**
  60231. * The dxgiFormat of the texture
  60232. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60233. */
  60234. dxgiFormat: number;
  60235. /**
  60236. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60237. */
  60238. textureType: number;
  60239. /**
  60240. * Sphericle polynomial created for the dds texture
  60241. */
  60242. sphericalPolynomial?: SphericalPolynomial;
  60243. }
  60244. /**
  60245. * Class used to provide DDS decompression tools
  60246. */
  60247. export class DDSTools {
  60248. /**
  60249. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60250. */
  60251. static StoreLODInAlphaChannel: boolean;
  60252. /**
  60253. * Gets DDS information from an array buffer
  60254. * @param data defines the array buffer view to read data from
  60255. * @returns the DDS information
  60256. */
  60257. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60258. private static _FloatView;
  60259. private static _Int32View;
  60260. private static _ToHalfFloat;
  60261. private static _FromHalfFloat;
  60262. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60263. private static _GetHalfFloatRGBAArrayBuffer;
  60264. private static _GetFloatRGBAArrayBuffer;
  60265. private static _GetFloatAsUIntRGBAArrayBuffer;
  60266. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60267. private static _GetRGBAArrayBuffer;
  60268. private static _ExtractLongWordOrder;
  60269. private static _GetRGBArrayBuffer;
  60270. private static _GetLuminanceArrayBuffer;
  60271. /**
  60272. * Uploads DDS Levels to a Babylon Texture
  60273. * @hidden
  60274. */
  60275. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60276. }
  60277. module "babylonjs/Engines/thinEngine" {
  60278. interface ThinEngine {
  60279. /**
  60280. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60281. * @param rootUrl defines the url where the file to load is located
  60282. * @param scene defines the current scene
  60283. * @param lodScale defines scale to apply to the mip map selection
  60284. * @param lodOffset defines offset to apply to the mip map selection
  60285. * @param onLoad defines an optional callback raised when the texture is loaded
  60286. * @param onError defines an optional callback raised if there is an issue to load the texture
  60287. * @param format defines the format of the data
  60288. * @param forcedExtension defines the extension to use to pick the right loader
  60289. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60290. * @returns the cube texture as an InternalTexture
  60291. */
  60292. 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;
  60293. }
  60294. }
  60295. }
  60296. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60297. import { Nullable } from "babylonjs/types";
  60298. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60299. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60300. /**
  60301. * Implementation of the DDS Texture Loader.
  60302. * @hidden
  60303. */
  60304. export class _DDSTextureLoader implements IInternalTextureLoader {
  60305. /**
  60306. * Defines wether the loader supports cascade loading the different faces.
  60307. */
  60308. readonly supportCascades: boolean;
  60309. /**
  60310. * This returns if the loader support the current file information.
  60311. * @param extension defines the file extension of the file being loaded
  60312. * @returns true if the loader can load the specified file
  60313. */
  60314. canLoad(extension: string): boolean;
  60315. /**
  60316. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60317. * @param data contains the texture data
  60318. * @param texture defines the BabylonJS internal texture
  60319. * @param createPolynomials will be true if polynomials have been requested
  60320. * @param onLoad defines the callback to trigger once the texture is ready
  60321. * @param onError defines the callback to trigger in case of error
  60322. */
  60323. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60324. /**
  60325. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60326. * @param data contains the texture data
  60327. * @param texture defines the BabylonJS internal texture
  60328. * @param callback defines the method to call once ready to upload
  60329. */
  60330. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60331. }
  60332. }
  60333. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60334. import { Nullable } from "babylonjs/types";
  60335. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60336. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60337. /**
  60338. * Implementation of the ENV Texture Loader.
  60339. * @hidden
  60340. */
  60341. export class _ENVTextureLoader implements IInternalTextureLoader {
  60342. /**
  60343. * Defines wether the loader supports cascade loading the different faces.
  60344. */
  60345. readonly supportCascades: boolean;
  60346. /**
  60347. * This returns if the loader support the current file information.
  60348. * @param extension defines the file extension of the file being loaded
  60349. * @returns true if the loader can load the specified file
  60350. */
  60351. canLoad(extension: string): boolean;
  60352. /**
  60353. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60354. * @param data contains the texture data
  60355. * @param texture defines the BabylonJS internal texture
  60356. * @param createPolynomials will be true if polynomials have been requested
  60357. * @param onLoad defines the callback to trigger once the texture is ready
  60358. * @param onError defines the callback to trigger in case of error
  60359. */
  60360. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60361. /**
  60362. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60363. * @param data contains the texture data
  60364. * @param texture defines the BabylonJS internal texture
  60365. * @param callback defines the method to call once ready to upload
  60366. */
  60367. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60368. }
  60369. }
  60370. declare module "babylonjs/Misc/khronosTextureContainer" {
  60371. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60372. /**
  60373. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60374. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60375. */
  60376. export class KhronosTextureContainer {
  60377. /** contents of the KTX container file */
  60378. data: ArrayBufferView;
  60379. private static HEADER_LEN;
  60380. private static COMPRESSED_2D;
  60381. private static COMPRESSED_3D;
  60382. private static TEX_2D;
  60383. private static TEX_3D;
  60384. /**
  60385. * Gets the openGL type
  60386. */
  60387. glType: number;
  60388. /**
  60389. * Gets the openGL type size
  60390. */
  60391. glTypeSize: number;
  60392. /**
  60393. * Gets the openGL format
  60394. */
  60395. glFormat: number;
  60396. /**
  60397. * Gets the openGL internal format
  60398. */
  60399. glInternalFormat: number;
  60400. /**
  60401. * Gets the base internal format
  60402. */
  60403. glBaseInternalFormat: number;
  60404. /**
  60405. * Gets image width in pixel
  60406. */
  60407. pixelWidth: number;
  60408. /**
  60409. * Gets image height in pixel
  60410. */
  60411. pixelHeight: number;
  60412. /**
  60413. * Gets image depth in pixels
  60414. */
  60415. pixelDepth: number;
  60416. /**
  60417. * Gets the number of array elements
  60418. */
  60419. numberOfArrayElements: number;
  60420. /**
  60421. * Gets the number of faces
  60422. */
  60423. numberOfFaces: number;
  60424. /**
  60425. * Gets the number of mipmap levels
  60426. */
  60427. numberOfMipmapLevels: number;
  60428. /**
  60429. * Gets the bytes of key value data
  60430. */
  60431. bytesOfKeyValueData: number;
  60432. /**
  60433. * Gets the load type
  60434. */
  60435. loadType: number;
  60436. /**
  60437. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60438. */
  60439. isInvalid: boolean;
  60440. /**
  60441. * Creates a new KhronosTextureContainer
  60442. * @param data contents of the KTX container file
  60443. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60444. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60445. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60446. */
  60447. constructor(
  60448. /** contents of the KTX container file */
  60449. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60450. /**
  60451. * Uploads KTX content to a Babylon Texture.
  60452. * It is assumed that the texture has already been created & is currently bound
  60453. * @hidden
  60454. */
  60455. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60456. private _upload2DCompressedLevels;
  60457. /**
  60458. * Checks if the given data starts with a KTX file identifier.
  60459. * @param data the data to check
  60460. * @returns true if the data is a KTX file or false otherwise
  60461. */
  60462. static IsValid(data: ArrayBufferView): boolean;
  60463. }
  60464. }
  60465. declare module "babylonjs/Misc/workerPool" {
  60466. import { IDisposable } from "babylonjs/scene";
  60467. /**
  60468. * Helper class to push actions to a pool of workers.
  60469. */
  60470. export class WorkerPool implements IDisposable {
  60471. private _workerInfos;
  60472. private _pendingActions;
  60473. /**
  60474. * Constructor
  60475. * @param workers Array of workers to use for actions
  60476. */
  60477. constructor(workers: Array<Worker>);
  60478. /**
  60479. * Terminates all workers and clears any pending actions.
  60480. */
  60481. dispose(): void;
  60482. /**
  60483. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60484. * pended until a worker has completed its action.
  60485. * @param action The action to perform. Call onComplete when the action is complete.
  60486. */
  60487. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60488. private _execute;
  60489. }
  60490. }
  60491. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60492. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60493. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60494. /**
  60495. * Class for loading KTX2 files
  60496. * @hidden
  60497. */
  60498. export class KhronosTextureContainer2 {
  60499. private static _WorkerPoolPromise?;
  60500. private static _Initialized;
  60501. private static _Ktx2Decoder;
  60502. /**
  60503. * URL to use when loading the KTX2 decoder module
  60504. */
  60505. static JSModuleURL: string;
  60506. /**
  60507. * Default number of workers used to handle data decoding
  60508. */
  60509. static DefaultNumWorkers: number;
  60510. private static GetDefaultNumWorkers;
  60511. private _engine;
  60512. private static _CreateWorkerPool;
  60513. /**
  60514. * Constructor
  60515. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60516. */
  60517. constructor(engine: ThinEngine, numWorkers?: number);
  60518. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60519. /**
  60520. * Stop all async operations and release resources.
  60521. */
  60522. dispose(): void;
  60523. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60524. /**
  60525. * Checks if the given data starts with a KTX2 file identifier.
  60526. * @param data the data to check
  60527. * @returns true if the data is a KTX2 file or false otherwise
  60528. */
  60529. static IsValid(data: ArrayBufferView): boolean;
  60530. }
  60531. export function workerFunc(): void;
  60532. }
  60533. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60534. import { Nullable } from "babylonjs/types";
  60535. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60536. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60537. /**
  60538. * Implementation of the KTX Texture Loader.
  60539. * @hidden
  60540. */
  60541. export class _KTXTextureLoader implements IInternalTextureLoader {
  60542. /**
  60543. * Defines wether the loader supports cascade loading the different faces.
  60544. */
  60545. readonly supportCascades: boolean;
  60546. /**
  60547. * This returns if the loader support the current file information.
  60548. * @param extension defines the file extension of the file being loaded
  60549. * @param mimeType defines the optional mime type of the file being loaded
  60550. * @returns true if the loader can load the specified file
  60551. */
  60552. canLoad(extension: string, mimeType?: string): boolean;
  60553. /**
  60554. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60555. * @param data contains the texture data
  60556. * @param texture defines the BabylonJS internal texture
  60557. * @param createPolynomials will be true if polynomials have been requested
  60558. * @param onLoad defines the callback to trigger once the texture is ready
  60559. * @param onError defines the callback to trigger in case of error
  60560. */
  60561. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60562. /**
  60563. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60564. * @param data contains the texture data
  60565. * @param texture defines the BabylonJS internal texture
  60566. * @param callback defines the method to call once ready to upload
  60567. */
  60568. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60569. }
  60570. }
  60571. declare module "babylonjs/Helpers/sceneHelpers" {
  60572. import { Nullable } from "babylonjs/types";
  60573. import { Mesh } from "babylonjs/Meshes/mesh";
  60574. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60575. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60576. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60577. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60578. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60579. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60580. import "babylonjs/Meshes/Builders/boxBuilder";
  60581. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60582. /** @hidden */
  60583. export var _forceSceneHelpersToBundle: boolean;
  60584. module "babylonjs/scene" {
  60585. interface Scene {
  60586. /**
  60587. * Creates a default light for the scene.
  60588. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60589. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60590. */
  60591. createDefaultLight(replace?: boolean): void;
  60592. /**
  60593. * Creates a default camera for the scene.
  60594. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60595. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60596. * @param replace has default false, when true replaces the active camera in the scene
  60597. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60598. */
  60599. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60600. /**
  60601. * Creates a default camera and a default light.
  60602. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60603. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60604. * @param replace has the default false, when true replaces the active camera/light in the scene
  60605. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60606. */
  60607. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60608. /**
  60609. * Creates a new sky box
  60610. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60611. * @param environmentTexture defines the texture to use as environment texture
  60612. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60613. * @param scale defines the overall scale of the skybox
  60614. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60615. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60616. * @returns a new mesh holding the sky box
  60617. */
  60618. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60619. /**
  60620. * Creates a new environment
  60621. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60622. * @param options defines the options you can use to configure the environment
  60623. * @returns the new EnvironmentHelper
  60624. */
  60625. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60626. /**
  60627. * Creates a new VREXperienceHelper
  60628. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60629. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60630. * @returns a new VREXperienceHelper
  60631. */
  60632. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60633. /**
  60634. * Creates a new WebXRDefaultExperience
  60635. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60636. * @param options experience options
  60637. * @returns a promise for a new WebXRDefaultExperience
  60638. */
  60639. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60640. }
  60641. }
  60642. }
  60643. declare module "babylonjs/Helpers/videoDome" {
  60644. import { Scene } from "babylonjs/scene";
  60645. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60646. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60647. /**
  60648. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60649. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60650. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60651. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60652. */
  60653. export class VideoDome extends TextureDome<VideoTexture> {
  60654. /**
  60655. * Define the video source as a Monoscopic panoramic 360 video.
  60656. */
  60657. static readonly MODE_MONOSCOPIC: number;
  60658. /**
  60659. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60660. */
  60661. static readonly MODE_TOPBOTTOM: number;
  60662. /**
  60663. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60664. */
  60665. static readonly MODE_SIDEBYSIDE: number;
  60666. /**
  60667. * Get the video texture associated with this video dome
  60668. */
  60669. get videoTexture(): VideoTexture;
  60670. /**
  60671. * Get the video mode of this dome
  60672. */
  60673. get videoMode(): number;
  60674. /**
  60675. * Set the video mode of this dome.
  60676. * @see textureMode
  60677. */
  60678. set videoMode(value: number);
  60679. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60680. }
  60681. }
  60682. declare module "babylonjs/Helpers/index" {
  60683. export * from "babylonjs/Helpers/environmentHelper";
  60684. export * from "babylonjs/Helpers/photoDome";
  60685. export * from "babylonjs/Helpers/sceneHelpers";
  60686. export * from "babylonjs/Helpers/videoDome";
  60687. }
  60688. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60689. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60690. import { IDisposable } from "babylonjs/scene";
  60691. import { Engine } from "babylonjs/Engines/engine";
  60692. /**
  60693. * This class can be used to get instrumentation data from a Babylon engine
  60694. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60695. */
  60696. export class EngineInstrumentation implements IDisposable {
  60697. /**
  60698. * Define the instrumented engine.
  60699. */
  60700. engine: Engine;
  60701. private _captureGPUFrameTime;
  60702. private _gpuFrameTimeToken;
  60703. private _gpuFrameTime;
  60704. private _captureShaderCompilationTime;
  60705. private _shaderCompilationTime;
  60706. private _onBeginFrameObserver;
  60707. private _onEndFrameObserver;
  60708. private _onBeforeShaderCompilationObserver;
  60709. private _onAfterShaderCompilationObserver;
  60710. /**
  60711. * Gets the perf counter used for GPU frame time
  60712. */
  60713. get gpuFrameTimeCounter(): PerfCounter;
  60714. /**
  60715. * Gets the GPU frame time capture status
  60716. */
  60717. get captureGPUFrameTime(): boolean;
  60718. /**
  60719. * Enable or disable the GPU frame time capture
  60720. */
  60721. set captureGPUFrameTime(value: boolean);
  60722. /**
  60723. * Gets the perf counter used for shader compilation time
  60724. */
  60725. get shaderCompilationTimeCounter(): PerfCounter;
  60726. /**
  60727. * Gets the shader compilation time capture status
  60728. */
  60729. get captureShaderCompilationTime(): boolean;
  60730. /**
  60731. * Enable or disable the shader compilation time capture
  60732. */
  60733. set captureShaderCompilationTime(value: boolean);
  60734. /**
  60735. * Instantiates a new engine instrumentation.
  60736. * This class can be used to get instrumentation data from a Babylon engine
  60737. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60738. * @param engine Defines the engine to instrument
  60739. */
  60740. constructor(
  60741. /**
  60742. * Define the instrumented engine.
  60743. */
  60744. engine: Engine);
  60745. /**
  60746. * Dispose and release associated resources.
  60747. */
  60748. dispose(): void;
  60749. }
  60750. }
  60751. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60752. import { Scene, IDisposable } from "babylonjs/scene";
  60753. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60754. /**
  60755. * This class can be used to get instrumentation data from a Babylon engine
  60756. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60757. */
  60758. export class SceneInstrumentation implements IDisposable {
  60759. /**
  60760. * Defines the scene to instrument
  60761. */
  60762. scene: Scene;
  60763. private _captureActiveMeshesEvaluationTime;
  60764. private _activeMeshesEvaluationTime;
  60765. private _captureRenderTargetsRenderTime;
  60766. private _renderTargetsRenderTime;
  60767. private _captureFrameTime;
  60768. private _frameTime;
  60769. private _captureRenderTime;
  60770. private _renderTime;
  60771. private _captureInterFrameTime;
  60772. private _interFrameTime;
  60773. private _captureParticlesRenderTime;
  60774. private _particlesRenderTime;
  60775. private _captureSpritesRenderTime;
  60776. private _spritesRenderTime;
  60777. private _capturePhysicsTime;
  60778. private _physicsTime;
  60779. private _captureAnimationsTime;
  60780. private _animationsTime;
  60781. private _captureCameraRenderTime;
  60782. private _cameraRenderTime;
  60783. private _onBeforeActiveMeshesEvaluationObserver;
  60784. private _onAfterActiveMeshesEvaluationObserver;
  60785. private _onBeforeRenderTargetsRenderObserver;
  60786. private _onAfterRenderTargetsRenderObserver;
  60787. private _onAfterRenderObserver;
  60788. private _onBeforeDrawPhaseObserver;
  60789. private _onAfterDrawPhaseObserver;
  60790. private _onBeforeAnimationsObserver;
  60791. private _onBeforeParticlesRenderingObserver;
  60792. private _onAfterParticlesRenderingObserver;
  60793. private _onBeforeSpritesRenderingObserver;
  60794. private _onAfterSpritesRenderingObserver;
  60795. private _onBeforePhysicsObserver;
  60796. private _onAfterPhysicsObserver;
  60797. private _onAfterAnimationsObserver;
  60798. private _onBeforeCameraRenderObserver;
  60799. private _onAfterCameraRenderObserver;
  60800. /**
  60801. * Gets the perf counter used for active meshes evaluation time
  60802. */
  60803. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60804. /**
  60805. * Gets the active meshes evaluation time capture status
  60806. */
  60807. get captureActiveMeshesEvaluationTime(): boolean;
  60808. /**
  60809. * Enable or disable the active meshes evaluation time capture
  60810. */
  60811. set captureActiveMeshesEvaluationTime(value: boolean);
  60812. /**
  60813. * Gets the perf counter used for render targets render time
  60814. */
  60815. get renderTargetsRenderTimeCounter(): PerfCounter;
  60816. /**
  60817. * Gets the render targets render time capture status
  60818. */
  60819. get captureRenderTargetsRenderTime(): boolean;
  60820. /**
  60821. * Enable or disable the render targets render time capture
  60822. */
  60823. set captureRenderTargetsRenderTime(value: boolean);
  60824. /**
  60825. * Gets the perf counter used for particles render time
  60826. */
  60827. get particlesRenderTimeCounter(): PerfCounter;
  60828. /**
  60829. * Gets the particles render time capture status
  60830. */
  60831. get captureParticlesRenderTime(): boolean;
  60832. /**
  60833. * Enable or disable the particles render time capture
  60834. */
  60835. set captureParticlesRenderTime(value: boolean);
  60836. /**
  60837. * Gets the perf counter used for sprites render time
  60838. */
  60839. get spritesRenderTimeCounter(): PerfCounter;
  60840. /**
  60841. * Gets the sprites render time capture status
  60842. */
  60843. get captureSpritesRenderTime(): boolean;
  60844. /**
  60845. * Enable or disable the sprites render time capture
  60846. */
  60847. set captureSpritesRenderTime(value: boolean);
  60848. /**
  60849. * Gets the perf counter used for physics time
  60850. */
  60851. get physicsTimeCounter(): PerfCounter;
  60852. /**
  60853. * Gets the physics time capture status
  60854. */
  60855. get capturePhysicsTime(): boolean;
  60856. /**
  60857. * Enable or disable the physics time capture
  60858. */
  60859. set capturePhysicsTime(value: boolean);
  60860. /**
  60861. * Gets the perf counter used for animations time
  60862. */
  60863. get animationsTimeCounter(): PerfCounter;
  60864. /**
  60865. * Gets the animations time capture status
  60866. */
  60867. get captureAnimationsTime(): boolean;
  60868. /**
  60869. * Enable or disable the animations time capture
  60870. */
  60871. set captureAnimationsTime(value: boolean);
  60872. /**
  60873. * Gets the perf counter used for frame time capture
  60874. */
  60875. get frameTimeCounter(): PerfCounter;
  60876. /**
  60877. * Gets the frame time capture status
  60878. */
  60879. get captureFrameTime(): boolean;
  60880. /**
  60881. * Enable or disable the frame time capture
  60882. */
  60883. set captureFrameTime(value: boolean);
  60884. /**
  60885. * Gets the perf counter used for inter-frames time capture
  60886. */
  60887. get interFrameTimeCounter(): PerfCounter;
  60888. /**
  60889. * Gets the inter-frames time capture status
  60890. */
  60891. get captureInterFrameTime(): boolean;
  60892. /**
  60893. * Enable or disable the inter-frames time capture
  60894. */
  60895. set captureInterFrameTime(value: boolean);
  60896. /**
  60897. * Gets the perf counter used for render time capture
  60898. */
  60899. get renderTimeCounter(): PerfCounter;
  60900. /**
  60901. * Gets the render time capture status
  60902. */
  60903. get captureRenderTime(): boolean;
  60904. /**
  60905. * Enable or disable the render time capture
  60906. */
  60907. set captureRenderTime(value: boolean);
  60908. /**
  60909. * Gets the perf counter used for camera render time capture
  60910. */
  60911. get cameraRenderTimeCounter(): PerfCounter;
  60912. /**
  60913. * Gets the camera render time capture status
  60914. */
  60915. get captureCameraRenderTime(): boolean;
  60916. /**
  60917. * Enable or disable the camera render time capture
  60918. */
  60919. set captureCameraRenderTime(value: boolean);
  60920. /**
  60921. * Gets the perf counter used for draw calls
  60922. */
  60923. get drawCallsCounter(): PerfCounter;
  60924. /**
  60925. * Instantiates a new scene instrumentation.
  60926. * This class can be used to get instrumentation data from a Babylon engine
  60927. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60928. * @param scene Defines the scene to instrument
  60929. */
  60930. constructor(
  60931. /**
  60932. * Defines the scene to instrument
  60933. */
  60934. scene: Scene);
  60935. /**
  60936. * Dispose and release associated resources.
  60937. */
  60938. dispose(): void;
  60939. }
  60940. }
  60941. declare module "babylonjs/Instrumentation/index" {
  60942. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60943. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60944. export * from "babylonjs/Instrumentation/timeToken";
  60945. }
  60946. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60947. /** @hidden */
  60948. export var glowMapGenerationPixelShader: {
  60949. name: string;
  60950. shader: string;
  60951. };
  60952. }
  60953. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60954. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60955. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60956. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60957. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60958. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60959. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60960. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60961. /** @hidden */
  60962. export var glowMapGenerationVertexShader: {
  60963. name: string;
  60964. shader: string;
  60965. };
  60966. }
  60967. declare module "babylonjs/Layers/effectLayer" {
  60968. import { Observable } from "babylonjs/Misc/observable";
  60969. import { Nullable } from "babylonjs/types";
  60970. import { Camera } from "babylonjs/Cameras/camera";
  60971. import { Scene } from "babylonjs/scene";
  60972. import { ISize } from "babylonjs/Maths/math.size";
  60973. import { Color4 } from "babylonjs/Maths/math.color";
  60974. import { Engine } from "babylonjs/Engines/engine";
  60975. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60977. import { Mesh } from "babylonjs/Meshes/mesh";
  60978. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60979. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60980. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60981. import { Effect } from "babylonjs/Materials/effect";
  60982. import { Material } from "babylonjs/Materials/material";
  60983. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60984. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60985. /**
  60986. * Effect layer options. This helps customizing the behaviour
  60987. * of the effect layer.
  60988. */
  60989. export interface IEffectLayerOptions {
  60990. /**
  60991. * Multiplication factor apply to the canvas size to compute the render target size
  60992. * used to generated the objects (the smaller the faster).
  60993. */
  60994. mainTextureRatio: number;
  60995. /**
  60996. * Enforces a fixed size texture to ensure effect stability across devices.
  60997. */
  60998. mainTextureFixedSize?: number;
  60999. /**
  61000. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61001. */
  61002. alphaBlendingMode: number;
  61003. /**
  61004. * The camera attached to the layer.
  61005. */
  61006. camera: Nullable<Camera>;
  61007. /**
  61008. * The rendering group to draw the layer in.
  61009. */
  61010. renderingGroupId: number;
  61011. }
  61012. /**
  61013. * The effect layer Helps adding post process effect blended with the main pass.
  61014. *
  61015. * This can be for instance use to generate glow or higlight effects on the scene.
  61016. *
  61017. * The effect layer class can not be used directly and is intented to inherited from to be
  61018. * customized per effects.
  61019. */
  61020. export abstract class EffectLayer {
  61021. private _vertexBuffers;
  61022. private _indexBuffer;
  61023. private _cachedDefines;
  61024. private _effectLayerMapGenerationEffect;
  61025. private _effectLayerOptions;
  61026. private _mergeEffect;
  61027. protected _scene: Scene;
  61028. protected _engine: Engine;
  61029. protected _maxSize: number;
  61030. protected _mainTextureDesiredSize: ISize;
  61031. protected _mainTexture: RenderTargetTexture;
  61032. protected _shouldRender: boolean;
  61033. protected _postProcesses: PostProcess[];
  61034. protected _textures: BaseTexture[];
  61035. protected _emissiveTextureAndColor: {
  61036. texture: Nullable<BaseTexture>;
  61037. color: Color4;
  61038. };
  61039. /**
  61040. * The name of the layer
  61041. */
  61042. name: string;
  61043. /**
  61044. * The clear color of the texture used to generate the glow map.
  61045. */
  61046. neutralColor: Color4;
  61047. /**
  61048. * Specifies whether the highlight layer is enabled or not.
  61049. */
  61050. isEnabled: boolean;
  61051. /**
  61052. * Gets the camera attached to the layer.
  61053. */
  61054. get camera(): Nullable<Camera>;
  61055. /**
  61056. * Gets the rendering group id the layer should render in.
  61057. */
  61058. get renderingGroupId(): number;
  61059. set renderingGroupId(renderingGroupId: number);
  61060. /**
  61061. * An event triggered when the effect layer has been disposed.
  61062. */
  61063. onDisposeObservable: Observable<EffectLayer>;
  61064. /**
  61065. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61066. */
  61067. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61068. /**
  61069. * An event triggered when the generated texture is being merged in the scene.
  61070. */
  61071. onBeforeComposeObservable: Observable<EffectLayer>;
  61072. /**
  61073. * An event triggered when the mesh is rendered into the effect render target.
  61074. */
  61075. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61076. /**
  61077. * An event triggered after the mesh has been rendered into the effect render target.
  61078. */
  61079. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61080. /**
  61081. * An event triggered when the generated texture has been merged in the scene.
  61082. */
  61083. onAfterComposeObservable: Observable<EffectLayer>;
  61084. /**
  61085. * An event triggered when the efffect layer changes its size.
  61086. */
  61087. onSizeChangedObservable: Observable<EffectLayer>;
  61088. /** @hidden */
  61089. static _SceneComponentInitialization: (scene: Scene) => void;
  61090. /**
  61091. * Instantiates a new effect Layer and references it in the scene.
  61092. * @param name The name of the layer
  61093. * @param scene The scene to use the layer in
  61094. */
  61095. constructor(
  61096. /** The Friendly of the effect in the scene */
  61097. name: string, scene: Scene);
  61098. /**
  61099. * Get the effect name of the layer.
  61100. * @return The effect name
  61101. */
  61102. abstract getEffectName(): string;
  61103. /**
  61104. * Checks for the readiness of the element composing the layer.
  61105. * @param subMesh the mesh to check for
  61106. * @param useInstances specify whether or not to use instances to render the mesh
  61107. * @return true if ready otherwise, false
  61108. */
  61109. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61110. /**
  61111. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61112. * @returns true if the effect requires stencil during the main canvas render pass.
  61113. */
  61114. abstract needStencil(): boolean;
  61115. /**
  61116. * Create the merge effect. This is the shader use to blit the information back
  61117. * to the main canvas at the end of the scene rendering.
  61118. * @returns The effect containing the shader used to merge the effect on the main canvas
  61119. */
  61120. protected abstract _createMergeEffect(): Effect;
  61121. /**
  61122. * Creates the render target textures and post processes used in the effect layer.
  61123. */
  61124. protected abstract _createTextureAndPostProcesses(): void;
  61125. /**
  61126. * Implementation specific of rendering the generating effect on the main canvas.
  61127. * @param effect The effect used to render through
  61128. */
  61129. protected abstract _internalRender(effect: Effect): void;
  61130. /**
  61131. * Sets the required values for both the emissive texture and and the main color.
  61132. */
  61133. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61134. /**
  61135. * Free any resources and references associated to a mesh.
  61136. * Internal use
  61137. * @param mesh The mesh to free.
  61138. */
  61139. abstract _disposeMesh(mesh: Mesh): void;
  61140. /**
  61141. * Serializes this layer (Glow or Highlight for example)
  61142. * @returns a serialized layer object
  61143. */
  61144. abstract serialize?(): any;
  61145. /**
  61146. * Initializes the effect layer with the required options.
  61147. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61148. */
  61149. protected _init(options: Partial<IEffectLayerOptions>): void;
  61150. /**
  61151. * Generates the index buffer of the full screen quad blending to the main canvas.
  61152. */
  61153. private _generateIndexBuffer;
  61154. /**
  61155. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61156. */
  61157. private _generateVertexBuffer;
  61158. /**
  61159. * Sets the main texture desired size which is the closest power of two
  61160. * of the engine canvas size.
  61161. */
  61162. private _setMainTextureSize;
  61163. /**
  61164. * Creates the main texture for the effect layer.
  61165. */
  61166. protected _createMainTexture(): void;
  61167. /**
  61168. * Adds specific effects defines.
  61169. * @param defines The defines to add specifics to.
  61170. */
  61171. protected _addCustomEffectDefines(defines: string[]): void;
  61172. /**
  61173. * Checks for the readiness of the element composing the layer.
  61174. * @param subMesh the mesh to check for
  61175. * @param useInstances specify whether or not to use instances to render the mesh
  61176. * @param emissiveTexture the associated emissive texture used to generate the glow
  61177. * @return true if ready otherwise, false
  61178. */
  61179. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61180. /**
  61181. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61182. */
  61183. render(): void;
  61184. /**
  61185. * Determine if a given mesh will be used in the current effect.
  61186. * @param mesh mesh to test
  61187. * @returns true if the mesh will be used
  61188. */
  61189. hasMesh(mesh: AbstractMesh): boolean;
  61190. /**
  61191. * Returns true if the layer contains information to display, otherwise false.
  61192. * @returns true if the glow layer should be rendered
  61193. */
  61194. shouldRender(): boolean;
  61195. /**
  61196. * Returns true if the mesh should render, otherwise false.
  61197. * @param mesh The mesh to render
  61198. * @returns true if it should render otherwise false
  61199. */
  61200. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61201. /**
  61202. * Returns true if the mesh can be rendered, otherwise false.
  61203. * @param mesh The mesh to render
  61204. * @param material The material used on the mesh
  61205. * @returns true if it can be rendered otherwise false
  61206. */
  61207. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61208. /**
  61209. * Returns true if the mesh should render, otherwise false.
  61210. * @param mesh The mesh to render
  61211. * @returns true if it should render otherwise false
  61212. */
  61213. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61214. /**
  61215. * Renders the submesh passed in parameter to the generation map.
  61216. */
  61217. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61218. /**
  61219. * Defines whether the current material of the mesh should be use to render the effect.
  61220. * @param mesh defines the current mesh to render
  61221. */
  61222. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61223. /**
  61224. * Rebuild the required buffers.
  61225. * @hidden Internal use only.
  61226. */
  61227. _rebuild(): void;
  61228. /**
  61229. * Dispose only the render target textures and post process.
  61230. */
  61231. private _disposeTextureAndPostProcesses;
  61232. /**
  61233. * Dispose the highlight layer and free resources.
  61234. */
  61235. dispose(): void;
  61236. /**
  61237. * Gets the class name of the effect layer
  61238. * @returns the string with the class name of the effect layer
  61239. */
  61240. getClassName(): string;
  61241. /**
  61242. * Creates an effect layer from parsed effect layer data
  61243. * @param parsedEffectLayer defines effect layer data
  61244. * @param scene defines the current scene
  61245. * @param rootUrl defines the root URL containing the effect layer information
  61246. * @returns a parsed effect Layer
  61247. */
  61248. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61249. }
  61250. }
  61251. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61252. import { Scene } from "babylonjs/scene";
  61253. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61254. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61255. import { AbstractScene } from "babylonjs/abstractScene";
  61256. module "babylonjs/abstractScene" {
  61257. interface AbstractScene {
  61258. /**
  61259. * The list of effect layers (highlights/glow) added to the scene
  61260. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61261. * @see https://doc.babylonjs.com/how_to/glow_layer
  61262. */
  61263. effectLayers: Array<EffectLayer>;
  61264. /**
  61265. * Removes the given effect layer from this scene.
  61266. * @param toRemove defines the effect layer to remove
  61267. * @returns the index of the removed effect layer
  61268. */
  61269. removeEffectLayer(toRemove: EffectLayer): number;
  61270. /**
  61271. * Adds the given effect layer to this scene
  61272. * @param newEffectLayer defines the effect layer to add
  61273. */
  61274. addEffectLayer(newEffectLayer: EffectLayer): void;
  61275. }
  61276. }
  61277. /**
  61278. * Defines the layer scene component responsible to manage any effect layers
  61279. * in a given scene.
  61280. */
  61281. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61282. /**
  61283. * The component name helpfull to identify the component in the list of scene components.
  61284. */
  61285. readonly name: string;
  61286. /**
  61287. * The scene the component belongs to.
  61288. */
  61289. scene: Scene;
  61290. private _engine;
  61291. private _renderEffects;
  61292. private _needStencil;
  61293. private _previousStencilState;
  61294. /**
  61295. * Creates a new instance of the component for the given scene
  61296. * @param scene Defines the scene to register the component in
  61297. */
  61298. constructor(scene: Scene);
  61299. /**
  61300. * Registers the component in a given scene
  61301. */
  61302. register(): void;
  61303. /**
  61304. * Rebuilds the elements related to this component in case of
  61305. * context lost for instance.
  61306. */
  61307. rebuild(): void;
  61308. /**
  61309. * Serializes the component data to the specified json object
  61310. * @param serializationObject The object to serialize to
  61311. */
  61312. serialize(serializationObject: any): void;
  61313. /**
  61314. * Adds all the elements from the container to the scene
  61315. * @param container the container holding the elements
  61316. */
  61317. addFromContainer(container: AbstractScene): void;
  61318. /**
  61319. * Removes all the elements in the container from the scene
  61320. * @param container contains the elements to remove
  61321. * @param dispose if the removed element should be disposed (default: false)
  61322. */
  61323. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61324. /**
  61325. * Disposes the component and the associated ressources.
  61326. */
  61327. dispose(): void;
  61328. private _isReadyForMesh;
  61329. private _renderMainTexture;
  61330. private _setStencil;
  61331. private _setStencilBack;
  61332. private _draw;
  61333. private _drawCamera;
  61334. private _drawRenderingGroup;
  61335. }
  61336. }
  61337. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61338. /** @hidden */
  61339. export var glowMapMergePixelShader: {
  61340. name: string;
  61341. shader: string;
  61342. };
  61343. }
  61344. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61345. /** @hidden */
  61346. export var glowMapMergeVertexShader: {
  61347. name: string;
  61348. shader: string;
  61349. };
  61350. }
  61351. declare module "babylonjs/Layers/glowLayer" {
  61352. import { Nullable } from "babylonjs/types";
  61353. import { Camera } from "babylonjs/Cameras/camera";
  61354. import { Scene } from "babylonjs/scene";
  61355. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61357. import { Mesh } from "babylonjs/Meshes/mesh";
  61358. import { Texture } from "babylonjs/Materials/Textures/texture";
  61359. import { Effect } from "babylonjs/Materials/effect";
  61360. import { Material } from "babylonjs/Materials/material";
  61361. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61362. import { Color4 } from "babylonjs/Maths/math.color";
  61363. import "babylonjs/Shaders/glowMapMerge.fragment";
  61364. import "babylonjs/Shaders/glowMapMerge.vertex";
  61365. import "babylonjs/Layers/effectLayerSceneComponent";
  61366. module "babylonjs/abstractScene" {
  61367. interface AbstractScene {
  61368. /**
  61369. * Return a the first highlight layer of the scene with a given name.
  61370. * @param name The name of the highlight layer to look for.
  61371. * @return The highlight layer if found otherwise null.
  61372. */
  61373. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61374. }
  61375. }
  61376. /**
  61377. * Glow layer options. This helps customizing the behaviour
  61378. * of the glow layer.
  61379. */
  61380. export interface IGlowLayerOptions {
  61381. /**
  61382. * Multiplication factor apply to the canvas size to compute the render target size
  61383. * used to generated the glowing objects (the smaller the faster).
  61384. */
  61385. mainTextureRatio: number;
  61386. /**
  61387. * Enforces a fixed size texture to ensure resize independant blur.
  61388. */
  61389. mainTextureFixedSize?: number;
  61390. /**
  61391. * How big is the kernel of the blur texture.
  61392. */
  61393. blurKernelSize: number;
  61394. /**
  61395. * The camera attached to the layer.
  61396. */
  61397. camera: Nullable<Camera>;
  61398. /**
  61399. * Enable MSAA by chosing the number of samples.
  61400. */
  61401. mainTextureSamples?: number;
  61402. /**
  61403. * The rendering group to draw the layer in.
  61404. */
  61405. renderingGroupId: number;
  61406. }
  61407. /**
  61408. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61409. *
  61410. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61411. *
  61412. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61413. */
  61414. export class GlowLayer extends EffectLayer {
  61415. /**
  61416. * Effect Name of the layer.
  61417. */
  61418. static readonly EffectName: string;
  61419. /**
  61420. * The default blur kernel size used for the glow.
  61421. */
  61422. static DefaultBlurKernelSize: number;
  61423. /**
  61424. * The default texture size ratio used for the glow.
  61425. */
  61426. static DefaultTextureRatio: number;
  61427. /**
  61428. * Sets the kernel size of the blur.
  61429. */
  61430. set blurKernelSize(value: number);
  61431. /**
  61432. * Gets the kernel size of the blur.
  61433. */
  61434. get blurKernelSize(): number;
  61435. /**
  61436. * Sets the glow intensity.
  61437. */
  61438. set intensity(value: number);
  61439. /**
  61440. * Gets the glow intensity.
  61441. */
  61442. get intensity(): number;
  61443. private _options;
  61444. private _intensity;
  61445. private _horizontalBlurPostprocess1;
  61446. private _verticalBlurPostprocess1;
  61447. private _horizontalBlurPostprocess2;
  61448. private _verticalBlurPostprocess2;
  61449. private _blurTexture1;
  61450. private _blurTexture2;
  61451. private _postProcesses1;
  61452. private _postProcesses2;
  61453. private _includedOnlyMeshes;
  61454. private _excludedMeshes;
  61455. private _meshesUsingTheirOwnMaterials;
  61456. /**
  61457. * Callback used to let the user override the color selection on a per mesh basis
  61458. */
  61459. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61460. /**
  61461. * Callback used to let the user override the texture selection on a per mesh basis
  61462. */
  61463. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61464. /**
  61465. * Instantiates a new glow Layer and references it to the scene.
  61466. * @param name The name of the layer
  61467. * @param scene The scene to use the layer in
  61468. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61469. */
  61470. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61471. /**
  61472. * Get the effect name of the layer.
  61473. * @return The effect name
  61474. */
  61475. getEffectName(): string;
  61476. /**
  61477. * Create the merge effect. This is the shader use to blit the information back
  61478. * to the main canvas at the end of the scene rendering.
  61479. */
  61480. protected _createMergeEffect(): Effect;
  61481. /**
  61482. * Creates the render target textures and post processes used in the glow layer.
  61483. */
  61484. protected _createTextureAndPostProcesses(): void;
  61485. /**
  61486. * Checks for the readiness of the element composing the layer.
  61487. * @param subMesh the mesh to check for
  61488. * @param useInstances specify wether or not to use instances to render the mesh
  61489. * @param emissiveTexture the associated emissive texture used to generate the glow
  61490. * @return true if ready otherwise, false
  61491. */
  61492. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61493. /**
  61494. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61495. */
  61496. needStencil(): boolean;
  61497. /**
  61498. * Returns true if the mesh can be rendered, otherwise false.
  61499. * @param mesh The mesh to render
  61500. * @param material The material used on the mesh
  61501. * @returns true if it can be rendered otherwise false
  61502. */
  61503. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61504. /**
  61505. * Implementation specific of rendering the generating effect on the main canvas.
  61506. * @param effect The effect used to render through
  61507. */
  61508. protected _internalRender(effect: Effect): void;
  61509. /**
  61510. * Sets the required values for both the emissive texture and and the main color.
  61511. */
  61512. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61513. /**
  61514. * Returns true if the mesh should render, otherwise false.
  61515. * @param mesh The mesh to render
  61516. * @returns true if it should render otherwise false
  61517. */
  61518. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61519. /**
  61520. * Adds specific effects defines.
  61521. * @param defines The defines to add specifics to.
  61522. */
  61523. protected _addCustomEffectDefines(defines: string[]): void;
  61524. /**
  61525. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61526. * @param mesh The mesh to exclude from the glow layer
  61527. */
  61528. addExcludedMesh(mesh: Mesh): void;
  61529. /**
  61530. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61531. * @param mesh The mesh to remove
  61532. */
  61533. removeExcludedMesh(mesh: Mesh): void;
  61534. /**
  61535. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61536. * @param mesh The mesh to include in the glow layer
  61537. */
  61538. addIncludedOnlyMesh(mesh: Mesh): void;
  61539. /**
  61540. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61541. * @param mesh The mesh to remove
  61542. */
  61543. removeIncludedOnlyMesh(mesh: Mesh): void;
  61544. /**
  61545. * Determine if a given mesh will be used in the glow layer
  61546. * @param mesh The mesh to test
  61547. * @returns true if the mesh will be highlighted by the current glow layer
  61548. */
  61549. hasMesh(mesh: AbstractMesh): boolean;
  61550. /**
  61551. * Defines whether the current material of the mesh should be use to render the effect.
  61552. * @param mesh defines the current mesh to render
  61553. */
  61554. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61555. /**
  61556. * Add a mesh to be rendered through its own material and not with emissive only.
  61557. * @param mesh The mesh for which we need to use its material
  61558. */
  61559. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61560. /**
  61561. * Remove a mesh from being rendered through its own material and not with emissive only.
  61562. * @param mesh The mesh for which we need to not use its material
  61563. */
  61564. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61565. /**
  61566. * Free any resources and references associated to a mesh.
  61567. * Internal use
  61568. * @param mesh The mesh to free.
  61569. * @hidden
  61570. */
  61571. _disposeMesh(mesh: Mesh): void;
  61572. /**
  61573. * Gets the class name of the effect layer
  61574. * @returns the string with the class name of the effect layer
  61575. */
  61576. getClassName(): string;
  61577. /**
  61578. * Serializes this glow layer
  61579. * @returns a serialized glow layer object
  61580. */
  61581. serialize(): any;
  61582. /**
  61583. * Creates a Glow Layer from parsed glow layer data
  61584. * @param parsedGlowLayer defines glow layer data
  61585. * @param scene defines the current scene
  61586. * @param rootUrl defines the root URL containing the glow layer information
  61587. * @returns a parsed Glow Layer
  61588. */
  61589. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61590. }
  61591. }
  61592. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61593. /** @hidden */
  61594. export var glowBlurPostProcessPixelShader: {
  61595. name: string;
  61596. shader: string;
  61597. };
  61598. }
  61599. declare module "babylonjs/Layers/highlightLayer" {
  61600. import { Observable } from "babylonjs/Misc/observable";
  61601. import { Nullable } from "babylonjs/types";
  61602. import { Camera } from "babylonjs/Cameras/camera";
  61603. import { Scene } from "babylonjs/scene";
  61604. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61606. import { Mesh } from "babylonjs/Meshes/mesh";
  61607. import { Effect } from "babylonjs/Materials/effect";
  61608. import { Material } from "babylonjs/Materials/material";
  61609. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61610. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61611. import "babylonjs/Shaders/glowMapMerge.fragment";
  61612. import "babylonjs/Shaders/glowMapMerge.vertex";
  61613. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61614. module "babylonjs/abstractScene" {
  61615. interface AbstractScene {
  61616. /**
  61617. * Return a the first highlight layer of the scene with a given name.
  61618. * @param name The name of the highlight layer to look for.
  61619. * @return The highlight layer if found otherwise null.
  61620. */
  61621. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61622. }
  61623. }
  61624. /**
  61625. * Highlight layer options. This helps customizing the behaviour
  61626. * of the highlight layer.
  61627. */
  61628. export interface IHighlightLayerOptions {
  61629. /**
  61630. * Multiplication factor apply to the canvas size to compute the render target size
  61631. * used to generated the glowing objects (the smaller the faster).
  61632. */
  61633. mainTextureRatio: number;
  61634. /**
  61635. * Enforces a fixed size texture to ensure resize independant blur.
  61636. */
  61637. mainTextureFixedSize?: number;
  61638. /**
  61639. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61640. * of the picture to blur (the smaller the faster).
  61641. */
  61642. blurTextureSizeRatio: number;
  61643. /**
  61644. * How big in texel of the blur texture is the vertical blur.
  61645. */
  61646. blurVerticalSize: number;
  61647. /**
  61648. * How big in texel of the blur texture is the horizontal blur.
  61649. */
  61650. blurHorizontalSize: number;
  61651. /**
  61652. * Alpha blending mode used to apply the blur. Default is combine.
  61653. */
  61654. alphaBlendingMode: number;
  61655. /**
  61656. * The camera attached to the layer.
  61657. */
  61658. camera: Nullable<Camera>;
  61659. /**
  61660. * Should we display highlight as a solid stroke?
  61661. */
  61662. isStroke?: boolean;
  61663. /**
  61664. * The rendering group to draw the layer in.
  61665. */
  61666. renderingGroupId: number;
  61667. }
  61668. /**
  61669. * The highlight layer Helps adding a glow effect around a mesh.
  61670. *
  61671. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61672. * glowy meshes to your scene.
  61673. *
  61674. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61675. */
  61676. export class HighlightLayer extends EffectLayer {
  61677. name: string;
  61678. /**
  61679. * Effect Name of the highlight layer.
  61680. */
  61681. static readonly EffectName: string;
  61682. /**
  61683. * The neutral color used during the preparation of the glow effect.
  61684. * This is black by default as the blend operation is a blend operation.
  61685. */
  61686. static NeutralColor: Color4;
  61687. /**
  61688. * Stencil value used for glowing meshes.
  61689. */
  61690. static GlowingMeshStencilReference: number;
  61691. /**
  61692. * Stencil value used for the other meshes in the scene.
  61693. */
  61694. static NormalMeshStencilReference: number;
  61695. /**
  61696. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61697. */
  61698. innerGlow: boolean;
  61699. /**
  61700. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61701. */
  61702. outerGlow: boolean;
  61703. /**
  61704. * Specifies the horizontal size of the blur.
  61705. */
  61706. set blurHorizontalSize(value: number);
  61707. /**
  61708. * Specifies the vertical size of the blur.
  61709. */
  61710. set blurVerticalSize(value: number);
  61711. /**
  61712. * Gets the horizontal size of the blur.
  61713. */
  61714. get blurHorizontalSize(): number;
  61715. /**
  61716. * Gets the vertical size of the blur.
  61717. */
  61718. get blurVerticalSize(): number;
  61719. /**
  61720. * An event triggered when the highlight layer is being blurred.
  61721. */
  61722. onBeforeBlurObservable: Observable<HighlightLayer>;
  61723. /**
  61724. * An event triggered when the highlight layer has been blurred.
  61725. */
  61726. onAfterBlurObservable: Observable<HighlightLayer>;
  61727. private _instanceGlowingMeshStencilReference;
  61728. private _options;
  61729. private _downSamplePostprocess;
  61730. private _horizontalBlurPostprocess;
  61731. private _verticalBlurPostprocess;
  61732. private _blurTexture;
  61733. private _meshes;
  61734. private _excludedMeshes;
  61735. /**
  61736. * Instantiates a new highlight Layer and references it to the scene..
  61737. * @param name The name of the layer
  61738. * @param scene The scene to use the layer in
  61739. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61740. */
  61741. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61742. /**
  61743. * Get the effect name of the layer.
  61744. * @return The effect name
  61745. */
  61746. getEffectName(): string;
  61747. /**
  61748. * Create the merge effect. This is the shader use to blit the information back
  61749. * to the main canvas at the end of the scene rendering.
  61750. */
  61751. protected _createMergeEffect(): Effect;
  61752. /**
  61753. * Creates the render target textures and post processes used in the highlight layer.
  61754. */
  61755. protected _createTextureAndPostProcesses(): void;
  61756. /**
  61757. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61758. */
  61759. needStencil(): boolean;
  61760. /**
  61761. * Checks for the readiness of the element composing the layer.
  61762. * @param subMesh the mesh to check for
  61763. * @param useInstances specify wether or not to use instances to render the mesh
  61764. * @param emissiveTexture the associated emissive texture used to generate the glow
  61765. * @return true if ready otherwise, false
  61766. */
  61767. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61768. /**
  61769. * Implementation specific of rendering the generating effect on the main canvas.
  61770. * @param effect The effect used to render through
  61771. */
  61772. protected _internalRender(effect: Effect): void;
  61773. /**
  61774. * Returns true if the layer contains information to display, otherwise false.
  61775. */
  61776. shouldRender(): boolean;
  61777. /**
  61778. * Returns true if the mesh should render, otherwise false.
  61779. * @param mesh The mesh to render
  61780. * @returns true if it should render otherwise false
  61781. */
  61782. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61783. /**
  61784. * Returns true if the mesh can be rendered, otherwise false.
  61785. * @param mesh The mesh to render
  61786. * @param material The material used on the mesh
  61787. * @returns true if it can be rendered otherwise false
  61788. */
  61789. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61790. /**
  61791. * Adds specific effects defines.
  61792. * @param defines The defines to add specifics to.
  61793. */
  61794. protected _addCustomEffectDefines(defines: string[]): void;
  61795. /**
  61796. * Sets the required values for both the emissive texture and and the main color.
  61797. */
  61798. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61799. /**
  61800. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61801. * @param mesh The mesh to exclude from the highlight layer
  61802. */
  61803. addExcludedMesh(mesh: Mesh): void;
  61804. /**
  61805. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61806. * @param mesh The mesh to highlight
  61807. */
  61808. removeExcludedMesh(mesh: Mesh): void;
  61809. /**
  61810. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61811. * @param mesh mesh to test
  61812. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61813. */
  61814. hasMesh(mesh: AbstractMesh): boolean;
  61815. /**
  61816. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61817. * @param mesh The mesh to highlight
  61818. * @param color The color of the highlight
  61819. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61820. */
  61821. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61822. /**
  61823. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61824. * @param mesh The mesh to highlight
  61825. */
  61826. removeMesh(mesh: Mesh): void;
  61827. /**
  61828. * Remove all the meshes currently referenced in the highlight layer
  61829. */
  61830. removeAllMeshes(): void;
  61831. /**
  61832. * Force the stencil to the normal expected value for none glowing parts
  61833. */
  61834. private _defaultStencilReference;
  61835. /**
  61836. * Free any resources and references associated to a mesh.
  61837. * Internal use
  61838. * @param mesh The mesh to free.
  61839. * @hidden
  61840. */
  61841. _disposeMesh(mesh: Mesh): void;
  61842. /**
  61843. * Dispose the highlight layer and free resources.
  61844. */
  61845. dispose(): void;
  61846. /**
  61847. * Gets the class name of the effect layer
  61848. * @returns the string with the class name of the effect layer
  61849. */
  61850. getClassName(): string;
  61851. /**
  61852. * Serializes this Highlight layer
  61853. * @returns a serialized Highlight layer object
  61854. */
  61855. serialize(): any;
  61856. /**
  61857. * Creates a Highlight layer from parsed Highlight layer data
  61858. * @param parsedHightlightLayer defines the Highlight layer data
  61859. * @param scene defines the current scene
  61860. * @param rootUrl defines the root URL containing the Highlight layer information
  61861. * @returns a parsed Highlight layer
  61862. */
  61863. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61864. }
  61865. }
  61866. declare module "babylonjs/Layers/layerSceneComponent" {
  61867. import { Scene } from "babylonjs/scene";
  61868. import { ISceneComponent } from "babylonjs/sceneComponent";
  61869. import { Layer } from "babylonjs/Layers/layer";
  61870. import { AbstractScene } from "babylonjs/abstractScene";
  61871. module "babylonjs/abstractScene" {
  61872. interface AbstractScene {
  61873. /**
  61874. * The list of layers (background and foreground) of the scene
  61875. */
  61876. layers: Array<Layer>;
  61877. }
  61878. }
  61879. /**
  61880. * Defines the layer scene component responsible to manage any layers
  61881. * in a given scene.
  61882. */
  61883. export class LayerSceneComponent implements ISceneComponent {
  61884. /**
  61885. * The component name helpfull to identify the component in the list of scene components.
  61886. */
  61887. readonly name: string;
  61888. /**
  61889. * The scene the component belongs to.
  61890. */
  61891. scene: Scene;
  61892. private _engine;
  61893. /**
  61894. * Creates a new instance of the component for the given scene
  61895. * @param scene Defines the scene to register the component in
  61896. */
  61897. constructor(scene: Scene);
  61898. /**
  61899. * Registers the component in a given scene
  61900. */
  61901. register(): void;
  61902. /**
  61903. * Rebuilds the elements related to this component in case of
  61904. * context lost for instance.
  61905. */
  61906. rebuild(): void;
  61907. /**
  61908. * Disposes the component and the associated ressources.
  61909. */
  61910. dispose(): void;
  61911. private _draw;
  61912. private _drawCameraPredicate;
  61913. private _drawCameraBackground;
  61914. private _drawCameraForeground;
  61915. private _drawRenderTargetPredicate;
  61916. private _drawRenderTargetBackground;
  61917. private _drawRenderTargetForeground;
  61918. /**
  61919. * Adds all the elements from the container to the scene
  61920. * @param container the container holding the elements
  61921. */
  61922. addFromContainer(container: AbstractScene): void;
  61923. /**
  61924. * Removes all the elements in the container from the scene
  61925. * @param container contains the elements to remove
  61926. * @param dispose if the removed element should be disposed (default: false)
  61927. */
  61928. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61929. }
  61930. }
  61931. declare module "babylonjs/Shaders/layer.fragment" {
  61932. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61933. /** @hidden */
  61934. export var layerPixelShader: {
  61935. name: string;
  61936. shader: string;
  61937. };
  61938. }
  61939. declare module "babylonjs/Shaders/layer.vertex" {
  61940. /** @hidden */
  61941. export var layerVertexShader: {
  61942. name: string;
  61943. shader: string;
  61944. };
  61945. }
  61946. declare module "babylonjs/Layers/layer" {
  61947. import { Observable } from "babylonjs/Misc/observable";
  61948. import { Nullable } from "babylonjs/types";
  61949. import { Scene } from "babylonjs/scene";
  61950. import { Vector2 } from "babylonjs/Maths/math.vector";
  61951. import { Color4 } from "babylonjs/Maths/math.color";
  61952. import { Texture } from "babylonjs/Materials/Textures/texture";
  61953. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61954. import "babylonjs/Shaders/layer.fragment";
  61955. import "babylonjs/Shaders/layer.vertex";
  61956. /**
  61957. * This represents a full screen 2d layer.
  61958. * This can be useful to display a picture in the background of your scene for instance.
  61959. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61960. */
  61961. export class Layer {
  61962. /**
  61963. * Define the name of the layer.
  61964. */
  61965. name: string;
  61966. /**
  61967. * Define the texture the layer should display.
  61968. */
  61969. texture: Nullable<Texture>;
  61970. /**
  61971. * Is the layer in background or foreground.
  61972. */
  61973. isBackground: boolean;
  61974. /**
  61975. * Define the color of the layer (instead of texture).
  61976. */
  61977. color: Color4;
  61978. /**
  61979. * Define the scale of the layer in order to zoom in out of the texture.
  61980. */
  61981. scale: Vector2;
  61982. /**
  61983. * Define an offset for the layer in order to shift the texture.
  61984. */
  61985. offset: Vector2;
  61986. /**
  61987. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61988. */
  61989. alphaBlendingMode: number;
  61990. /**
  61991. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61992. * Alpha test will not mix with the background color in case of transparency.
  61993. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61994. */
  61995. alphaTest: boolean;
  61996. /**
  61997. * Define a mask to restrict the layer to only some of the scene cameras.
  61998. */
  61999. layerMask: number;
  62000. /**
  62001. * Define the list of render target the layer is visible into.
  62002. */
  62003. renderTargetTextures: RenderTargetTexture[];
  62004. /**
  62005. * Define if the layer is only used in renderTarget or if it also
  62006. * renders in the main frame buffer of the canvas.
  62007. */
  62008. renderOnlyInRenderTargetTextures: boolean;
  62009. private _scene;
  62010. private _vertexBuffers;
  62011. private _indexBuffer;
  62012. private _effect;
  62013. private _previousDefines;
  62014. /**
  62015. * An event triggered when the layer is disposed.
  62016. */
  62017. onDisposeObservable: Observable<Layer>;
  62018. private _onDisposeObserver;
  62019. /**
  62020. * Back compatibility with callback before the onDisposeObservable existed.
  62021. * The set callback will be triggered when the layer has been disposed.
  62022. */
  62023. set onDispose(callback: () => void);
  62024. /**
  62025. * An event triggered before rendering the scene
  62026. */
  62027. onBeforeRenderObservable: Observable<Layer>;
  62028. private _onBeforeRenderObserver;
  62029. /**
  62030. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62031. * The set callback will be triggered just before rendering the layer.
  62032. */
  62033. set onBeforeRender(callback: () => void);
  62034. /**
  62035. * An event triggered after rendering the scene
  62036. */
  62037. onAfterRenderObservable: Observable<Layer>;
  62038. private _onAfterRenderObserver;
  62039. /**
  62040. * Back compatibility with callback before the onAfterRenderObservable existed.
  62041. * The set callback will be triggered just after rendering the layer.
  62042. */
  62043. set onAfterRender(callback: () => void);
  62044. /**
  62045. * Instantiates a new layer.
  62046. * This represents a full screen 2d layer.
  62047. * This can be useful to display a picture in the background of your scene for instance.
  62048. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62049. * @param name Define the name of the layer in the scene
  62050. * @param imgUrl Define the url of the texture to display in the layer
  62051. * @param scene Define the scene the layer belongs to
  62052. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62053. * @param color Defines a color for the layer
  62054. */
  62055. constructor(
  62056. /**
  62057. * Define the name of the layer.
  62058. */
  62059. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62060. private _createIndexBuffer;
  62061. /** @hidden */
  62062. _rebuild(): void;
  62063. /**
  62064. * Renders the layer in the scene.
  62065. */
  62066. render(): void;
  62067. /**
  62068. * Disposes and releases the associated ressources.
  62069. */
  62070. dispose(): void;
  62071. }
  62072. }
  62073. declare module "babylonjs/Layers/index" {
  62074. export * from "babylonjs/Layers/effectLayer";
  62075. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62076. export * from "babylonjs/Layers/glowLayer";
  62077. export * from "babylonjs/Layers/highlightLayer";
  62078. export * from "babylonjs/Layers/layer";
  62079. export * from "babylonjs/Layers/layerSceneComponent";
  62080. }
  62081. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62082. /** @hidden */
  62083. export var lensFlarePixelShader: {
  62084. name: string;
  62085. shader: string;
  62086. };
  62087. }
  62088. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62089. /** @hidden */
  62090. export var lensFlareVertexShader: {
  62091. name: string;
  62092. shader: string;
  62093. };
  62094. }
  62095. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62096. import { Scene } from "babylonjs/scene";
  62097. import { Vector3 } from "babylonjs/Maths/math.vector";
  62098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62099. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62100. import "babylonjs/Shaders/lensFlare.fragment";
  62101. import "babylonjs/Shaders/lensFlare.vertex";
  62102. import { Viewport } from "babylonjs/Maths/math.viewport";
  62103. /**
  62104. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62105. * It is usually composed of several `lensFlare`.
  62106. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62107. */
  62108. export class LensFlareSystem {
  62109. /**
  62110. * Define the name of the lens flare system
  62111. */
  62112. name: string;
  62113. /**
  62114. * List of lens flares used in this system.
  62115. */
  62116. lensFlares: LensFlare[];
  62117. /**
  62118. * Define a limit from the border the lens flare can be visible.
  62119. */
  62120. borderLimit: number;
  62121. /**
  62122. * Define a viewport border we do not want to see the lens flare in.
  62123. */
  62124. viewportBorder: number;
  62125. /**
  62126. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62127. */
  62128. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62129. /**
  62130. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62131. */
  62132. layerMask: number;
  62133. /**
  62134. * Define the id of the lens flare system in the scene.
  62135. * (equal to name by default)
  62136. */
  62137. id: string;
  62138. private _scene;
  62139. private _emitter;
  62140. private _vertexBuffers;
  62141. private _indexBuffer;
  62142. private _effect;
  62143. private _positionX;
  62144. private _positionY;
  62145. private _isEnabled;
  62146. /** @hidden */
  62147. static _SceneComponentInitialization: (scene: Scene) => void;
  62148. /**
  62149. * Instantiates a lens flare system.
  62150. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62151. * It is usually composed of several `lensFlare`.
  62152. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62153. * @param name Define the name of the lens flare system in the scene
  62154. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62155. * @param scene Define the scene the lens flare system belongs to
  62156. */
  62157. constructor(
  62158. /**
  62159. * Define the name of the lens flare system
  62160. */
  62161. name: string, emitter: any, scene: Scene);
  62162. /**
  62163. * Define if the lens flare system is enabled.
  62164. */
  62165. get isEnabled(): boolean;
  62166. set isEnabled(value: boolean);
  62167. /**
  62168. * Get the scene the effects belongs to.
  62169. * @returns the scene holding the lens flare system
  62170. */
  62171. getScene(): Scene;
  62172. /**
  62173. * Get the emitter of the lens flare system.
  62174. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62175. * @returns the emitter of the lens flare system
  62176. */
  62177. getEmitter(): any;
  62178. /**
  62179. * Set the emitter of the lens flare system.
  62180. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62181. * @param newEmitter Define the new emitter of the system
  62182. */
  62183. setEmitter(newEmitter: any): void;
  62184. /**
  62185. * Get the lens flare system emitter position.
  62186. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62187. * @returns the position
  62188. */
  62189. getEmitterPosition(): Vector3;
  62190. /**
  62191. * @hidden
  62192. */
  62193. computeEffectivePosition(globalViewport: Viewport): boolean;
  62194. /** @hidden */
  62195. _isVisible(): boolean;
  62196. /**
  62197. * @hidden
  62198. */
  62199. render(): boolean;
  62200. /**
  62201. * Dispose and release the lens flare with its associated resources.
  62202. */
  62203. dispose(): void;
  62204. /**
  62205. * Parse a lens flare system from a JSON repressentation
  62206. * @param parsedLensFlareSystem Define the JSON to parse
  62207. * @param scene Define the scene the parsed system should be instantiated in
  62208. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62209. * @returns the parsed system
  62210. */
  62211. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62212. /**
  62213. * Serialize the current Lens Flare System into a JSON representation.
  62214. * @returns the serialized JSON
  62215. */
  62216. serialize(): any;
  62217. }
  62218. }
  62219. declare module "babylonjs/LensFlares/lensFlare" {
  62220. import { Nullable } from "babylonjs/types";
  62221. import { Color3 } from "babylonjs/Maths/math.color";
  62222. import { Texture } from "babylonjs/Materials/Textures/texture";
  62223. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62224. /**
  62225. * This represents one of the lens effect in a `lensFlareSystem`.
  62226. * It controls one of the indiviual texture used in the effect.
  62227. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62228. */
  62229. export class LensFlare {
  62230. /**
  62231. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62232. */
  62233. size: number;
  62234. /**
  62235. * 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.
  62236. */
  62237. position: number;
  62238. /**
  62239. * Define the lens color.
  62240. */
  62241. color: Color3;
  62242. /**
  62243. * Define the lens texture.
  62244. */
  62245. texture: Nullable<Texture>;
  62246. /**
  62247. * Define the alpha mode to render this particular lens.
  62248. */
  62249. alphaMode: number;
  62250. private _system;
  62251. /**
  62252. * Creates a new Lens Flare.
  62253. * This represents one of the lens effect in a `lensFlareSystem`.
  62254. * It controls one of the indiviual texture used in the effect.
  62255. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62256. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62257. * @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.
  62258. * @param color Define the lens color
  62259. * @param imgUrl Define the lens texture url
  62260. * @param system Define the `lensFlareSystem` this flare is part of
  62261. * @returns The newly created Lens Flare
  62262. */
  62263. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62264. /**
  62265. * Instantiates a new Lens Flare.
  62266. * This represents one of the lens effect in a `lensFlareSystem`.
  62267. * It controls one of the indiviual texture used in the effect.
  62268. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62269. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62270. * @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.
  62271. * @param color Define the lens color
  62272. * @param imgUrl Define the lens texture url
  62273. * @param system Define the `lensFlareSystem` this flare is part of
  62274. */
  62275. constructor(
  62276. /**
  62277. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62278. */
  62279. size: number,
  62280. /**
  62281. * 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.
  62282. */
  62283. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62284. /**
  62285. * Dispose and release the lens flare with its associated resources.
  62286. */
  62287. dispose(): void;
  62288. }
  62289. }
  62290. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62291. import { Nullable } from "babylonjs/types";
  62292. import { Scene } from "babylonjs/scene";
  62293. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62294. import { AbstractScene } from "babylonjs/abstractScene";
  62295. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62296. module "babylonjs/abstractScene" {
  62297. interface AbstractScene {
  62298. /**
  62299. * The list of lens flare system added to the scene
  62300. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62301. */
  62302. lensFlareSystems: Array<LensFlareSystem>;
  62303. /**
  62304. * Removes the given lens flare system from this scene.
  62305. * @param toRemove The lens flare system to remove
  62306. * @returns The index of the removed lens flare system
  62307. */
  62308. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62309. /**
  62310. * Adds the given lens flare system to this scene
  62311. * @param newLensFlareSystem The lens flare system to add
  62312. */
  62313. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62314. /**
  62315. * Gets a lens flare system using its name
  62316. * @param name defines the name to look for
  62317. * @returns the lens flare system or null if not found
  62318. */
  62319. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62320. /**
  62321. * Gets a lens flare system using its id
  62322. * @param id defines the id to look for
  62323. * @returns the lens flare system or null if not found
  62324. */
  62325. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62326. }
  62327. }
  62328. /**
  62329. * Defines the lens flare scene component responsible to manage any lens flares
  62330. * in a given scene.
  62331. */
  62332. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62333. /**
  62334. * The component name helpfull to identify the component in the list of scene components.
  62335. */
  62336. readonly name: string;
  62337. /**
  62338. * The scene the component belongs to.
  62339. */
  62340. scene: Scene;
  62341. /**
  62342. * Creates a new instance of the component for the given scene
  62343. * @param scene Defines the scene to register the component in
  62344. */
  62345. constructor(scene: Scene);
  62346. /**
  62347. * Registers the component in a given scene
  62348. */
  62349. register(): void;
  62350. /**
  62351. * Rebuilds the elements related to this component in case of
  62352. * context lost for instance.
  62353. */
  62354. rebuild(): void;
  62355. /**
  62356. * Adds all the elements from the container to the scene
  62357. * @param container the container holding the elements
  62358. */
  62359. addFromContainer(container: AbstractScene): void;
  62360. /**
  62361. * Removes all the elements in the container from the scene
  62362. * @param container contains the elements to remove
  62363. * @param dispose if the removed element should be disposed (default: false)
  62364. */
  62365. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62366. /**
  62367. * Serializes the component data to the specified json object
  62368. * @param serializationObject The object to serialize to
  62369. */
  62370. serialize(serializationObject: any): void;
  62371. /**
  62372. * Disposes the component and the associated ressources.
  62373. */
  62374. dispose(): void;
  62375. private _draw;
  62376. }
  62377. }
  62378. declare module "babylonjs/LensFlares/index" {
  62379. export * from "babylonjs/LensFlares/lensFlare";
  62380. export * from "babylonjs/LensFlares/lensFlareSystem";
  62381. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62382. }
  62383. declare module "babylonjs/Shaders/depth.fragment" {
  62384. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62385. /** @hidden */
  62386. export var depthPixelShader: {
  62387. name: string;
  62388. shader: string;
  62389. };
  62390. }
  62391. declare module "babylonjs/Shaders/depth.vertex" {
  62392. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62394. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62395. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62396. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62397. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62398. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62399. /** @hidden */
  62400. export var depthVertexShader: {
  62401. name: string;
  62402. shader: string;
  62403. };
  62404. }
  62405. declare module "babylonjs/Rendering/depthRenderer" {
  62406. import { Nullable } from "babylonjs/types";
  62407. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62408. import { Scene } from "babylonjs/scene";
  62409. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62410. import { Camera } from "babylonjs/Cameras/camera";
  62411. import "babylonjs/Shaders/depth.fragment";
  62412. import "babylonjs/Shaders/depth.vertex";
  62413. /**
  62414. * This represents a depth renderer in Babylon.
  62415. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62416. */
  62417. export class DepthRenderer {
  62418. private _scene;
  62419. private _depthMap;
  62420. private _effect;
  62421. private readonly _storeNonLinearDepth;
  62422. private readonly _clearColor;
  62423. /** Get if the depth renderer is using packed depth or not */
  62424. readonly isPacked: boolean;
  62425. private _cachedDefines;
  62426. private _camera;
  62427. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62428. enabled: boolean;
  62429. /**
  62430. * Specifiess that the depth renderer will only be used within
  62431. * the camera it is created for.
  62432. * This can help forcing its rendering during the camera processing.
  62433. */
  62434. useOnlyInActiveCamera: boolean;
  62435. /** @hidden */
  62436. static _SceneComponentInitialization: (scene: Scene) => void;
  62437. /**
  62438. * Instantiates a depth renderer
  62439. * @param scene The scene the renderer belongs to
  62440. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62441. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62442. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62443. */
  62444. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62445. /**
  62446. * Creates the depth rendering effect and checks if the effect is ready.
  62447. * @param subMesh The submesh to be used to render the depth map of
  62448. * @param useInstances If multiple world instances should be used
  62449. * @returns if the depth renderer is ready to render the depth map
  62450. */
  62451. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62452. /**
  62453. * Gets the texture which the depth map will be written to.
  62454. * @returns The depth map texture
  62455. */
  62456. getDepthMap(): RenderTargetTexture;
  62457. /**
  62458. * Disposes of the depth renderer.
  62459. */
  62460. dispose(): void;
  62461. }
  62462. }
  62463. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62464. /** @hidden */
  62465. export var minmaxReduxPixelShader: {
  62466. name: string;
  62467. shader: string;
  62468. };
  62469. }
  62470. declare module "babylonjs/Misc/minMaxReducer" {
  62471. import { Nullable } from "babylonjs/types";
  62472. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62473. import { Camera } from "babylonjs/Cameras/camera";
  62474. import { Observer } from "babylonjs/Misc/observable";
  62475. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62476. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62477. import { Observable } from "babylonjs/Misc/observable";
  62478. import "babylonjs/Shaders/minmaxRedux.fragment";
  62479. /**
  62480. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62481. * and maximum values from all values of the texture.
  62482. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62483. * The source values are read from the red channel of the texture.
  62484. */
  62485. export class MinMaxReducer {
  62486. /**
  62487. * Observable triggered when the computation has been performed
  62488. */
  62489. onAfterReductionPerformed: Observable<{
  62490. min: number;
  62491. max: number;
  62492. }>;
  62493. protected _camera: Camera;
  62494. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62495. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62496. protected _postProcessManager: PostProcessManager;
  62497. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62498. protected _forceFullscreenViewport: boolean;
  62499. /**
  62500. * Creates a min/max reducer
  62501. * @param camera The camera to use for the post processes
  62502. */
  62503. constructor(camera: Camera);
  62504. /**
  62505. * Gets the texture used to read the values from.
  62506. */
  62507. get sourceTexture(): Nullable<RenderTargetTexture>;
  62508. /**
  62509. * Sets the source texture to read the values from.
  62510. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62511. * because in such textures '1' value must not be taken into account to compute the maximum
  62512. * as this value is used to clear the texture.
  62513. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62514. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62515. * @param depthRedux Indicates if the texture is a depth texture or not
  62516. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62517. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62518. */
  62519. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62520. /**
  62521. * Defines the refresh rate of the computation.
  62522. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62523. */
  62524. get refreshRate(): number;
  62525. set refreshRate(value: number);
  62526. protected _activated: boolean;
  62527. /**
  62528. * Gets the activation status of the reducer
  62529. */
  62530. get activated(): boolean;
  62531. /**
  62532. * Activates the reduction computation.
  62533. * When activated, the observers registered in onAfterReductionPerformed are
  62534. * called after the compuation is performed
  62535. */
  62536. activate(): void;
  62537. /**
  62538. * Deactivates the reduction computation.
  62539. */
  62540. deactivate(): void;
  62541. /**
  62542. * Disposes the min/max reducer
  62543. * @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.
  62544. */
  62545. dispose(disposeAll?: boolean): void;
  62546. }
  62547. }
  62548. declare module "babylonjs/Misc/depthReducer" {
  62549. import { Nullable } from "babylonjs/types";
  62550. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62551. import { Camera } from "babylonjs/Cameras/camera";
  62552. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62553. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62554. /**
  62555. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62556. */
  62557. export class DepthReducer extends MinMaxReducer {
  62558. private _depthRenderer;
  62559. private _depthRendererId;
  62560. /**
  62561. * Gets the depth renderer used for the computation.
  62562. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62563. */
  62564. get depthRenderer(): Nullable<DepthRenderer>;
  62565. /**
  62566. * Creates a depth reducer
  62567. * @param camera The camera used to render the depth texture
  62568. */
  62569. constructor(camera: Camera);
  62570. /**
  62571. * Sets the depth renderer to use to generate the depth map
  62572. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62573. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62574. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62575. */
  62576. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62577. /** @hidden */
  62578. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62579. /**
  62580. * Activates the reduction computation.
  62581. * When activated, the observers registered in onAfterReductionPerformed are
  62582. * called after the compuation is performed
  62583. */
  62584. activate(): void;
  62585. /**
  62586. * Deactivates the reduction computation.
  62587. */
  62588. deactivate(): void;
  62589. /**
  62590. * Disposes the depth reducer
  62591. * @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.
  62592. */
  62593. dispose(disposeAll?: boolean): void;
  62594. }
  62595. }
  62596. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62597. import { Nullable } from "babylonjs/types";
  62598. import { Scene } from "babylonjs/scene";
  62599. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62600. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62602. import { Effect } from "babylonjs/Materials/effect";
  62603. import "babylonjs/Shaders/shadowMap.fragment";
  62604. import "babylonjs/Shaders/shadowMap.vertex";
  62605. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62606. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62607. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62608. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62609. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62610. /**
  62611. * A CSM implementation allowing casting shadows on large scenes.
  62612. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62613. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62614. */
  62615. export class CascadedShadowGenerator extends ShadowGenerator {
  62616. private static readonly frustumCornersNDCSpace;
  62617. /**
  62618. * Name of the CSM class
  62619. */
  62620. static CLASSNAME: string;
  62621. /**
  62622. * Defines the default number of cascades used by the CSM.
  62623. */
  62624. static readonly DEFAULT_CASCADES_COUNT: number;
  62625. /**
  62626. * Defines the minimum number of cascades used by the CSM.
  62627. */
  62628. static readonly MIN_CASCADES_COUNT: number;
  62629. /**
  62630. * Defines the maximum number of cascades used by the CSM.
  62631. */
  62632. static readonly MAX_CASCADES_COUNT: number;
  62633. protected _validateFilter(filter: number): number;
  62634. /**
  62635. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62636. */
  62637. penumbraDarkness: number;
  62638. private _numCascades;
  62639. /**
  62640. * Gets or set the number of cascades used by the CSM.
  62641. */
  62642. get numCascades(): number;
  62643. set numCascades(value: number);
  62644. /**
  62645. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62646. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62647. */
  62648. stabilizeCascades: boolean;
  62649. private _freezeShadowCastersBoundingInfo;
  62650. private _freezeShadowCastersBoundingInfoObservable;
  62651. /**
  62652. * Enables or disables the shadow casters bounding info computation.
  62653. * If your shadow casters don't move, you can disable this feature.
  62654. * If it is enabled, the bounding box computation is done every frame.
  62655. */
  62656. get freezeShadowCastersBoundingInfo(): boolean;
  62657. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62658. private _scbiMin;
  62659. private _scbiMax;
  62660. protected _computeShadowCastersBoundingInfo(): void;
  62661. protected _shadowCastersBoundingInfo: BoundingInfo;
  62662. /**
  62663. * Gets or sets the shadow casters bounding info.
  62664. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62665. * so that the system won't overwrite the bounds you provide
  62666. */
  62667. get shadowCastersBoundingInfo(): BoundingInfo;
  62668. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62669. protected _breaksAreDirty: boolean;
  62670. protected _minDistance: number;
  62671. protected _maxDistance: number;
  62672. /**
  62673. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62674. *
  62675. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62676. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62677. * @param min minimal distance for the breaks (default to 0.)
  62678. * @param max maximal distance for the breaks (default to 1.)
  62679. */
  62680. setMinMaxDistance(min: number, max: number): void;
  62681. /** Gets the minimal distance used in the cascade break computation */
  62682. get minDistance(): number;
  62683. /** Gets the maximal distance used in the cascade break computation */
  62684. get maxDistance(): number;
  62685. /**
  62686. * Gets the class name of that object
  62687. * @returns "CascadedShadowGenerator"
  62688. */
  62689. getClassName(): string;
  62690. private _cascadeMinExtents;
  62691. private _cascadeMaxExtents;
  62692. /**
  62693. * Gets a cascade minimum extents
  62694. * @param cascadeIndex index of the cascade
  62695. * @returns the minimum cascade extents
  62696. */
  62697. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62698. /**
  62699. * Gets a cascade maximum extents
  62700. * @param cascadeIndex index of the cascade
  62701. * @returns the maximum cascade extents
  62702. */
  62703. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62704. private _cascades;
  62705. private _currentLayer;
  62706. private _viewSpaceFrustumsZ;
  62707. private _viewMatrices;
  62708. private _projectionMatrices;
  62709. private _transformMatrices;
  62710. private _transformMatricesAsArray;
  62711. private _frustumLengths;
  62712. private _lightSizeUVCorrection;
  62713. private _depthCorrection;
  62714. private _frustumCornersWorldSpace;
  62715. private _frustumCenter;
  62716. private _shadowCameraPos;
  62717. private _shadowMaxZ;
  62718. /**
  62719. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62720. * It defaults to camera.maxZ
  62721. */
  62722. get shadowMaxZ(): number;
  62723. /**
  62724. * Sets the shadow max z distance.
  62725. */
  62726. set shadowMaxZ(value: number);
  62727. protected _debug: boolean;
  62728. /**
  62729. * Gets or sets the debug flag.
  62730. * When enabled, the cascades are materialized by different colors on the screen.
  62731. */
  62732. get debug(): boolean;
  62733. set debug(dbg: boolean);
  62734. private _depthClamp;
  62735. /**
  62736. * Gets or sets the depth clamping value.
  62737. *
  62738. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62739. * to account for the shadow casters far away.
  62740. *
  62741. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62742. */
  62743. get depthClamp(): boolean;
  62744. set depthClamp(value: boolean);
  62745. private _cascadeBlendPercentage;
  62746. /**
  62747. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62748. * It defaults to 0.1 (10% blending).
  62749. */
  62750. get cascadeBlendPercentage(): number;
  62751. set cascadeBlendPercentage(value: number);
  62752. private _lambda;
  62753. /**
  62754. * Gets or set the lambda parameter.
  62755. * This parameter is used to split the camera frustum and create the cascades.
  62756. * 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.
  62757. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62758. */
  62759. get lambda(): number;
  62760. set lambda(value: number);
  62761. /**
  62762. * Gets the view matrix corresponding to a given cascade
  62763. * @param cascadeNum cascade to retrieve the view matrix from
  62764. * @returns the cascade view matrix
  62765. */
  62766. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62767. /**
  62768. * Gets the projection matrix corresponding to a given cascade
  62769. * @param cascadeNum cascade to retrieve the projection matrix from
  62770. * @returns the cascade projection matrix
  62771. */
  62772. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62773. /**
  62774. * Gets the transformation matrix corresponding to a given cascade
  62775. * @param cascadeNum cascade to retrieve the transformation matrix from
  62776. * @returns the cascade transformation matrix
  62777. */
  62778. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62779. private _depthRenderer;
  62780. /**
  62781. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62782. *
  62783. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62784. *
  62785. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62786. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62787. * @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
  62788. */
  62789. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62790. private _depthReducer;
  62791. private _autoCalcDepthBounds;
  62792. /**
  62793. * Gets or sets the autoCalcDepthBounds property.
  62794. *
  62795. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62796. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62797. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62798. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62799. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62800. */
  62801. get autoCalcDepthBounds(): boolean;
  62802. set autoCalcDepthBounds(value: boolean);
  62803. /**
  62804. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62805. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62806. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62807. * for setting the refresh rate on the renderer yourself!
  62808. */
  62809. get autoCalcDepthBoundsRefreshRate(): number;
  62810. set autoCalcDepthBoundsRefreshRate(value: number);
  62811. /**
  62812. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62813. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62814. * you change the camera near/far planes!
  62815. */
  62816. splitFrustum(): void;
  62817. private _splitFrustum;
  62818. private _computeMatrices;
  62819. private _computeFrustumInWorldSpace;
  62820. private _computeCascadeFrustum;
  62821. /**
  62822. * Support test.
  62823. */
  62824. static get IsSupported(): boolean;
  62825. /** @hidden */
  62826. static _SceneComponentInitialization: (scene: Scene) => void;
  62827. /**
  62828. * Creates a Cascaded Shadow Generator object.
  62829. * A ShadowGenerator is the required tool to use the shadows.
  62830. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62831. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62832. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62833. * @param light The directional light object generating the shadows.
  62834. * @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.
  62835. */
  62836. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62837. protected _initializeGenerator(): void;
  62838. protected _createTargetRenderTexture(): void;
  62839. protected _initializeShadowMap(): void;
  62840. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62841. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62842. /**
  62843. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62844. * @param defines Defines of the material we want to update
  62845. * @param lightIndex Index of the light in the enabled light list of the material
  62846. */
  62847. prepareDefines(defines: any, lightIndex: number): void;
  62848. /**
  62849. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62850. * defined in the generator but impacting the effect).
  62851. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62852. * @param effect The effect we are binfing the information for
  62853. */
  62854. bindShadowLight(lightIndex: string, effect: Effect): void;
  62855. /**
  62856. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62857. * (eq to view projection * shadow projection matrices)
  62858. * @returns The transform matrix used to create the shadow map
  62859. */
  62860. getTransformMatrix(): Matrix;
  62861. /**
  62862. * Disposes the ShadowGenerator.
  62863. * Returns nothing.
  62864. */
  62865. dispose(): void;
  62866. /**
  62867. * Serializes the shadow generator setup to a json object.
  62868. * @returns The serialized JSON object
  62869. */
  62870. serialize(): any;
  62871. /**
  62872. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62873. * @param parsedShadowGenerator The JSON object to parse
  62874. * @param scene The scene to create the shadow map for
  62875. * @returns The parsed shadow generator
  62876. */
  62877. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62878. }
  62879. }
  62880. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62881. import { Scene } from "babylonjs/scene";
  62882. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62883. import { AbstractScene } from "babylonjs/abstractScene";
  62884. /**
  62885. * Defines the shadow generator component responsible to manage any shadow generators
  62886. * in a given scene.
  62887. */
  62888. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62889. /**
  62890. * The component name helpfull to identify the component in the list of scene components.
  62891. */
  62892. readonly name: string;
  62893. /**
  62894. * The scene the component belongs to.
  62895. */
  62896. scene: Scene;
  62897. /**
  62898. * Creates a new instance of the component for the given scene
  62899. * @param scene Defines the scene to register the component in
  62900. */
  62901. constructor(scene: Scene);
  62902. /**
  62903. * Registers the component in a given scene
  62904. */
  62905. register(): void;
  62906. /**
  62907. * Rebuilds the elements related to this component in case of
  62908. * context lost for instance.
  62909. */
  62910. rebuild(): void;
  62911. /**
  62912. * Serializes the component data to the specified json object
  62913. * @param serializationObject The object to serialize to
  62914. */
  62915. serialize(serializationObject: any): void;
  62916. /**
  62917. * Adds all the elements from the container to the scene
  62918. * @param container the container holding the elements
  62919. */
  62920. addFromContainer(container: AbstractScene): void;
  62921. /**
  62922. * Removes all the elements in the container from the scene
  62923. * @param container contains the elements to remove
  62924. * @param dispose if the removed element should be disposed (default: false)
  62925. */
  62926. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62927. /**
  62928. * Rebuilds the elements related to this component in case of
  62929. * context lost for instance.
  62930. */
  62931. dispose(): void;
  62932. private _gatherRenderTargets;
  62933. }
  62934. }
  62935. declare module "babylonjs/Lights/Shadows/index" {
  62936. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62937. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62938. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62939. }
  62940. declare module "babylonjs/Lights/pointLight" {
  62941. import { Scene } from "babylonjs/scene";
  62942. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62944. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62945. import { Effect } from "babylonjs/Materials/effect";
  62946. /**
  62947. * A point light is a light defined by an unique point in world space.
  62948. * The light is emitted in every direction from this point.
  62949. * A good example of a point light is a standard light bulb.
  62950. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62951. */
  62952. export class PointLight extends ShadowLight {
  62953. private _shadowAngle;
  62954. /**
  62955. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62956. * This specifies what angle the shadow will use to be created.
  62957. *
  62958. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62959. */
  62960. get shadowAngle(): number;
  62961. /**
  62962. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62963. * This specifies what angle the shadow will use to be created.
  62964. *
  62965. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62966. */
  62967. set shadowAngle(value: number);
  62968. /**
  62969. * Gets the direction if it has been set.
  62970. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62971. */
  62972. get direction(): Vector3;
  62973. /**
  62974. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62975. */
  62976. set direction(value: Vector3);
  62977. /**
  62978. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62979. * A PointLight emits the light in every direction.
  62980. * It can cast shadows.
  62981. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62982. * ```javascript
  62983. * var pointLight = new PointLight("pl", camera.position, scene);
  62984. * ```
  62985. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62986. * @param name The light friendly name
  62987. * @param position The position of the point light in the scene
  62988. * @param scene The scene the lights belongs to
  62989. */
  62990. constructor(name: string, position: Vector3, scene: Scene);
  62991. /**
  62992. * Returns the string "PointLight"
  62993. * @returns the class name
  62994. */
  62995. getClassName(): string;
  62996. /**
  62997. * Returns the integer 0.
  62998. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62999. */
  63000. getTypeID(): number;
  63001. /**
  63002. * Specifies wether or not the shadowmap should be a cube texture.
  63003. * @returns true if the shadowmap needs to be a cube texture.
  63004. */
  63005. needCube(): boolean;
  63006. /**
  63007. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63008. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63009. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63010. */
  63011. getShadowDirection(faceIndex?: number): Vector3;
  63012. /**
  63013. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63014. * - fov = PI / 2
  63015. * - aspect ratio : 1.0
  63016. * - z-near and far equal to the active camera minZ and maxZ.
  63017. * Returns the PointLight.
  63018. */
  63019. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63020. protected _buildUniformLayout(): void;
  63021. /**
  63022. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63023. * @param effect The effect to update
  63024. * @param lightIndex The index of the light in the effect to update
  63025. * @returns The point light
  63026. */
  63027. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63028. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63029. /**
  63030. * Prepares the list of defines specific to the light type.
  63031. * @param defines the list of defines
  63032. * @param lightIndex defines the index of the light for the effect
  63033. */
  63034. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63035. }
  63036. }
  63037. declare module "babylonjs/Lights/index" {
  63038. export * from "babylonjs/Lights/light";
  63039. export * from "babylonjs/Lights/shadowLight";
  63040. export * from "babylonjs/Lights/Shadows/index";
  63041. export * from "babylonjs/Lights/directionalLight";
  63042. export * from "babylonjs/Lights/hemisphericLight";
  63043. export * from "babylonjs/Lights/pointLight";
  63044. export * from "babylonjs/Lights/spotLight";
  63045. }
  63046. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63047. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63048. /**
  63049. * Header information of HDR texture files.
  63050. */
  63051. export interface HDRInfo {
  63052. /**
  63053. * The height of the texture in pixels.
  63054. */
  63055. height: number;
  63056. /**
  63057. * The width of the texture in pixels.
  63058. */
  63059. width: number;
  63060. /**
  63061. * The index of the beginning of the data in the binary file.
  63062. */
  63063. dataPosition: number;
  63064. }
  63065. /**
  63066. * This groups tools to convert HDR texture to native colors array.
  63067. */
  63068. export class HDRTools {
  63069. private static Ldexp;
  63070. private static Rgbe2float;
  63071. private static readStringLine;
  63072. /**
  63073. * Reads header information from an RGBE texture stored in a native array.
  63074. * More information on this format are available here:
  63075. * https://en.wikipedia.org/wiki/RGBE_image_format
  63076. *
  63077. * @param uint8array The binary file stored in native array.
  63078. * @return The header information.
  63079. */
  63080. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63081. /**
  63082. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63083. * This RGBE texture needs to store the information as a panorama.
  63084. *
  63085. * More information on this format are available here:
  63086. * https://en.wikipedia.org/wiki/RGBE_image_format
  63087. *
  63088. * @param buffer The binary file stored in an array buffer.
  63089. * @param size The expected size of the extracted cubemap.
  63090. * @return The Cube Map information.
  63091. */
  63092. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63093. /**
  63094. * Returns the pixels data extracted from an RGBE texture.
  63095. * This pixels will be stored left to right up to down in the R G B order in one array.
  63096. *
  63097. * More information on this format are available here:
  63098. * https://en.wikipedia.org/wiki/RGBE_image_format
  63099. *
  63100. * @param uint8array The binary file stored in an array buffer.
  63101. * @param hdrInfo The header information of the file.
  63102. * @return The pixels data in RGB right to left up to down order.
  63103. */
  63104. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63105. private static RGBE_ReadPixels_RLE;
  63106. private static RGBE_ReadPixels_NOT_RLE;
  63107. }
  63108. }
  63109. declare module "babylonjs/Materials/effectRenderer" {
  63110. import { Nullable } from "babylonjs/types";
  63111. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63112. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63113. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63114. import { Viewport } from "babylonjs/Maths/math.viewport";
  63115. import { Observable } from "babylonjs/Misc/observable";
  63116. import { Effect } from "babylonjs/Materials/effect";
  63117. import "babylonjs/Shaders/postprocess.vertex";
  63118. /**
  63119. * Effect Render Options
  63120. */
  63121. export interface IEffectRendererOptions {
  63122. /**
  63123. * Defines the vertices positions.
  63124. */
  63125. positions?: number[];
  63126. /**
  63127. * Defines the indices.
  63128. */
  63129. indices?: number[];
  63130. }
  63131. /**
  63132. * Helper class to render one or more effects.
  63133. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63134. */
  63135. export class EffectRenderer {
  63136. private engine;
  63137. private static _DefaultOptions;
  63138. private _vertexBuffers;
  63139. private _indexBuffer;
  63140. private _fullscreenViewport;
  63141. /**
  63142. * Creates an effect renderer
  63143. * @param engine the engine to use for rendering
  63144. * @param options defines the options of the effect renderer
  63145. */
  63146. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63147. /**
  63148. * Sets the current viewport in normalized coordinates 0-1
  63149. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63150. */
  63151. setViewport(viewport?: Viewport): void;
  63152. /**
  63153. * Binds the embedded attributes buffer to the effect.
  63154. * @param effect Defines the effect to bind the attributes for
  63155. */
  63156. bindBuffers(effect: Effect): void;
  63157. /**
  63158. * Sets the current effect wrapper to use during draw.
  63159. * The effect needs to be ready before calling this api.
  63160. * This also sets the default full screen position attribute.
  63161. * @param effectWrapper Defines the effect to draw with
  63162. */
  63163. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63164. /**
  63165. * Restores engine states
  63166. */
  63167. restoreStates(): void;
  63168. /**
  63169. * Draws a full screen quad.
  63170. */
  63171. draw(): void;
  63172. private isRenderTargetTexture;
  63173. /**
  63174. * renders one or more effects to a specified texture
  63175. * @param effectWrapper the effect to renderer
  63176. * @param outputTexture texture to draw to, if null it will render to the screen.
  63177. */
  63178. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63179. /**
  63180. * Disposes of the effect renderer
  63181. */
  63182. dispose(): void;
  63183. }
  63184. /**
  63185. * Options to create an EffectWrapper
  63186. */
  63187. interface EffectWrapperCreationOptions {
  63188. /**
  63189. * Engine to use to create the effect
  63190. */
  63191. engine: ThinEngine;
  63192. /**
  63193. * Fragment shader for the effect
  63194. */
  63195. fragmentShader: string;
  63196. /**
  63197. * Use the shader store instead of direct source code
  63198. */
  63199. useShaderStore?: boolean;
  63200. /**
  63201. * Vertex shader for the effect
  63202. */
  63203. vertexShader?: string;
  63204. /**
  63205. * Attributes to use in the shader
  63206. */
  63207. attributeNames?: Array<string>;
  63208. /**
  63209. * Uniforms to use in the shader
  63210. */
  63211. uniformNames?: Array<string>;
  63212. /**
  63213. * Texture sampler names to use in the shader
  63214. */
  63215. samplerNames?: Array<string>;
  63216. /**
  63217. * Defines to use in the shader
  63218. */
  63219. defines?: Array<string>;
  63220. /**
  63221. * Callback when effect is compiled
  63222. */
  63223. onCompiled?: Nullable<(effect: Effect) => void>;
  63224. /**
  63225. * The friendly name of the effect displayed in Spector.
  63226. */
  63227. name?: string;
  63228. }
  63229. /**
  63230. * Wraps an effect to be used for rendering
  63231. */
  63232. export class EffectWrapper {
  63233. /**
  63234. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63235. */
  63236. onApplyObservable: Observable<{}>;
  63237. /**
  63238. * The underlying effect
  63239. */
  63240. effect: Effect;
  63241. /**
  63242. * Creates an effect to be renderer
  63243. * @param creationOptions options to create the effect
  63244. */
  63245. constructor(creationOptions: EffectWrapperCreationOptions);
  63246. /**
  63247. * Disposes of the effect wrapper
  63248. */
  63249. dispose(): void;
  63250. }
  63251. }
  63252. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63253. /** @hidden */
  63254. export var hdrFilteringVertexShader: {
  63255. name: string;
  63256. shader: string;
  63257. };
  63258. }
  63259. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63260. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63261. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63262. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63263. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63264. /** @hidden */
  63265. export var hdrFilteringPixelShader: {
  63266. name: string;
  63267. shader: string;
  63268. };
  63269. }
  63270. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63271. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63272. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63273. import { Nullable } from "babylonjs/types";
  63274. import "babylonjs/Shaders/hdrFiltering.vertex";
  63275. import "babylonjs/Shaders/hdrFiltering.fragment";
  63276. /**
  63277. * Options for texture filtering
  63278. */
  63279. interface IHDRFilteringOptions {
  63280. /**
  63281. * Scales pixel intensity for the input HDR map.
  63282. */
  63283. hdrScale?: number;
  63284. /**
  63285. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63286. */
  63287. quality?: number;
  63288. }
  63289. /**
  63290. * Filters HDR maps to get correct renderings of PBR reflections
  63291. */
  63292. export class HDRFiltering {
  63293. private _engine;
  63294. private _effectRenderer;
  63295. private _effectWrapper;
  63296. private _lodGenerationOffset;
  63297. private _lodGenerationScale;
  63298. /**
  63299. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63300. * you care about baking speed.
  63301. */
  63302. quality: number;
  63303. /**
  63304. * Scales pixel intensity for the input HDR map.
  63305. */
  63306. hdrScale: number;
  63307. /**
  63308. * Instantiates HDR filter for reflection maps
  63309. *
  63310. * @param engine Thin engine
  63311. * @param options Options
  63312. */
  63313. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63314. private _createRenderTarget;
  63315. private _prefilterInternal;
  63316. private _createEffect;
  63317. /**
  63318. * Get a value indicating if the filter is ready to be used
  63319. * @param texture Texture to filter
  63320. * @returns true if the filter is ready
  63321. */
  63322. isReady(texture: BaseTexture): boolean;
  63323. /**
  63324. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63325. * Prefiltering will be invoked at the end of next rendering pass.
  63326. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63327. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63328. * @param texture Texture to filter
  63329. * @param onFinished Callback when filtering is done
  63330. * @return Promise called when prefiltering is done
  63331. */
  63332. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63333. }
  63334. }
  63335. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63336. import { Nullable } from "babylonjs/types";
  63337. import { Scene } from "babylonjs/scene";
  63338. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63339. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63340. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63341. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63342. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63343. /**
  63344. * This represents a texture coming from an HDR input.
  63345. *
  63346. * The only supported format is currently panorama picture stored in RGBE format.
  63347. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63348. */
  63349. export class HDRCubeTexture extends BaseTexture {
  63350. private static _facesMapping;
  63351. private _generateHarmonics;
  63352. private _noMipmap;
  63353. private _prefilterOnLoad;
  63354. private _textureMatrix;
  63355. private _size;
  63356. private _onLoad;
  63357. private _onError;
  63358. /**
  63359. * The texture URL.
  63360. */
  63361. url: string;
  63362. protected _isBlocking: boolean;
  63363. /**
  63364. * Sets wether or not the texture is blocking during loading.
  63365. */
  63366. set isBlocking(value: boolean);
  63367. /**
  63368. * Gets wether or not the texture is blocking during loading.
  63369. */
  63370. get isBlocking(): boolean;
  63371. protected _rotationY: number;
  63372. /**
  63373. * Sets texture matrix rotation angle around Y axis in radians.
  63374. */
  63375. set rotationY(value: number);
  63376. /**
  63377. * Gets texture matrix rotation angle around Y axis radians.
  63378. */
  63379. get rotationY(): number;
  63380. /**
  63381. * Gets or sets the center of the bounding box associated with the cube texture
  63382. * It must define where the camera used to render the texture was set
  63383. */
  63384. boundingBoxPosition: Vector3;
  63385. private _boundingBoxSize;
  63386. /**
  63387. * Gets or sets the size of the bounding box associated with the cube texture
  63388. * When defined, the cubemap will switch to local mode
  63389. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63390. * @example https://www.babylonjs-playground.com/#RNASML
  63391. */
  63392. set boundingBoxSize(value: Vector3);
  63393. get boundingBoxSize(): Vector3;
  63394. /**
  63395. * Instantiates an HDRTexture from the following parameters.
  63396. *
  63397. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63398. * @param sceneOrEngine The scene or engine the texture will be used in
  63399. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63400. * @param noMipmap Forces to not generate the mipmap if true
  63401. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63402. * @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)
  63403. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63404. */
  63405. 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>);
  63406. /**
  63407. * Get the current class name of the texture useful for serialization or dynamic coding.
  63408. * @returns "HDRCubeTexture"
  63409. */
  63410. getClassName(): string;
  63411. /**
  63412. * Occurs when the file is raw .hdr file.
  63413. */
  63414. private loadTexture;
  63415. clone(): HDRCubeTexture;
  63416. delayLoad(): void;
  63417. /**
  63418. * Get the texture reflection matrix used to rotate/transform the reflection.
  63419. * @returns the reflection matrix
  63420. */
  63421. getReflectionTextureMatrix(): Matrix;
  63422. /**
  63423. * Set the texture reflection matrix used to rotate/transform the reflection.
  63424. * @param value Define the reflection matrix to set
  63425. */
  63426. setReflectionTextureMatrix(value: Matrix): void;
  63427. /**
  63428. * Parses a JSON representation of an HDR Texture in order to create the texture
  63429. * @param parsedTexture Define the JSON representation
  63430. * @param scene Define the scene the texture should be created in
  63431. * @param rootUrl Define the root url in case we need to load relative dependencies
  63432. * @returns the newly created texture after parsing
  63433. */
  63434. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63435. serialize(): any;
  63436. }
  63437. }
  63438. declare module "babylonjs/Physics/physicsEngine" {
  63439. import { Nullable } from "babylonjs/types";
  63440. import { Vector3 } from "babylonjs/Maths/math.vector";
  63441. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63442. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63443. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63444. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63445. /**
  63446. * Class used to control physics engine
  63447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63448. */
  63449. export class PhysicsEngine implements IPhysicsEngine {
  63450. private _physicsPlugin;
  63451. /**
  63452. * Global value used to control the smallest number supported by the simulation
  63453. */
  63454. static Epsilon: number;
  63455. private _impostors;
  63456. private _joints;
  63457. private _subTimeStep;
  63458. /**
  63459. * Gets the gravity vector used by the simulation
  63460. */
  63461. gravity: Vector3;
  63462. /**
  63463. * Factory used to create the default physics plugin.
  63464. * @returns The default physics plugin
  63465. */
  63466. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63467. /**
  63468. * Creates a new Physics Engine
  63469. * @param gravity defines the gravity vector used by the simulation
  63470. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63471. */
  63472. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63473. /**
  63474. * Sets the gravity vector used by the simulation
  63475. * @param gravity defines the gravity vector to use
  63476. */
  63477. setGravity(gravity: Vector3): void;
  63478. /**
  63479. * Set the time step of the physics engine.
  63480. * Default is 1/60.
  63481. * To slow it down, enter 1/600 for example.
  63482. * To speed it up, 1/30
  63483. * @param newTimeStep defines the new timestep to apply to this world.
  63484. */
  63485. setTimeStep(newTimeStep?: number): void;
  63486. /**
  63487. * Get the time step of the physics engine.
  63488. * @returns the current time step
  63489. */
  63490. getTimeStep(): number;
  63491. /**
  63492. * Set the sub time step of the physics engine.
  63493. * Default is 0 meaning there is no sub steps
  63494. * To increase physics resolution precision, set a small value (like 1 ms)
  63495. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63496. */
  63497. setSubTimeStep(subTimeStep?: number): void;
  63498. /**
  63499. * Get the sub time step of the physics engine.
  63500. * @returns the current sub time step
  63501. */
  63502. getSubTimeStep(): number;
  63503. /**
  63504. * Release all resources
  63505. */
  63506. dispose(): void;
  63507. /**
  63508. * Gets the name of the current physics plugin
  63509. * @returns the name of the plugin
  63510. */
  63511. getPhysicsPluginName(): string;
  63512. /**
  63513. * Adding a new impostor for the impostor tracking.
  63514. * This will be done by the impostor itself.
  63515. * @param impostor the impostor to add
  63516. */
  63517. addImpostor(impostor: PhysicsImpostor): void;
  63518. /**
  63519. * Remove an impostor from the engine.
  63520. * This impostor and its mesh will not longer be updated by the physics engine.
  63521. * @param impostor the impostor to remove
  63522. */
  63523. removeImpostor(impostor: PhysicsImpostor): void;
  63524. /**
  63525. * Add a joint to the physics engine
  63526. * @param mainImpostor defines the main impostor to which the joint is added.
  63527. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63528. * @param joint defines the joint that will connect both impostors.
  63529. */
  63530. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63531. /**
  63532. * Removes a joint from the simulation
  63533. * @param mainImpostor defines the impostor used with the joint
  63534. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63535. * @param joint defines the joint to remove
  63536. */
  63537. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63538. /**
  63539. * Called by the scene. No need to call it.
  63540. * @param delta defines the timespam between frames
  63541. */
  63542. _step(delta: number): void;
  63543. /**
  63544. * Gets the current plugin used to run the simulation
  63545. * @returns current plugin
  63546. */
  63547. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63548. /**
  63549. * Gets the list of physic impostors
  63550. * @returns an array of PhysicsImpostor
  63551. */
  63552. getImpostors(): Array<PhysicsImpostor>;
  63553. /**
  63554. * Gets the impostor for a physics enabled object
  63555. * @param object defines the object impersonated by the impostor
  63556. * @returns the PhysicsImpostor or null if not found
  63557. */
  63558. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63559. /**
  63560. * Gets the impostor for a physics body object
  63561. * @param body defines physics body used by the impostor
  63562. * @returns the PhysicsImpostor or null if not found
  63563. */
  63564. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63565. /**
  63566. * Does a raycast in the physics world
  63567. * @param from when should the ray start?
  63568. * @param to when should the ray end?
  63569. * @returns PhysicsRaycastResult
  63570. */
  63571. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63572. }
  63573. }
  63574. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63575. import { Nullable } from "babylonjs/types";
  63576. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63578. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63579. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63580. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63581. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63582. /** @hidden */
  63583. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63584. private _useDeltaForWorldStep;
  63585. world: any;
  63586. name: string;
  63587. private _physicsMaterials;
  63588. private _fixedTimeStep;
  63589. private _cannonRaycastResult;
  63590. private _raycastResult;
  63591. private _physicsBodysToRemoveAfterStep;
  63592. private _firstFrame;
  63593. BJSCANNON: any;
  63594. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63595. setGravity(gravity: Vector3): void;
  63596. setTimeStep(timeStep: number): void;
  63597. getTimeStep(): number;
  63598. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63599. private _removeMarkedPhysicsBodiesFromWorld;
  63600. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63601. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63602. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63603. private _processChildMeshes;
  63604. removePhysicsBody(impostor: PhysicsImpostor): void;
  63605. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63606. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63607. private _addMaterial;
  63608. private _checkWithEpsilon;
  63609. private _createShape;
  63610. private _createHeightmap;
  63611. private _minus90X;
  63612. private _plus90X;
  63613. private _tmpPosition;
  63614. private _tmpDeltaPosition;
  63615. private _tmpUnityRotation;
  63616. private _updatePhysicsBodyTransformation;
  63617. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63618. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63619. isSupported(): boolean;
  63620. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63621. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63622. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63623. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63624. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63625. getBodyMass(impostor: PhysicsImpostor): number;
  63626. getBodyFriction(impostor: PhysicsImpostor): number;
  63627. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63628. getBodyRestitution(impostor: PhysicsImpostor): number;
  63629. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63630. sleepBody(impostor: PhysicsImpostor): void;
  63631. wakeUpBody(impostor: PhysicsImpostor): void;
  63632. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63633. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63634. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63635. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63636. getRadius(impostor: PhysicsImpostor): number;
  63637. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63638. dispose(): void;
  63639. private _extendNamespace;
  63640. /**
  63641. * Does a raycast in the physics world
  63642. * @param from when should the ray start?
  63643. * @param to when should the ray end?
  63644. * @returns PhysicsRaycastResult
  63645. */
  63646. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63647. }
  63648. }
  63649. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63650. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63651. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63652. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63654. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63655. import { Nullable } from "babylonjs/types";
  63656. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63657. /** @hidden */
  63658. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63659. private _useDeltaForWorldStep;
  63660. world: any;
  63661. name: string;
  63662. BJSOIMO: any;
  63663. private _raycastResult;
  63664. private _fixedTimeStep;
  63665. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63666. setGravity(gravity: Vector3): void;
  63667. setTimeStep(timeStep: number): void;
  63668. getTimeStep(): number;
  63669. private _tmpImpostorsArray;
  63670. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63671. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63672. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63673. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63674. private _tmpPositionVector;
  63675. removePhysicsBody(impostor: PhysicsImpostor): void;
  63676. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63677. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63678. isSupported(): boolean;
  63679. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63680. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63681. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63682. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63683. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63684. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63685. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63686. getBodyMass(impostor: PhysicsImpostor): number;
  63687. getBodyFriction(impostor: PhysicsImpostor): number;
  63688. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63689. getBodyRestitution(impostor: PhysicsImpostor): number;
  63690. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63691. sleepBody(impostor: PhysicsImpostor): void;
  63692. wakeUpBody(impostor: PhysicsImpostor): void;
  63693. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63694. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63695. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63696. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63697. getRadius(impostor: PhysicsImpostor): number;
  63698. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63699. dispose(): void;
  63700. /**
  63701. * Does a raycast in the physics world
  63702. * @param from when should the ray start?
  63703. * @param to when should the ray end?
  63704. * @returns PhysicsRaycastResult
  63705. */
  63706. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63707. }
  63708. }
  63709. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63710. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63711. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63712. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63713. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63714. import { Nullable } from "babylonjs/types";
  63715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63716. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63717. /**
  63718. * AmmoJS Physics plugin
  63719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63720. * @see https://github.com/kripken/ammo.js/
  63721. */
  63722. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63723. private _useDeltaForWorldStep;
  63724. /**
  63725. * Reference to the Ammo library
  63726. */
  63727. bjsAMMO: any;
  63728. /**
  63729. * Created ammoJS world which physics bodies are added to
  63730. */
  63731. world: any;
  63732. /**
  63733. * Name of the plugin
  63734. */
  63735. name: string;
  63736. private _timeStep;
  63737. private _fixedTimeStep;
  63738. private _maxSteps;
  63739. private _tmpQuaternion;
  63740. private _tmpAmmoTransform;
  63741. private _tmpAmmoQuaternion;
  63742. private _tmpAmmoConcreteContactResultCallback;
  63743. private _collisionConfiguration;
  63744. private _dispatcher;
  63745. private _overlappingPairCache;
  63746. private _solver;
  63747. private _softBodySolver;
  63748. private _tmpAmmoVectorA;
  63749. private _tmpAmmoVectorB;
  63750. private _tmpAmmoVectorC;
  63751. private _tmpAmmoVectorD;
  63752. private _tmpContactCallbackResult;
  63753. private _tmpAmmoVectorRCA;
  63754. private _tmpAmmoVectorRCB;
  63755. private _raycastResult;
  63756. private static readonly DISABLE_COLLISION_FLAG;
  63757. private static readonly KINEMATIC_FLAG;
  63758. private static readonly DISABLE_DEACTIVATION_FLAG;
  63759. /**
  63760. * Initializes the ammoJS plugin
  63761. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63762. * @param ammoInjection can be used to inject your own ammo reference
  63763. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63764. */
  63765. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63766. /**
  63767. * Sets the gravity of the physics world (m/(s^2))
  63768. * @param gravity Gravity to set
  63769. */
  63770. setGravity(gravity: Vector3): void;
  63771. /**
  63772. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63773. * @param timeStep timestep to use in seconds
  63774. */
  63775. setTimeStep(timeStep: number): void;
  63776. /**
  63777. * 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)
  63778. * @param fixedTimeStep fixedTimeStep to use in seconds
  63779. */
  63780. setFixedTimeStep(fixedTimeStep: number): void;
  63781. /**
  63782. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63783. * @param maxSteps the maximum number of steps by the physics engine per frame
  63784. */
  63785. setMaxSteps(maxSteps: number): void;
  63786. /**
  63787. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63788. * @returns the current timestep in seconds
  63789. */
  63790. getTimeStep(): number;
  63791. /**
  63792. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63793. */
  63794. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63795. private _isImpostorInContact;
  63796. private _isImpostorPairInContact;
  63797. private _stepSimulation;
  63798. /**
  63799. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63800. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63801. * After the step the babylon meshes are set to the position of the physics imposters
  63802. * @param delta amount of time to step forward
  63803. * @param impostors array of imposters to update before/after the step
  63804. */
  63805. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63806. /**
  63807. * Update babylon mesh to match physics world object
  63808. * @param impostor imposter to match
  63809. */
  63810. private _afterSoftStep;
  63811. /**
  63812. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63813. * @param impostor imposter to match
  63814. */
  63815. private _ropeStep;
  63816. /**
  63817. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63818. * @param impostor imposter to match
  63819. */
  63820. private _softbodyOrClothStep;
  63821. private _tmpMatrix;
  63822. /**
  63823. * Applies an impulse on the imposter
  63824. * @param impostor imposter to apply impulse to
  63825. * @param force amount of force to be applied to the imposter
  63826. * @param contactPoint the location to apply the impulse on the imposter
  63827. */
  63828. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63829. /**
  63830. * Applies a force on the imposter
  63831. * @param impostor imposter to apply force
  63832. * @param force amount of force to be applied to the imposter
  63833. * @param contactPoint the location to apply the force on the imposter
  63834. */
  63835. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63836. /**
  63837. * Creates a physics body using the plugin
  63838. * @param impostor the imposter to create the physics body on
  63839. */
  63840. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63841. /**
  63842. * Removes the physics body from the imposter and disposes of the body's memory
  63843. * @param impostor imposter to remove the physics body from
  63844. */
  63845. removePhysicsBody(impostor: PhysicsImpostor): void;
  63846. /**
  63847. * Generates a joint
  63848. * @param impostorJoint the imposter joint to create the joint with
  63849. */
  63850. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63851. /**
  63852. * Removes a joint
  63853. * @param impostorJoint the imposter joint to remove the joint from
  63854. */
  63855. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63856. private _addMeshVerts;
  63857. /**
  63858. * Initialise the soft body vertices to match its object's (mesh) vertices
  63859. * Softbody vertices (nodes) are in world space and to match this
  63860. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63861. * @param impostor to create the softbody for
  63862. */
  63863. private _softVertexData;
  63864. /**
  63865. * Create an impostor's soft body
  63866. * @param impostor to create the softbody for
  63867. */
  63868. private _createSoftbody;
  63869. /**
  63870. * Create cloth for an impostor
  63871. * @param impostor to create the softbody for
  63872. */
  63873. private _createCloth;
  63874. /**
  63875. * Create rope for an impostor
  63876. * @param impostor to create the softbody for
  63877. */
  63878. private _createRope;
  63879. /**
  63880. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63881. * @param impostor to create the custom physics shape for
  63882. */
  63883. private _createCustom;
  63884. private _addHullVerts;
  63885. private _createShape;
  63886. /**
  63887. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63888. * @param impostor imposter containing the physics body and babylon object
  63889. */
  63890. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63891. /**
  63892. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63893. * @param impostor imposter containing the physics body and babylon object
  63894. * @param newPosition new position
  63895. * @param newRotation new rotation
  63896. */
  63897. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63898. /**
  63899. * If this plugin is supported
  63900. * @returns true if its supported
  63901. */
  63902. isSupported(): boolean;
  63903. /**
  63904. * Sets the linear velocity of the physics body
  63905. * @param impostor imposter to set the velocity on
  63906. * @param velocity velocity to set
  63907. */
  63908. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63909. /**
  63910. * Sets the angular velocity of the physics body
  63911. * @param impostor imposter to set the velocity on
  63912. * @param velocity velocity to set
  63913. */
  63914. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63915. /**
  63916. * gets the linear velocity
  63917. * @param impostor imposter to get linear velocity from
  63918. * @returns linear velocity
  63919. */
  63920. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63921. /**
  63922. * gets the angular velocity
  63923. * @param impostor imposter to get angular velocity from
  63924. * @returns angular velocity
  63925. */
  63926. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63927. /**
  63928. * Sets the mass of physics body
  63929. * @param impostor imposter to set the mass on
  63930. * @param mass mass to set
  63931. */
  63932. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63933. /**
  63934. * Gets the mass of the physics body
  63935. * @param impostor imposter to get the mass from
  63936. * @returns mass
  63937. */
  63938. getBodyMass(impostor: PhysicsImpostor): number;
  63939. /**
  63940. * Gets friction of the impostor
  63941. * @param impostor impostor to get friction from
  63942. * @returns friction value
  63943. */
  63944. getBodyFriction(impostor: PhysicsImpostor): number;
  63945. /**
  63946. * Sets friction of the impostor
  63947. * @param impostor impostor to set friction on
  63948. * @param friction friction value
  63949. */
  63950. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63951. /**
  63952. * Gets restitution of the impostor
  63953. * @param impostor impostor to get restitution from
  63954. * @returns restitution value
  63955. */
  63956. getBodyRestitution(impostor: PhysicsImpostor): number;
  63957. /**
  63958. * Sets resitution of the impostor
  63959. * @param impostor impostor to set resitution on
  63960. * @param restitution resitution value
  63961. */
  63962. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63963. /**
  63964. * Gets pressure inside the impostor
  63965. * @param impostor impostor to get pressure from
  63966. * @returns pressure value
  63967. */
  63968. getBodyPressure(impostor: PhysicsImpostor): number;
  63969. /**
  63970. * Sets pressure inside a soft body impostor
  63971. * Cloth and rope must remain 0 pressure
  63972. * @param impostor impostor to set pressure on
  63973. * @param pressure pressure value
  63974. */
  63975. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63976. /**
  63977. * Gets stiffness of the impostor
  63978. * @param impostor impostor to get stiffness from
  63979. * @returns pressure value
  63980. */
  63981. getBodyStiffness(impostor: PhysicsImpostor): number;
  63982. /**
  63983. * Sets stiffness of the impostor
  63984. * @param impostor impostor to set stiffness on
  63985. * @param stiffness stiffness value from 0 to 1
  63986. */
  63987. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63988. /**
  63989. * Gets velocityIterations of the impostor
  63990. * @param impostor impostor to get velocity iterations from
  63991. * @returns velocityIterations value
  63992. */
  63993. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63994. /**
  63995. * Sets velocityIterations of the impostor
  63996. * @param impostor impostor to set velocity iterations on
  63997. * @param velocityIterations velocityIterations value
  63998. */
  63999. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64000. /**
  64001. * Gets positionIterations of the impostor
  64002. * @param impostor impostor to get position iterations from
  64003. * @returns positionIterations value
  64004. */
  64005. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64006. /**
  64007. * Sets positionIterations of the impostor
  64008. * @param impostor impostor to set position on
  64009. * @param positionIterations positionIterations value
  64010. */
  64011. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64012. /**
  64013. * Append an anchor to a cloth object
  64014. * @param impostor is the cloth impostor to add anchor to
  64015. * @param otherImpostor is the rigid impostor to anchor to
  64016. * @param width ratio across width from 0 to 1
  64017. * @param height ratio up height from 0 to 1
  64018. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64019. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64020. */
  64021. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64022. /**
  64023. * Append an hook to a rope object
  64024. * @param impostor is the rope impostor to add hook to
  64025. * @param otherImpostor is the rigid impostor to hook to
  64026. * @param length ratio along the rope from 0 to 1
  64027. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64028. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64029. */
  64030. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64031. /**
  64032. * Sleeps the physics body and stops it from being active
  64033. * @param impostor impostor to sleep
  64034. */
  64035. sleepBody(impostor: PhysicsImpostor): void;
  64036. /**
  64037. * Activates the physics body
  64038. * @param impostor impostor to activate
  64039. */
  64040. wakeUpBody(impostor: PhysicsImpostor): void;
  64041. /**
  64042. * Updates the distance parameters of the joint
  64043. * @param joint joint to update
  64044. * @param maxDistance maximum distance of the joint
  64045. * @param minDistance minimum distance of the joint
  64046. */
  64047. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64048. /**
  64049. * Sets a motor on the joint
  64050. * @param joint joint to set motor on
  64051. * @param speed speed of the motor
  64052. * @param maxForce maximum force of the motor
  64053. * @param motorIndex index of the motor
  64054. */
  64055. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64056. /**
  64057. * Sets the motors limit
  64058. * @param joint joint to set limit on
  64059. * @param upperLimit upper limit
  64060. * @param lowerLimit lower limit
  64061. */
  64062. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64063. /**
  64064. * Syncs the position and rotation of a mesh with the impostor
  64065. * @param mesh mesh to sync
  64066. * @param impostor impostor to update the mesh with
  64067. */
  64068. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64069. /**
  64070. * Gets the radius of the impostor
  64071. * @param impostor impostor to get radius from
  64072. * @returns the radius
  64073. */
  64074. getRadius(impostor: PhysicsImpostor): number;
  64075. /**
  64076. * Gets the box size of the impostor
  64077. * @param impostor impostor to get box size from
  64078. * @param result the resulting box size
  64079. */
  64080. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64081. /**
  64082. * Disposes of the impostor
  64083. */
  64084. dispose(): void;
  64085. /**
  64086. * Does a raycast in the physics world
  64087. * @param from when should the ray start?
  64088. * @param to when should the ray end?
  64089. * @returns PhysicsRaycastResult
  64090. */
  64091. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64092. }
  64093. }
  64094. declare module "babylonjs/Probes/reflectionProbe" {
  64095. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64096. import { Vector3 } from "babylonjs/Maths/math.vector";
  64097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64098. import { Nullable } from "babylonjs/types";
  64099. import { Scene } from "babylonjs/scene";
  64100. module "babylonjs/abstractScene" {
  64101. interface AbstractScene {
  64102. /**
  64103. * The list of reflection probes added to the scene
  64104. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64105. */
  64106. reflectionProbes: Array<ReflectionProbe>;
  64107. /**
  64108. * Removes the given reflection probe from this scene.
  64109. * @param toRemove The reflection probe to remove
  64110. * @returns The index of the removed reflection probe
  64111. */
  64112. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64113. /**
  64114. * Adds the given reflection probe to this scene.
  64115. * @param newReflectionProbe The reflection probe to add
  64116. */
  64117. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64118. }
  64119. }
  64120. /**
  64121. * Class used to generate realtime reflection / refraction cube textures
  64122. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64123. */
  64124. export class ReflectionProbe {
  64125. /** defines the name of the probe */
  64126. name: string;
  64127. private _scene;
  64128. private _renderTargetTexture;
  64129. private _projectionMatrix;
  64130. private _viewMatrix;
  64131. private _target;
  64132. private _add;
  64133. private _attachedMesh;
  64134. private _invertYAxis;
  64135. /** Gets or sets probe position (center of the cube map) */
  64136. position: Vector3;
  64137. /**
  64138. * Creates a new reflection probe
  64139. * @param name defines the name of the probe
  64140. * @param size defines the texture resolution (for each face)
  64141. * @param scene defines the hosting scene
  64142. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64143. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64144. */
  64145. constructor(
  64146. /** defines the name of the probe */
  64147. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64148. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64149. get samples(): number;
  64150. set samples(value: number);
  64151. /** Gets or sets the refresh rate to use (on every frame by default) */
  64152. get refreshRate(): number;
  64153. set refreshRate(value: number);
  64154. /**
  64155. * Gets the hosting scene
  64156. * @returns a Scene
  64157. */
  64158. getScene(): Scene;
  64159. /** Gets the internal CubeTexture used to render to */
  64160. get cubeTexture(): RenderTargetTexture;
  64161. /** Gets the list of meshes to render */
  64162. get renderList(): Nullable<AbstractMesh[]>;
  64163. /**
  64164. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64165. * @param mesh defines the mesh to attach to
  64166. */
  64167. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64168. /**
  64169. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64170. * @param renderingGroupId The rendering group id corresponding to its index
  64171. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64172. */
  64173. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64174. /**
  64175. * Clean all associated resources
  64176. */
  64177. dispose(): void;
  64178. /**
  64179. * Converts the reflection probe information to a readable string for debug purpose.
  64180. * @param fullDetails Supports for multiple levels of logging within scene loading
  64181. * @returns the human readable reflection probe info
  64182. */
  64183. toString(fullDetails?: boolean): string;
  64184. /**
  64185. * Get the class name of the relfection probe.
  64186. * @returns "ReflectionProbe"
  64187. */
  64188. getClassName(): string;
  64189. /**
  64190. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64191. * @returns The JSON representation of the texture
  64192. */
  64193. serialize(): any;
  64194. /**
  64195. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64196. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64197. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64198. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64199. * @returns The parsed reflection probe if successful
  64200. */
  64201. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64202. }
  64203. }
  64204. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64205. /** @hidden */
  64206. export var _BabylonLoaderRegistered: boolean;
  64207. /**
  64208. * Helps setting up some configuration for the babylon file loader.
  64209. */
  64210. export class BabylonFileLoaderConfiguration {
  64211. /**
  64212. * The loader does not allow injecting custom physix engine into the plugins.
  64213. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64214. * So you could set this variable to your engine import to make it work.
  64215. */
  64216. static LoaderInjectedPhysicsEngine: any;
  64217. }
  64218. }
  64219. declare module "babylonjs/Loading/Plugins/index" {
  64220. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64221. }
  64222. declare module "babylonjs/Loading/index" {
  64223. export * from "babylonjs/Loading/loadingScreen";
  64224. export * from "babylonjs/Loading/Plugins/index";
  64225. export * from "babylonjs/Loading/sceneLoader";
  64226. export * from "babylonjs/Loading/sceneLoaderFlags";
  64227. }
  64228. declare module "babylonjs/Materials/Background/index" {
  64229. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64230. }
  64231. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64232. import { Scene } from "babylonjs/scene";
  64233. import { Color3 } from "babylonjs/Maths/math.color";
  64234. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64235. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64236. /**
  64237. * The Physically based simple base material of BJS.
  64238. *
  64239. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64240. * It is used as the base class for both the specGloss and metalRough conventions.
  64241. */
  64242. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64243. /**
  64244. * Number of Simultaneous lights allowed on the material.
  64245. */
  64246. maxSimultaneousLights: number;
  64247. /**
  64248. * If sets to true, disables all the lights affecting the material.
  64249. */
  64250. disableLighting: boolean;
  64251. /**
  64252. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64253. */
  64254. environmentTexture: BaseTexture;
  64255. /**
  64256. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64257. */
  64258. invertNormalMapX: boolean;
  64259. /**
  64260. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64261. */
  64262. invertNormalMapY: boolean;
  64263. /**
  64264. * Normal map used in the model.
  64265. */
  64266. normalTexture: BaseTexture;
  64267. /**
  64268. * Emissivie color used to self-illuminate the model.
  64269. */
  64270. emissiveColor: Color3;
  64271. /**
  64272. * Emissivie texture used to self-illuminate the model.
  64273. */
  64274. emissiveTexture: BaseTexture;
  64275. /**
  64276. * Occlusion Channel Strenght.
  64277. */
  64278. occlusionStrength: number;
  64279. /**
  64280. * Occlusion Texture of the material (adding extra occlusion effects).
  64281. */
  64282. occlusionTexture: BaseTexture;
  64283. /**
  64284. * Defines the alpha limits in alpha test mode.
  64285. */
  64286. alphaCutOff: number;
  64287. /**
  64288. * Gets the current double sided mode.
  64289. */
  64290. get doubleSided(): boolean;
  64291. /**
  64292. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64293. */
  64294. set doubleSided(value: boolean);
  64295. /**
  64296. * Stores the pre-calculated light information of a mesh in a texture.
  64297. */
  64298. lightmapTexture: BaseTexture;
  64299. /**
  64300. * If true, the light map contains occlusion information instead of lighting info.
  64301. */
  64302. useLightmapAsShadowmap: boolean;
  64303. /**
  64304. * Instantiates a new PBRMaterial instance.
  64305. *
  64306. * @param name The material name
  64307. * @param scene The scene the material will be use in.
  64308. */
  64309. constructor(name: string, scene: Scene);
  64310. getClassName(): string;
  64311. }
  64312. }
  64313. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64314. import { Scene } from "babylonjs/scene";
  64315. import { Color3 } from "babylonjs/Maths/math.color";
  64316. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64317. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64318. /**
  64319. * The PBR material of BJS following the metal roughness convention.
  64320. *
  64321. * This fits to the PBR convention in the GLTF definition:
  64322. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64323. */
  64324. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64325. /**
  64326. * The base color has two different interpretations depending on the value of metalness.
  64327. * When the material is a metal, the base color is the specific measured reflectance value
  64328. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64329. * of the material.
  64330. */
  64331. baseColor: Color3;
  64332. /**
  64333. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64334. * well as opacity information in the alpha channel.
  64335. */
  64336. baseTexture: BaseTexture;
  64337. /**
  64338. * Specifies the metallic scalar value of the material.
  64339. * Can also be used to scale the metalness values of the metallic texture.
  64340. */
  64341. metallic: number;
  64342. /**
  64343. * Specifies the roughness scalar value of the material.
  64344. * Can also be used to scale the roughness values of the metallic texture.
  64345. */
  64346. roughness: number;
  64347. /**
  64348. * Texture containing both the metallic value in the B channel and the
  64349. * roughness value in the G channel to keep better precision.
  64350. */
  64351. metallicRoughnessTexture: BaseTexture;
  64352. /**
  64353. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64354. *
  64355. * @param name The material name
  64356. * @param scene The scene the material will be use in.
  64357. */
  64358. constructor(name: string, scene: Scene);
  64359. /**
  64360. * Return the currrent class name of the material.
  64361. */
  64362. getClassName(): string;
  64363. /**
  64364. * Makes a duplicate of the current material.
  64365. * @param name - name to use for the new material.
  64366. */
  64367. clone(name: string): PBRMetallicRoughnessMaterial;
  64368. /**
  64369. * Serialize the material to a parsable JSON object.
  64370. */
  64371. serialize(): any;
  64372. /**
  64373. * Parses a JSON object correponding to the serialize function.
  64374. */
  64375. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64376. }
  64377. }
  64378. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64379. import { Scene } from "babylonjs/scene";
  64380. import { Color3 } from "babylonjs/Maths/math.color";
  64381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64382. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64383. /**
  64384. * The PBR material of BJS following the specular glossiness convention.
  64385. *
  64386. * This fits to the PBR convention in the GLTF definition:
  64387. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64388. */
  64389. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64390. /**
  64391. * Specifies the diffuse color of the material.
  64392. */
  64393. diffuseColor: Color3;
  64394. /**
  64395. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64396. * channel.
  64397. */
  64398. diffuseTexture: BaseTexture;
  64399. /**
  64400. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64401. */
  64402. specularColor: Color3;
  64403. /**
  64404. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64405. */
  64406. glossiness: number;
  64407. /**
  64408. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64409. */
  64410. specularGlossinessTexture: BaseTexture;
  64411. /**
  64412. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64413. *
  64414. * @param name The material name
  64415. * @param scene The scene the material will be use in.
  64416. */
  64417. constructor(name: string, scene: Scene);
  64418. /**
  64419. * Return the currrent class name of the material.
  64420. */
  64421. getClassName(): string;
  64422. /**
  64423. * Makes a duplicate of the current material.
  64424. * @param name - name to use for the new material.
  64425. */
  64426. clone(name: string): PBRSpecularGlossinessMaterial;
  64427. /**
  64428. * Serialize the material to a parsable JSON object.
  64429. */
  64430. serialize(): any;
  64431. /**
  64432. * Parses a JSON object correponding to the serialize function.
  64433. */
  64434. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64435. }
  64436. }
  64437. declare module "babylonjs/Materials/PBR/index" {
  64438. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64439. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64440. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64441. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64442. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64443. }
  64444. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64445. import { Nullable } from "babylonjs/types";
  64446. import { Scene } from "babylonjs/scene";
  64447. import { Matrix } from "babylonjs/Maths/math.vector";
  64448. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64449. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64450. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64451. /**
  64452. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64453. * It can help converting any input color in a desired output one. This can then be used to create effects
  64454. * from sepia, black and white to sixties or futuristic rendering...
  64455. *
  64456. * The only supported format is currently 3dl.
  64457. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64458. */
  64459. export class ColorGradingTexture extends BaseTexture {
  64460. /**
  64461. * The texture URL.
  64462. */
  64463. url: string;
  64464. /**
  64465. * Empty line regex stored for GC.
  64466. */
  64467. private static _noneEmptyLineRegex;
  64468. private _textureMatrix;
  64469. private _onLoad;
  64470. /**
  64471. * Instantiates a ColorGradingTexture from the following parameters.
  64472. *
  64473. * @param url The location of the color gradind data (currently only supporting 3dl)
  64474. * @param sceneOrEngine The scene or engine the texture will be used in
  64475. * @param onLoad defines a callback triggered when the texture has been loaded
  64476. */
  64477. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64478. /**
  64479. * Fires the onload event from the constructor if requested.
  64480. */
  64481. private _triggerOnLoad;
  64482. /**
  64483. * Returns the texture matrix used in most of the material.
  64484. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64485. */
  64486. getTextureMatrix(): Matrix;
  64487. /**
  64488. * Occurs when the file being loaded is a .3dl LUT file.
  64489. */
  64490. private load3dlTexture;
  64491. /**
  64492. * Starts the loading process of the texture.
  64493. */
  64494. private loadTexture;
  64495. /**
  64496. * Clones the color gradind texture.
  64497. */
  64498. clone(): ColorGradingTexture;
  64499. /**
  64500. * Called during delayed load for textures.
  64501. */
  64502. delayLoad(): void;
  64503. /**
  64504. * Parses a color grading texture serialized by Babylon.
  64505. * @param parsedTexture The texture information being parsedTexture
  64506. * @param scene The scene to load the texture in
  64507. * @param rootUrl The root url of the data assets to load
  64508. * @return A color gradind texture
  64509. */
  64510. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64511. /**
  64512. * Serializes the LUT texture to json format.
  64513. */
  64514. serialize(): any;
  64515. }
  64516. }
  64517. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64518. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64519. import { Scene } from "babylonjs/scene";
  64520. import { Nullable } from "babylonjs/types";
  64521. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64522. /**
  64523. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64524. */
  64525. export class EquiRectangularCubeTexture extends BaseTexture {
  64526. /** The six faces of the cube. */
  64527. private static _FacesMapping;
  64528. private _noMipmap;
  64529. private _onLoad;
  64530. private _onError;
  64531. /** The size of the cubemap. */
  64532. private _size;
  64533. /** The buffer of the image. */
  64534. private _buffer;
  64535. /** The width of the input image. */
  64536. private _width;
  64537. /** The height of the input image. */
  64538. private _height;
  64539. /** The URL to the image. */
  64540. url: string;
  64541. /**
  64542. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64543. * @param url The location of the image
  64544. * @param scene The scene the texture will be used in
  64545. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64546. * @param noMipmap Forces to not generate the mipmap if true
  64547. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64548. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64549. * @param onLoad — defines a callback called when texture is loaded
  64550. * @param onError — defines a callback called if there is an error
  64551. */
  64552. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64553. /**
  64554. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64555. */
  64556. private loadImage;
  64557. /**
  64558. * Convert the image buffer into a cubemap and create a CubeTexture.
  64559. */
  64560. private loadTexture;
  64561. /**
  64562. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64563. * @param buffer The ArrayBuffer that should be converted.
  64564. * @returns The buffer as Float32Array.
  64565. */
  64566. private getFloat32ArrayFromArrayBuffer;
  64567. /**
  64568. * Get the current class name of the texture useful for serialization or dynamic coding.
  64569. * @returns "EquiRectangularCubeTexture"
  64570. */
  64571. getClassName(): string;
  64572. /**
  64573. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64574. * @returns A clone of the current EquiRectangularCubeTexture.
  64575. */
  64576. clone(): EquiRectangularCubeTexture;
  64577. }
  64578. }
  64579. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64580. import { Nullable } from "babylonjs/types";
  64581. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64582. import { Matrix } from "babylonjs/Maths/math.vector";
  64583. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64584. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64585. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64586. import { Scene } from "babylonjs/scene";
  64587. /**
  64588. * Defines the options related to the creation of an HtmlElementTexture
  64589. */
  64590. export interface IHtmlElementTextureOptions {
  64591. /**
  64592. * Defines wether mip maps should be created or not.
  64593. */
  64594. generateMipMaps?: boolean;
  64595. /**
  64596. * Defines the sampling mode of the texture.
  64597. */
  64598. samplingMode?: number;
  64599. /**
  64600. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64601. */
  64602. engine: Nullable<ThinEngine>;
  64603. /**
  64604. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64605. */
  64606. scene: Nullable<Scene>;
  64607. }
  64608. /**
  64609. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64610. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64611. * is automatically managed.
  64612. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64613. * in your application.
  64614. *
  64615. * As the update is not automatic, you need to call them manually.
  64616. */
  64617. export class HtmlElementTexture extends BaseTexture {
  64618. /**
  64619. * The texture URL.
  64620. */
  64621. element: HTMLVideoElement | HTMLCanvasElement;
  64622. private static readonly DefaultOptions;
  64623. private _textureMatrix;
  64624. private _isVideo;
  64625. private _generateMipMaps;
  64626. private _samplingMode;
  64627. /**
  64628. * Instantiates a HtmlElementTexture from the following parameters.
  64629. *
  64630. * @param name Defines the name of the texture
  64631. * @param element Defines the video or canvas the texture is filled with
  64632. * @param options Defines the other none mandatory texture creation options
  64633. */
  64634. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64635. private _createInternalTexture;
  64636. /**
  64637. * Returns the texture matrix used in most of the material.
  64638. */
  64639. getTextureMatrix(): Matrix;
  64640. /**
  64641. * Updates the content of the texture.
  64642. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64643. */
  64644. update(invertY?: Nullable<boolean>): void;
  64645. }
  64646. }
  64647. declare module "babylonjs/Misc/tga" {
  64648. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64649. /**
  64650. * Based on jsTGALoader - Javascript loader for TGA file
  64651. * By Vincent Thibault
  64652. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64653. */
  64654. export class TGATools {
  64655. private static _TYPE_INDEXED;
  64656. private static _TYPE_RGB;
  64657. private static _TYPE_GREY;
  64658. private static _TYPE_RLE_INDEXED;
  64659. private static _TYPE_RLE_RGB;
  64660. private static _TYPE_RLE_GREY;
  64661. private static _ORIGIN_MASK;
  64662. private static _ORIGIN_SHIFT;
  64663. private static _ORIGIN_BL;
  64664. private static _ORIGIN_BR;
  64665. private static _ORIGIN_UL;
  64666. private static _ORIGIN_UR;
  64667. /**
  64668. * Gets the header of a TGA file
  64669. * @param data defines the TGA data
  64670. * @returns the header
  64671. */
  64672. static GetTGAHeader(data: Uint8Array): any;
  64673. /**
  64674. * Uploads TGA content to a Babylon Texture
  64675. * @hidden
  64676. */
  64677. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64678. /** @hidden */
  64679. 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;
  64680. /** @hidden */
  64681. 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;
  64682. /** @hidden */
  64683. 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;
  64684. /** @hidden */
  64685. 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;
  64686. /** @hidden */
  64687. 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;
  64688. /** @hidden */
  64689. 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;
  64690. }
  64691. }
  64692. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64693. import { Nullable } from "babylonjs/types";
  64694. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64695. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64696. /**
  64697. * Implementation of the TGA Texture Loader.
  64698. * @hidden
  64699. */
  64700. export class _TGATextureLoader implements IInternalTextureLoader {
  64701. /**
  64702. * Defines wether the loader supports cascade loading the different faces.
  64703. */
  64704. readonly supportCascades: boolean;
  64705. /**
  64706. * This returns if the loader support the current file information.
  64707. * @param extension defines the file extension of the file being loaded
  64708. * @returns true if the loader can load the specified file
  64709. */
  64710. canLoad(extension: string): boolean;
  64711. /**
  64712. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64713. * @param data contains the texture data
  64714. * @param texture defines the BabylonJS internal texture
  64715. * @param createPolynomials will be true if polynomials have been requested
  64716. * @param onLoad defines the callback to trigger once the texture is ready
  64717. * @param onError defines the callback to trigger in case of error
  64718. */
  64719. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64720. /**
  64721. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64722. * @param data contains the texture data
  64723. * @param texture defines the BabylonJS internal texture
  64724. * @param callback defines the method to call once ready to upload
  64725. */
  64726. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64727. }
  64728. }
  64729. declare module "babylonjs/Misc/basis" {
  64730. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64731. /**
  64732. * Info about the .basis files
  64733. */
  64734. class BasisFileInfo {
  64735. /**
  64736. * If the file has alpha
  64737. */
  64738. hasAlpha: boolean;
  64739. /**
  64740. * Info about each image of the basis file
  64741. */
  64742. images: Array<{
  64743. levels: Array<{
  64744. width: number;
  64745. height: number;
  64746. transcodedPixels: ArrayBufferView;
  64747. }>;
  64748. }>;
  64749. }
  64750. /**
  64751. * Result of transcoding a basis file
  64752. */
  64753. class TranscodeResult {
  64754. /**
  64755. * Info about the .basis file
  64756. */
  64757. fileInfo: BasisFileInfo;
  64758. /**
  64759. * Format to use when loading the file
  64760. */
  64761. format: number;
  64762. }
  64763. /**
  64764. * Configuration options for the Basis transcoder
  64765. */
  64766. export class BasisTranscodeConfiguration {
  64767. /**
  64768. * Supported compression formats used to determine the supported output format of the transcoder
  64769. */
  64770. supportedCompressionFormats?: {
  64771. /**
  64772. * etc1 compression format
  64773. */
  64774. etc1?: boolean;
  64775. /**
  64776. * s3tc compression format
  64777. */
  64778. s3tc?: boolean;
  64779. /**
  64780. * pvrtc compression format
  64781. */
  64782. pvrtc?: boolean;
  64783. /**
  64784. * etc2 compression format
  64785. */
  64786. etc2?: boolean;
  64787. };
  64788. /**
  64789. * If mipmap levels should be loaded for transcoded images (Default: true)
  64790. */
  64791. loadMipmapLevels?: boolean;
  64792. /**
  64793. * Index of a single image to load (Default: all images)
  64794. */
  64795. loadSingleImage?: number;
  64796. }
  64797. /**
  64798. * Used to load .Basis files
  64799. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64800. */
  64801. export class BasisTools {
  64802. private static _IgnoreSupportedFormats;
  64803. /**
  64804. * URL to use when loading the basis transcoder
  64805. */
  64806. static JSModuleURL: string;
  64807. /**
  64808. * URL to use when loading the wasm module for the transcoder
  64809. */
  64810. static WasmModuleURL: string;
  64811. /**
  64812. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64813. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64814. * @returns internal format corresponding to the Basis format
  64815. */
  64816. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64817. private static _WorkerPromise;
  64818. private static _Worker;
  64819. private static _actionId;
  64820. private static _CreateWorkerAsync;
  64821. /**
  64822. * Transcodes a loaded image file to compressed pixel data
  64823. * @param data image data to transcode
  64824. * @param config configuration options for the transcoding
  64825. * @returns a promise resulting in the transcoded image
  64826. */
  64827. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64828. /**
  64829. * Loads a texture from the transcode result
  64830. * @param texture texture load to
  64831. * @param transcodeResult the result of transcoding the basis file to load from
  64832. */
  64833. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64834. }
  64835. }
  64836. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64837. import { Nullable } from "babylonjs/types";
  64838. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64839. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64840. /**
  64841. * Loader for .basis file format
  64842. */
  64843. export class _BasisTextureLoader implements IInternalTextureLoader {
  64844. /**
  64845. * Defines whether the loader supports cascade loading the different faces.
  64846. */
  64847. readonly supportCascades: boolean;
  64848. /**
  64849. * This returns if the loader support the current file information.
  64850. * @param extension defines the file extension of the file being loaded
  64851. * @returns true if the loader can load the specified file
  64852. */
  64853. canLoad(extension: string): boolean;
  64854. /**
  64855. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64856. * @param data contains the texture data
  64857. * @param texture defines the BabylonJS internal texture
  64858. * @param createPolynomials will be true if polynomials have been requested
  64859. * @param onLoad defines the callback to trigger once the texture is ready
  64860. * @param onError defines the callback to trigger in case of error
  64861. */
  64862. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64863. /**
  64864. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64865. * @param data contains the texture data
  64866. * @param texture defines the BabylonJS internal texture
  64867. * @param callback defines the method to call once ready to upload
  64868. */
  64869. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64870. }
  64871. }
  64872. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64873. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64874. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64875. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64876. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64877. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64878. }
  64879. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64880. import { Vector2 } from "babylonjs/Maths/math.vector";
  64881. /**
  64882. * Defines the basic options interface of a TexturePacker Frame
  64883. */
  64884. export interface ITexturePackerFrame {
  64885. /**
  64886. * The frame ID
  64887. */
  64888. id: number;
  64889. /**
  64890. * The frames Scale
  64891. */
  64892. scale: Vector2;
  64893. /**
  64894. * The Frames offset
  64895. */
  64896. offset: Vector2;
  64897. }
  64898. /**
  64899. * This is a support class for frame Data on texture packer sets.
  64900. */
  64901. export class TexturePackerFrame implements ITexturePackerFrame {
  64902. /**
  64903. * The frame ID
  64904. */
  64905. id: number;
  64906. /**
  64907. * The frames Scale
  64908. */
  64909. scale: Vector2;
  64910. /**
  64911. * The Frames offset
  64912. */
  64913. offset: Vector2;
  64914. /**
  64915. * Initializes a texture package frame.
  64916. * @param id The numerical frame identifier
  64917. * @param scale Scalar Vector2 for UV frame
  64918. * @param offset Vector2 for the frame position in UV units.
  64919. * @returns TexturePackerFrame
  64920. */
  64921. constructor(id: number, scale: Vector2, offset: Vector2);
  64922. }
  64923. }
  64924. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64926. import { Scene } from "babylonjs/scene";
  64927. import { Nullable } from "babylonjs/types";
  64928. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64929. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64930. /**
  64931. * Defines the basic options interface of a TexturePacker
  64932. */
  64933. export interface ITexturePackerOptions {
  64934. /**
  64935. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64936. */
  64937. map?: string[];
  64938. /**
  64939. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64940. */
  64941. uvsIn?: string;
  64942. /**
  64943. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64944. */
  64945. uvsOut?: string;
  64946. /**
  64947. * number representing the layout style. Defaults to LAYOUT_STRIP
  64948. */
  64949. layout?: number;
  64950. /**
  64951. * number of columns if using custom column count layout(2). This defaults to 4.
  64952. */
  64953. colnum?: number;
  64954. /**
  64955. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64956. */
  64957. updateInputMeshes?: boolean;
  64958. /**
  64959. * boolean flag to dispose all the source textures. Defaults to true.
  64960. */
  64961. disposeSources?: boolean;
  64962. /**
  64963. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64964. */
  64965. fillBlanks?: boolean;
  64966. /**
  64967. * string value representing the context fill style color. Defaults to 'black'.
  64968. */
  64969. customFillColor?: string;
  64970. /**
  64971. * Width and Height Value of each Frame in the TexturePacker Sets
  64972. */
  64973. frameSize?: number;
  64974. /**
  64975. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64976. */
  64977. paddingRatio?: number;
  64978. /**
  64979. * Number that declares the fill method for the padding gutter.
  64980. */
  64981. paddingMode?: number;
  64982. /**
  64983. * If in SUBUV_COLOR padding mode what color to use.
  64984. */
  64985. paddingColor?: Color3 | Color4;
  64986. }
  64987. /**
  64988. * Defines the basic interface of a TexturePacker JSON File
  64989. */
  64990. export interface ITexturePackerJSON {
  64991. /**
  64992. * The frame ID
  64993. */
  64994. name: string;
  64995. /**
  64996. * The base64 channel data
  64997. */
  64998. sets: any;
  64999. /**
  65000. * The options of the Packer
  65001. */
  65002. options: ITexturePackerOptions;
  65003. /**
  65004. * The frame data of the Packer
  65005. */
  65006. frames: Array<number>;
  65007. }
  65008. /**
  65009. * This is a support class that generates a series of packed texture sets.
  65010. * @see https://doc.babylonjs.com/babylon101/materials
  65011. */
  65012. export class TexturePacker {
  65013. /** Packer Layout Constant 0 */
  65014. static readonly LAYOUT_STRIP: number;
  65015. /** Packer Layout Constant 1 */
  65016. static readonly LAYOUT_POWER2: number;
  65017. /** Packer Layout Constant 2 */
  65018. static readonly LAYOUT_COLNUM: number;
  65019. /** Packer Layout Constant 0 */
  65020. static readonly SUBUV_WRAP: number;
  65021. /** Packer Layout Constant 1 */
  65022. static readonly SUBUV_EXTEND: number;
  65023. /** Packer Layout Constant 2 */
  65024. static readonly SUBUV_COLOR: number;
  65025. /** The Name of the Texture Package */
  65026. name: string;
  65027. /** The scene scope of the TexturePacker */
  65028. scene: Scene;
  65029. /** The Meshes to target */
  65030. meshes: AbstractMesh[];
  65031. /** Arguments passed with the Constructor */
  65032. options: ITexturePackerOptions;
  65033. /** The promise that is started upon initialization */
  65034. promise: Nullable<Promise<TexturePacker | string>>;
  65035. /** The Container object for the channel sets that are generated */
  65036. sets: object;
  65037. /** The Container array for the frames that are generated */
  65038. frames: TexturePackerFrame[];
  65039. /** The expected number of textures the system is parsing. */
  65040. private _expecting;
  65041. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65042. private _paddingValue;
  65043. /**
  65044. * Initializes a texture package series from an array of meshes or a single mesh.
  65045. * @param name The name of the package
  65046. * @param meshes The target meshes to compose the package from
  65047. * @param options The arguments that texture packer should follow while building.
  65048. * @param scene The scene which the textures are scoped to.
  65049. * @returns TexturePacker
  65050. */
  65051. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65052. /**
  65053. * Starts the package process
  65054. * @param resolve The promises resolution function
  65055. * @returns TexturePacker
  65056. */
  65057. private _createFrames;
  65058. /**
  65059. * Calculates the Size of the Channel Sets
  65060. * @returns Vector2
  65061. */
  65062. private _calculateSize;
  65063. /**
  65064. * Calculates the UV data for the frames.
  65065. * @param baseSize the base frameSize
  65066. * @param padding the base frame padding
  65067. * @param dtSize size of the Dynamic Texture for that channel
  65068. * @param dtUnits is 1/dtSize
  65069. * @param update flag to update the input meshes
  65070. */
  65071. private _calculateMeshUVFrames;
  65072. /**
  65073. * Calculates the frames Offset.
  65074. * @param index of the frame
  65075. * @returns Vector2
  65076. */
  65077. private _getFrameOffset;
  65078. /**
  65079. * Updates a Mesh to the frame data
  65080. * @param mesh that is the target
  65081. * @param frameID or the frame index
  65082. */
  65083. private _updateMeshUV;
  65084. /**
  65085. * Updates a Meshes materials to use the texture packer channels
  65086. * @param m is the mesh to target
  65087. * @param force all channels on the packer to be set.
  65088. */
  65089. private _updateTextureReferences;
  65090. /**
  65091. * Public method to set a Mesh to a frame
  65092. * @param m that is the target
  65093. * @param frameID or the frame index
  65094. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65095. */
  65096. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65097. /**
  65098. * Starts the async promise to compile the texture packer.
  65099. * @returns Promise<void>
  65100. */
  65101. processAsync(): Promise<void>;
  65102. /**
  65103. * Disposes all textures associated with this packer
  65104. */
  65105. dispose(): void;
  65106. /**
  65107. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65108. * @param imageType is the image type to use.
  65109. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65110. */
  65111. download(imageType?: string, quality?: number): void;
  65112. /**
  65113. * Public method to load a texturePacker JSON file.
  65114. * @param data of the JSON file in string format.
  65115. */
  65116. updateFromJSON(data: string): void;
  65117. }
  65118. }
  65119. declare module "babylonjs/Materials/Textures/Packer/index" {
  65120. export * from "babylonjs/Materials/Textures/Packer/packer";
  65121. export * from "babylonjs/Materials/Textures/Packer/frame";
  65122. }
  65123. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65124. import { Scene } from "babylonjs/scene";
  65125. import { Texture } from "babylonjs/Materials/Textures/texture";
  65126. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65127. /**
  65128. * 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.
  65129. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65130. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65131. */
  65132. export class CustomProceduralTexture extends ProceduralTexture {
  65133. private _animate;
  65134. private _time;
  65135. private _config;
  65136. private _texturePath;
  65137. /**
  65138. * Instantiates a new Custom Procedural Texture.
  65139. * 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.
  65140. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65141. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65142. * @param name Define the name of the texture
  65143. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65144. * @param size Define the size of the texture to create
  65145. * @param scene Define the scene the texture belongs to
  65146. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65147. * @param generateMipMaps Define if the texture should creates mip maps or not
  65148. */
  65149. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65150. private _loadJson;
  65151. /**
  65152. * Is the texture ready to be used ? (rendered at least once)
  65153. * @returns true if ready, otherwise, false.
  65154. */
  65155. isReady(): boolean;
  65156. /**
  65157. * Render the texture to its associated render target.
  65158. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65159. */
  65160. render(useCameraPostProcess?: boolean): void;
  65161. /**
  65162. * Update the list of dependant textures samplers in the shader.
  65163. */
  65164. updateTextures(): void;
  65165. /**
  65166. * Update the uniform values of the procedural texture in the shader.
  65167. */
  65168. updateShaderUniforms(): void;
  65169. /**
  65170. * Define if the texture animates or not.
  65171. */
  65172. get animate(): boolean;
  65173. set animate(value: boolean);
  65174. }
  65175. }
  65176. declare module "babylonjs/Shaders/noise.fragment" {
  65177. /** @hidden */
  65178. export var noisePixelShader: {
  65179. name: string;
  65180. shader: string;
  65181. };
  65182. }
  65183. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65184. import { Nullable } from "babylonjs/types";
  65185. import { Scene } from "babylonjs/scene";
  65186. import { Texture } from "babylonjs/Materials/Textures/texture";
  65187. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65188. import "babylonjs/Shaders/noise.fragment";
  65189. /**
  65190. * Class used to generate noise procedural textures
  65191. */
  65192. export class NoiseProceduralTexture extends ProceduralTexture {
  65193. /** Gets or sets the start time (default is 0) */
  65194. time: number;
  65195. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65196. brightness: number;
  65197. /** Defines the number of octaves to process */
  65198. octaves: number;
  65199. /** Defines the level of persistence (0.8 by default) */
  65200. persistence: number;
  65201. /** Gets or sets animation speed factor (default is 1) */
  65202. animationSpeedFactor: number;
  65203. /**
  65204. * Creates a new NoiseProceduralTexture
  65205. * @param name defines the name fo the texture
  65206. * @param size defines the size of the texture (default is 256)
  65207. * @param scene defines the hosting scene
  65208. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65209. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65210. */
  65211. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65212. private _updateShaderUniforms;
  65213. protected _getDefines(): string;
  65214. /** Generate the current state of the procedural texture */
  65215. render(useCameraPostProcess?: boolean): void;
  65216. /**
  65217. * Serializes this noise procedural texture
  65218. * @returns a serialized noise procedural texture object
  65219. */
  65220. serialize(): any;
  65221. /**
  65222. * Clone the texture.
  65223. * @returns the cloned texture
  65224. */
  65225. clone(): NoiseProceduralTexture;
  65226. /**
  65227. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65228. * @param parsedTexture defines parsed texture data
  65229. * @param scene defines the current scene
  65230. * @param rootUrl defines the root URL containing noise procedural texture information
  65231. * @returns a parsed NoiseProceduralTexture
  65232. */
  65233. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65234. }
  65235. }
  65236. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65237. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65238. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65239. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65240. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65241. }
  65242. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65243. import { Nullable } from "babylonjs/types";
  65244. import { Scene } from "babylonjs/scene";
  65245. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65246. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65247. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65248. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65249. /**
  65250. * Raw cube texture where the raw buffers are passed in
  65251. */
  65252. export class RawCubeTexture extends CubeTexture {
  65253. /**
  65254. * Creates a cube texture where the raw buffers are passed in.
  65255. * @param scene defines the scene the texture is attached to
  65256. * @param data defines the array of data to use to create each face
  65257. * @param size defines the size of the textures
  65258. * @param format defines the format of the data
  65259. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65260. * @param generateMipMaps defines if the engine should generate the mip levels
  65261. * @param invertY defines if data must be stored with Y axis inverted
  65262. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65263. * @param compression defines the compression used (null by default)
  65264. */
  65265. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65266. /**
  65267. * Updates the raw cube texture.
  65268. * @param data defines the data to store
  65269. * @param format defines the data format
  65270. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65271. * @param invertY defines if data must be stored with Y axis inverted
  65272. * @param compression defines the compression used (null by default)
  65273. * @param level defines which level of the texture to update
  65274. */
  65275. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65276. /**
  65277. * Updates a raw cube texture with RGBD encoded data.
  65278. * @param data defines the array of data [mipmap][face] to use to create each face
  65279. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65280. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65281. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65282. * @returns a promsie that resolves when the operation is complete
  65283. */
  65284. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65285. /**
  65286. * Clones the raw cube texture.
  65287. * @return a new cube texture
  65288. */
  65289. clone(): CubeTexture;
  65290. /** @hidden */
  65291. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65292. }
  65293. }
  65294. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65295. import { Scene } from "babylonjs/scene";
  65296. import { Texture } from "babylonjs/Materials/Textures/texture";
  65297. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65298. /**
  65299. * Class used to store 2D array textures containing user data
  65300. */
  65301. export class RawTexture2DArray extends Texture {
  65302. /** Gets or sets the texture format to use */
  65303. format: number;
  65304. /**
  65305. * Create a new RawTexture2DArray
  65306. * @param data defines the data of the texture
  65307. * @param width defines the width of the texture
  65308. * @param height defines the height of the texture
  65309. * @param depth defines the number of layers of the texture
  65310. * @param format defines the texture format to use
  65311. * @param scene defines the hosting scene
  65312. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65313. * @param invertY defines if texture must be stored with Y axis inverted
  65314. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65315. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65316. */
  65317. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65318. /** Gets or sets the texture format to use */
  65319. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65320. /**
  65321. * Update the texture with new data
  65322. * @param data defines the data to store in the texture
  65323. */
  65324. update(data: ArrayBufferView): void;
  65325. }
  65326. }
  65327. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65328. import { Scene } from "babylonjs/scene";
  65329. import { Texture } from "babylonjs/Materials/Textures/texture";
  65330. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65331. /**
  65332. * Class used to store 3D textures containing user data
  65333. */
  65334. export class RawTexture3D extends Texture {
  65335. /** Gets or sets the texture format to use */
  65336. format: number;
  65337. /**
  65338. * Create a new RawTexture3D
  65339. * @param data defines the data of the texture
  65340. * @param width defines the width of the texture
  65341. * @param height defines the height of the texture
  65342. * @param depth defines the depth of the texture
  65343. * @param format defines the texture format to use
  65344. * @param scene defines the hosting scene
  65345. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65346. * @param invertY defines if texture must be stored with Y axis inverted
  65347. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65348. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65349. */
  65350. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65351. /** Gets or sets the texture format to use */
  65352. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65353. /**
  65354. * Update the texture with new data
  65355. * @param data defines the data to store in the texture
  65356. */
  65357. update(data: ArrayBufferView): void;
  65358. }
  65359. }
  65360. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65361. import { Scene } from "babylonjs/scene";
  65362. import { Plane } from "babylonjs/Maths/math.plane";
  65363. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65364. /**
  65365. * Creates a refraction texture used by refraction channel of the standard material.
  65366. * It is like a mirror but to see through a material.
  65367. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65368. */
  65369. export class RefractionTexture extends RenderTargetTexture {
  65370. /**
  65371. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65372. * 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.
  65373. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65374. */
  65375. refractionPlane: Plane;
  65376. /**
  65377. * Define how deep under the surface we should see.
  65378. */
  65379. depth: number;
  65380. /**
  65381. * Creates a refraction texture used by refraction channel of the standard material.
  65382. * It is like a mirror but to see through a material.
  65383. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65384. * @param name Define the texture name
  65385. * @param size Define the size of the underlying texture
  65386. * @param scene Define the scene the refraction belongs to
  65387. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65388. */
  65389. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65390. /**
  65391. * Clone the refraction texture.
  65392. * @returns the cloned texture
  65393. */
  65394. clone(): RefractionTexture;
  65395. /**
  65396. * Serialize the texture to a JSON representation you could use in Parse later on
  65397. * @returns the serialized JSON representation
  65398. */
  65399. serialize(): any;
  65400. }
  65401. }
  65402. declare module "babylonjs/Materials/Textures/index" {
  65403. export * from "babylonjs/Materials/Textures/baseTexture";
  65404. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65405. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65406. export * from "babylonjs/Materials/Textures/cubeTexture";
  65407. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65408. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65409. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65410. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65411. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65412. export * from "babylonjs/Materials/Textures/internalTexture";
  65413. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65414. export * from "babylonjs/Materials/Textures/Loaders/index";
  65415. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65416. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65417. export * from "babylonjs/Materials/Textures/Packer/index";
  65418. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65419. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65420. export * from "babylonjs/Materials/Textures/rawTexture";
  65421. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65422. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65423. export * from "babylonjs/Materials/Textures/refractionTexture";
  65424. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65425. export * from "babylonjs/Materials/Textures/texture";
  65426. export * from "babylonjs/Materials/Textures/videoTexture";
  65427. }
  65428. declare module "babylonjs/Materials/Node/Enums/index" {
  65429. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65430. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65431. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65432. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65433. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65434. }
  65435. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65439. import { Mesh } from "babylonjs/Meshes/mesh";
  65440. import { Effect } from "babylonjs/Materials/effect";
  65441. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65442. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65443. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65444. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65445. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65446. /**
  65447. * Block used to add support for vertex skinning (bones)
  65448. */
  65449. export class BonesBlock extends NodeMaterialBlock {
  65450. /**
  65451. * Creates a new BonesBlock
  65452. * @param name defines the block name
  65453. */
  65454. constructor(name: string);
  65455. /**
  65456. * Initialize the block and prepare the context for build
  65457. * @param state defines the state that will be used for the build
  65458. */
  65459. initialize(state: NodeMaterialBuildState): void;
  65460. /**
  65461. * Gets the current class name
  65462. * @returns the class name
  65463. */
  65464. getClassName(): string;
  65465. /**
  65466. * Gets the matrix indices input component
  65467. */
  65468. get matricesIndices(): NodeMaterialConnectionPoint;
  65469. /**
  65470. * Gets the matrix weights input component
  65471. */
  65472. get matricesWeights(): NodeMaterialConnectionPoint;
  65473. /**
  65474. * Gets the extra matrix indices input component
  65475. */
  65476. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65477. /**
  65478. * Gets the extra matrix weights input component
  65479. */
  65480. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65481. /**
  65482. * Gets the world input component
  65483. */
  65484. get world(): NodeMaterialConnectionPoint;
  65485. /**
  65486. * Gets the output component
  65487. */
  65488. get output(): NodeMaterialConnectionPoint;
  65489. autoConfigure(material: NodeMaterial): void;
  65490. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65491. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65492. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65493. protected _buildBlock(state: NodeMaterialBuildState): this;
  65494. }
  65495. }
  65496. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65497. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65501. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65502. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65503. /**
  65504. * Block used to add support for instances
  65505. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65506. */
  65507. export class InstancesBlock extends NodeMaterialBlock {
  65508. /**
  65509. * Creates a new InstancesBlock
  65510. * @param name defines the block name
  65511. */
  65512. constructor(name: string);
  65513. /**
  65514. * Gets the current class name
  65515. * @returns the class name
  65516. */
  65517. getClassName(): string;
  65518. /**
  65519. * Gets the first world row input component
  65520. */
  65521. get world0(): NodeMaterialConnectionPoint;
  65522. /**
  65523. * Gets the second world row input component
  65524. */
  65525. get world1(): NodeMaterialConnectionPoint;
  65526. /**
  65527. * Gets the third world row input component
  65528. */
  65529. get world2(): NodeMaterialConnectionPoint;
  65530. /**
  65531. * Gets the forth world row input component
  65532. */
  65533. get world3(): NodeMaterialConnectionPoint;
  65534. /**
  65535. * Gets the world input component
  65536. */
  65537. get world(): NodeMaterialConnectionPoint;
  65538. /**
  65539. * Gets the output component
  65540. */
  65541. get output(): NodeMaterialConnectionPoint;
  65542. /**
  65543. * Gets the isntanceID component
  65544. */
  65545. get instanceID(): NodeMaterialConnectionPoint;
  65546. autoConfigure(material: NodeMaterial): void;
  65547. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65548. protected _buildBlock(state: NodeMaterialBuildState): this;
  65549. }
  65550. }
  65551. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65556. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65557. import { Effect } from "babylonjs/Materials/effect";
  65558. import { Mesh } from "babylonjs/Meshes/mesh";
  65559. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65560. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65561. /**
  65562. * Block used to add morph targets support to vertex shader
  65563. */
  65564. export class MorphTargetsBlock extends NodeMaterialBlock {
  65565. private _repeatableContentAnchor;
  65566. /**
  65567. * Create a new MorphTargetsBlock
  65568. * @param name defines the block name
  65569. */
  65570. constructor(name: string);
  65571. /**
  65572. * Gets the current class name
  65573. * @returns the class name
  65574. */
  65575. getClassName(): string;
  65576. /**
  65577. * Gets the position input component
  65578. */
  65579. get position(): NodeMaterialConnectionPoint;
  65580. /**
  65581. * Gets the normal input component
  65582. */
  65583. get normal(): NodeMaterialConnectionPoint;
  65584. /**
  65585. * Gets the tangent input component
  65586. */
  65587. get tangent(): NodeMaterialConnectionPoint;
  65588. /**
  65589. * Gets the tangent input component
  65590. */
  65591. get uv(): NodeMaterialConnectionPoint;
  65592. /**
  65593. * Gets the position output component
  65594. */
  65595. get positionOutput(): NodeMaterialConnectionPoint;
  65596. /**
  65597. * Gets the normal output component
  65598. */
  65599. get normalOutput(): NodeMaterialConnectionPoint;
  65600. /**
  65601. * Gets the tangent output component
  65602. */
  65603. get tangentOutput(): NodeMaterialConnectionPoint;
  65604. /**
  65605. * Gets the tangent output component
  65606. */
  65607. get uvOutput(): NodeMaterialConnectionPoint;
  65608. initialize(state: NodeMaterialBuildState): void;
  65609. autoConfigure(material: NodeMaterial): void;
  65610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65611. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65612. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65613. protected _buildBlock(state: NodeMaterialBuildState): this;
  65614. }
  65615. }
  65616. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65617. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65618. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65619. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65620. import { Nullable } from "babylonjs/types";
  65621. import { Scene } from "babylonjs/scene";
  65622. import { Effect } from "babylonjs/Materials/effect";
  65623. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65624. import { Mesh } from "babylonjs/Meshes/mesh";
  65625. import { Light } from "babylonjs/Lights/light";
  65626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65627. /**
  65628. * Block used to get data information from a light
  65629. */
  65630. export class LightInformationBlock extends NodeMaterialBlock {
  65631. private _lightDataUniformName;
  65632. private _lightColorUniformName;
  65633. private _lightTypeDefineName;
  65634. /**
  65635. * Gets or sets the light associated with this block
  65636. */
  65637. light: Nullable<Light>;
  65638. /**
  65639. * Creates a new LightInformationBlock
  65640. * @param name defines the block name
  65641. */
  65642. constructor(name: string);
  65643. /**
  65644. * Gets the current class name
  65645. * @returns the class name
  65646. */
  65647. getClassName(): string;
  65648. /**
  65649. * Gets the world position input component
  65650. */
  65651. get worldPosition(): NodeMaterialConnectionPoint;
  65652. /**
  65653. * Gets the direction output component
  65654. */
  65655. get direction(): NodeMaterialConnectionPoint;
  65656. /**
  65657. * Gets the direction output component
  65658. */
  65659. get color(): NodeMaterialConnectionPoint;
  65660. /**
  65661. * Gets the direction output component
  65662. */
  65663. get intensity(): NodeMaterialConnectionPoint;
  65664. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65666. protected _buildBlock(state: NodeMaterialBuildState): this;
  65667. serialize(): any;
  65668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65669. }
  65670. }
  65671. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65672. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65673. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65674. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65675. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65676. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65677. }
  65678. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65683. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65684. import { Effect } from "babylonjs/Materials/effect";
  65685. import { Mesh } from "babylonjs/Meshes/mesh";
  65686. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65687. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65688. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65689. /**
  65690. * Block used to add image processing support to fragment shader
  65691. */
  65692. export class ImageProcessingBlock extends NodeMaterialBlock {
  65693. /**
  65694. * Create a new ImageProcessingBlock
  65695. * @param name defines the block name
  65696. */
  65697. constructor(name: string);
  65698. /**
  65699. * Gets the current class name
  65700. * @returns the class name
  65701. */
  65702. getClassName(): string;
  65703. /**
  65704. * Gets the color input component
  65705. */
  65706. get color(): NodeMaterialConnectionPoint;
  65707. /**
  65708. * Gets the output component
  65709. */
  65710. get output(): NodeMaterialConnectionPoint;
  65711. /**
  65712. * Initialize the block and prepare the context for build
  65713. * @param state defines the state that will be used for the build
  65714. */
  65715. initialize(state: NodeMaterialBuildState): void;
  65716. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65717. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65718. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65719. protected _buildBlock(state: NodeMaterialBuildState): this;
  65720. }
  65721. }
  65722. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65726. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65728. import { Effect } from "babylonjs/Materials/effect";
  65729. import { Mesh } from "babylonjs/Meshes/mesh";
  65730. import { Scene } from "babylonjs/scene";
  65731. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65732. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65733. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65734. /**
  65735. * Block used to pertub normals based on a normal map
  65736. */
  65737. export class PerturbNormalBlock extends NodeMaterialBlock {
  65738. private _tangentSpaceParameterName;
  65739. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65740. invertX: boolean;
  65741. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65742. invertY: boolean;
  65743. /**
  65744. * Create a new PerturbNormalBlock
  65745. * @param name defines the block name
  65746. */
  65747. constructor(name: string);
  65748. /**
  65749. * Gets the current class name
  65750. * @returns the class name
  65751. */
  65752. getClassName(): string;
  65753. /**
  65754. * Gets the world position input component
  65755. */
  65756. get worldPosition(): NodeMaterialConnectionPoint;
  65757. /**
  65758. * Gets the world normal input component
  65759. */
  65760. get worldNormal(): NodeMaterialConnectionPoint;
  65761. /**
  65762. * Gets the world tangent input component
  65763. */
  65764. get worldTangent(): NodeMaterialConnectionPoint;
  65765. /**
  65766. * Gets the uv input component
  65767. */
  65768. get uv(): NodeMaterialConnectionPoint;
  65769. /**
  65770. * Gets the normal map color input component
  65771. */
  65772. get normalMapColor(): NodeMaterialConnectionPoint;
  65773. /**
  65774. * Gets the strength input component
  65775. */
  65776. get strength(): NodeMaterialConnectionPoint;
  65777. /**
  65778. * Gets the output component
  65779. */
  65780. get output(): NodeMaterialConnectionPoint;
  65781. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65782. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65783. autoConfigure(material: NodeMaterial): void;
  65784. protected _buildBlock(state: NodeMaterialBuildState): this;
  65785. protected _dumpPropertiesCode(): string;
  65786. serialize(): any;
  65787. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65788. }
  65789. }
  65790. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65794. /**
  65795. * Block used to discard a pixel if a value is smaller than a cutoff
  65796. */
  65797. export class DiscardBlock extends NodeMaterialBlock {
  65798. /**
  65799. * Create a new DiscardBlock
  65800. * @param name defines the block name
  65801. */
  65802. constructor(name: string);
  65803. /**
  65804. * Gets the current class name
  65805. * @returns the class name
  65806. */
  65807. getClassName(): string;
  65808. /**
  65809. * Gets the color input component
  65810. */
  65811. get value(): NodeMaterialConnectionPoint;
  65812. /**
  65813. * Gets the cutoff input component
  65814. */
  65815. get cutoff(): NodeMaterialConnectionPoint;
  65816. protected _buildBlock(state: NodeMaterialBuildState): this;
  65817. }
  65818. }
  65819. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65820. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65821. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65822. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65823. /**
  65824. * Block used to test if the fragment shader is front facing
  65825. */
  65826. export class FrontFacingBlock extends NodeMaterialBlock {
  65827. /**
  65828. * Creates a new FrontFacingBlock
  65829. * @param name defines the block name
  65830. */
  65831. constructor(name: string);
  65832. /**
  65833. * Gets the current class name
  65834. * @returns the class name
  65835. */
  65836. getClassName(): string;
  65837. /**
  65838. * Gets the output component
  65839. */
  65840. get output(): NodeMaterialConnectionPoint;
  65841. protected _buildBlock(state: NodeMaterialBuildState): this;
  65842. }
  65843. }
  65844. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65845. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65846. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65847. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65848. /**
  65849. * Block used to get the derivative value on x and y of a given input
  65850. */
  65851. export class DerivativeBlock extends NodeMaterialBlock {
  65852. /**
  65853. * Create a new DerivativeBlock
  65854. * @param name defines the block name
  65855. */
  65856. constructor(name: string);
  65857. /**
  65858. * Gets the current class name
  65859. * @returns the class name
  65860. */
  65861. getClassName(): string;
  65862. /**
  65863. * Gets the input component
  65864. */
  65865. get input(): NodeMaterialConnectionPoint;
  65866. /**
  65867. * Gets the derivative output on x
  65868. */
  65869. get dx(): NodeMaterialConnectionPoint;
  65870. /**
  65871. * Gets the derivative output on y
  65872. */
  65873. get dy(): NodeMaterialConnectionPoint;
  65874. protected _buildBlock(state: NodeMaterialBuildState): this;
  65875. }
  65876. }
  65877. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65881. /**
  65882. * Block used to make gl_FragCoord available
  65883. */
  65884. export class FragCoordBlock extends NodeMaterialBlock {
  65885. /**
  65886. * Creates a new FragCoordBlock
  65887. * @param name defines the block name
  65888. */
  65889. constructor(name: string);
  65890. /**
  65891. * Gets the current class name
  65892. * @returns the class name
  65893. */
  65894. getClassName(): string;
  65895. /**
  65896. * Gets the xy component
  65897. */
  65898. get xy(): NodeMaterialConnectionPoint;
  65899. /**
  65900. * Gets the xyz component
  65901. */
  65902. get xyz(): NodeMaterialConnectionPoint;
  65903. /**
  65904. * Gets the xyzw component
  65905. */
  65906. get xyzw(): NodeMaterialConnectionPoint;
  65907. /**
  65908. * Gets the x component
  65909. */
  65910. get x(): NodeMaterialConnectionPoint;
  65911. /**
  65912. * Gets the y component
  65913. */
  65914. get y(): NodeMaterialConnectionPoint;
  65915. /**
  65916. * Gets the z component
  65917. */
  65918. get z(): NodeMaterialConnectionPoint;
  65919. /**
  65920. * Gets the w component
  65921. */
  65922. get output(): NodeMaterialConnectionPoint;
  65923. protected writeOutputs(state: NodeMaterialBuildState): string;
  65924. protected _buildBlock(state: NodeMaterialBuildState): this;
  65925. }
  65926. }
  65927. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65928. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65929. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65930. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65931. import { Effect } from "babylonjs/Materials/effect";
  65932. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65933. import { Mesh } from "babylonjs/Meshes/mesh";
  65934. /**
  65935. * Block used to get the screen sizes
  65936. */
  65937. export class ScreenSizeBlock extends NodeMaterialBlock {
  65938. private _varName;
  65939. private _scene;
  65940. /**
  65941. * Creates a new ScreenSizeBlock
  65942. * @param name defines the block name
  65943. */
  65944. constructor(name: string);
  65945. /**
  65946. * Gets the current class name
  65947. * @returns the class name
  65948. */
  65949. getClassName(): string;
  65950. /**
  65951. * Gets the xy component
  65952. */
  65953. get xy(): NodeMaterialConnectionPoint;
  65954. /**
  65955. * Gets the x component
  65956. */
  65957. get x(): NodeMaterialConnectionPoint;
  65958. /**
  65959. * Gets the y component
  65960. */
  65961. get y(): NodeMaterialConnectionPoint;
  65962. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65963. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65964. protected _buildBlock(state: NodeMaterialBuildState): this;
  65965. }
  65966. }
  65967. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65968. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65969. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65970. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65971. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65972. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65973. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65974. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65975. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65976. }
  65977. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65980. import { Mesh } from "babylonjs/Meshes/mesh";
  65981. import { Effect } from "babylonjs/Materials/effect";
  65982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65984. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65985. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65986. /**
  65987. * Block used to add support for scene fog
  65988. */
  65989. export class FogBlock extends NodeMaterialBlock {
  65990. private _fogDistanceName;
  65991. private _fogParameters;
  65992. /**
  65993. * Create a new FogBlock
  65994. * @param name defines the block name
  65995. */
  65996. constructor(name: string);
  65997. /**
  65998. * Gets the current class name
  65999. * @returns the class name
  66000. */
  66001. getClassName(): string;
  66002. /**
  66003. * Gets the world position input component
  66004. */
  66005. get worldPosition(): NodeMaterialConnectionPoint;
  66006. /**
  66007. * Gets the view input component
  66008. */
  66009. get view(): NodeMaterialConnectionPoint;
  66010. /**
  66011. * Gets the color input component
  66012. */
  66013. get input(): NodeMaterialConnectionPoint;
  66014. /**
  66015. * Gets the fog color input component
  66016. */
  66017. get fogColor(): NodeMaterialConnectionPoint;
  66018. /**
  66019. * Gets the output component
  66020. */
  66021. get output(): NodeMaterialConnectionPoint;
  66022. autoConfigure(material: NodeMaterial): void;
  66023. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66024. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66025. protected _buildBlock(state: NodeMaterialBuildState): this;
  66026. }
  66027. }
  66028. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66033. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66034. import { Effect } from "babylonjs/Materials/effect";
  66035. import { Mesh } from "babylonjs/Meshes/mesh";
  66036. import { Light } from "babylonjs/Lights/light";
  66037. import { Nullable } from "babylonjs/types";
  66038. import { Scene } from "babylonjs/scene";
  66039. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66040. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66041. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66042. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66043. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66044. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66045. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66046. /**
  66047. * Block used to add light in the fragment shader
  66048. */
  66049. export class LightBlock extends NodeMaterialBlock {
  66050. private _lightId;
  66051. /**
  66052. * Gets or sets the light associated with this block
  66053. */
  66054. light: Nullable<Light>;
  66055. /**
  66056. * Create a new LightBlock
  66057. * @param name defines the block name
  66058. */
  66059. constructor(name: string);
  66060. /**
  66061. * Gets the current class name
  66062. * @returns the class name
  66063. */
  66064. getClassName(): string;
  66065. /**
  66066. * Gets the world position input component
  66067. */
  66068. get worldPosition(): NodeMaterialConnectionPoint;
  66069. /**
  66070. * Gets the world normal input component
  66071. */
  66072. get worldNormal(): NodeMaterialConnectionPoint;
  66073. /**
  66074. * Gets the camera (or eye) position component
  66075. */
  66076. get cameraPosition(): NodeMaterialConnectionPoint;
  66077. /**
  66078. * Gets the glossiness component
  66079. */
  66080. get glossiness(): NodeMaterialConnectionPoint;
  66081. /**
  66082. * Gets the glossinness power component
  66083. */
  66084. get glossPower(): NodeMaterialConnectionPoint;
  66085. /**
  66086. * Gets the diffuse color component
  66087. */
  66088. get diffuseColor(): NodeMaterialConnectionPoint;
  66089. /**
  66090. * Gets the specular color component
  66091. */
  66092. get specularColor(): NodeMaterialConnectionPoint;
  66093. /**
  66094. * Gets the diffuse output component
  66095. */
  66096. get diffuseOutput(): NodeMaterialConnectionPoint;
  66097. /**
  66098. * Gets the specular output component
  66099. */
  66100. get specularOutput(): NodeMaterialConnectionPoint;
  66101. /**
  66102. * Gets the shadow output component
  66103. */
  66104. get shadow(): NodeMaterialConnectionPoint;
  66105. autoConfigure(material: NodeMaterial): void;
  66106. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66107. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66108. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66109. private _injectVertexCode;
  66110. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66111. serialize(): any;
  66112. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66113. }
  66114. }
  66115. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66116. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66117. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66118. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66119. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66120. /**
  66121. * Block used to read a reflection texture from a sampler
  66122. */
  66123. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66124. /**
  66125. * Create a new ReflectionTextureBlock
  66126. * @param name defines the block name
  66127. */
  66128. constructor(name: string);
  66129. /**
  66130. * Gets the current class name
  66131. * @returns the class name
  66132. */
  66133. getClassName(): string;
  66134. /**
  66135. * Gets the world position input component
  66136. */
  66137. get position(): NodeMaterialConnectionPoint;
  66138. /**
  66139. * Gets the world position input component
  66140. */
  66141. get worldPosition(): NodeMaterialConnectionPoint;
  66142. /**
  66143. * Gets the world normal input component
  66144. */
  66145. get worldNormal(): NodeMaterialConnectionPoint;
  66146. /**
  66147. * Gets the world input component
  66148. */
  66149. get world(): NodeMaterialConnectionPoint;
  66150. /**
  66151. * Gets the camera (or eye) position component
  66152. */
  66153. get cameraPosition(): NodeMaterialConnectionPoint;
  66154. /**
  66155. * Gets the view input component
  66156. */
  66157. get view(): NodeMaterialConnectionPoint;
  66158. /**
  66159. * Gets the rgb output component
  66160. */
  66161. get rgb(): NodeMaterialConnectionPoint;
  66162. /**
  66163. * Gets the rgba output component
  66164. */
  66165. get rgba(): NodeMaterialConnectionPoint;
  66166. /**
  66167. * Gets the r output component
  66168. */
  66169. get r(): NodeMaterialConnectionPoint;
  66170. /**
  66171. * Gets the g output component
  66172. */
  66173. get g(): NodeMaterialConnectionPoint;
  66174. /**
  66175. * Gets the b output component
  66176. */
  66177. get b(): NodeMaterialConnectionPoint;
  66178. /**
  66179. * Gets the a output component
  66180. */
  66181. get a(): NodeMaterialConnectionPoint;
  66182. autoConfigure(material: NodeMaterial): void;
  66183. protected _buildBlock(state: NodeMaterialBuildState): this;
  66184. }
  66185. }
  66186. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66187. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66188. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66189. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66190. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66191. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66192. }
  66193. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66194. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66195. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66196. }
  66197. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66201. /**
  66202. * Block used to add 2 vectors
  66203. */
  66204. export class AddBlock extends NodeMaterialBlock {
  66205. /**
  66206. * Creates a new AddBlock
  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 left operand input component
  66217. */
  66218. get left(): NodeMaterialConnectionPoint;
  66219. /**
  66220. * Gets the right operand input component
  66221. */
  66222. get right(): NodeMaterialConnectionPoint;
  66223. /**
  66224. * Gets the output component
  66225. */
  66226. get output(): NodeMaterialConnectionPoint;
  66227. protected _buildBlock(state: NodeMaterialBuildState): this;
  66228. }
  66229. }
  66230. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66234. /**
  66235. * Block used to scale a vector by a float
  66236. */
  66237. export class ScaleBlock extends NodeMaterialBlock {
  66238. /**
  66239. * Creates a new ScaleBlock
  66240. * @param name defines the block name
  66241. */
  66242. constructor(name: string);
  66243. /**
  66244. * Gets the current class name
  66245. * @returns the class name
  66246. */
  66247. getClassName(): string;
  66248. /**
  66249. * Gets the input component
  66250. */
  66251. get input(): NodeMaterialConnectionPoint;
  66252. /**
  66253. * Gets the factor input component
  66254. */
  66255. get factor(): NodeMaterialConnectionPoint;
  66256. /**
  66257. * Gets the output component
  66258. */
  66259. get output(): NodeMaterialConnectionPoint;
  66260. protected _buildBlock(state: NodeMaterialBuildState): this;
  66261. }
  66262. }
  66263. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66267. import { Scene } from "babylonjs/scene";
  66268. /**
  66269. * Block used to clamp a float
  66270. */
  66271. export class ClampBlock extends NodeMaterialBlock {
  66272. /** Gets or sets the minimum range */
  66273. minimum: number;
  66274. /** Gets or sets the maximum range */
  66275. maximum: number;
  66276. /**
  66277. * Creates a new ClampBlock
  66278. * @param name defines the block name
  66279. */
  66280. constructor(name: string);
  66281. /**
  66282. * Gets the current class name
  66283. * @returns the class name
  66284. */
  66285. getClassName(): string;
  66286. /**
  66287. * Gets the value input component
  66288. */
  66289. get value(): NodeMaterialConnectionPoint;
  66290. /**
  66291. * Gets the output component
  66292. */
  66293. get output(): NodeMaterialConnectionPoint;
  66294. protected _buildBlock(state: NodeMaterialBuildState): this;
  66295. protected _dumpPropertiesCode(): string;
  66296. serialize(): any;
  66297. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66298. }
  66299. }
  66300. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66304. /**
  66305. * Block used to apply a cross product between 2 vectors
  66306. */
  66307. export class CrossBlock extends NodeMaterialBlock {
  66308. /**
  66309. * Creates a new CrossBlock
  66310. * @param name defines the block name
  66311. */
  66312. constructor(name: string);
  66313. /**
  66314. * Gets the current class name
  66315. * @returns the class name
  66316. */
  66317. getClassName(): string;
  66318. /**
  66319. * Gets the left operand input component
  66320. */
  66321. get left(): NodeMaterialConnectionPoint;
  66322. /**
  66323. * Gets the right operand input component
  66324. */
  66325. get right(): NodeMaterialConnectionPoint;
  66326. /**
  66327. * Gets the output component
  66328. */
  66329. get output(): NodeMaterialConnectionPoint;
  66330. protected _buildBlock(state: NodeMaterialBuildState): this;
  66331. }
  66332. }
  66333. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66337. /**
  66338. * Block used to apply a dot product between 2 vectors
  66339. */
  66340. export class DotBlock extends NodeMaterialBlock {
  66341. /**
  66342. * Creates a new DotBlock
  66343. * @param name defines the block name
  66344. */
  66345. constructor(name: string);
  66346. /**
  66347. * Gets the current class name
  66348. * @returns the class name
  66349. */
  66350. getClassName(): string;
  66351. /**
  66352. * Gets the left operand input component
  66353. */
  66354. get left(): NodeMaterialConnectionPoint;
  66355. /**
  66356. * Gets the right operand input component
  66357. */
  66358. get right(): NodeMaterialConnectionPoint;
  66359. /**
  66360. * Gets the output component
  66361. */
  66362. get output(): NodeMaterialConnectionPoint;
  66363. protected _buildBlock(state: NodeMaterialBuildState): this;
  66364. }
  66365. }
  66366. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66370. /**
  66371. * Block used to normalize a vector
  66372. */
  66373. export class NormalizeBlock extends NodeMaterialBlock {
  66374. /**
  66375. * Creates a new NormalizeBlock
  66376. * @param name defines the block name
  66377. */
  66378. constructor(name: string);
  66379. /**
  66380. * Gets the current class name
  66381. * @returns the class name
  66382. */
  66383. getClassName(): string;
  66384. /**
  66385. * Gets the input component
  66386. */
  66387. get input(): NodeMaterialConnectionPoint;
  66388. /**
  66389. * Gets the output component
  66390. */
  66391. get output(): NodeMaterialConnectionPoint;
  66392. protected _buildBlock(state: NodeMaterialBuildState): this;
  66393. }
  66394. }
  66395. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66396. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66397. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66398. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66399. /**
  66400. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66401. */
  66402. export class ColorMergerBlock extends NodeMaterialBlock {
  66403. /**
  66404. * Create a new ColorMergerBlock
  66405. * @param name defines the block name
  66406. */
  66407. constructor(name: string);
  66408. /**
  66409. * Gets the current class name
  66410. * @returns the class name
  66411. */
  66412. getClassName(): string;
  66413. /**
  66414. * Gets the rgb component (input)
  66415. */
  66416. get rgbIn(): NodeMaterialConnectionPoint;
  66417. /**
  66418. * Gets the r component (input)
  66419. */
  66420. get r(): NodeMaterialConnectionPoint;
  66421. /**
  66422. * Gets the g component (input)
  66423. */
  66424. get g(): NodeMaterialConnectionPoint;
  66425. /**
  66426. * Gets the b component (input)
  66427. */
  66428. get b(): NodeMaterialConnectionPoint;
  66429. /**
  66430. * Gets the a component (input)
  66431. */
  66432. get a(): NodeMaterialConnectionPoint;
  66433. /**
  66434. * Gets the rgba component (output)
  66435. */
  66436. get rgba(): NodeMaterialConnectionPoint;
  66437. /**
  66438. * Gets the rgb component (output)
  66439. */
  66440. get rgbOut(): NodeMaterialConnectionPoint;
  66441. /**
  66442. * Gets the rgb component (output)
  66443. * @deprecated Please use rgbOut instead.
  66444. */
  66445. get rgb(): NodeMaterialConnectionPoint;
  66446. protected _buildBlock(state: NodeMaterialBuildState): this;
  66447. }
  66448. }
  66449. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66453. /**
  66454. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66455. */
  66456. export class VectorSplitterBlock extends NodeMaterialBlock {
  66457. /**
  66458. * Create a new VectorSplitterBlock
  66459. * @param name defines the block name
  66460. */
  66461. constructor(name: string);
  66462. /**
  66463. * Gets the current class name
  66464. * @returns the class name
  66465. */
  66466. getClassName(): string;
  66467. /**
  66468. * Gets the xyzw component (input)
  66469. */
  66470. get xyzw(): NodeMaterialConnectionPoint;
  66471. /**
  66472. * Gets the xyz component (input)
  66473. */
  66474. get xyzIn(): NodeMaterialConnectionPoint;
  66475. /**
  66476. * Gets the xy component (input)
  66477. */
  66478. get xyIn(): NodeMaterialConnectionPoint;
  66479. /**
  66480. * Gets the xyz component (output)
  66481. */
  66482. get xyzOut(): NodeMaterialConnectionPoint;
  66483. /**
  66484. * Gets the xy component (output)
  66485. */
  66486. get xyOut(): NodeMaterialConnectionPoint;
  66487. /**
  66488. * Gets the x component (output)
  66489. */
  66490. get x(): NodeMaterialConnectionPoint;
  66491. /**
  66492. * Gets the y component (output)
  66493. */
  66494. get y(): NodeMaterialConnectionPoint;
  66495. /**
  66496. * Gets the z component (output)
  66497. */
  66498. get z(): NodeMaterialConnectionPoint;
  66499. /**
  66500. * Gets the w component (output)
  66501. */
  66502. get w(): NodeMaterialConnectionPoint;
  66503. protected _inputRename(name: string): string;
  66504. protected _outputRename(name: string): string;
  66505. protected _buildBlock(state: NodeMaterialBuildState): this;
  66506. }
  66507. }
  66508. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66510. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66511. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66512. /**
  66513. * Block used to lerp between 2 values
  66514. */
  66515. export class LerpBlock extends NodeMaterialBlock {
  66516. /**
  66517. * Creates a new LerpBlock
  66518. * @param name defines the block name
  66519. */
  66520. constructor(name: string);
  66521. /**
  66522. * Gets the current class name
  66523. * @returns the class name
  66524. */
  66525. getClassName(): string;
  66526. /**
  66527. * Gets the left operand input component
  66528. */
  66529. get left(): NodeMaterialConnectionPoint;
  66530. /**
  66531. * Gets the right operand input component
  66532. */
  66533. get right(): NodeMaterialConnectionPoint;
  66534. /**
  66535. * Gets the gradient operand input component
  66536. */
  66537. get gradient(): NodeMaterialConnectionPoint;
  66538. /**
  66539. * Gets the output component
  66540. */
  66541. get output(): NodeMaterialConnectionPoint;
  66542. protected _buildBlock(state: NodeMaterialBuildState): this;
  66543. }
  66544. }
  66545. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66546. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66547. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66548. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66549. /**
  66550. * Block used to divide 2 vectors
  66551. */
  66552. export class DivideBlock extends NodeMaterialBlock {
  66553. /**
  66554. * Creates a new DivideBlock
  66555. * @param name defines the block name
  66556. */
  66557. constructor(name: string);
  66558. /**
  66559. * Gets the current class name
  66560. * @returns the class name
  66561. */
  66562. getClassName(): string;
  66563. /**
  66564. * Gets the left operand input component
  66565. */
  66566. get left(): NodeMaterialConnectionPoint;
  66567. /**
  66568. * Gets the right operand input component
  66569. */
  66570. get right(): NodeMaterialConnectionPoint;
  66571. /**
  66572. * Gets the output component
  66573. */
  66574. get output(): NodeMaterialConnectionPoint;
  66575. protected _buildBlock(state: NodeMaterialBuildState): this;
  66576. }
  66577. }
  66578. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66582. /**
  66583. * Block used to subtract 2 vectors
  66584. */
  66585. export class SubtractBlock extends NodeMaterialBlock {
  66586. /**
  66587. * Creates a new SubtractBlock
  66588. * @param name defines the block name
  66589. */
  66590. constructor(name: string);
  66591. /**
  66592. * Gets the current class name
  66593. * @returns the class name
  66594. */
  66595. getClassName(): string;
  66596. /**
  66597. * Gets the left operand input component
  66598. */
  66599. get left(): NodeMaterialConnectionPoint;
  66600. /**
  66601. * Gets the right operand input component
  66602. */
  66603. get right(): NodeMaterialConnectionPoint;
  66604. /**
  66605. * Gets the output component
  66606. */
  66607. get output(): NodeMaterialConnectionPoint;
  66608. protected _buildBlock(state: NodeMaterialBuildState): this;
  66609. }
  66610. }
  66611. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66615. /**
  66616. * Block used to step a value
  66617. */
  66618. export class StepBlock extends NodeMaterialBlock {
  66619. /**
  66620. * Creates a new StepBlock
  66621. * @param name defines the block name
  66622. */
  66623. constructor(name: string);
  66624. /**
  66625. * Gets the current class name
  66626. * @returns the class name
  66627. */
  66628. getClassName(): string;
  66629. /**
  66630. * Gets the value operand input component
  66631. */
  66632. get value(): NodeMaterialConnectionPoint;
  66633. /**
  66634. * Gets the edge operand input component
  66635. */
  66636. get edge(): NodeMaterialConnectionPoint;
  66637. /**
  66638. * Gets the output component
  66639. */
  66640. get output(): NodeMaterialConnectionPoint;
  66641. protected _buildBlock(state: NodeMaterialBuildState): this;
  66642. }
  66643. }
  66644. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66648. /**
  66649. * Block used to get the opposite (1 - x) of a value
  66650. */
  66651. export class OneMinusBlock extends NodeMaterialBlock {
  66652. /**
  66653. * Creates a new OneMinusBlock
  66654. * @param name defines the block name
  66655. */
  66656. constructor(name: string);
  66657. /**
  66658. * Gets the current class name
  66659. * @returns the class name
  66660. */
  66661. getClassName(): string;
  66662. /**
  66663. * Gets the input component
  66664. */
  66665. get input(): NodeMaterialConnectionPoint;
  66666. /**
  66667. * Gets the output component
  66668. */
  66669. get output(): NodeMaterialConnectionPoint;
  66670. protected _buildBlock(state: NodeMaterialBuildState): this;
  66671. }
  66672. }
  66673. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66674. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66675. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66677. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66678. /**
  66679. * Block used to get the view direction
  66680. */
  66681. export class ViewDirectionBlock extends NodeMaterialBlock {
  66682. /**
  66683. * Creates a new ViewDirectionBlock
  66684. * @param name defines the block name
  66685. */
  66686. constructor(name: string);
  66687. /**
  66688. * Gets the current class name
  66689. * @returns the class name
  66690. */
  66691. getClassName(): string;
  66692. /**
  66693. * Gets the world position component
  66694. */
  66695. get worldPosition(): NodeMaterialConnectionPoint;
  66696. /**
  66697. * Gets the camera position component
  66698. */
  66699. get cameraPosition(): NodeMaterialConnectionPoint;
  66700. /**
  66701. * Gets the output component
  66702. */
  66703. get output(): NodeMaterialConnectionPoint;
  66704. autoConfigure(material: NodeMaterial): void;
  66705. protected _buildBlock(state: NodeMaterialBuildState): this;
  66706. }
  66707. }
  66708. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66710. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66712. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66713. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66714. /**
  66715. * Block used to compute fresnel value
  66716. */
  66717. export class FresnelBlock extends NodeMaterialBlock {
  66718. /**
  66719. * Create a new FresnelBlock
  66720. * @param name defines the block name
  66721. */
  66722. constructor(name: string);
  66723. /**
  66724. * Gets the current class name
  66725. * @returns the class name
  66726. */
  66727. getClassName(): string;
  66728. /**
  66729. * Gets the world normal input component
  66730. */
  66731. get worldNormal(): NodeMaterialConnectionPoint;
  66732. /**
  66733. * Gets the view direction input component
  66734. */
  66735. get viewDirection(): NodeMaterialConnectionPoint;
  66736. /**
  66737. * Gets the bias input component
  66738. */
  66739. get bias(): NodeMaterialConnectionPoint;
  66740. /**
  66741. * Gets the camera (or eye) position component
  66742. */
  66743. get power(): NodeMaterialConnectionPoint;
  66744. /**
  66745. * Gets the fresnel output component
  66746. */
  66747. get fresnel(): NodeMaterialConnectionPoint;
  66748. autoConfigure(material: NodeMaterial): void;
  66749. protected _buildBlock(state: NodeMaterialBuildState): this;
  66750. }
  66751. }
  66752. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66756. /**
  66757. * Block used to get the max of 2 values
  66758. */
  66759. export class MaxBlock extends NodeMaterialBlock {
  66760. /**
  66761. * Creates a new MaxBlock
  66762. * @param name defines the block name
  66763. */
  66764. constructor(name: string);
  66765. /**
  66766. * Gets the current class name
  66767. * @returns the class name
  66768. */
  66769. getClassName(): string;
  66770. /**
  66771. * Gets the left operand input component
  66772. */
  66773. get left(): NodeMaterialConnectionPoint;
  66774. /**
  66775. * Gets the right operand input component
  66776. */
  66777. get right(): NodeMaterialConnectionPoint;
  66778. /**
  66779. * Gets the output component
  66780. */
  66781. get output(): NodeMaterialConnectionPoint;
  66782. protected _buildBlock(state: NodeMaterialBuildState): this;
  66783. }
  66784. }
  66785. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66786. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66787. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66788. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66789. /**
  66790. * Block used to get the min of 2 values
  66791. */
  66792. export class MinBlock extends NodeMaterialBlock {
  66793. /**
  66794. * Creates a new MinBlock
  66795. * @param name defines the block name
  66796. */
  66797. constructor(name: string);
  66798. /**
  66799. * Gets the current class name
  66800. * @returns the class name
  66801. */
  66802. getClassName(): string;
  66803. /**
  66804. * Gets the left operand input component
  66805. */
  66806. get left(): NodeMaterialConnectionPoint;
  66807. /**
  66808. * Gets the right operand input component
  66809. */
  66810. get right(): NodeMaterialConnectionPoint;
  66811. /**
  66812. * Gets the output component
  66813. */
  66814. get output(): NodeMaterialConnectionPoint;
  66815. protected _buildBlock(state: NodeMaterialBuildState): this;
  66816. }
  66817. }
  66818. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66819. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66820. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66821. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66822. /**
  66823. * Block used to get the distance between 2 values
  66824. */
  66825. export class DistanceBlock extends NodeMaterialBlock {
  66826. /**
  66827. * Creates a new DistanceBlock
  66828. * @param name defines the block name
  66829. */
  66830. constructor(name: string);
  66831. /**
  66832. * Gets the current class name
  66833. * @returns the class name
  66834. */
  66835. getClassName(): string;
  66836. /**
  66837. * Gets the left operand input component
  66838. */
  66839. get left(): NodeMaterialConnectionPoint;
  66840. /**
  66841. * Gets the right operand input component
  66842. */
  66843. get right(): NodeMaterialConnectionPoint;
  66844. /**
  66845. * Gets the output component
  66846. */
  66847. get output(): NodeMaterialConnectionPoint;
  66848. protected _buildBlock(state: NodeMaterialBuildState): this;
  66849. }
  66850. }
  66851. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66855. /**
  66856. * Block used to get the length of a vector
  66857. */
  66858. export class LengthBlock extends NodeMaterialBlock {
  66859. /**
  66860. * Creates a new LengthBlock
  66861. * @param name defines the block name
  66862. */
  66863. constructor(name: string);
  66864. /**
  66865. * Gets the current class name
  66866. * @returns the class name
  66867. */
  66868. getClassName(): string;
  66869. /**
  66870. * Gets the value input component
  66871. */
  66872. get value(): NodeMaterialConnectionPoint;
  66873. /**
  66874. * Gets the output component
  66875. */
  66876. get output(): NodeMaterialConnectionPoint;
  66877. protected _buildBlock(state: NodeMaterialBuildState): this;
  66878. }
  66879. }
  66880. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66884. /**
  66885. * Block used to get negative version of a value (i.e. x * -1)
  66886. */
  66887. export class NegateBlock extends NodeMaterialBlock {
  66888. /**
  66889. * Creates a new NegateBlock
  66890. * @param name defines the block name
  66891. */
  66892. constructor(name: string);
  66893. /**
  66894. * Gets the current class name
  66895. * @returns the class name
  66896. */
  66897. getClassName(): string;
  66898. /**
  66899. * Gets the value input component
  66900. */
  66901. get value(): NodeMaterialConnectionPoint;
  66902. /**
  66903. * Gets the output component
  66904. */
  66905. get output(): NodeMaterialConnectionPoint;
  66906. protected _buildBlock(state: NodeMaterialBuildState): this;
  66907. }
  66908. }
  66909. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66910. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66911. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66913. /**
  66914. * Block used to get the value of the first parameter raised to the power of the second
  66915. */
  66916. export class PowBlock extends NodeMaterialBlock {
  66917. /**
  66918. * Creates a new PowBlock
  66919. * @param name defines the block name
  66920. */
  66921. constructor(name: string);
  66922. /**
  66923. * Gets the current class name
  66924. * @returns the class name
  66925. */
  66926. getClassName(): string;
  66927. /**
  66928. * Gets the value operand input component
  66929. */
  66930. get value(): NodeMaterialConnectionPoint;
  66931. /**
  66932. * Gets the power operand input component
  66933. */
  66934. get power(): NodeMaterialConnectionPoint;
  66935. /**
  66936. * Gets the output component
  66937. */
  66938. get output(): NodeMaterialConnectionPoint;
  66939. protected _buildBlock(state: NodeMaterialBuildState): this;
  66940. }
  66941. }
  66942. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66946. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66947. /**
  66948. * Block used to get a random number
  66949. */
  66950. export class RandomNumberBlock extends NodeMaterialBlock {
  66951. /**
  66952. * Creates a new RandomNumberBlock
  66953. * @param name defines the block name
  66954. */
  66955. constructor(name: string);
  66956. /**
  66957. * Gets the current class name
  66958. * @returns the class name
  66959. */
  66960. getClassName(): string;
  66961. /**
  66962. * Gets the seed input component
  66963. */
  66964. get seed(): NodeMaterialConnectionPoint;
  66965. /**
  66966. * Gets the output component
  66967. */
  66968. get output(): NodeMaterialConnectionPoint;
  66969. protected _buildBlock(state: NodeMaterialBuildState): this;
  66970. }
  66971. }
  66972. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66973. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66974. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66976. /**
  66977. * Block used to compute arc tangent of 2 values
  66978. */
  66979. export class ArcTan2Block extends NodeMaterialBlock {
  66980. /**
  66981. * Creates a new ArcTan2Block
  66982. * @param name defines the block name
  66983. */
  66984. constructor(name: string);
  66985. /**
  66986. * Gets the current class name
  66987. * @returns the class name
  66988. */
  66989. getClassName(): string;
  66990. /**
  66991. * Gets the x operand input component
  66992. */
  66993. get x(): NodeMaterialConnectionPoint;
  66994. /**
  66995. * Gets the y operand input component
  66996. */
  66997. get y(): NodeMaterialConnectionPoint;
  66998. /**
  66999. * Gets the output component
  67000. */
  67001. get output(): NodeMaterialConnectionPoint;
  67002. protected _buildBlock(state: NodeMaterialBuildState): this;
  67003. }
  67004. }
  67005. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67006. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67007. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67009. /**
  67010. * Block used to smooth step a value
  67011. */
  67012. export class SmoothStepBlock extends NodeMaterialBlock {
  67013. /**
  67014. * Creates a new SmoothStepBlock
  67015. * @param name defines the block name
  67016. */
  67017. constructor(name: string);
  67018. /**
  67019. * Gets the current class name
  67020. * @returns the class name
  67021. */
  67022. getClassName(): string;
  67023. /**
  67024. * Gets the value operand input component
  67025. */
  67026. get value(): NodeMaterialConnectionPoint;
  67027. /**
  67028. * Gets the first edge operand input component
  67029. */
  67030. get edge0(): NodeMaterialConnectionPoint;
  67031. /**
  67032. * Gets the second edge operand input component
  67033. */
  67034. get edge1(): NodeMaterialConnectionPoint;
  67035. /**
  67036. * Gets the output component
  67037. */
  67038. get output(): NodeMaterialConnectionPoint;
  67039. protected _buildBlock(state: NodeMaterialBuildState): this;
  67040. }
  67041. }
  67042. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67046. /**
  67047. * Block used to get the reciprocal (1 / x) of a value
  67048. */
  67049. export class ReciprocalBlock extends NodeMaterialBlock {
  67050. /**
  67051. * Creates a new ReciprocalBlock
  67052. * @param name defines the block name
  67053. */
  67054. constructor(name: string);
  67055. /**
  67056. * Gets the current class name
  67057. * @returns the class name
  67058. */
  67059. getClassName(): string;
  67060. /**
  67061. * Gets the input component
  67062. */
  67063. get input(): NodeMaterialConnectionPoint;
  67064. /**
  67065. * Gets the output component
  67066. */
  67067. get output(): NodeMaterialConnectionPoint;
  67068. protected _buildBlock(state: NodeMaterialBuildState): this;
  67069. }
  67070. }
  67071. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67075. /**
  67076. * Block used to replace a color by another one
  67077. */
  67078. export class ReplaceColorBlock extends NodeMaterialBlock {
  67079. /**
  67080. * Creates a new ReplaceColorBlock
  67081. * @param name defines the block name
  67082. */
  67083. constructor(name: string);
  67084. /**
  67085. * Gets the current class name
  67086. * @returns the class name
  67087. */
  67088. getClassName(): string;
  67089. /**
  67090. * Gets the value input component
  67091. */
  67092. get value(): NodeMaterialConnectionPoint;
  67093. /**
  67094. * Gets the reference input component
  67095. */
  67096. get reference(): NodeMaterialConnectionPoint;
  67097. /**
  67098. * Gets the distance input component
  67099. */
  67100. get distance(): NodeMaterialConnectionPoint;
  67101. /**
  67102. * Gets the replacement input component
  67103. */
  67104. get replacement(): NodeMaterialConnectionPoint;
  67105. /**
  67106. * Gets the output component
  67107. */
  67108. get output(): NodeMaterialConnectionPoint;
  67109. protected _buildBlock(state: NodeMaterialBuildState): this;
  67110. }
  67111. }
  67112. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67113. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67114. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67116. /**
  67117. * Block used to posterize a value
  67118. * @see https://en.wikipedia.org/wiki/Posterization
  67119. */
  67120. export class PosterizeBlock extends NodeMaterialBlock {
  67121. /**
  67122. * Creates a new PosterizeBlock
  67123. * @param name defines the block name
  67124. */
  67125. constructor(name: string);
  67126. /**
  67127. * Gets the current class name
  67128. * @returns the class name
  67129. */
  67130. getClassName(): string;
  67131. /**
  67132. * Gets the value input component
  67133. */
  67134. get value(): NodeMaterialConnectionPoint;
  67135. /**
  67136. * Gets the steps input component
  67137. */
  67138. get steps(): NodeMaterialConnectionPoint;
  67139. /**
  67140. * Gets the output component
  67141. */
  67142. get output(): NodeMaterialConnectionPoint;
  67143. protected _buildBlock(state: NodeMaterialBuildState): this;
  67144. }
  67145. }
  67146. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67147. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67148. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67149. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67150. import { Scene } from "babylonjs/scene";
  67151. /**
  67152. * Operations supported by the Wave block
  67153. */
  67154. export enum WaveBlockKind {
  67155. /** SawTooth */
  67156. SawTooth = 0,
  67157. /** Square */
  67158. Square = 1,
  67159. /** Triangle */
  67160. Triangle = 2
  67161. }
  67162. /**
  67163. * Block used to apply wave operation to floats
  67164. */
  67165. export class WaveBlock extends NodeMaterialBlock {
  67166. /**
  67167. * Gets or sets the kibnd of wave to be applied by the block
  67168. */
  67169. kind: WaveBlockKind;
  67170. /**
  67171. * Creates a new WaveBlock
  67172. * @param name defines the block name
  67173. */
  67174. constructor(name: string);
  67175. /**
  67176. * Gets the current class name
  67177. * @returns the class name
  67178. */
  67179. getClassName(): string;
  67180. /**
  67181. * Gets the input component
  67182. */
  67183. get input(): NodeMaterialConnectionPoint;
  67184. /**
  67185. * Gets the output component
  67186. */
  67187. get output(): NodeMaterialConnectionPoint;
  67188. protected _buildBlock(state: NodeMaterialBuildState): this;
  67189. serialize(): any;
  67190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67191. }
  67192. }
  67193. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67194. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67195. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67196. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67197. import { Color3 } from "babylonjs/Maths/math.color";
  67198. import { Scene } from "babylonjs/scene";
  67199. import { Observable } from "babylonjs/Misc/observable";
  67200. /**
  67201. * Class used to store a color step for the GradientBlock
  67202. */
  67203. export class GradientBlockColorStep {
  67204. private _step;
  67205. /**
  67206. * Gets value indicating which step this color is associated with (between 0 and 1)
  67207. */
  67208. get step(): number;
  67209. /**
  67210. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67211. */
  67212. set step(val: number);
  67213. private _color;
  67214. /**
  67215. * Gets the color associated with this step
  67216. */
  67217. get color(): Color3;
  67218. /**
  67219. * Sets the color associated with this step
  67220. */
  67221. set color(val: Color3);
  67222. /**
  67223. * Creates a new GradientBlockColorStep
  67224. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67225. * @param color defines the color associated with this step
  67226. */
  67227. constructor(step: number, color: Color3);
  67228. }
  67229. /**
  67230. * Block used to return a color from a gradient based on an input value between 0 and 1
  67231. */
  67232. export class GradientBlock extends NodeMaterialBlock {
  67233. /**
  67234. * Gets or sets the list of color steps
  67235. */
  67236. colorSteps: GradientBlockColorStep[];
  67237. /** Gets an observable raised when the value is changed */
  67238. onValueChangedObservable: Observable<GradientBlock>;
  67239. /** calls observable when the value is changed*/
  67240. colorStepsUpdated(): void;
  67241. /**
  67242. * Creates a new GradientBlock
  67243. * @param name defines the block name
  67244. */
  67245. constructor(name: string);
  67246. /**
  67247. * Gets the current class name
  67248. * @returns the class name
  67249. */
  67250. getClassName(): string;
  67251. /**
  67252. * Gets the gradient input component
  67253. */
  67254. get gradient(): NodeMaterialConnectionPoint;
  67255. /**
  67256. * Gets the output component
  67257. */
  67258. get output(): NodeMaterialConnectionPoint;
  67259. private _writeColorConstant;
  67260. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67261. serialize(): any;
  67262. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67263. protected _dumpPropertiesCode(): string;
  67264. }
  67265. }
  67266. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67267. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67268. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67269. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67270. /**
  67271. * Block used to normalize lerp between 2 values
  67272. */
  67273. export class NLerpBlock extends NodeMaterialBlock {
  67274. /**
  67275. * Creates a new NLerpBlock
  67276. * @param name defines the block name
  67277. */
  67278. constructor(name: string);
  67279. /**
  67280. * Gets the current class name
  67281. * @returns the class name
  67282. */
  67283. getClassName(): string;
  67284. /**
  67285. * Gets the left operand input component
  67286. */
  67287. get left(): NodeMaterialConnectionPoint;
  67288. /**
  67289. * Gets the right operand input component
  67290. */
  67291. get right(): NodeMaterialConnectionPoint;
  67292. /**
  67293. * Gets the gradient operand input component
  67294. */
  67295. get gradient(): NodeMaterialConnectionPoint;
  67296. /**
  67297. * Gets the output component
  67298. */
  67299. get output(): NodeMaterialConnectionPoint;
  67300. protected _buildBlock(state: NodeMaterialBuildState): this;
  67301. }
  67302. }
  67303. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67304. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67305. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67306. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67307. import { Scene } from "babylonjs/scene";
  67308. /**
  67309. * block used to Generate a Worley Noise 3D Noise Pattern
  67310. */
  67311. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67312. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67313. manhattanDistance: boolean;
  67314. /**
  67315. * Creates a new WorleyNoise3DBlock
  67316. * @param name defines the block name
  67317. */
  67318. constructor(name: string);
  67319. /**
  67320. * Gets the current class name
  67321. * @returns the class name
  67322. */
  67323. getClassName(): string;
  67324. /**
  67325. * Gets the seed input component
  67326. */
  67327. get seed(): NodeMaterialConnectionPoint;
  67328. /**
  67329. * Gets the jitter input component
  67330. */
  67331. get jitter(): NodeMaterialConnectionPoint;
  67332. /**
  67333. * Gets the output component
  67334. */
  67335. get output(): NodeMaterialConnectionPoint;
  67336. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67337. /**
  67338. * Exposes the properties to the UI?
  67339. */
  67340. protected _dumpPropertiesCode(): string;
  67341. /**
  67342. * Exposes the properties to the Seralize?
  67343. */
  67344. serialize(): any;
  67345. /**
  67346. * Exposes the properties to the deseralize?
  67347. */
  67348. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67349. }
  67350. }
  67351. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67352. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67353. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67354. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67355. /**
  67356. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67357. */
  67358. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67359. /**
  67360. * Creates a new SimplexPerlin3DBlock
  67361. * @param name defines the block name
  67362. */
  67363. constructor(name: string);
  67364. /**
  67365. * Gets the current class name
  67366. * @returns the class name
  67367. */
  67368. getClassName(): string;
  67369. /**
  67370. * Gets the seed operand input component
  67371. */
  67372. get seed(): NodeMaterialConnectionPoint;
  67373. /**
  67374. * Gets the output component
  67375. */
  67376. get output(): NodeMaterialConnectionPoint;
  67377. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67378. }
  67379. }
  67380. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67384. /**
  67385. * Block used to blend normals
  67386. */
  67387. export class NormalBlendBlock extends NodeMaterialBlock {
  67388. /**
  67389. * Creates a new NormalBlendBlock
  67390. * @param name defines the block name
  67391. */
  67392. constructor(name: string);
  67393. /**
  67394. * Gets the current class name
  67395. * @returns the class name
  67396. */
  67397. getClassName(): string;
  67398. /**
  67399. * Gets the first input component
  67400. */
  67401. get normalMap0(): NodeMaterialConnectionPoint;
  67402. /**
  67403. * Gets the second input component
  67404. */
  67405. get normalMap1(): NodeMaterialConnectionPoint;
  67406. /**
  67407. * Gets the output component
  67408. */
  67409. get output(): NodeMaterialConnectionPoint;
  67410. protected _buildBlock(state: NodeMaterialBuildState): this;
  67411. }
  67412. }
  67413. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67417. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67418. /**
  67419. * Block used to rotate a 2d vector by a given angle
  67420. */
  67421. export class Rotate2dBlock extends NodeMaterialBlock {
  67422. /**
  67423. * Creates a new Rotate2dBlock
  67424. * @param name defines the block name
  67425. */
  67426. constructor(name: string);
  67427. /**
  67428. * Gets the current class name
  67429. * @returns the class name
  67430. */
  67431. getClassName(): string;
  67432. /**
  67433. * Gets the input vector
  67434. */
  67435. get input(): NodeMaterialConnectionPoint;
  67436. /**
  67437. * Gets the input angle
  67438. */
  67439. get angle(): NodeMaterialConnectionPoint;
  67440. /**
  67441. * Gets the output component
  67442. */
  67443. get output(): NodeMaterialConnectionPoint;
  67444. autoConfigure(material: NodeMaterial): void;
  67445. protected _buildBlock(state: NodeMaterialBuildState): this;
  67446. }
  67447. }
  67448. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67452. /**
  67453. * Block used to get the reflected vector from a direction and a normal
  67454. */
  67455. export class ReflectBlock extends NodeMaterialBlock {
  67456. /**
  67457. * Creates a new ReflectBlock
  67458. * @param name defines the block name
  67459. */
  67460. constructor(name: string);
  67461. /**
  67462. * Gets the current class name
  67463. * @returns the class name
  67464. */
  67465. getClassName(): string;
  67466. /**
  67467. * Gets the incident component
  67468. */
  67469. get incident(): NodeMaterialConnectionPoint;
  67470. /**
  67471. * Gets the normal component
  67472. */
  67473. get normal(): NodeMaterialConnectionPoint;
  67474. /**
  67475. * Gets the output component
  67476. */
  67477. get output(): NodeMaterialConnectionPoint;
  67478. protected _buildBlock(state: NodeMaterialBuildState): this;
  67479. }
  67480. }
  67481. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67485. /**
  67486. * Block used to get the refracted vector from a direction and a normal
  67487. */
  67488. export class RefractBlock extends NodeMaterialBlock {
  67489. /**
  67490. * Creates a new RefractBlock
  67491. * @param name defines the block name
  67492. */
  67493. constructor(name: string);
  67494. /**
  67495. * Gets the current class name
  67496. * @returns the class name
  67497. */
  67498. getClassName(): string;
  67499. /**
  67500. * Gets the incident component
  67501. */
  67502. get incident(): NodeMaterialConnectionPoint;
  67503. /**
  67504. * Gets the normal component
  67505. */
  67506. get normal(): NodeMaterialConnectionPoint;
  67507. /**
  67508. * Gets the index of refraction component
  67509. */
  67510. get ior(): NodeMaterialConnectionPoint;
  67511. /**
  67512. * Gets the output component
  67513. */
  67514. get output(): NodeMaterialConnectionPoint;
  67515. protected _buildBlock(state: NodeMaterialBuildState): this;
  67516. }
  67517. }
  67518. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67519. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67520. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67521. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67522. /**
  67523. * Block used to desaturate a color
  67524. */
  67525. export class DesaturateBlock extends NodeMaterialBlock {
  67526. /**
  67527. * Creates a new DesaturateBlock
  67528. * @param name defines the block name
  67529. */
  67530. constructor(name: string);
  67531. /**
  67532. * Gets the current class name
  67533. * @returns the class name
  67534. */
  67535. getClassName(): string;
  67536. /**
  67537. * Gets the color operand input component
  67538. */
  67539. get color(): NodeMaterialConnectionPoint;
  67540. /**
  67541. * Gets the level operand input component
  67542. */
  67543. get level(): NodeMaterialConnectionPoint;
  67544. /**
  67545. * Gets the output component
  67546. */
  67547. get output(): NodeMaterialConnectionPoint;
  67548. protected _buildBlock(state: NodeMaterialBuildState): this;
  67549. }
  67550. }
  67551. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67555. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67556. import { Nullable } from "babylonjs/types";
  67557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67558. import { Scene } from "babylonjs/scene";
  67559. /**
  67560. * Block used to implement the ambient occlusion module of the PBR material
  67561. */
  67562. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67563. /**
  67564. * Create a new AmbientOcclusionBlock
  67565. * @param name defines the block name
  67566. */
  67567. constructor(name: string);
  67568. /**
  67569. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67570. */
  67571. useAmbientInGrayScale: boolean;
  67572. /**
  67573. * Initialize the block and prepare the context for build
  67574. * @param state defines the state that will be used for the build
  67575. */
  67576. initialize(state: NodeMaterialBuildState): void;
  67577. /**
  67578. * Gets the current class name
  67579. * @returns the class name
  67580. */
  67581. getClassName(): string;
  67582. /**
  67583. * Gets the texture input component
  67584. */
  67585. get texture(): NodeMaterialConnectionPoint;
  67586. /**
  67587. * Gets the texture intensity component
  67588. */
  67589. get intensity(): NodeMaterialConnectionPoint;
  67590. /**
  67591. * Gets the direct light intensity input component
  67592. */
  67593. get directLightIntensity(): NodeMaterialConnectionPoint;
  67594. /**
  67595. * Gets the ambient occlusion object output component
  67596. */
  67597. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67598. /**
  67599. * Gets the main code of the block (fragment side)
  67600. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67601. * @returns the shader code
  67602. */
  67603. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67604. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67605. protected _buildBlock(state: NodeMaterialBuildState): this;
  67606. protected _dumpPropertiesCode(): string;
  67607. serialize(): any;
  67608. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67609. }
  67610. }
  67611. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67612. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67613. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67614. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67615. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67617. import { Nullable } from "babylonjs/types";
  67618. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67619. import { Mesh } from "babylonjs/Meshes/mesh";
  67620. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67621. import { Effect } from "babylonjs/Materials/effect";
  67622. import { Scene } from "babylonjs/scene";
  67623. /**
  67624. * Block used to implement the reflection module of the PBR material
  67625. */
  67626. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67627. /** @hidden */
  67628. _defineLODReflectionAlpha: string;
  67629. /** @hidden */
  67630. _defineLinearSpecularReflection: string;
  67631. private _vEnvironmentIrradianceName;
  67632. /** @hidden */
  67633. _vReflectionMicrosurfaceInfosName: string;
  67634. /** @hidden */
  67635. _vReflectionInfosName: string;
  67636. /** @hidden */
  67637. _vReflectionFilteringInfoName: string;
  67638. private _scene;
  67639. /**
  67640. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67641. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67642. * It's less burden on the user side in the editor part.
  67643. */
  67644. /** @hidden */
  67645. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67646. /** @hidden */
  67647. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67648. /** @hidden */
  67649. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67650. /**
  67651. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67652. * diffuse part of the IBL.
  67653. */
  67654. useSphericalHarmonics: boolean;
  67655. /**
  67656. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67657. */
  67658. forceIrradianceInFragment: boolean;
  67659. /**
  67660. * Create a new ReflectionBlock
  67661. * @param name defines the block name
  67662. */
  67663. constructor(name: string);
  67664. /**
  67665. * Gets the current class name
  67666. * @returns the class name
  67667. */
  67668. getClassName(): string;
  67669. /**
  67670. * Gets the position input component
  67671. */
  67672. get position(): NodeMaterialConnectionPoint;
  67673. /**
  67674. * Gets the world position input component
  67675. */
  67676. get worldPosition(): NodeMaterialConnectionPoint;
  67677. /**
  67678. * Gets the world normal input component
  67679. */
  67680. get worldNormal(): NodeMaterialConnectionPoint;
  67681. /**
  67682. * Gets the world input component
  67683. */
  67684. get world(): NodeMaterialConnectionPoint;
  67685. /**
  67686. * Gets the camera (or eye) position component
  67687. */
  67688. get cameraPosition(): NodeMaterialConnectionPoint;
  67689. /**
  67690. * Gets the view input component
  67691. */
  67692. get view(): NodeMaterialConnectionPoint;
  67693. /**
  67694. * Gets the color input component
  67695. */
  67696. get color(): NodeMaterialConnectionPoint;
  67697. /**
  67698. * Gets the reflection object output component
  67699. */
  67700. get reflection(): NodeMaterialConnectionPoint;
  67701. /**
  67702. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67703. */
  67704. get hasTexture(): boolean;
  67705. /**
  67706. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67707. */
  67708. get reflectionColor(): string;
  67709. protected _getTexture(): Nullable<BaseTexture>;
  67710. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67711. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67712. /**
  67713. * Gets the code to inject in the vertex shader
  67714. * @param state current state of the node material building
  67715. * @returns the shader code
  67716. */
  67717. handleVertexSide(state: NodeMaterialBuildState): string;
  67718. /**
  67719. * Gets the main code of the block (fragment side)
  67720. * @param state current state of the node material building
  67721. * @param normalVarName name of the existing variable corresponding to the normal
  67722. * @returns the shader code
  67723. */
  67724. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67725. protected _buildBlock(state: NodeMaterialBuildState): this;
  67726. protected _dumpPropertiesCode(): string;
  67727. serialize(): any;
  67728. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67729. }
  67730. }
  67731. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  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. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67737. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67738. import { Scene } from "babylonjs/scene";
  67739. import { Nullable } from "babylonjs/types";
  67740. /**
  67741. * Block used to implement the sheen module of the PBR material
  67742. */
  67743. export class SheenBlock extends NodeMaterialBlock {
  67744. /**
  67745. * Create a new SheenBlock
  67746. * @param name defines the block name
  67747. */
  67748. constructor(name: string);
  67749. /**
  67750. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67751. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67752. * making it easier to setup and tweak the effect
  67753. */
  67754. albedoScaling: boolean;
  67755. /**
  67756. * Defines if the sheen is linked to the sheen color.
  67757. */
  67758. linkSheenWithAlbedo: boolean;
  67759. /**
  67760. * Initialize the block and prepare the context for build
  67761. * @param state defines the state that will be used for the build
  67762. */
  67763. initialize(state: NodeMaterialBuildState): void;
  67764. /**
  67765. * Gets the current class name
  67766. * @returns the class name
  67767. */
  67768. getClassName(): string;
  67769. /**
  67770. * Gets the intensity input component
  67771. */
  67772. get intensity(): NodeMaterialConnectionPoint;
  67773. /**
  67774. * Gets the color input component
  67775. */
  67776. get color(): NodeMaterialConnectionPoint;
  67777. /**
  67778. * Gets the roughness input component
  67779. */
  67780. get roughness(): NodeMaterialConnectionPoint;
  67781. /**
  67782. * Gets the sheen object output component
  67783. */
  67784. get sheen(): NodeMaterialConnectionPoint;
  67785. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67786. /**
  67787. * Gets the main code of the block (fragment side)
  67788. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67789. * @returns the shader code
  67790. */
  67791. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67792. protected _buildBlock(state: NodeMaterialBuildState): this;
  67793. protected _dumpPropertiesCode(): string;
  67794. serialize(): any;
  67795. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67796. }
  67797. }
  67798. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67799. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67804. import { Scene } from "babylonjs/scene";
  67805. import { Nullable } from "babylonjs/types";
  67806. import { Mesh } from "babylonjs/Meshes/mesh";
  67807. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67808. import { Effect } from "babylonjs/Materials/effect";
  67809. /**
  67810. * Block used to implement the reflectivity module of the PBR material
  67811. */
  67812. export class ReflectivityBlock extends NodeMaterialBlock {
  67813. private _metallicReflectanceColor;
  67814. private _metallicF0Factor;
  67815. /** @hidden */
  67816. _vMetallicReflectanceFactorsName: string;
  67817. /**
  67818. * The property below is set by the main PBR block prior to calling methods of this class.
  67819. */
  67820. /** @hidden */
  67821. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67822. /**
  67823. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67824. */
  67825. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67826. /**
  67827. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67828. */
  67829. useMetallnessFromMetallicTextureBlue: boolean;
  67830. /**
  67831. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67832. */
  67833. useRoughnessFromMetallicTextureAlpha: boolean;
  67834. /**
  67835. * Specifies if the metallic texture contains the roughness information in its green channel.
  67836. */
  67837. useRoughnessFromMetallicTextureGreen: boolean;
  67838. /**
  67839. * Create a new ReflectivityBlock
  67840. * @param name defines the block name
  67841. */
  67842. constructor(name: string);
  67843. /**
  67844. * Initialize the block and prepare the context for build
  67845. * @param state defines the state that will be used for the build
  67846. */
  67847. initialize(state: NodeMaterialBuildState): void;
  67848. /**
  67849. * Gets the current class name
  67850. * @returns the class name
  67851. */
  67852. getClassName(): string;
  67853. /**
  67854. * Gets the metallic input component
  67855. */
  67856. get metallic(): NodeMaterialConnectionPoint;
  67857. /**
  67858. * Gets the roughness input component
  67859. */
  67860. get roughness(): NodeMaterialConnectionPoint;
  67861. /**
  67862. * Gets the texture input component
  67863. */
  67864. get texture(): NodeMaterialConnectionPoint;
  67865. /**
  67866. * Gets the reflectivity object output component
  67867. */
  67868. get reflectivity(): NodeMaterialConnectionPoint;
  67869. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67870. /**
  67871. * Gets the main code of the block (fragment side)
  67872. * @param state current state of the node material building
  67873. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67874. * @returns the shader code
  67875. */
  67876. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67878. protected _buildBlock(state: NodeMaterialBuildState): this;
  67879. protected _dumpPropertiesCode(): string;
  67880. serialize(): any;
  67881. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67882. }
  67883. }
  67884. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67885. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67890. /**
  67891. * Block used to implement the anisotropy module of the PBR material
  67892. */
  67893. export class AnisotropyBlock extends NodeMaterialBlock {
  67894. /**
  67895. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67896. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67897. * It's less burden on the user side in the editor part.
  67898. */
  67899. /** @hidden */
  67900. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67901. /** @hidden */
  67902. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67903. /**
  67904. * Create a new AnisotropyBlock
  67905. * @param name defines the block name
  67906. */
  67907. constructor(name: string);
  67908. /**
  67909. * Initialize the block and prepare the context for build
  67910. * @param state defines the state that will be used for the build
  67911. */
  67912. initialize(state: NodeMaterialBuildState): void;
  67913. /**
  67914. * Gets the current class name
  67915. * @returns the class name
  67916. */
  67917. getClassName(): string;
  67918. /**
  67919. * Gets the intensity input component
  67920. */
  67921. get intensity(): NodeMaterialConnectionPoint;
  67922. /**
  67923. * Gets the direction input component
  67924. */
  67925. get direction(): NodeMaterialConnectionPoint;
  67926. /**
  67927. * Gets the texture input component
  67928. */
  67929. get texture(): NodeMaterialConnectionPoint;
  67930. /**
  67931. * Gets the uv input component
  67932. */
  67933. get uv(): NodeMaterialConnectionPoint;
  67934. /**
  67935. * Gets the worldTangent input component
  67936. */
  67937. get worldTangent(): NodeMaterialConnectionPoint;
  67938. /**
  67939. * Gets the anisotropy object output component
  67940. */
  67941. get anisotropy(): NodeMaterialConnectionPoint;
  67942. private _generateTBNSpace;
  67943. /**
  67944. * Gets the main code of the block (fragment side)
  67945. * @param state current state of the node material building
  67946. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67947. * @returns the shader code
  67948. */
  67949. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67950. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67951. protected _buildBlock(state: NodeMaterialBuildState): this;
  67952. }
  67953. }
  67954. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67958. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67960. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67961. import { Nullable } from "babylonjs/types";
  67962. import { Mesh } from "babylonjs/Meshes/mesh";
  67963. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67964. import { Effect } from "babylonjs/Materials/effect";
  67965. /**
  67966. * Block used to implement the clear coat module of the PBR material
  67967. */
  67968. export class ClearCoatBlock extends NodeMaterialBlock {
  67969. private _scene;
  67970. /**
  67971. * Create a new ClearCoatBlock
  67972. * @param name defines the block name
  67973. */
  67974. constructor(name: string);
  67975. /**
  67976. * Initialize the block and prepare the context for build
  67977. * @param state defines the state that will be used for the build
  67978. */
  67979. initialize(state: NodeMaterialBuildState): void;
  67980. /**
  67981. * Gets the current class name
  67982. * @returns the class name
  67983. */
  67984. getClassName(): string;
  67985. /**
  67986. * Gets the intensity input component
  67987. */
  67988. get intensity(): NodeMaterialConnectionPoint;
  67989. /**
  67990. * Gets the roughness input component
  67991. */
  67992. get roughness(): NodeMaterialConnectionPoint;
  67993. /**
  67994. * Gets the ior input component
  67995. */
  67996. get ior(): NodeMaterialConnectionPoint;
  67997. /**
  67998. * Gets the texture input component
  67999. */
  68000. get texture(): NodeMaterialConnectionPoint;
  68001. /**
  68002. * Gets the bump texture input component
  68003. */
  68004. get bumpTexture(): NodeMaterialConnectionPoint;
  68005. /**
  68006. * Gets the uv input component
  68007. */
  68008. get uv(): NodeMaterialConnectionPoint;
  68009. /**
  68010. * Gets the tint color input component
  68011. */
  68012. get tintColor(): NodeMaterialConnectionPoint;
  68013. /**
  68014. * Gets the tint "at distance" input component
  68015. */
  68016. get tintAtDistance(): NodeMaterialConnectionPoint;
  68017. /**
  68018. * Gets the tint thickness input component
  68019. */
  68020. get tintThickness(): NodeMaterialConnectionPoint;
  68021. /**
  68022. * Gets the world tangent input component
  68023. */
  68024. get worldTangent(): NodeMaterialConnectionPoint;
  68025. /**
  68026. * Gets the clear coat object output component
  68027. */
  68028. get clearcoat(): NodeMaterialConnectionPoint;
  68029. autoConfigure(material: NodeMaterial): void;
  68030. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68031. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68032. private _generateTBNSpace;
  68033. /**
  68034. * Gets the main code of the block (fragment side)
  68035. * @param state current state of the node material building
  68036. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68037. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68038. * @param worldPosVarName name of the variable holding the world position
  68039. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68040. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68041. * @param worldNormalVarName name of the variable holding the world normal
  68042. * @returns the shader code
  68043. */
  68044. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68045. protected _buildBlock(state: NodeMaterialBuildState): this;
  68046. }
  68047. }
  68048. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68049. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68050. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68051. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68052. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68054. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68055. import { Nullable } from "babylonjs/types";
  68056. /**
  68057. * Block used to implement the sub surface module of the PBR material
  68058. */
  68059. export class SubSurfaceBlock extends NodeMaterialBlock {
  68060. /**
  68061. * Create a new SubSurfaceBlock
  68062. * @param name defines the block name
  68063. */
  68064. constructor(name: string);
  68065. /**
  68066. * Stores the intensity of the different subsurface effects in the thickness texture.
  68067. * * the green channel is the translucency intensity.
  68068. * * the blue channel is the scattering intensity.
  68069. * * the alpha channel is the refraction intensity.
  68070. */
  68071. useMaskFromThicknessTexture: boolean;
  68072. /**
  68073. * Initialize the block and prepare the context for build
  68074. * @param state defines the state that will be used for the build
  68075. */
  68076. initialize(state: NodeMaterialBuildState): void;
  68077. /**
  68078. * Gets the current class name
  68079. * @returns the class name
  68080. */
  68081. getClassName(): string;
  68082. /**
  68083. * Gets the min thickness input component
  68084. */
  68085. get minThickness(): NodeMaterialConnectionPoint;
  68086. /**
  68087. * Gets the max thickness input component
  68088. */
  68089. get maxThickness(): NodeMaterialConnectionPoint;
  68090. /**
  68091. * Gets the thickness texture component
  68092. */
  68093. get thicknessTexture(): NodeMaterialConnectionPoint;
  68094. /**
  68095. * Gets the tint color input component
  68096. */
  68097. get tintColor(): NodeMaterialConnectionPoint;
  68098. /**
  68099. * Gets the translucency intensity input component
  68100. */
  68101. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68102. /**
  68103. * Gets the translucency diffusion distance input component
  68104. */
  68105. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68106. /**
  68107. * Gets the refraction object parameters
  68108. */
  68109. get refraction(): NodeMaterialConnectionPoint;
  68110. /**
  68111. * Gets the sub surface object output component
  68112. */
  68113. get subsurface(): NodeMaterialConnectionPoint;
  68114. autoConfigure(material: NodeMaterial): void;
  68115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68116. /**
  68117. * Gets the main code of the block (fragment side)
  68118. * @param state current state of the node material building
  68119. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68120. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68121. * @param worldPosVarName name of the variable holding the world position
  68122. * @returns the shader code
  68123. */
  68124. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68125. protected _buildBlock(state: NodeMaterialBuildState): this;
  68126. }
  68127. }
  68128. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68132. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68133. import { Light } from "babylonjs/Lights/light";
  68134. import { Nullable } from "babylonjs/types";
  68135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68136. import { Effect } from "babylonjs/Materials/effect";
  68137. import { Mesh } from "babylonjs/Meshes/mesh";
  68138. import { Scene } from "babylonjs/scene";
  68139. /**
  68140. * Block used to implement the PBR metallic/roughness model
  68141. */
  68142. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68143. /**
  68144. * Gets or sets the light associated with this block
  68145. */
  68146. light: Nullable<Light>;
  68147. private _lightId;
  68148. private _scene;
  68149. private _environmentBRDFTexture;
  68150. private _environmentBrdfSamplerName;
  68151. private _vNormalWName;
  68152. private _invertNormalName;
  68153. /**
  68154. * Create a new ReflectionBlock
  68155. * @param name defines the block name
  68156. */
  68157. constructor(name: string);
  68158. /**
  68159. * Intensity of the direct lights e.g. the four lights available in your scene.
  68160. * This impacts both the direct diffuse and specular highlights.
  68161. */
  68162. directIntensity: number;
  68163. /**
  68164. * Intensity of the environment e.g. how much the environment will light the object
  68165. * either through harmonics for rough material or through the refelction for shiny ones.
  68166. */
  68167. environmentIntensity: number;
  68168. /**
  68169. * This is a special control allowing the reduction of the specular highlights coming from the
  68170. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68171. */
  68172. specularIntensity: number;
  68173. /**
  68174. * Defines the falloff type used in this material.
  68175. * It by default is Physical.
  68176. */
  68177. lightFalloff: number;
  68178. /**
  68179. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68180. */
  68181. useAlphaFromAlbedoTexture: boolean;
  68182. /**
  68183. * Specifies that alpha test should be used
  68184. */
  68185. useAlphaTest: boolean;
  68186. /**
  68187. * Defines the alpha limits in alpha test mode.
  68188. */
  68189. alphaTestCutoff: number;
  68190. /**
  68191. * Specifies that alpha blending should be used
  68192. */
  68193. useAlphaBlending: boolean;
  68194. /**
  68195. * Defines if the alpha value should be determined via the rgb values.
  68196. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68197. */
  68198. opacityRGB: boolean;
  68199. /**
  68200. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68201. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68202. */
  68203. useRadianceOverAlpha: boolean;
  68204. /**
  68205. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68206. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68207. */
  68208. useSpecularOverAlpha: boolean;
  68209. /**
  68210. * Enables specular anti aliasing in the PBR shader.
  68211. * It will both interacts on the Geometry for analytical and IBL lighting.
  68212. * It also prefilter the roughness map based on the bump values.
  68213. */
  68214. enableSpecularAntiAliasing: boolean;
  68215. /**
  68216. * Enables realtime filtering on the texture.
  68217. */
  68218. realTimeFiltering: boolean;
  68219. /**
  68220. * Quality switch for realtime filtering
  68221. */
  68222. realTimeFilteringQuality: number;
  68223. /**
  68224. * Defines if the material uses energy conservation.
  68225. */
  68226. useEnergyConservation: boolean;
  68227. /**
  68228. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68229. * too much the area relying on ambient texture to define their ambient occlusion.
  68230. */
  68231. useRadianceOcclusion: boolean;
  68232. /**
  68233. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68234. * makes the reflect vector face the model (under horizon).
  68235. */
  68236. useHorizonOcclusion: boolean;
  68237. /**
  68238. * If set to true, no lighting calculations will be applied.
  68239. */
  68240. unlit: boolean;
  68241. /**
  68242. * Force normal to face away from face.
  68243. */
  68244. forceNormalForward: boolean;
  68245. /**
  68246. * Defines the material debug mode.
  68247. * It helps seeing only some components of the material while troubleshooting.
  68248. */
  68249. debugMode: number;
  68250. /**
  68251. * Specify from where on screen the debug mode should start.
  68252. * The value goes from -1 (full screen) to 1 (not visible)
  68253. * It helps with side by side comparison against the final render
  68254. * This defaults to 0
  68255. */
  68256. debugLimit: number;
  68257. /**
  68258. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68259. * You can use the factor to better multiply the final value.
  68260. */
  68261. debugFactor: number;
  68262. /**
  68263. * Initialize the block and prepare the context for build
  68264. * @param state defines the state that will be used for the build
  68265. */
  68266. initialize(state: NodeMaterialBuildState): void;
  68267. /**
  68268. * Gets the current class name
  68269. * @returns the class name
  68270. */
  68271. getClassName(): string;
  68272. /**
  68273. * Gets the world position input component
  68274. */
  68275. get worldPosition(): NodeMaterialConnectionPoint;
  68276. /**
  68277. * Gets the world normal input component
  68278. */
  68279. get worldNormal(): NodeMaterialConnectionPoint;
  68280. /**
  68281. * Gets the perturbed normal input component
  68282. */
  68283. get perturbedNormal(): NodeMaterialConnectionPoint;
  68284. /**
  68285. * Gets the camera position input component
  68286. */
  68287. get cameraPosition(): NodeMaterialConnectionPoint;
  68288. /**
  68289. * Gets the base color input component
  68290. */
  68291. get baseColor(): NodeMaterialConnectionPoint;
  68292. /**
  68293. * Gets the opacity texture input component
  68294. */
  68295. get opacityTexture(): NodeMaterialConnectionPoint;
  68296. /**
  68297. * Gets the ambient color input component
  68298. */
  68299. get ambientColor(): NodeMaterialConnectionPoint;
  68300. /**
  68301. * Gets the reflectivity object parameters
  68302. */
  68303. get reflectivity(): NodeMaterialConnectionPoint;
  68304. /**
  68305. * Gets the ambient occlusion object parameters
  68306. */
  68307. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68308. /**
  68309. * Gets the reflection object parameters
  68310. */
  68311. get reflection(): NodeMaterialConnectionPoint;
  68312. /**
  68313. * Gets the sheen object parameters
  68314. */
  68315. get sheen(): NodeMaterialConnectionPoint;
  68316. /**
  68317. * Gets the clear coat object parameters
  68318. */
  68319. get clearcoat(): NodeMaterialConnectionPoint;
  68320. /**
  68321. * Gets the sub surface object parameters
  68322. */
  68323. get subsurface(): NodeMaterialConnectionPoint;
  68324. /**
  68325. * Gets the anisotropy object parameters
  68326. */
  68327. get anisotropy(): NodeMaterialConnectionPoint;
  68328. /**
  68329. * Gets the ambient output component
  68330. */
  68331. get ambient(): NodeMaterialConnectionPoint;
  68332. /**
  68333. * Gets the diffuse output component
  68334. */
  68335. get diffuse(): NodeMaterialConnectionPoint;
  68336. /**
  68337. * Gets the specular output component
  68338. */
  68339. get specular(): NodeMaterialConnectionPoint;
  68340. /**
  68341. * Gets the sheen output component
  68342. */
  68343. get sheenDir(): NodeMaterialConnectionPoint;
  68344. /**
  68345. * Gets the clear coat output component
  68346. */
  68347. get clearcoatDir(): NodeMaterialConnectionPoint;
  68348. /**
  68349. * Gets the indirect diffuse output component
  68350. */
  68351. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68352. /**
  68353. * Gets the indirect specular output component
  68354. */
  68355. get specularIndirect(): NodeMaterialConnectionPoint;
  68356. /**
  68357. * Gets the indirect sheen output component
  68358. */
  68359. get sheenIndirect(): NodeMaterialConnectionPoint;
  68360. /**
  68361. * Gets the indirect clear coat output component
  68362. */
  68363. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68364. /**
  68365. * Gets the refraction output component
  68366. */
  68367. get refraction(): NodeMaterialConnectionPoint;
  68368. /**
  68369. * Gets the global lighting output component
  68370. */
  68371. get lighting(): NodeMaterialConnectionPoint;
  68372. /**
  68373. * Gets the shadow output component
  68374. */
  68375. get shadow(): NodeMaterialConnectionPoint;
  68376. /**
  68377. * Gets the alpha output component
  68378. */
  68379. get alpha(): NodeMaterialConnectionPoint;
  68380. autoConfigure(material: NodeMaterial): void;
  68381. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68382. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68383. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68384. private _injectVertexCode;
  68385. /**
  68386. * Gets the code corresponding to the albedo/opacity module
  68387. * @returns the shader code
  68388. */
  68389. getAlbedoOpacityCode(): string;
  68390. protected _buildBlock(state: NodeMaterialBuildState): this;
  68391. protected _dumpPropertiesCode(): string;
  68392. serialize(): any;
  68393. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68394. }
  68395. }
  68396. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68397. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68398. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68399. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68400. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68401. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68402. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68403. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68404. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68405. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68406. }
  68407. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68408. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68409. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68410. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68411. }
  68412. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68416. /**
  68417. * Block used to compute value of one parameter modulo another
  68418. */
  68419. export class ModBlock extends NodeMaterialBlock {
  68420. /**
  68421. * Creates a new ModBlock
  68422. * @param name defines the block name
  68423. */
  68424. constructor(name: string);
  68425. /**
  68426. * Gets the current class name
  68427. * @returns the class name
  68428. */
  68429. getClassName(): string;
  68430. /**
  68431. * Gets the left operand input component
  68432. */
  68433. get left(): NodeMaterialConnectionPoint;
  68434. /**
  68435. * Gets the right operand input component
  68436. */
  68437. get right(): NodeMaterialConnectionPoint;
  68438. /**
  68439. * Gets the output component
  68440. */
  68441. get output(): NodeMaterialConnectionPoint;
  68442. protected _buildBlock(state: NodeMaterialBuildState): this;
  68443. }
  68444. }
  68445. declare module "babylonjs/Materials/Node/Blocks/index" {
  68446. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68447. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68448. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68449. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68450. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68451. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68452. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68453. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68454. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68455. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68456. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68457. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68458. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68459. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68460. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68461. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68462. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68463. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68464. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68465. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68466. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68467. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68468. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68469. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68470. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68471. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68472. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68473. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68474. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68475. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68476. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68477. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68478. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68479. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68480. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68481. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68482. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68483. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68484. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68485. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68486. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68487. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68488. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68489. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68490. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68491. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68492. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68493. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68494. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68495. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68496. }
  68497. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68498. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68499. }
  68500. declare module "babylonjs/Materials/Node/index" {
  68501. export * from "babylonjs/Materials/Node/Enums/index";
  68502. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68503. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68504. export * from "babylonjs/Materials/Node/nodeMaterial";
  68505. export * from "babylonjs/Materials/Node/Blocks/index";
  68506. export * from "babylonjs/Materials/Node/Optimizers/index";
  68507. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68508. }
  68509. declare module "babylonjs/Materials/index" {
  68510. export * from "babylonjs/Materials/Background/index";
  68511. export * from "babylonjs/Materials/colorCurves";
  68512. export * from "babylonjs/Materials/iEffectFallbacks";
  68513. export * from "babylonjs/Materials/effectFallbacks";
  68514. export * from "babylonjs/Materials/effect";
  68515. export * from "babylonjs/Materials/fresnelParameters";
  68516. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68517. export * from "babylonjs/Materials/material";
  68518. export * from "babylonjs/Materials/materialDefines";
  68519. export * from "babylonjs/Materials/thinMaterialHelper";
  68520. export * from "babylonjs/Materials/materialHelper";
  68521. export * from "babylonjs/Materials/multiMaterial";
  68522. export * from "babylonjs/Materials/PBR/index";
  68523. export * from "babylonjs/Materials/pushMaterial";
  68524. export * from "babylonjs/Materials/shaderMaterial";
  68525. export * from "babylonjs/Materials/standardMaterial";
  68526. export * from "babylonjs/Materials/Textures/index";
  68527. export * from "babylonjs/Materials/uniformBuffer";
  68528. export * from "babylonjs/Materials/materialFlags";
  68529. export * from "babylonjs/Materials/Node/index";
  68530. export * from "babylonjs/Materials/effectRenderer";
  68531. export * from "babylonjs/Materials/shadowDepthWrapper";
  68532. }
  68533. declare module "babylonjs/Maths/index" {
  68534. export * from "babylonjs/Maths/math.scalar";
  68535. export * from "babylonjs/Maths/math";
  68536. export * from "babylonjs/Maths/sphericalPolynomial";
  68537. }
  68538. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68539. import { IDisposable } from "babylonjs/scene";
  68540. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68541. /**
  68542. * Configuration for Draco compression
  68543. */
  68544. export interface IDracoCompressionConfiguration {
  68545. /**
  68546. * Configuration for the decoder.
  68547. */
  68548. decoder: {
  68549. /**
  68550. * The url to the WebAssembly module.
  68551. */
  68552. wasmUrl?: string;
  68553. /**
  68554. * The url to the WebAssembly binary.
  68555. */
  68556. wasmBinaryUrl?: string;
  68557. /**
  68558. * The url to the fallback JavaScript module.
  68559. */
  68560. fallbackUrl?: string;
  68561. };
  68562. }
  68563. /**
  68564. * Draco compression (https://google.github.io/draco/)
  68565. *
  68566. * This class wraps the Draco module.
  68567. *
  68568. * **Encoder**
  68569. *
  68570. * The encoder is not currently implemented.
  68571. *
  68572. * **Decoder**
  68573. *
  68574. * 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.
  68575. *
  68576. * To update the configuration, use the following code:
  68577. * ```javascript
  68578. * DracoCompression.Configuration = {
  68579. * decoder: {
  68580. * wasmUrl: "<url to the WebAssembly library>",
  68581. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68582. * fallbackUrl: "<url to the fallback JavaScript library>",
  68583. * }
  68584. * };
  68585. * ```
  68586. *
  68587. * 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.
  68588. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68589. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68590. *
  68591. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68592. * ```javascript
  68593. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68594. * ```
  68595. *
  68596. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68597. */
  68598. export class DracoCompression implements IDisposable {
  68599. private _workerPoolPromise?;
  68600. private _decoderModulePromise?;
  68601. /**
  68602. * The configuration. Defaults to the following urls:
  68603. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68604. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68605. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68606. */
  68607. static Configuration: IDracoCompressionConfiguration;
  68608. /**
  68609. * Returns true if the decoder configuration is available.
  68610. */
  68611. static get DecoderAvailable(): boolean;
  68612. /**
  68613. * Default number of workers to create when creating the draco compression object.
  68614. */
  68615. static DefaultNumWorkers: number;
  68616. private static GetDefaultNumWorkers;
  68617. private static _Default;
  68618. /**
  68619. * Default instance for the draco compression object.
  68620. */
  68621. static get Default(): DracoCompression;
  68622. /**
  68623. * Constructor
  68624. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68625. */
  68626. constructor(numWorkers?: number);
  68627. /**
  68628. * Stop all async operations and release resources.
  68629. */
  68630. dispose(): void;
  68631. /**
  68632. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68633. * @returns a promise that resolves when ready
  68634. */
  68635. whenReadyAsync(): Promise<void>;
  68636. /**
  68637. * Decode Draco compressed mesh data to vertex data.
  68638. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68639. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68640. * @returns A promise that resolves with the decoded vertex data
  68641. */
  68642. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68643. [kind: string]: number;
  68644. }): Promise<VertexData>;
  68645. }
  68646. }
  68647. declare module "babylonjs/Meshes/Compression/index" {
  68648. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68649. }
  68650. declare module "babylonjs/Meshes/csg" {
  68651. import { Nullable } from "babylonjs/types";
  68652. import { Scene } from "babylonjs/scene";
  68653. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68654. import { Mesh } from "babylonjs/Meshes/mesh";
  68655. import { Material } from "babylonjs/Materials/material";
  68656. /**
  68657. * Class for building Constructive Solid Geometry
  68658. */
  68659. export class CSG {
  68660. private polygons;
  68661. /**
  68662. * The world matrix
  68663. */
  68664. matrix: Matrix;
  68665. /**
  68666. * Stores the position
  68667. */
  68668. position: Vector3;
  68669. /**
  68670. * Stores the rotation
  68671. */
  68672. rotation: Vector3;
  68673. /**
  68674. * Stores the rotation quaternion
  68675. */
  68676. rotationQuaternion: Nullable<Quaternion>;
  68677. /**
  68678. * Stores the scaling vector
  68679. */
  68680. scaling: Vector3;
  68681. /**
  68682. * Convert the Mesh to CSG
  68683. * @param mesh The Mesh to convert to CSG
  68684. * @returns A new CSG from the Mesh
  68685. */
  68686. static FromMesh(mesh: Mesh): CSG;
  68687. /**
  68688. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68689. * @param polygons Polygons used to construct a CSG solid
  68690. */
  68691. private static FromPolygons;
  68692. /**
  68693. * Clones, or makes a deep copy, of the CSG
  68694. * @returns A new CSG
  68695. */
  68696. clone(): CSG;
  68697. /**
  68698. * Unions this CSG with another CSG
  68699. * @param csg The CSG to union against this CSG
  68700. * @returns The unioned CSG
  68701. */
  68702. union(csg: CSG): CSG;
  68703. /**
  68704. * Unions this CSG with another CSG in place
  68705. * @param csg The CSG to union against this CSG
  68706. */
  68707. unionInPlace(csg: CSG): void;
  68708. /**
  68709. * Subtracts this CSG with another CSG
  68710. * @param csg The CSG to subtract against this CSG
  68711. * @returns A new CSG
  68712. */
  68713. subtract(csg: CSG): CSG;
  68714. /**
  68715. * Subtracts this CSG with another CSG in place
  68716. * @param csg The CSG to subtact against this CSG
  68717. */
  68718. subtractInPlace(csg: CSG): void;
  68719. /**
  68720. * Intersect this CSG with another CSG
  68721. * @param csg The CSG to intersect against this CSG
  68722. * @returns A new CSG
  68723. */
  68724. intersect(csg: CSG): CSG;
  68725. /**
  68726. * Intersects this CSG with another CSG in place
  68727. * @param csg The CSG to intersect against this CSG
  68728. */
  68729. intersectInPlace(csg: CSG): void;
  68730. /**
  68731. * Return a new CSG solid with solid and empty space switched. This solid is
  68732. * not modified.
  68733. * @returns A new CSG solid with solid and empty space switched
  68734. */
  68735. inverse(): CSG;
  68736. /**
  68737. * Inverses the CSG in place
  68738. */
  68739. inverseInPlace(): void;
  68740. /**
  68741. * This is used to keep meshes transformations so they can be restored
  68742. * when we build back a Babylon Mesh
  68743. * NB : All CSG operations are performed in world coordinates
  68744. * @param csg The CSG to copy the transform attributes from
  68745. * @returns This CSG
  68746. */
  68747. copyTransformAttributes(csg: CSG): CSG;
  68748. /**
  68749. * Build Raw mesh from CSG
  68750. * Coordinates here are in world space
  68751. * @param name The name of the mesh geometry
  68752. * @param scene The Scene
  68753. * @param keepSubMeshes Specifies if the submeshes should be kept
  68754. * @returns A new Mesh
  68755. */
  68756. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68757. /**
  68758. * Build Mesh from CSG taking material and transforms into account
  68759. * @param name The name of the Mesh
  68760. * @param material The material of the Mesh
  68761. * @param scene The Scene
  68762. * @param keepSubMeshes Specifies if submeshes should be kept
  68763. * @returns The new Mesh
  68764. */
  68765. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68766. }
  68767. }
  68768. declare module "babylonjs/Meshes/trailMesh" {
  68769. import { Mesh } from "babylonjs/Meshes/mesh";
  68770. import { Scene } from "babylonjs/scene";
  68771. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68772. /**
  68773. * Class used to create a trail following a mesh
  68774. */
  68775. export class TrailMesh extends Mesh {
  68776. private _generator;
  68777. private _autoStart;
  68778. private _running;
  68779. private _diameter;
  68780. private _length;
  68781. private _sectionPolygonPointsCount;
  68782. private _sectionVectors;
  68783. private _sectionNormalVectors;
  68784. private _beforeRenderObserver;
  68785. /**
  68786. * @constructor
  68787. * @param name The value used by scene.getMeshByName() to do a lookup.
  68788. * @param generator The mesh or transform node to generate a trail.
  68789. * @param scene The scene to add this mesh to.
  68790. * @param diameter Diameter of trailing mesh. Default is 1.
  68791. * @param length Length of trailing mesh. Default is 60.
  68792. * @param autoStart Automatically start trailing mesh. Default true.
  68793. */
  68794. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68795. /**
  68796. * "TrailMesh"
  68797. * @returns "TrailMesh"
  68798. */
  68799. getClassName(): string;
  68800. private _createMesh;
  68801. /**
  68802. * Start trailing mesh.
  68803. */
  68804. start(): void;
  68805. /**
  68806. * Stop trailing mesh.
  68807. */
  68808. stop(): void;
  68809. /**
  68810. * Update trailing mesh geometry.
  68811. */
  68812. update(): void;
  68813. /**
  68814. * Returns a new TrailMesh object.
  68815. * @param name is a string, the name given to the new mesh
  68816. * @param newGenerator use new generator object for cloned trail mesh
  68817. * @returns a new mesh
  68818. */
  68819. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68820. /**
  68821. * Serializes this trail mesh
  68822. * @param serializationObject object to write serialization to
  68823. */
  68824. serialize(serializationObject: any): void;
  68825. /**
  68826. * Parses a serialized trail mesh
  68827. * @param parsedMesh the serialized mesh
  68828. * @param scene the scene to create the trail mesh in
  68829. * @returns the created trail mesh
  68830. */
  68831. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68832. }
  68833. }
  68834. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68835. import { Nullable } from "babylonjs/types";
  68836. import { Scene } from "babylonjs/scene";
  68837. import { Vector4 } from "babylonjs/Maths/math.vector";
  68838. import { Color4 } from "babylonjs/Maths/math.color";
  68839. import { Mesh } from "babylonjs/Meshes/mesh";
  68840. /**
  68841. * Class containing static functions to help procedurally build meshes
  68842. */
  68843. export class TiledBoxBuilder {
  68844. /**
  68845. * Creates a box mesh
  68846. * 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)
  68847. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68849. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68851. * @param name defines the name of the mesh
  68852. * @param options defines the options used to create the mesh
  68853. * @param scene defines the hosting scene
  68854. * @returns the box mesh
  68855. */
  68856. static CreateTiledBox(name: string, options: {
  68857. pattern?: number;
  68858. width?: number;
  68859. height?: number;
  68860. depth?: number;
  68861. tileSize?: number;
  68862. tileWidth?: number;
  68863. tileHeight?: number;
  68864. alignHorizontal?: number;
  68865. alignVertical?: number;
  68866. faceUV?: Vector4[];
  68867. faceColors?: Color4[];
  68868. sideOrientation?: number;
  68869. updatable?: boolean;
  68870. }, scene?: Nullable<Scene>): Mesh;
  68871. }
  68872. }
  68873. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68874. import { Vector4 } from "babylonjs/Maths/math.vector";
  68875. import { Mesh } from "babylonjs/Meshes/mesh";
  68876. /**
  68877. * Class containing static functions to help procedurally build meshes
  68878. */
  68879. export class TorusKnotBuilder {
  68880. /**
  68881. * Creates a torus knot mesh
  68882. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68883. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68884. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68885. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68889. * @param name defines the name of the mesh
  68890. * @param options defines the options used to create the mesh
  68891. * @param scene defines the hosting scene
  68892. * @returns the torus knot mesh
  68893. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68894. */
  68895. static CreateTorusKnot(name: string, options: {
  68896. radius?: number;
  68897. tube?: number;
  68898. radialSegments?: number;
  68899. tubularSegments?: number;
  68900. p?: number;
  68901. q?: number;
  68902. updatable?: boolean;
  68903. sideOrientation?: number;
  68904. frontUVs?: Vector4;
  68905. backUVs?: Vector4;
  68906. }, scene: any): Mesh;
  68907. }
  68908. }
  68909. declare module "babylonjs/Meshes/polygonMesh" {
  68910. import { Scene } from "babylonjs/scene";
  68911. import { Vector2 } from "babylonjs/Maths/math.vector";
  68912. import { Mesh } from "babylonjs/Meshes/mesh";
  68913. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68914. import { Path2 } from "babylonjs/Maths/math.path";
  68915. /**
  68916. * Polygon
  68917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68918. */
  68919. export class Polygon {
  68920. /**
  68921. * Creates a rectangle
  68922. * @param xmin bottom X coord
  68923. * @param ymin bottom Y coord
  68924. * @param xmax top X coord
  68925. * @param ymax top Y coord
  68926. * @returns points that make the resulting rectation
  68927. */
  68928. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68929. /**
  68930. * Creates a circle
  68931. * @param radius radius of circle
  68932. * @param cx scale in x
  68933. * @param cy scale in y
  68934. * @param numberOfSides number of sides that make up the circle
  68935. * @returns points that make the resulting circle
  68936. */
  68937. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68938. /**
  68939. * Creates a polygon from input string
  68940. * @param input Input polygon data
  68941. * @returns the parsed points
  68942. */
  68943. static Parse(input: string): Vector2[];
  68944. /**
  68945. * Starts building a polygon from x and y coordinates
  68946. * @param x x coordinate
  68947. * @param y y coordinate
  68948. * @returns the started path2
  68949. */
  68950. static StartingAt(x: number, y: number): Path2;
  68951. }
  68952. /**
  68953. * Builds a polygon
  68954. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68955. */
  68956. export class PolygonMeshBuilder {
  68957. private _points;
  68958. private _outlinepoints;
  68959. private _holes;
  68960. private _name;
  68961. private _scene;
  68962. private _epoints;
  68963. private _eholes;
  68964. private _addToepoint;
  68965. /**
  68966. * Babylon reference to the earcut plugin.
  68967. */
  68968. bjsEarcut: any;
  68969. /**
  68970. * Creates a PolygonMeshBuilder
  68971. * @param name name of the builder
  68972. * @param contours Path of the polygon
  68973. * @param scene scene to add to when creating the mesh
  68974. * @param earcutInjection can be used to inject your own earcut reference
  68975. */
  68976. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68977. /**
  68978. * Adds a whole within the polygon
  68979. * @param hole Array of points defining the hole
  68980. * @returns this
  68981. */
  68982. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68983. /**
  68984. * Creates the polygon
  68985. * @param updatable If the mesh should be updatable
  68986. * @param depth The depth of the mesh created
  68987. * @returns the created mesh
  68988. */
  68989. build(updatable?: boolean, depth?: number): Mesh;
  68990. /**
  68991. * Creates the polygon
  68992. * @param depth The depth of the mesh created
  68993. * @returns the created VertexData
  68994. */
  68995. buildVertexData(depth?: number): VertexData;
  68996. /**
  68997. * Adds a side to the polygon
  68998. * @param positions points that make the polygon
  68999. * @param normals normals of the polygon
  69000. * @param uvs uvs of the polygon
  69001. * @param indices indices of the polygon
  69002. * @param bounds bounds of the polygon
  69003. * @param points points of the polygon
  69004. * @param depth depth of the polygon
  69005. * @param flip flip of the polygon
  69006. */
  69007. private addSide;
  69008. }
  69009. }
  69010. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69011. import { Scene } from "babylonjs/scene";
  69012. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69013. import { Color4 } from "babylonjs/Maths/math.color";
  69014. import { Mesh } from "babylonjs/Meshes/mesh";
  69015. import { Nullable } from "babylonjs/types";
  69016. /**
  69017. * Class containing static functions to help procedurally build meshes
  69018. */
  69019. export class PolygonBuilder {
  69020. /**
  69021. * Creates a polygon mesh
  69022. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69023. * * 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
  69024. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69027. * * Remember you can only change the shape positions, not their number when updating a polygon
  69028. * @param name defines the name of the mesh
  69029. * @param options defines the options used to create the mesh
  69030. * @param scene defines the hosting scene
  69031. * @param earcutInjection can be used to inject your own earcut reference
  69032. * @returns the polygon mesh
  69033. */
  69034. static CreatePolygon(name: string, options: {
  69035. shape: Vector3[];
  69036. holes?: Vector3[][];
  69037. depth?: number;
  69038. faceUV?: Vector4[];
  69039. faceColors?: Color4[];
  69040. updatable?: boolean;
  69041. sideOrientation?: number;
  69042. frontUVs?: Vector4;
  69043. backUVs?: Vector4;
  69044. wrap?: boolean;
  69045. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69046. /**
  69047. * Creates an extruded polygon mesh, with depth in the Y direction.
  69048. * * 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)
  69049. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69050. * @param name defines the name of the mesh
  69051. * @param options defines the options used to create the mesh
  69052. * @param scene defines the hosting scene
  69053. * @param earcutInjection can be used to inject your own earcut reference
  69054. * @returns the polygon mesh
  69055. */
  69056. static ExtrudePolygon(name: string, options: {
  69057. shape: Vector3[];
  69058. holes?: Vector3[][];
  69059. depth?: number;
  69060. faceUV?: Vector4[];
  69061. faceColors?: Color4[];
  69062. updatable?: boolean;
  69063. sideOrientation?: number;
  69064. frontUVs?: Vector4;
  69065. backUVs?: Vector4;
  69066. wrap?: boolean;
  69067. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69068. }
  69069. }
  69070. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69071. import { Scene } from "babylonjs/scene";
  69072. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69073. import { Mesh } from "babylonjs/Meshes/mesh";
  69074. import { Nullable } from "babylonjs/types";
  69075. /**
  69076. * Class containing static functions to help procedurally build meshes
  69077. */
  69078. export class LatheBuilder {
  69079. /**
  69080. * Creates lathe mesh.
  69081. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69082. * * 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
  69083. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69084. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69085. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69086. * * 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
  69087. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69088. * * 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
  69089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69090. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69091. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69093. * @param name defines the name of the mesh
  69094. * @param options defines the options used to create the mesh
  69095. * @param scene defines the hosting scene
  69096. * @returns the lathe mesh
  69097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69098. */
  69099. static CreateLathe(name: string, options: {
  69100. shape: Vector3[];
  69101. radius?: number;
  69102. tessellation?: number;
  69103. clip?: number;
  69104. arc?: number;
  69105. closed?: boolean;
  69106. updatable?: boolean;
  69107. sideOrientation?: number;
  69108. frontUVs?: Vector4;
  69109. backUVs?: Vector4;
  69110. cap?: number;
  69111. invertUV?: boolean;
  69112. }, scene?: Nullable<Scene>): Mesh;
  69113. }
  69114. }
  69115. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69116. import { Nullable } from "babylonjs/types";
  69117. import { Scene } from "babylonjs/scene";
  69118. import { Vector4 } from "babylonjs/Maths/math.vector";
  69119. import { Mesh } from "babylonjs/Meshes/mesh";
  69120. /**
  69121. * Class containing static functions to help procedurally build meshes
  69122. */
  69123. export class TiledPlaneBuilder {
  69124. /**
  69125. * Creates a tiled plane mesh
  69126. * * The parameter `pattern` will, depending on value, do nothing or
  69127. * * * flip (reflect about central vertical) alternate tiles across and up
  69128. * * * flip every tile on alternate rows
  69129. * * * rotate (180 degs) alternate tiles across and up
  69130. * * * rotate every tile on alternate rows
  69131. * * * flip and rotate alternate tiles across and up
  69132. * * * flip and rotate every tile on alternate rows
  69133. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69134. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69137. * * 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)
  69138. * * 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)
  69139. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69140. * @param name defines the name of the mesh
  69141. * @param options defines the options used to create the mesh
  69142. * @param scene defines the hosting scene
  69143. * @returns the box mesh
  69144. */
  69145. static CreateTiledPlane(name: string, options: {
  69146. pattern?: number;
  69147. tileSize?: number;
  69148. tileWidth?: number;
  69149. tileHeight?: number;
  69150. size?: number;
  69151. width?: number;
  69152. height?: number;
  69153. alignHorizontal?: number;
  69154. alignVertical?: number;
  69155. sideOrientation?: number;
  69156. frontUVs?: Vector4;
  69157. backUVs?: Vector4;
  69158. updatable?: boolean;
  69159. }, scene?: Nullable<Scene>): Mesh;
  69160. }
  69161. }
  69162. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69163. import { Nullable } from "babylonjs/types";
  69164. import { Scene } from "babylonjs/scene";
  69165. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69166. import { Mesh } from "babylonjs/Meshes/mesh";
  69167. /**
  69168. * Class containing static functions to help procedurally build meshes
  69169. */
  69170. export class TubeBuilder {
  69171. /**
  69172. * Creates a tube mesh.
  69173. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69174. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69175. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69176. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69177. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69178. * * 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)
  69179. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69180. * * 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
  69181. * * 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
  69182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69184. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69186. * @param name defines the name of the mesh
  69187. * @param options defines the options used to create the mesh
  69188. * @param scene defines the hosting scene
  69189. * @returns the tube mesh
  69190. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69191. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69192. */
  69193. static CreateTube(name: string, options: {
  69194. path: Vector3[];
  69195. radius?: number;
  69196. tessellation?: number;
  69197. radiusFunction?: {
  69198. (i: number, distance: number): number;
  69199. };
  69200. cap?: number;
  69201. arc?: number;
  69202. updatable?: boolean;
  69203. sideOrientation?: number;
  69204. frontUVs?: Vector4;
  69205. backUVs?: Vector4;
  69206. instance?: Mesh;
  69207. invertUV?: boolean;
  69208. }, scene?: Nullable<Scene>): Mesh;
  69209. }
  69210. }
  69211. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69212. import { Scene } from "babylonjs/scene";
  69213. import { Vector4 } from "babylonjs/Maths/math.vector";
  69214. import { Mesh } from "babylonjs/Meshes/mesh";
  69215. import { Nullable } from "babylonjs/types";
  69216. /**
  69217. * Class containing static functions to help procedurally build meshes
  69218. */
  69219. export class IcoSphereBuilder {
  69220. /**
  69221. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69222. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69223. * * 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`)
  69224. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69225. * * 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
  69226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69229. * @param name defines the name of the mesh
  69230. * @param options defines the options used to create the mesh
  69231. * @param scene defines the hosting scene
  69232. * @returns the icosahedron mesh
  69233. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69234. */
  69235. static CreateIcoSphere(name: string, options: {
  69236. radius?: number;
  69237. radiusX?: number;
  69238. radiusY?: number;
  69239. radiusZ?: number;
  69240. flat?: boolean;
  69241. subdivisions?: number;
  69242. sideOrientation?: number;
  69243. frontUVs?: Vector4;
  69244. backUVs?: Vector4;
  69245. updatable?: boolean;
  69246. }, scene?: Nullable<Scene>): Mesh;
  69247. }
  69248. }
  69249. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69250. import { Vector3 } from "babylonjs/Maths/math.vector";
  69251. import { Mesh } from "babylonjs/Meshes/mesh";
  69252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69253. /**
  69254. * Class containing static functions to help procedurally build meshes
  69255. */
  69256. export class DecalBuilder {
  69257. /**
  69258. * Creates a decal mesh.
  69259. * 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
  69260. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69261. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69262. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69263. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69264. * @param name defines the name of the mesh
  69265. * @param sourceMesh defines the mesh where the decal must be applied
  69266. * @param options defines the options used to create the mesh
  69267. * @param scene defines the hosting scene
  69268. * @returns the decal mesh
  69269. * @see https://doc.babylonjs.com/how_to/decals
  69270. */
  69271. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69272. position?: Vector3;
  69273. normal?: Vector3;
  69274. size?: Vector3;
  69275. angle?: number;
  69276. }): Mesh;
  69277. }
  69278. }
  69279. declare module "babylonjs/Meshes/meshBuilder" {
  69280. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69281. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69282. import { Nullable } from "babylonjs/types";
  69283. import { Scene } from "babylonjs/scene";
  69284. import { Mesh } from "babylonjs/Meshes/mesh";
  69285. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69286. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69288. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69289. import { Plane } from "babylonjs/Maths/math.plane";
  69290. /**
  69291. * Class containing static functions to help procedurally build meshes
  69292. */
  69293. export class MeshBuilder {
  69294. /**
  69295. * Creates a box mesh
  69296. * * The parameter `size` sets the size (float) of each box side (default 1)
  69297. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69298. * * 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)
  69299. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69303. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69304. * @param name defines the name of the mesh
  69305. * @param options defines the options used to create the mesh
  69306. * @param scene defines the hosting scene
  69307. * @returns the box mesh
  69308. */
  69309. static CreateBox(name: string, options: {
  69310. size?: number;
  69311. width?: number;
  69312. height?: number;
  69313. depth?: number;
  69314. faceUV?: Vector4[];
  69315. faceColors?: Color4[];
  69316. sideOrientation?: number;
  69317. frontUVs?: Vector4;
  69318. backUVs?: Vector4;
  69319. wrap?: boolean;
  69320. topBaseAt?: number;
  69321. bottomBaseAt?: number;
  69322. updatable?: boolean;
  69323. }, scene?: Nullable<Scene>): Mesh;
  69324. /**
  69325. * Creates a tiled box mesh
  69326. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69328. * @param name defines the name of the mesh
  69329. * @param options defines the options used to create the mesh
  69330. * @param scene defines the hosting scene
  69331. * @returns the tiled box mesh
  69332. */
  69333. static CreateTiledBox(name: string, options: {
  69334. pattern?: number;
  69335. size?: number;
  69336. width?: number;
  69337. height?: number;
  69338. depth: number;
  69339. tileSize?: number;
  69340. tileWidth?: number;
  69341. tileHeight?: number;
  69342. faceUV?: Vector4[];
  69343. faceColors?: Color4[];
  69344. alignHorizontal?: number;
  69345. alignVertical?: number;
  69346. sideOrientation?: number;
  69347. updatable?: boolean;
  69348. }, scene?: Nullable<Scene>): Mesh;
  69349. /**
  69350. * Creates a sphere mesh
  69351. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69352. * * 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`)
  69353. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69354. * * 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
  69355. * * 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)
  69356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69359. * @param name defines the name of the mesh
  69360. * @param options defines the options used to create the mesh
  69361. * @param scene defines the hosting scene
  69362. * @returns the sphere mesh
  69363. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69364. */
  69365. static CreateSphere(name: string, options: {
  69366. segments?: number;
  69367. diameter?: number;
  69368. diameterX?: number;
  69369. diameterY?: number;
  69370. diameterZ?: number;
  69371. arc?: number;
  69372. slice?: number;
  69373. sideOrientation?: number;
  69374. frontUVs?: Vector4;
  69375. backUVs?: Vector4;
  69376. updatable?: boolean;
  69377. }, scene?: Nullable<Scene>): Mesh;
  69378. /**
  69379. * Creates a plane polygonal mesh. By default, this is a disc
  69380. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69381. * * 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
  69382. * * 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
  69383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69386. * @param name defines the name of the mesh
  69387. * @param options defines the options used to create the mesh
  69388. * @param scene defines the hosting scene
  69389. * @returns the plane polygonal mesh
  69390. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69391. */
  69392. static CreateDisc(name: string, options: {
  69393. radius?: number;
  69394. tessellation?: number;
  69395. arc?: number;
  69396. updatable?: boolean;
  69397. sideOrientation?: number;
  69398. frontUVs?: Vector4;
  69399. backUVs?: Vector4;
  69400. }, scene?: Nullable<Scene>): Mesh;
  69401. /**
  69402. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69403. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69404. * * 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`)
  69405. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69406. * * 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
  69407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69410. * @param name defines the name of the mesh
  69411. * @param options defines the options used to create the mesh
  69412. * @param scene defines the hosting scene
  69413. * @returns the icosahedron mesh
  69414. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69415. */
  69416. static CreateIcoSphere(name: string, options: {
  69417. radius?: number;
  69418. radiusX?: number;
  69419. radiusY?: number;
  69420. radiusZ?: number;
  69421. flat?: boolean;
  69422. subdivisions?: number;
  69423. sideOrientation?: number;
  69424. frontUVs?: Vector4;
  69425. backUVs?: Vector4;
  69426. updatable?: boolean;
  69427. }, scene?: Nullable<Scene>): Mesh;
  69428. /**
  69429. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69430. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69431. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69432. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69433. * * 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
  69434. * * 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
  69435. * * 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
  69436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69438. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69439. * * 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
  69440. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69441. * * 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
  69442. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69444. * @param name defines the name of the mesh
  69445. * @param options defines the options used to create the mesh
  69446. * @param scene defines the hosting scene
  69447. * @returns the ribbon mesh
  69448. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69449. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69450. */
  69451. static CreateRibbon(name: string, options: {
  69452. pathArray: Vector3[][];
  69453. closeArray?: boolean;
  69454. closePath?: boolean;
  69455. offset?: number;
  69456. updatable?: boolean;
  69457. sideOrientation?: number;
  69458. frontUVs?: Vector4;
  69459. backUVs?: Vector4;
  69460. instance?: Mesh;
  69461. invertUV?: boolean;
  69462. uvs?: Vector2[];
  69463. colors?: Color4[];
  69464. }, scene?: Nullable<Scene>): Mesh;
  69465. /**
  69466. * Creates a cylinder or a cone mesh
  69467. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69468. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69469. * * 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.
  69470. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69471. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69472. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69473. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69474. * * 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).
  69475. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69476. * * 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).
  69477. * * 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
  69478. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69479. * * 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
  69480. * * 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.
  69481. * * If `enclose` is false, a ring surface is one element.
  69482. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69483. * * 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
  69484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69487. * @param name defines the name of the mesh
  69488. * @param options defines the options used to create the mesh
  69489. * @param scene defines the hosting scene
  69490. * @returns the cylinder mesh
  69491. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69492. */
  69493. static CreateCylinder(name: string, options: {
  69494. height?: number;
  69495. diameterTop?: number;
  69496. diameterBottom?: number;
  69497. diameter?: number;
  69498. tessellation?: number;
  69499. subdivisions?: number;
  69500. arc?: number;
  69501. faceColors?: Color4[];
  69502. faceUV?: Vector4[];
  69503. updatable?: boolean;
  69504. hasRings?: boolean;
  69505. enclose?: boolean;
  69506. cap?: number;
  69507. sideOrientation?: number;
  69508. frontUVs?: Vector4;
  69509. backUVs?: Vector4;
  69510. }, scene?: Nullable<Scene>): Mesh;
  69511. /**
  69512. * Creates a torus mesh
  69513. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69514. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69515. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69519. * @param name defines the name of the mesh
  69520. * @param options defines the options used to create the mesh
  69521. * @param scene defines the hosting scene
  69522. * @returns the torus mesh
  69523. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69524. */
  69525. static CreateTorus(name: string, options: {
  69526. diameter?: number;
  69527. thickness?: number;
  69528. tessellation?: number;
  69529. updatable?: boolean;
  69530. sideOrientation?: number;
  69531. frontUVs?: Vector4;
  69532. backUVs?: Vector4;
  69533. }, scene?: Nullable<Scene>): Mesh;
  69534. /**
  69535. * Creates a torus knot mesh
  69536. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69537. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69538. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69539. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69543. * @param name defines the name of the mesh
  69544. * @param options defines the options used to create the mesh
  69545. * @param scene defines the hosting scene
  69546. * @returns the torus knot mesh
  69547. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69548. */
  69549. static CreateTorusKnot(name: string, options: {
  69550. radius?: number;
  69551. tube?: number;
  69552. radialSegments?: number;
  69553. tubularSegments?: number;
  69554. p?: number;
  69555. q?: number;
  69556. updatable?: boolean;
  69557. sideOrientation?: number;
  69558. frontUVs?: Vector4;
  69559. backUVs?: Vector4;
  69560. }, scene?: Nullable<Scene>): Mesh;
  69561. /**
  69562. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69563. * * 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
  69564. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69565. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69566. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69567. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69568. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69569. * * 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
  69570. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69573. * @param name defines the name of the new line system
  69574. * @param options defines the options used to create the line system
  69575. * @param scene defines the hosting scene
  69576. * @returns a new line system mesh
  69577. */
  69578. static CreateLineSystem(name: string, options: {
  69579. lines: Vector3[][];
  69580. updatable?: boolean;
  69581. instance?: Nullable<LinesMesh>;
  69582. colors?: Nullable<Color4[][]>;
  69583. useVertexAlpha?: boolean;
  69584. }, scene: Nullable<Scene>): LinesMesh;
  69585. /**
  69586. * Creates a line mesh
  69587. * 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
  69588. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69589. * * The parameter `points` is an array successive Vector3
  69590. * * 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
  69591. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69592. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69593. * * When updating an instance, remember that only point positions can change, not the number of points
  69594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69596. * @param name defines the name of the new line system
  69597. * @param options defines the options used to create the line system
  69598. * @param scene defines the hosting scene
  69599. * @returns a new line mesh
  69600. */
  69601. static CreateLines(name: string, options: {
  69602. points: Vector3[];
  69603. updatable?: boolean;
  69604. instance?: Nullable<LinesMesh>;
  69605. colors?: Color4[];
  69606. useVertexAlpha?: boolean;
  69607. }, scene?: Nullable<Scene>): LinesMesh;
  69608. /**
  69609. * Creates a dashed line mesh
  69610. * * 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
  69611. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69612. * * The parameter `points` is an array successive Vector3
  69613. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69614. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69615. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69616. * * 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
  69617. * * When updating an instance, remember that only point positions can change, not the number of points
  69618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69619. * @param name defines the name of the mesh
  69620. * @param options defines the options used to create the mesh
  69621. * @param scene defines the hosting scene
  69622. * @returns the dashed line mesh
  69623. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69624. */
  69625. static CreateDashedLines(name: string, options: {
  69626. points: Vector3[];
  69627. dashSize?: number;
  69628. gapSize?: number;
  69629. dashNb?: number;
  69630. updatable?: boolean;
  69631. instance?: LinesMesh;
  69632. }, scene?: Nullable<Scene>): LinesMesh;
  69633. /**
  69634. * 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.
  69635. * * 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.
  69636. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69637. * * 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.
  69638. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69639. * * 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
  69640. * * 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
  69641. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69644. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69646. * @param name defines the name of the mesh
  69647. * @param options defines the options used to create the mesh
  69648. * @param scene defines the hosting scene
  69649. * @returns the extruded shape mesh
  69650. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69652. */
  69653. static ExtrudeShape(name: string, options: {
  69654. shape: Vector3[];
  69655. path: Vector3[];
  69656. scale?: number;
  69657. rotation?: number;
  69658. cap?: number;
  69659. updatable?: boolean;
  69660. sideOrientation?: number;
  69661. frontUVs?: Vector4;
  69662. backUVs?: Vector4;
  69663. instance?: Mesh;
  69664. invertUV?: boolean;
  69665. }, scene?: Nullable<Scene>): Mesh;
  69666. /**
  69667. * Creates an custom extruded shape mesh.
  69668. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69669. * * 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.
  69670. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69671. * * 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
  69672. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69673. * * 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
  69674. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69675. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69676. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69677. * * 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
  69678. * * 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
  69679. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69682. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69684. * @param name defines the name of the mesh
  69685. * @param options defines the options used to create the mesh
  69686. * @param scene defines the hosting scene
  69687. * @returns the custom extruded shape mesh
  69688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69689. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69690. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69691. */
  69692. static ExtrudeShapeCustom(name: string, options: {
  69693. shape: Vector3[];
  69694. path: Vector3[];
  69695. scaleFunction?: any;
  69696. rotationFunction?: any;
  69697. ribbonCloseArray?: boolean;
  69698. ribbonClosePath?: boolean;
  69699. cap?: number;
  69700. updatable?: boolean;
  69701. sideOrientation?: number;
  69702. frontUVs?: Vector4;
  69703. backUVs?: Vector4;
  69704. instance?: Mesh;
  69705. invertUV?: boolean;
  69706. }, scene?: Nullable<Scene>): Mesh;
  69707. /**
  69708. * Creates lathe mesh.
  69709. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69710. * * 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
  69711. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69712. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69713. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69714. * * 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
  69715. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69716. * * 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
  69717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69719. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69721. * @param name defines the name of the mesh
  69722. * @param options defines the options used to create the mesh
  69723. * @param scene defines the hosting scene
  69724. * @returns the lathe mesh
  69725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69726. */
  69727. static CreateLathe(name: string, options: {
  69728. shape: Vector3[];
  69729. radius?: number;
  69730. tessellation?: number;
  69731. clip?: number;
  69732. arc?: number;
  69733. closed?: boolean;
  69734. updatable?: boolean;
  69735. sideOrientation?: number;
  69736. frontUVs?: Vector4;
  69737. backUVs?: Vector4;
  69738. cap?: number;
  69739. invertUV?: boolean;
  69740. }, scene?: Nullable<Scene>): Mesh;
  69741. /**
  69742. * Creates a tiled plane mesh
  69743. * * You can set a limited pattern arrangement with the tiles
  69744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69747. * @param name defines the name of the mesh
  69748. * @param options defines the options used to create the mesh
  69749. * @param scene defines the hosting scene
  69750. * @returns the plane mesh
  69751. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69752. */
  69753. static CreateTiledPlane(name: string, options: {
  69754. pattern?: number;
  69755. tileSize?: number;
  69756. tileWidth?: number;
  69757. tileHeight?: number;
  69758. size?: number;
  69759. width?: number;
  69760. height?: number;
  69761. alignHorizontal?: number;
  69762. alignVertical?: number;
  69763. sideOrientation?: number;
  69764. frontUVs?: Vector4;
  69765. backUVs?: Vector4;
  69766. updatable?: boolean;
  69767. }, scene?: Nullable<Scene>): Mesh;
  69768. /**
  69769. * Creates a plane mesh
  69770. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69771. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69772. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69776. * @param name defines the name of the mesh
  69777. * @param options defines the options used to create the mesh
  69778. * @param scene defines the hosting scene
  69779. * @returns the plane mesh
  69780. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69781. */
  69782. static CreatePlane(name: string, options: {
  69783. size?: number;
  69784. width?: number;
  69785. height?: number;
  69786. sideOrientation?: number;
  69787. frontUVs?: Vector4;
  69788. backUVs?: Vector4;
  69789. updatable?: boolean;
  69790. sourcePlane?: Plane;
  69791. }, scene?: Nullable<Scene>): Mesh;
  69792. /**
  69793. * Creates a ground mesh
  69794. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69795. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69797. * @param name defines the name of the mesh
  69798. * @param options defines the options used to create the mesh
  69799. * @param scene defines the hosting scene
  69800. * @returns the ground mesh
  69801. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69802. */
  69803. static CreateGround(name: string, options: {
  69804. width?: number;
  69805. height?: number;
  69806. subdivisions?: number;
  69807. subdivisionsX?: number;
  69808. subdivisionsY?: number;
  69809. updatable?: boolean;
  69810. }, scene?: Nullable<Scene>): Mesh;
  69811. /**
  69812. * Creates a tiled ground mesh
  69813. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69814. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69815. * * 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
  69816. * * 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
  69817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69818. * @param name defines the name of the mesh
  69819. * @param options defines the options used to create the mesh
  69820. * @param scene defines the hosting scene
  69821. * @returns the tiled ground mesh
  69822. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69823. */
  69824. static CreateTiledGround(name: string, options: {
  69825. xmin: number;
  69826. zmin: number;
  69827. xmax: number;
  69828. zmax: number;
  69829. subdivisions?: {
  69830. w: number;
  69831. h: number;
  69832. };
  69833. precision?: {
  69834. w: number;
  69835. h: number;
  69836. };
  69837. updatable?: boolean;
  69838. }, scene?: Nullable<Scene>): Mesh;
  69839. /**
  69840. * Creates a ground mesh from a height map
  69841. * * The parameter `url` sets the URL of the height map image resource.
  69842. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69843. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69844. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69845. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69846. * * 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.
  69847. * * 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).
  69848. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69850. * @param name defines the name of the mesh
  69851. * @param url defines the url to the height map
  69852. * @param options defines the options used to create the mesh
  69853. * @param scene defines the hosting scene
  69854. * @returns the ground mesh
  69855. * @see https://doc.babylonjs.com/babylon101/height_map
  69856. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69857. */
  69858. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69859. width?: number;
  69860. height?: number;
  69861. subdivisions?: number;
  69862. minHeight?: number;
  69863. maxHeight?: number;
  69864. colorFilter?: Color3;
  69865. alphaFilter?: number;
  69866. updatable?: boolean;
  69867. onReady?: (mesh: GroundMesh) => void;
  69868. }, scene?: Nullable<Scene>): GroundMesh;
  69869. /**
  69870. * Creates a polygon mesh
  69871. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69872. * * 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
  69873. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69876. * * Remember you can only change the shape positions, not their number when updating a polygon
  69877. * @param name defines the name of the mesh
  69878. * @param options defines the options used to create the mesh
  69879. * @param scene defines the hosting scene
  69880. * @param earcutInjection can be used to inject your own earcut reference
  69881. * @returns the polygon mesh
  69882. */
  69883. static CreatePolygon(name: string, options: {
  69884. shape: Vector3[];
  69885. holes?: Vector3[][];
  69886. depth?: number;
  69887. faceUV?: Vector4[];
  69888. faceColors?: Color4[];
  69889. updatable?: boolean;
  69890. sideOrientation?: number;
  69891. frontUVs?: Vector4;
  69892. backUVs?: Vector4;
  69893. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69894. /**
  69895. * Creates an extruded polygon mesh, with depth in the Y direction.
  69896. * * 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)
  69897. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69898. * @param name defines the name of the mesh
  69899. * @param options defines the options used to create the mesh
  69900. * @param scene defines the hosting scene
  69901. * @param earcutInjection can be used to inject your own earcut reference
  69902. * @returns the polygon mesh
  69903. */
  69904. static ExtrudePolygon(name: string, options: {
  69905. shape: Vector3[];
  69906. holes?: Vector3[][];
  69907. depth?: number;
  69908. faceUV?: Vector4[];
  69909. faceColors?: Color4[];
  69910. updatable?: boolean;
  69911. sideOrientation?: number;
  69912. frontUVs?: Vector4;
  69913. backUVs?: Vector4;
  69914. wrap?: boolean;
  69915. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69916. /**
  69917. * Creates a tube mesh.
  69918. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69919. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69920. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69921. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69922. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69923. * * 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)
  69924. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69925. * * 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
  69926. * * 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
  69927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69929. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69931. * @param name defines the name of the mesh
  69932. * @param options defines the options used to create the mesh
  69933. * @param scene defines the hosting scene
  69934. * @returns the tube mesh
  69935. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69936. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69937. */
  69938. static CreateTube(name: string, options: {
  69939. path: Vector3[];
  69940. radius?: number;
  69941. tessellation?: number;
  69942. radiusFunction?: {
  69943. (i: number, distance: number): number;
  69944. };
  69945. cap?: number;
  69946. arc?: number;
  69947. updatable?: boolean;
  69948. sideOrientation?: number;
  69949. frontUVs?: Vector4;
  69950. backUVs?: Vector4;
  69951. instance?: Mesh;
  69952. invertUV?: boolean;
  69953. }, scene?: Nullable<Scene>): Mesh;
  69954. /**
  69955. * Creates a polyhedron mesh
  69956. * * 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
  69957. * * The parameter `size` (positive float, default 1) sets the polygon size
  69958. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69959. * * 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`
  69960. * * 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
  69961. * * 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)`)
  69962. * * 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
  69963. * * 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
  69964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69967. * @param name defines the name of the mesh
  69968. * @param options defines the options used to create the mesh
  69969. * @param scene defines the hosting scene
  69970. * @returns the polyhedron mesh
  69971. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69972. */
  69973. static CreatePolyhedron(name: string, options: {
  69974. type?: number;
  69975. size?: number;
  69976. sizeX?: number;
  69977. sizeY?: number;
  69978. sizeZ?: number;
  69979. custom?: any;
  69980. faceUV?: Vector4[];
  69981. faceColors?: Color4[];
  69982. flat?: boolean;
  69983. updatable?: boolean;
  69984. sideOrientation?: number;
  69985. frontUVs?: Vector4;
  69986. backUVs?: Vector4;
  69987. }, scene?: Nullable<Scene>): Mesh;
  69988. /**
  69989. * Creates a decal mesh.
  69990. * 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
  69991. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69992. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69993. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69994. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69995. * @param name defines the name of the mesh
  69996. * @param sourceMesh defines the mesh where the decal must be applied
  69997. * @param options defines the options used to create the mesh
  69998. * @param scene defines the hosting scene
  69999. * @returns the decal mesh
  70000. * @see https://doc.babylonjs.com/how_to/decals
  70001. */
  70002. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70003. position?: Vector3;
  70004. normal?: Vector3;
  70005. size?: Vector3;
  70006. angle?: number;
  70007. }): Mesh;
  70008. /**
  70009. * Creates a Capsule Mesh
  70010. * @param name defines the name of the mesh.
  70011. * @param options the constructors options used to shape the mesh.
  70012. * @param scene defines the scene the mesh is scoped to.
  70013. * @returns the capsule mesh
  70014. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70015. */
  70016. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70017. }
  70018. }
  70019. declare module "babylonjs/Meshes/meshSimplification" {
  70020. import { Mesh } from "babylonjs/Meshes/mesh";
  70021. /**
  70022. * A simplifier interface for future simplification implementations
  70023. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70024. */
  70025. export interface ISimplifier {
  70026. /**
  70027. * Simplification of a given mesh according to the given settings.
  70028. * Since this requires computation, it is assumed that the function runs async.
  70029. * @param settings The settings of the simplification, including quality and distance
  70030. * @param successCallback A callback that will be called after the mesh was simplified.
  70031. * @param errorCallback in case of an error, this callback will be called. optional.
  70032. */
  70033. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70034. }
  70035. /**
  70036. * Expected simplification settings.
  70037. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70038. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70039. */
  70040. export interface ISimplificationSettings {
  70041. /**
  70042. * Gets or sets the expected quality
  70043. */
  70044. quality: number;
  70045. /**
  70046. * Gets or sets the distance when this optimized version should be used
  70047. */
  70048. distance: number;
  70049. /**
  70050. * Gets an already optimized mesh
  70051. */
  70052. optimizeMesh?: boolean;
  70053. }
  70054. /**
  70055. * Class used to specify simplification options
  70056. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70057. */
  70058. export class SimplificationSettings implements ISimplificationSettings {
  70059. /** expected quality */
  70060. quality: number;
  70061. /** distance when this optimized version should be used */
  70062. distance: number;
  70063. /** already optimized mesh */
  70064. optimizeMesh?: boolean | undefined;
  70065. /**
  70066. * Creates a SimplificationSettings
  70067. * @param quality expected quality
  70068. * @param distance distance when this optimized version should be used
  70069. * @param optimizeMesh already optimized mesh
  70070. */
  70071. constructor(
  70072. /** expected quality */
  70073. quality: number,
  70074. /** distance when this optimized version should be used */
  70075. distance: number,
  70076. /** already optimized mesh */
  70077. optimizeMesh?: boolean | undefined);
  70078. }
  70079. /**
  70080. * Interface used to define a simplification task
  70081. */
  70082. export interface ISimplificationTask {
  70083. /**
  70084. * Array of settings
  70085. */
  70086. settings: Array<ISimplificationSettings>;
  70087. /**
  70088. * Simplification type
  70089. */
  70090. simplificationType: SimplificationType;
  70091. /**
  70092. * Mesh to simplify
  70093. */
  70094. mesh: Mesh;
  70095. /**
  70096. * Callback called on success
  70097. */
  70098. successCallback?: () => void;
  70099. /**
  70100. * Defines if parallel processing can be used
  70101. */
  70102. parallelProcessing: boolean;
  70103. }
  70104. /**
  70105. * Queue used to order the simplification tasks
  70106. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70107. */
  70108. export class SimplificationQueue {
  70109. private _simplificationArray;
  70110. /**
  70111. * Gets a boolean indicating that the process is still running
  70112. */
  70113. running: boolean;
  70114. /**
  70115. * Creates a new queue
  70116. */
  70117. constructor();
  70118. /**
  70119. * Adds a new simplification task
  70120. * @param task defines a task to add
  70121. */
  70122. addTask(task: ISimplificationTask): void;
  70123. /**
  70124. * Execute next task
  70125. */
  70126. executeNext(): void;
  70127. /**
  70128. * Execute a simplification task
  70129. * @param task defines the task to run
  70130. */
  70131. runSimplification(task: ISimplificationTask): void;
  70132. private getSimplifier;
  70133. }
  70134. /**
  70135. * The implemented types of simplification
  70136. * At the moment only Quadratic Error Decimation is implemented
  70137. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70138. */
  70139. export enum SimplificationType {
  70140. /** Quadratic error decimation */
  70141. QUADRATIC = 0
  70142. }
  70143. /**
  70144. * An implementation of the Quadratic Error simplification algorithm.
  70145. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70146. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70147. * @author RaananW
  70148. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70149. */
  70150. export class QuadraticErrorSimplification implements ISimplifier {
  70151. private _mesh;
  70152. private triangles;
  70153. private vertices;
  70154. private references;
  70155. private _reconstructedMesh;
  70156. /** Gets or sets the number pf sync interations */
  70157. syncIterations: number;
  70158. /** Gets or sets the aggressiveness of the simplifier */
  70159. aggressiveness: number;
  70160. /** Gets or sets the number of allowed iterations for decimation */
  70161. decimationIterations: number;
  70162. /** Gets or sets the espilon to use for bounding box computation */
  70163. boundingBoxEpsilon: number;
  70164. /**
  70165. * Creates a new QuadraticErrorSimplification
  70166. * @param _mesh defines the target mesh
  70167. */
  70168. constructor(_mesh: Mesh);
  70169. /**
  70170. * Simplification of a given mesh according to the given settings.
  70171. * Since this requires computation, it is assumed that the function runs async.
  70172. * @param settings The settings of the simplification, including quality and distance
  70173. * @param successCallback A callback that will be called after the mesh was simplified.
  70174. */
  70175. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70176. private runDecimation;
  70177. private initWithMesh;
  70178. private init;
  70179. private reconstructMesh;
  70180. private initDecimatedMesh;
  70181. private isFlipped;
  70182. private updateTriangles;
  70183. private identifyBorder;
  70184. private updateMesh;
  70185. private vertexError;
  70186. private calculateError;
  70187. }
  70188. }
  70189. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70190. import { Scene } from "babylonjs/scene";
  70191. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70192. import { ISceneComponent } from "babylonjs/sceneComponent";
  70193. module "babylonjs/scene" {
  70194. interface Scene {
  70195. /** @hidden (Backing field) */
  70196. _simplificationQueue: SimplificationQueue;
  70197. /**
  70198. * Gets or sets the simplification queue attached to the scene
  70199. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70200. */
  70201. simplificationQueue: SimplificationQueue;
  70202. }
  70203. }
  70204. module "babylonjs/Meshes/mesh" {
  70205. interface Mesh {
  70206. /**
  70207. * Simplify the mesh according to the given array of settings.
  70208. * Function will return immediately and will simplify async
  70209. * @param settings a collection of simplification settings
  70210. * @param parallelProcessing should all levels calculate parallel or one after the other
  70211. * @param simplificationType the type of simplification to run
  70212. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70213. * @returns the current mesh
  70214. */
  70215. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70216. }
  70217. }
  70218. /**
  70219. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70220. * created in a scene
  70221. */
  70222. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70223. /**
  70224. * The component name helpfull to identify the component in the list of scene components.
  70225. */
  70226. readonly name: string;
  70227. /**
  70228. * The scene the component belongs to.
  70229. */
  70230. scene: Scene;
  70231. /**
  70232. * Creates a new instance of the component for the given scene
  70233. * @param scene Defines the scene to register the component in
  70234. */
  70235. constructor(scene: Scene);
  70236. /**
  70237. * Registers the component in a given scene
  70238. */
  70239. register(): void;
  70240. /**
  70241. * Rebuilds the elements related to this component in case of
  70242. * context lost for instance.
  70243. */
  70244. rebuild(): void;
  70245. /**
  70246. * Disposes the component and the associated ressources
  70247. */
  70248. dispose(): void;
  70249. private _beforeCameraUpdate;
  70250. }
  70251. }
  70252. declare module "babylonjs/Meshes/Builders/index" {
  70253. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70254. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70255. export * from "babylonjs/Meshes/Builders/discBuilder";
  70256. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70257. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70258. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70259. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70260. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70261. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70262. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70263. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70264. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70265. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70266. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70267. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70268. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70269. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70270. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70271. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70272. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70273. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70274. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70275. }
  70276. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70277. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70278. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70279. import { Matrix } from "babylonjs/Maths/math.vector";
  70280. module "babylonjs/Meshes/mesh" {
  70281. interface Mesh {
  70282. /**
  70283. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70284. */
  70285. thinInstanceEnablePicking: boolean;
  70286. /**
  70287. * Creates a new thin instance
  70288. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70289. * @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
  70290. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70291. */
  70292. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70293. /**
  70294. * Adds the transformation (matrix) of the current mesh as a thin instance
  70295. * @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
  70296. * @returns the thin instance index number
  70297. */
  70298. thinInstanceAddSelf(refresh: boolean): number;
  70299. /**
  70300. * Registers a custom attribute to be used with thin instances
  70301. * @param kind name of the attribute
  70302. * @param stride size in floats of the attribute
  70303. */
  70304. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70305. /**
  70306. * Sets the matrix of a thin instance
  70307. * @param index index of the thin instance
  70308. * @param matrix matrix to set
  70309. * @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
  70310. */
  70311. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70312. /**
  70313. * Sets the value of a custom attribute for a thin instance
  70314. * @param kind name of the attribute
  70315. * @param index index of the thin instance
  70316. * @param value value to set
  70317. * @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
  70318. */
  70319. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70320. /**
  70321. * 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.
  70322. */
  70323. thinInstanceCount: number;
  70324. /**
  70325. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70326. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70327. * @param buffer buffer to set
  70328. * @param stride size in floats of each value of the buffer
  70329. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70330. */
  70331. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70332. /**
  70333. * Gets the list of world matrices
  70334. * @return an array containing all the world matrices from the thin instances
  70335. */
  70336. thinInstanceGetWorldMatrices(): Matrix[];
  70337. /**
  70338. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70339. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70340. */
  70341. thinInstanceBufferUpdated(kind: string): void;
  70342. /**
  70343. * Applies a partial update to a buffer directly on the GPU
  70344. * 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
  70345. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70346. * @param data the data to set in the GPU buffer
  70347. * @param offset the offset in the GPU buffer where to update the data
  70348. */
  70349. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70350. /**
  70351. * Refreshes the bounding info, taking into account all the thin instances defined
  70352. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70353. */
  70354. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70355. /** @hidden */
  70356. _thinInstanceInitializeUserStorage(): void;
  70357. /** @hidden */
  70358. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70359. /** @hidden */
  70360. _userThinInstanceBuffersStorage: {
  70361. data: {
  70362. [key: string]: Float32Array;
  70363. };
  70364. sizes: {
  70365. [key: string]: number;
  70366. };
  70367. vertexBuffers: {
  70368. [key: string]: Nullable<VertexBuffer>;
  70369. };
  70370. strides: {
  70371. [key: string]: number;
  70372. };
  70373. };
  70374. }
  70375. }
  70376. }
  70377. declare module "babylonjs/Meshes/index" {
  70378. export * from "babylonjs/Meshes/abstractMesh";
  70379. export * from "babylonjs/Meshes/buffer";
  70380. export * from "babylonjs/Meshes/Compression/index";
  70381. export * from "babylonjs/Meshes/csg";
  70382. export * from "babylonjs/Meshes/geometry";
  70383. export * from "babylonjs/Meshes/groundMesh";
  70384. export * from "babylonjs/Meshes/trailMesh";
  70385. export * from "babylonjs/Meshes/instancedMesh";
  70386. export * from "babylonjs/Meshes/linesMesh";
  70387. export * from "babylonjs/Meshes/mesh";
  70388. export * from "babylonjs/Meshes/mesh.vertexData";
  70389. export * from "babylonjs/Meshes/meshBuilder";
  70390. export * from "babylonjs/Meshes/meshSimplification";
  70391. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70392. export * from "babylonjs/Meshes/polygonMesh";
  70393. export * from "babylonjs/Meshes/subMesh";
  70394. export * from "babylonjs/Meshes/meshLODLevel";
  70395. export * from "babylonjs/Meshes/transformNode";
  70396. export * from "babylonjs/Meshes/Builders/index";
  70397. export * from "babylonjs/Meshes/dataBuffer";
  70398. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70399. import "babylonjs/Meshes/thinInstanceMesh";
  70400. export * from "babylonjs/Meshes/thinInstanceMesh";
  70401. }
  70402. declare module "babylonjs/Morph/index" {
  70403. export * from "babylonjs/Morph/morphTarget";
  70404. export * from "babylonjs/Morph/morphTargetManager";
  70405. }
  70406. declare module "babylonjs/Navigation/INavigationEngine" {
  70407. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70408. import { Vector3 } from "babylonjs/Maths/math";
  70409. import { Mesh } from "babylonjs/Meshes/mesh";
  70410. import { Scene } from "babylonjs/scene";
  70411. /**
  70412. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70413. */
  70414. export interface INavigationEnginePlugin {
  70415. /**
  70416. * plugin name
  70417. */
  70418. name: string;
  70419. /**
  70420. * Creates a navigation mesh
  70421. * @param meshes array of all the geometry used to compute the navigatio mesh
  70422. * @param parameters bunch of parameters used to filter geometry
  70423. */
  70424. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70425. /**
  70426. * Create a navigation mesh debug mesh
  70427. * @param scene is where the mesh will be added
  70428. * @returns debug display mesh
  70429. */
  70430. createDebugNavMesh(scene: Scene): Mesh;
  70431. /**
  70432. * Get a navigation mesh constrained position, closest to the parameter position
  70433. * @param position world position
  70434. * @returns the closest point to position constrained by the navigation mesh
  70435. */
  70436. getClosestPoint(position: Vector3): Vector3;
  70437. /**
  70438. * Get a navigation mesh constrained position, closest to the parameter position
  70439. * @param position world position
  70440. * @param result output the closest point to position constrained by the navigation mesh
  70441. */
  70442. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70443. /**
  70444. * Get a navigation mesh constrained position, within a particular radius
  70445. * @param position world position
  70446. * @param maxRadius the maximum distance to the constrained world position
  70447. * @returns the closest point to position constrained by the navigation mesh
  70448. */
  70449. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70450. /**
  70451. * Get a navigation mesh constrained position, within a particular radius
  70452. * @param position world position
  70453. * @param maxRadius the maximum distance to the constrained world position
  70454. * @param result output the closest point to position constrained by the navigation mesh
  70455. */
  70456. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70457. /**
  70458. * Compute the final position from a segment made of destination-position
  70459. * @param position world position
  70460. * @param destination world position
  70461. * @returns the resulting point along the navmesh
  70462. */
  70463. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70464. /**
  70465. * Compute the final position from a segment made of destination-position
  70466. * @param position world position
  70467. * @param destination world position
  70468. * @param result output the resulting point along the navmesh
  70469. */
  70470. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70471. /**
  70472. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70473. * @param start world position
  70474. * @param end world position
  70475. * @returns array containing world position composing the path
  70476. */
  70477. computePath(start: Vector3, end: Vector3): Vector3[];
  70478. /**
  70479. * If this plugin is supported
  70480. * @returns true if plugin is supported
  70481. */
  70482. isSupported(): boolean;
  70483. /**
  70484. * Create a new Crowd so you can add agents
  70485. * @param maxAgents the maximum agent count in the crowd
  70486. * @param maxAgentRadius the maximum radius an agent can have
  70487. * @param scene to attach the crowd to
  70488. * @returns the crowd you can add agents to
  70489. */
  70490. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70491. /**
  70492. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70493. * The queries will try to find a solution within those bounds
  70494. * default is (1,1,1)
  70495. * @param extent x,y,z value that define the extent around the queries point of reference
  70496. */
  70497. setDefaultQueryExtent(extent: Vector3): void;
  70498. /**
  70499. * Get the Bounding box extent specified by setDefaultQueryExtent
  70500. * @returns the box extent values
  70501. */
  70502. getDefaultQueryExtent(): Vector3;
  70503. /**
  70504. * build the navmesh from a previously saved state using getNavmeshData
  70505. * @param data the Uint8Array returned by getNavmeshData
  70506. */
  70507. buildFromNavmeshData(data: Uint8Array): void;
  70508. /**
  70509. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70510. * @returns data the Uint8Array that can be saved and reused
  70511. */
  70512. getNavmeshData(): Uint8Array;
  70513. /**
  70514. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70515. * @param result output the box extent values
  70516. */
  70517. getDefaultQueryExtentToRef(result: Vector3): void;
  70518. /**
  70519. * Release all resources
  70520. */
  70521. dispose(): void;
  70522. }
  70523. /**
  70524. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70525. */
  70526. export interface ICrowd {
  70527. /**
  70528. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70529. * You can attach anything to that node. The node position is updated in the scene update tick.
  70530. * @param pos world position that will be constrained by the navigation mesh
  70531. * @param parameters agent parameters
  70532. * @param transform hooked to the agent that will be update by the scene
  70533. * @returns agent index
  70534. */
  70535. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70536. /**
  70537. * Returns the agent position in world space
  70538. * @param index agent index returned by addAgent
  70539. * @returns world space position
  70540. */
  70541. getAgentPosition(index: number): Vector3;
  70542. /**
  70543. * Gets the agent position result in world space
  70544. * @param index agent index returned by addAgent
  70545. * @param result output world space position
  70546. */
  70547. getAgentPositionToRef(index: number, result: Vector3): void;
  70548. /**
  70549. * Gets the agent velocity in world space
  70550. * @param index agent index returned by addAgent
  70551. * @returns world space velocity
  70552. */
  70553. getAgentVelocity(index: number): Vector3;
  70554. /**
  70555. * Gets the agent velocity result in world space
  70556. * @param index agent index returned by addAgent
  70557. * @param result output world space velocity
  70558. */
  70559. getAgentVelocityToRef(index: number, result: Vector3): void;
  70560. /**
  70561. * remove a particular agent previously created
  70562. * @param index agent index returned by addAgent
  70563. */
  70564. removeAgent(index: number): void;
  70565. /**
  70566. * get the list of all agents attached to this crowd
  70567. * @returns list of agent indices
  70568. */
  70569. getAgents(): number[];
  70570. /**
  70571. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70572. * @param deltaTime in seconds
  70573. */
  70574. update(deltaTime: number): void;
  70575. /**
  70576. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70577. * @param index agent index returned by addAgent
  70578. * @param destination targeted world position
  70579. */
  70580. agentGoto(index: number, destination: Vector3): void;
  70581. /**
  70582. * Teleport the agent to a new position
  70583. * @param index agent index returned by addAgent
  70584. * @param destination targeted world position
  70585. */
  70586. agentTeleport(index: number, destination: Vector3): void;
  70587. /**
  70588. * Update agent parameters
  70589. * @param index agent index returned by addAgent
  70590. * @param parameters agent parameters
  70591. */
  70592. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70593. /**
  70594. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70595. * The queries will try to find a solution within those bounds
  70596. * default is (1,1,1)
  70597. * @param extent x,y,z value that define the extent around the queries point of reference
  70598. */
  70599. setDefaultQueryExtent(extent: Vector3): void;
  70600. /**
  70601. * Get the Bounding box extent specified by setDefaultQueryExtent
  70602. * @returns the box extent values
  70603. */
  70604. getDefaultQueryExtent(): Vector3;
  70605. /**
  70606. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70607. * @param result output the box extent values
  70608. */
  70609. getDefaultQueryExtentToRef(result: Vector3): void;
  70610. /**
  70611. * Release all resources
  70612. */
  70613. dispose(): void;
  70614. }
  70615. /**
  70616. * Configures an agent
  70617. */
  70618. export interface IAgentParameters {
  70619. /**
  70620. * Agent radius. [Limit: >= 0]
  70621. */
  70622. radius: number;
  70623. /**
  70624. * Agent height. [Limit: > 0]
  70625. */
  70626. height: number;
  70627. /**
  70628. * Maximum allowed acceleration. [Limit: >= 0]
  70629. */
  70630. maxAcceleration: number;
  70631. /**
  70632. * Maximum allowed speed. [Limit: >= 0]
  70633. */
  70634. maxSpeed: number;
  70635. /**
  70636. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70637. */
  70638. collisionQueryRange: number;
  70639. /**
  70640. * The path visibility optimization range. [Limit: > 0]
  70641. */
  70642. pathOptimizationRange: number;
  70643. /**
  70644. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70645. */
  70646. separationWeight: number;
  70647. }
  70648. /**
  70649. * Configures the navigation mesh creation
  70650. */
  70651. export interface INavMeshParameters {
  70652. /**
  70653. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70654. */
  70655. cs: number;
  70656. /**
  70657. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70658. */
  70659. ch: number;
  70660. /**
  70661. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70662. */
  70663. walkableSlopeAngle: number;
  70664. /**
  70665. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70666. * be considered walkable. [Limit: >= 3] [Units: vx]
  70667. */
  70668. walkableHeight: number;
  70669. /**
  70670. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70671. */
  70672. walkableClimb: number;
  70673. /**
  70674. * The distance to erode/shrink the walkable area of the heightfield away from
  70675. * obstructions. [Limit: >=0] [Units: vx]
  70676. */
  70677. walkableRadius: number;
  70678. /**
  70679. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70680. */
  70681. maxEdgeLen: number;
  70682. /**
  70683. * The maximum distance a simplfied contour's border edges should deviate
  70684. * the original raw contour. [Limit: >=0] [Units: vx]
  70685. */
  70686. maxSimplificationError: number;
  70687. /**
  70688. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70689. */
  70690. minRegionArea: number;
  70691. /**
  70692. * Any regions with a span count smaller than this value will, if possible,
  70693. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70694. */
  70695. mergeRegionArea: number;
  70696. /**
  70697. * The maximum number of vertices allowed for polygons generated during the
  70698. * contour to polygon conversion process. [Limit: >= 3]
  70699. */
  70700. maxVertsPerPoly: number;
  70701. /**
  70702. * Sets the sampling distance to use when generating the detail mesh.
  70703. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70704. */
  70705. detailSampleDist: number;
  70706. /**
  70707. * The maximum distance the detail mesh surface should deviate from heightfield
  70708. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70709. */
  70710. detailSampleMaxError: number;
  70711. }
  70712. }
  70713. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70714. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70715. import { Mesh } from "babylonjs/Meshes/mesh";
  70716. import { Scene } from "babylonjs/scene";
  70717. import { Vector3 } from "babylonjs/Maths/math";
  70718. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70719. /**
  70720. * RecastJS navigation plugin
  70721. */
  70722. export class RecastJSPlugin implements INavigationEnginePlugin {
  70723. /**
  70724. * Reference to the Recast library
  70725. */
  70726. bjsRECAST: any;
  70727. /**
  70728. * plugin name
  70729. */
  70730. name: string;
  70731. /**
  70732. * the first navmesh created. We might extend this to support multiple navmeshes
  70733. */
  70734. navMesh: any;
  70735. /**
  70736. * Initializes the recastJS plugin
  70737. * @param recastInjection can be used to inject your own recast reference
  70738. */
  70739. constructor(recastInjection?: any);
  70740. /**
  70741. * Creates a navigation mesh
  70742. * @param meshes array of all the geometry used to compute the navigatio mesh
  70743. * @param parameters bunch of parameters used to filter geometry
  70744. */
  70745. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70746. /**
  70747. * Create a navigation mesh debug mesh
  70748. * @param scene is where the mesh will be added
  70749. * @returns debug display mesh
  70750. */
  70751. createDebugNavMesh(scene: Scene): Mesh;
  70752. /**
  70753. * Get a navigation mesh constrained position, closest to the parameter position
  70754. * @param position world position
  70755. * @returns the closest point to position constrained by the navigation mesh
  70756. */
  70757. getClosestPoint(position: Vector3): Vector3;
  70758. /**
  70759. * Get a navigation mesh constrained position, closest to the parameter position
  70760. * @param position world position
  70761. * @param result output the closest point to position constrained by the navigation mesh
  70762. */
  70763. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70764. /**
  70765. * Get a navigation mesh constrained position, within a particular radius
  70766. * @param position world position
  70767. * @param maxRadius the maximum distance to the constrained world position
  70768. * @returns the closest point to position constrained by the navigation mesh
  70769. */
  70770. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70771. /**
  70772. * Get a navigation mesh constrained position, within a particular radius
  70773. * @param position world position
  70774. * @param maxRadius the maximum distance to the constrained world position
  70775. * @param result output the closest point to position constrained by the navigation mesh
  70776. */
  70777. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70778. /**
  70779. * Compute the final position from a segment made of destination-position
  70780. * @param position world position
  70781. * @param destination world position
  70782. * @returns the resulting point along the navmesh
  70783. */
  70784. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70785. /**
  70786. * Compute the final position from a segment made of destination-position
  70787. * @param position world position
  70788. * @param destination world position
  70789. * @param result output the resulting point along the navmesh
  70790. */
  70791. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70792. /**
  70793. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70794. * @param start world position
  70795. * @param end world position
  70796. * @returns array containing world position composing the path
  70797. */
  70798. computePath(start: Vector3, end: Vector3): Vector3[];
  70799. /**
  70800. * Create a new Crowd so you can add agents
  70801. * @param maxAgents the maximum agent count in the crowd
  70802. * @param maxAgentRadius the maximum radius an agent can have
  70803. * @param scene to attach the crowd to
  70804. * @returns the crowd you can add agents to
  70805. */
  70806. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70807. /**
  70808. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70809. * The queries will try to find a solution within those bounds
  70810. * default is (1,1,1)
  70811. * @param extent x,y,z value that define the extent around the queries point of reference
  70812. */
  70813. setDefaultQueryExtent(extent: Vector3): void;
  70814. /**
  70815. * Get the Bounding box extent specified by setDefaultQueryExtent
  70816. * @returns the box extent values
  70817. */
  70818. getDefaultQueryExtent(): Vector3;
  70819. /**
  70820. * build the navmesh from a previously saved state using getNavmeshData
  70821. * @param data the Uint8Array returned by getNavmeshData
  70822. */
  70823. buildFromNavmeshData(data: Uint8Array): void;
  70824. /**
  70825. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70826. * @returns data the Uint8Array that can be saved and reused
  70827. */
  70828. getNavmeshData(): Uint8Array;
  70829. /**
  70830. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70831. * @param result output the box extent values
  70832. */
  70833. getDefaultQueryExtentToRef(result: Vector3): void;
  70834. /**
  70835. * Disposes
  70836. */
  70837. dispose(): void;
  70838. /**
  70839. * If this plugin is supported
  70840. * @returns true if plugin is supported
  70841. */
  70842. isSupported(): boolean;
  70843. }
  70844. /**
  70845. * Recast detour crowd implementation
  70846. */
  70847. export class RecastJSCrowd implements ICrowd {
  70848. /**
  70849. * Recast/detour plugin
  70850. */
  70851. bjsRECASTPlugin: RecastJSPlugin;
  70852. /**
  70853. * Link to the detour crowd
  70854. */
  70855. recastCrowd: any;
  70856. /**
  70857. * One transform per agent
  70858. */
  70859. transforms: TransformNode[];
  70860. /**
  70861. * All agents created
  70862. */
  70863. agents: number[];
  70864. /**
  70865. * Link to the scene is kept to unregister the crowd from the scene
  70866. */
  70867. private _scene;
  70868. /**
  70869. * Observer for crowd updates
  70870. */
  70871. private _onBeforeAnimationsObserver;
  70872. /**
  70873. * Constructor
  70874. * @param plugin recastJS plugin
  70875. * @param maxAgents the maximum agent count in the crowd
  70876. * @param maxAgentRadius the maximum radius an agent can have
  70877. * @param scene to attach the crowd to
  70878. * @returns the crowd you can add agents to
  70879. */
  70880. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70881. /**
  70882. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70883. * You can attach anything to that node. The node position is updated in the scene update tick.
  70884. * @param pos world position that will be constrained by the navigation mesh
  70885. * @param parameters agent parameters
  70886. * @param transform hooked to the agent that will be update by the scene
  70887. * @returns agent index
  70888. */
  70889. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70890. /**
  70891. * Returns the agent position in world space
  70892. * @param index agent index returned by addAgent
  70893. * @returns world space position
  70894. */
  70895. getAgentPosition(index: number): Vector3;
  70896. /**
  70897. * Returns the agent position result in world space
  70898. * @param index agent index returned by addAgent
  70899. * @param result output world space position
  70900. */
  70901. getAgentPositionToRef(index: number, result: Vector3): void;
  70902. /**
  70903. * Returns the agent velocity in world space
  70904. * @param index agent index returned by addAgent
  70905. * @returns world space velocity
  70906. */
  70907. getAgentVelocity(index: number): Vector3;
  70908. /**
  70909. * Returns the agent velocity result in world space
  70910. * @param index agent index returned by addAgent
  70911. * @param result output world space velocity
  70912. */
  70913. getAgentVelocityToRef(index: number, result: Vector3): void;
  70914. /**
  70915. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70916. * @param index agent index returned by addAgent
  70917. * @param destination targeted world position
  70918. */
  70919. agentGoto(index: number, destination: Vector3): void;
  70920. /**
  70921. * Teleport the agent to a new position
  70922. * @param index agent index returned by addAgent
  70923. * @param destination targeted world position
  70924. */
  70925. agentTeleport(index: number, destination: Vector3): void;
  70926. /**
  70927. * Update agent parameters
  70928. * @param index agent index returned by addAgent
  70929. * @param parameters agent parameters
  70930. */
  70931. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70932. /**
  70933. * remove a particular agent previously created
  70934. * @param index agent index returned by addAgent
  70935. */
  70936. removeAgent(index: number): void;
  70937. /**
  70938. * get the list of all agents attached to this crowd
  70939. * @returns list of agent indices
  70940. */
  70941. getAgents(): number[];
  70942. /**
  70943. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70944. * @param deltaTime in seconds
  70945. */
  70946. update(deltaTime: number): void;
  70947. /**
  70948. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70949. * The queries will try to find a solution within those bounds
  70950. * default is (1,1,1)
  70951. * @param extent x,y,z value that define the extent around the queries point of reference
  70952. */
  70953. setDefaultQueryExtent(extent: Vector3): void;
  70954. /**
  70955. * Get the Bounding box extent specified by setDefaultQueryExtent
  70956. * @returns the box extent values
  70957. */
  70958. getDefaultQueryExtent(): Vector3;
  70959. /**
  70960. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70961. * @param result output the box extent values
  70962. */
  70963. getDefaultQueryExtentToRef(result: Vector3): void;
  70964. /**
  70965. * Release all resources
  70966. */
  70967. dispose(): void;
  70968. }
  70969. }
  70970. declare module "babylonjs/Navigation/Plugins/index" {
  70971. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70972. }
  70973. declare module "babylonjs/Navigation/index" {
  70974. export * from "babylonjs/Navigation/INavigationEngine";
  70975. export * from "babylonjs/Navigation/Plugins/index";
  70976. }
  70977. declare module "babylonjs/Offline/database" {
  70978. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70979. /**
  70980. * Class used to enable access to IndexedDB
  70981. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70982. */
  70983. export class Database implements IOfflineProvider {
  70984. private _callbackManifestChecked;
  70985. private _currentSceneUrl;
  70986. private _db;
  70987. private _enableSceneOffline;
  70988. private _enableTexturesOffline;
  70989. private _manifestVersionFound;
  70990. private _mustUpdateRessources;
  70991. private _hasReachedQuota;
  70992. private _isSupported;
  70993. private _idbFactory;
  70994. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70995. private static IsUASupportingBlobStorage;
  70996. /**
  70997. * Gets a boolean indicating if Database storate is enabled (off by default)
  70998. */
  70999. static IDBStorageEnabled: boolean;
  71000. /**
  71001. * Gets a boolean indicating if scene must be saved in the database
  71002. */
  71003. get enableSceneOffline(): boolean;
  71004. /**
  71005. * Gets a boolean indicating if textures must be saved in the database
  71006. */
  71007. get enableTexturesOffline(): boolean;
  71008. /**
  71009. * Creates a new Database
  71010. * @param urlToScene defines the url to load the scene
  71011. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71012. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71013. */
  71014. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71015. private static _ParseURL;
  71016. private static _ReturnFullUrlLocation;
  71017. private _checkManifestFile;
  71018. /**
  71019. * Open the database and make it available
  71020. * @param successCallback defines the callback to call on success
  71021. * @param errorCallback defines the callback to call on error
  71022. */
  71023. open(successCallback: () => void, errorCallback: () => void): void;
  71024. /**
  71025. * Loads an image from the database
  71026. * @param url defines the url to load from
  71027. * @param image defines the target DOM image
  71028. */
  71029. loadImage(url: string, image: HTMLImageElement): void;
  71030. private _loadImageFromDBAsync;
  71031. private _saveImageIntoDBAsync;
  71032. private _checkVersionFromDB;
  71033. private _loadVersionFromDBAsync;
  71034. private _saveVersionIntoDBAsync;
  71035. /**
  71036. * Loads a file from database
  71037. * @param url defines the URL to load from
  71038. * @param sceneLoaded defines a callback to call on success
  71039. * @param progressCallBack defines a callback to call when progress changed
  71040. * @param errorCallback defines a callback to call on error
  71041. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71042. */
  71043. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71044. private _loadFileAsync;
  71045. private _saveFileAsync;
  71046. /**
  71047. * Validates if xhr data is correct
  71048. * @param xhr defines the request to validate
  71049. * @param dataType defines the expected data type
  71050. * @returns true if data is correct
  71051. */
  71052. private static _ValidateXHRData;
  71053. }
  71054. }
  71055. declare module "babylonjs/Offline/index" {
  71056. export * from "babylonjs/Offline/database";
  71057. export * from "babylonjs/Offline/IOfflineProvider";
  71058. }
  71059. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71060. /** @hidden */
  71061. export var gpuUpdateParticlesPixelShader: {
  71062. name: string;
  71063. shader: string;
  71064. };
  71065. }
  71066. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71067. /** @hidden */
  71068. export var gpuUpdateParticlesVertexShader: {
  71069. name: string;
  71070. shader: string;
  71071. };
  71072. }
  71073. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71074. /** @hidden */
  71075. export var clipPlaneFragmentDeclaration2: {
  71076. name: string;
  71077. shader: string;
  71078. };
  71079. }
  71080. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71081. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71082. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71083. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71084. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71085. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71086. /** @hidden */
  71087. export var gpuRenderParticlesPixelShader: {
  71088. name: string;
  71089. shader: string;
  71090. };
  71091. }
  71092. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71093. /** @hidden */
  71094. export var clipPlaneVertexDeclaration2: {
  71095. name: string;
  71096. shader: string;
  71097. };
  71098. }
  71099. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71100. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71101. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71102. /** @hidden */
  71103. export var gpuRenderParticlesVertexShader: {
  71104. name: string;
  71105. shader: string;
  71106. };
  71107. }
  71108. declare module "babylonjs/Particles/gpuParticleSystem" {
  71109. import { Nullable } from "babylonjs/types";
  71110. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71111. import { Observable } from "babylonjs/Misc/observable";
  71112. import { Matrix } from "babylonjs/Maths/math.vector";
  71113. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71114. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71115. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71116. import { IDisposable } from "babylonjs/scene";
  71117. import { Effect } from "babylonjs/Materials/effect";
  71118. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71119. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71120. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71121. import { Scene } from "babylonjs/scene";
  71122. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71123. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71124. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71125. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71126. /**
  71127. * This represents a GPU particle system in Babylon
  71128. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71129. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71130. */
  71131. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71132. /**
  71133. * The layer mask we are rendering the particles through.
  71134. */
  71135. layerMask: number;
  71136. private _capacity;
  71137. private _activeCount;
  71138. private _currentActiveCount;
  71139. private _accumulatedCount;
  71140. private _renderEffect;
  71141. private _updateEffect;
  71142. private _buffer0;
  71143. private _buffer1;
  71144. private _spriteBuffer;
  71145. private _updateVAO;
  71146. private _renderVAO;
  71147. private _targetIndex;
  71148. private _sourceBuffer;
  71149. private _targetBuffer;
  71150. private _currentRenderId;
  71151. private _started;
  71152. private _stopped;
  71153. private _timeDelta;
  71154. private _randomTexture;
  71155. private _randomTexture2;
  71156. private _attributesStrideSize;
  71157. private _updateEffectOptions;
  71158. private _randomTextureSize;
  71159. private _actualFrame;
  71160. private _customEffect;
  71161. private readonly _rawTextureWidth;
  71162. /**
  71163. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71164. */
  71165. static get IsSupported(): boolean;
  71166. /**
  71167. * An event triggered when the system is disposed.
  71168. */
  71169. onDisposeObservable: Observable<IParticleSystem>;
  71170. /**
  71171. * Gets the maximum number of particles active at the same time.
  71172. * @returns The max number of active particles.
  71173. */
  71174. getCapacity(): number;
  71175. /**
  71176. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71177. * to override the particles.
  71178. */
  71179. forceDepthWrite: boolean;
  71180. /**
  71181. * Gets or set the number of active particles
  71182. */
  71183. get activeParticleCount(): number;
  71184. set activeParticleCount(value: number);
  71185. private _preWarmDone;
  71186. /**
  71187. * Specifies if the particles are updated in emitter local space or world space.
  71188. */
  71189. isLocal: boolean;
  71190. /** Gets or sets a matrix to use to compute projection */
  71191. defaultProjectionMatrix: Matrix;
  71192. /**
  71193. * Is this system ready to be used/rendered
  71194. * @return true if the system is ready
  71195. */
  71196. isReady(): boolean;
  71197. /**
  71198. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71199. * @returns True if it has been started, otherwise false.
  71200. */
  71201. isStarted(): boolean;
  71202. /**
  71203. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71204. * @returns True if it has been stopped, otherwise false.
  71205. */
  71206. isStopped(): boolean;
  71207. /**
  71208. * Gets a boolean indicating that the system is stopping
  71209. * @returns true if the system is currently stopping
  71210. */
  71211. isStopping(): boolean;
  71212. /**
  71213. * Gets the number of particles active at the same time.
  71214. * @returns The number of active particles.
  71215. */
  71216. getActiveCount(): number;
  71217. /**
  71218. * Starts the particle system and begins to emit
  71219. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71220. */
  71221. start(delay?: number): void;
  71222. /**
  71223. * Stops the particle system.
  71224. */
  71225. stop(): void;
  71226. /**
  71227. * Remove all active particles
  71228. */
  71229. reset(): void;
  71230. /**
  71231. * Returns the string "GPUParticleSystem"
  71232. * @returns a string containing the class name
  71233. */
  71234. getClassName(): string;
  71235. /**
  71236. * Gets the custom effect used to render the particles
  71237. * @param blendMode Blend mode for which the effect should be retrieved
  71238. * @returns The effect
  71239. */
  71240. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71241. /**
  71242. * Sets the custom effect used to render the particles
  71243. * @param effect The effect to set
  71244. * @param blendMode Blend mode for which the effect should be set
  71245. */
  71246. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71247. /** @hidden */
  71248. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71249. /**
  71250. * Observable that will be called just before the particles are drawn
  71251. */
  71252. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71253. /**
  71254. * Gets the name of the particle vertex shader
  71255. */
  71256. get vertexShaderName(): string;
  71257. private _colorGradientsTexture;
  71258. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71259. /**
  71260. * Adds a new color gradient
  71261. * @param gradient defines the gradient to use (between 0 and 1)
  71262. * @param color1 defines the color to affect to the specified gradient
  71263. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71264. * @returns the current particle system
  71265. */
  71266. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71267. private _refreshColorGradient;
  71268. /** Force the system to rebuild all gradients that need to be resync */
  71269. forceRefreshGradients(): void;
  71270. /**
  71271. * Remove a specific color gradient
  71272. * @param gradient defines the gradient to remove
  71273. * @returns the current particle system
  71274. */
  71275. removeColorGradient(gradient: number): GPUParticleSystem;
  71276. private _angularSpeedGradientsTexture;
  71277. private _sizeGradientsTexture;
  71278. private _velocityGradientsTexture;
  71279. private _limitVelocityGradientsTexture;
  71280. private _dragGradientsTexture;
  71281. private _addFactorGradient;
  71282. /**
  71283. * Adds a new size gradient
  71284. * @param gradient defines the gradient to use (between 0 and 1)
  71285. * @param factor defines the size factor to affect to the specified gradient
  71286. * @returns the current particle system
  71287. */
  71288. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71289. /**
  71290. * Remove a specific size gradient
  71291. * @param gradient defines the gradient to remove
  71292. * @returns the current particle system
  71293. */
  71294. removeSizeGradient(gradient: number): GPUParticleSystem;
  71295. private _refreshFactorGradient;
  71296. /**
  71297. * Adds a new angular speed gradient
  71298. * @param gradient defines the gradient to use (between 0 and 1)
  71299. * @param factor defines the angular speed to affect to the specified gradient
  71300. * @returns the current particle system
  71301. */
  71302. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71303. /**
  71304. * Remove a specific angular speed gradient
  71305. * @param gradient defines the gradient to remove
  71306. * @returns the current particle system
  71307. */
  71308. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71309. /**
  71310. * Adds a new velocity gradient
  71311. * @param gradient defines the gradient to use (between 0 and 1)
  71312. * @param factor defines the velocity to affect to the specified gradient
  71313. * @returns the current particle system
  71314. */
  71315. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71316. /**
  71317. * Remove a specific velocity gradient
  71318. * @param gradient defines the gradient to remove
  71319. * @returns the current particle system
  71320. */
  71321. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71322. /**
  71323. * Adds a new limit velocity gradient
  71324. * @param gradient defines the gradient to use (between 0 and 1)
  71325. * @param factor defines the limit velocity value to affect to the specified gradient
  71326. * @returns the current particle system
  71327. */
  71328. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71329. /**
  71330. * Remove a specific limit velocity gradient
  71331. * @param gradient defines the gradient to remove
  71332. * @returns the current particle system
  71333. */
  71334. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71335. /**
  71336. * Adds a new drag gradient
  71337. * @param gradient defines the gradient to use (between 0 and 1)
  71338. * @param factor defines the drag value to affect to the specified gradient
  71339. * @returns the current particle system
  71340. */
  71341. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71342. /**
  71343. * Remove a specific drag gradient
  71344. * @param gradient defines the gradient to remove
  71345. * @returns the current particle system
  71346. */
  71347. removeDragGradient(gradient: number): GPUParticleSystem;
  71348. /**
  71349. * Not supported by GPUParticleSystem
  71350. * @param gradient defines the gradient to use (between 0 and 1)
  71351. * @param factor defines the emit rate value to affect to the specified gradient
  71352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71353. * @returns the current particle system
  71354. */
  71355. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71356. /**
  71357. * Not supported by GPUParticleSystem
  71358. * @param gradient defines the gradient to remove
  71359. * @returns the current particle system
  71360. */
  71361. removeEmitRateGradient(gradient: number): IParticleSystem;
  71362. /**
  71363. * Not supported by GPUParticleSystem
  71364. * @param gradient defines the gradient to use (between 0 and 1)
  71365. * @param factor defines the start size value to affect to the specified gradient
  71366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71367. * @returns the current particle system
  71368. */
  71369. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71370. /**
  71371. * Not supported by GPUParticleSystem
  71372. * @param gradient defines the gradient to remove
  71373. * @returns the current particle system
  71374. */
  71375. removeStartSizeGradient(gradient: number): IParticleSystem;
  71376. /**
  71377. * Not supported by GPUParticleSystem
  71378. * @param gradient defines the gradient to use (between 0 and 1)
  71379. * @param min defines the color remap minimal range
  71380. * @param max defines the color remap maximal range
  71381. * @returns the current particle system
  71382. */
  71383. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71384. /**
  71385. * Not supported by GPUParticleSystem
  71386. * @param gradient defines the gradient to remove
  71387. * @returns the current particle system
  71388. */
  71389. removeColorRemapGradient(): IParticleSystem;
  71390. /**
  71391. * Not supported by GPUParticleSystem
  71392. * @param gradient defines the gradient to use (between 0 and 1)
  71393. * @param min defines the alpha remap minimal range
  71394. * @param max defines the alpha remap maximal range
  71395. * @returns the current particle system
  71396. */
  71397. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71398. /**
  71399. * Not supported by GPUParticleSystem
  71400. * @param gradient defines the gradient to remove
  71401. * @returns the current particle system
  71402. */
  71403. removeAlphaRemapGradient(): IParticleSystem;
  71404. /**
  71405. * Not supported by GPUParticleSystem
  71406. * @param gradient defines the gradient to use (between 0 and 1)
  71407. * @param color defines the color to affect to the specified gradient
  71408. * @returns the current particle system
  71409. */
  71410. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71411. /**
  71412. * Not supported by GPUParticleSystem
  71413. * @param gradient defines the gradient to remove
  71414. * @returns the current particle system
  71415. */
  71416. removeRampGradient(): IParticleSystem;
  71417. /**
  71418. * Not supported by GPUParticleSystem
  71419. * @returns the list of ramp gradients
  71420. */
  71421. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71422. /**
  71423. * Not supported by GPUParticleSystem
  71424. * Gets or sets a boolean indicating that ramp gradients must be used
  71425. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71426. */
  71427. get useRampGradients(): boolean;
  71428. set useRampGradients(value: boolean);
  71429. /**
  71430. * Not supported by GPUParticleSystem
  71431. * @param gradient defines the gradient to use (between 0 and 1)
  71432. * @param factor defines the life time factor to affect to the specified gradient
  71433. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71434. * @returns the current particle system
  71435. */
  71436. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71437. /**
  71438. * Not supported by GPUParticleSystem
  71439. * @param gradient defines the gradient to remove
  71440. * @returns the current particle system
  71441. */
  71442. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71443. /**
  71444. * Instantiates a GPU particle system.
  71445. * 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.
  71446. * @param name The name of the particle system
  71447. * @param options The options used to create the system
  71448. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71449. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71450. * @param customEffect a custom effect used to change the way particles are rendered by default
  71451. */
  71452. constructor(name: string, options: Partial<{
  71453. capacity: number;
  71454. randomTextureSize: number;
  71455. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71456. protected _reset(): void;
  71457. private _createUpdateVAO;
  71458. private _createRenderVAO;
  71459. private _initialize;
  71460. /** @hidden */
  71461. _recreateUpdateEffect(): void;
  71462. private _getEffect;
  71463. /**
  71464. * Fill the defines array according to the current settings of the particle system
  71465. * @param defines Array to be updated
  71466. * @param blendMode blend mode to take into account when updating the array
  71467. */
  71468. fillDefines(defines: Array<string>, blendMode?: number): void;
  71469. /**
  71470. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71471. * @param uniforms Uniforms array to fill
  71472. * @param attributes Attributes array to fill
  71473. * @param samplers Samplers array to fill
  71474. */
  71475. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71476. /** @hidden */
  71477. _recreateRenderEffect(): Effect;
  71478. /**
  71479. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71480. * @param preWarm defines if we are in the pre-warmimg phase
  71481. */
  71482. animate(preWarm?: boolean): void;
  71483. private _createFactorGradientTexture;
  71484. private _createSizeGradientTexture;
  71485. private _createAngularSpeedGradientTexture;
  71486. private _createVelocityGradientTexture;
  71487. private _createLimitVelocityGradientTexture;
  71488. private _createDragGradientTexture;
  71489. private _createColorGradientTexture;
  71490. /**
  71491. * Renders the particle system in its current state
  71492. * @param preWarm defines if the system should only update the particles but not render them
  71493. * @returns the current number of particles
  71494. */
  71495. render(preWarm?: boolean): number;
  71496. /**
  71497. * Rebuilds the particle system
  71498. */
  71499. rebuild(): void;
  71500. private _releaseBuffers;
  71501. private _releaseVAOs;
  71502. /**
  71503. * Disposes the particle system and free the associated resources
  71504. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71505. */
  71506. dispose(disposeTexture?: boolean): void;
  71507. /**
  71508. * Clones the particle system.
  71509. * @param name The name of the cloned object
  71510. * @param newEmitter The new emitter to use
  71511. * @returns the cloned particle system
  71512. */
  71513. clone(name: string, newEmitter: any): GPUParticleSystem;
  71514. /**
  71515. * Serializes the particle system to a JSON object
  71516. * @param serializeTexture defines if the texture must be serialized as well
  71517. * @returns the JSON object
  71518. */
  71519. serialize(serializeTexture?: boolean): any;
  71520. /**
  71521. * Parses a JSON object to create a GPU particle system.
  71522. * @param parsedParticleSystem The JSON object to parse
  71523. * @param sceneOrEngine The scene or the engine to create the particle system in
  71524. * @param rootUrl The root url to use to load external dependencies like texture
  71525. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71526. * @returns the parsed GPU particle system
  71527. */
  71528. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71529. }
  71530. }
  71531. declare module "babylonjs/Particles/particleSystemSet" {
  71532. import { Nullable } from "babylonjs/types";
  71533. import { Color3 } from "babylonjs/Maths/math.color";
  71534. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71536. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71537. import { Scene, IDisposable } from "babylonjs/scene";
  71538. /**
  71539. * Represents a set of particle systems working together to create a specific effect
  71540. */
  71541. export class ParticleSystemSet implements IDisposable {
  71542. /**
  71543. * Gets or sets base Assets URL
  71544. */
  71545. static BaseAssetsUrl: string;
  71546. private _emitterCreationOptions;
  71547. private _emitterNode;
  71548. /**
  71549. * Gets the particle system list
  71550. */
  71551. systems: IParticleSystem[];
  71552. /**
  71553. * Gets the emitter node used with this set
  71554. */
  71555. get emitterNode(): Nullable<TransformNode>;
  71556. /**
  71557. * Creates a new emitter mesh as a sphere
  71558. * @param options defines the options used to create the sphere
  71559. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71560. * @param scene defines the hosting scene
  71561. */
  71562. setEmitterAsSphere(options: {
  71563. diameter: number;
  71564. segments: number;
  71565. color: Color3;
  71566. }, renderingGroupId: number, scene: Scene): void;
  71567. /**
  71568. * Starts all particle systems of the set
  71569. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71570. */
  71571. start(emitter?: AbstractMesh): void;
  71572. /**
  71573. * Release all associated resources
  71574. */
  71575. dispose(): void;
  71576. /**
  71577. * Serialize the set into a JSON compatible object
  71578. * @param serializeTexture defines if the texture must be serialized as well
  71579. * @returns a JSON compatible representation of the set
  71580. */
  71581. serialize(serializeTexture?: boolean): any;
  71582. /**
  71583. * Parse a new ParticleSystemSet from a serialized source
  71584. * @param data defines a JSON compatible representation of the set
  71585. * @param scene defines the hosting scene
  71586. * @param gpu defines if we want GPU particles or CPU particles
  71587. * @returns a new ParticleSystemSet
  71588. */
  71589. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71590. }
  71591. }
  71592. declare module "babylonjs/Particles/particleHelper" {
  71593. import { Nullable } from "babylonjs/types";
  71594. import { Scene } from "babylonjs/scene";
  71595. import { Vector3 } from "babylonjs/Maths/math.vector";
  71596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71597. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71598. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71599. /**
  71600. * This class is made for on one-liner static method to help creating particle system set.
  71601. */
  71602. export class ParticleHelper {
  71603. /**
  71604. * Gets or sets base Assets URL
  71605. */
  71606. static BaseAssetsUrl: string;
  71607. /** Define the Url to load snippets */
  71608. static SnippetUrl: string;
  71609. /**
  71610. * Create a default particle system that you can tweak
  71611. * @param emitter defines the emitter to use
  71612. * @param capacity defines the system capacity (default is 500 particles)
  71613. * @param scene defines the hosting scene
  71614. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71615. * @returns the new Particle system
  71616. */
  71617. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71618. /**
  71619. * This is the main static method (one-liner) of this helper to create different particle systems
  71620. * @param type This string represents the type to the particle system to create
  71621. * @param scene The scene where the particle system should live
  71622. * @param gpu If the system will use gpu
  71623. * @returns the ParticleSystemSet created
  71624. */
  71625. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71626. /**
  71627. * Static function used to export a particle system to a ParticleSystemSet variable.
  71628. * Please note that the emitter shape is not exported
  71629. * @param systems defines the particle systems to export
  71630. * @returns the created particle system set
  71631. */
  71632. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71633. /**
  71634. * Creates a particle system from a snippet saved in a remote file
  71635. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71636. * @param url defines the url to load from
  71637. * @param scene defines the hosting scene
  71638. * @param gpu If the system will use gpu
  71639. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71640. * @returns a promise that will resolve to the new particle system
  71641. */
  71642. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71643. /**
  71644. * Creates a particle system from a snippet saved by the particle system editor
  71645. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71646. * @param scene defines the hosting scene
  71647. * @param gpu If the system will use gpu
  71648. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71649. * @returns a promise that will resolve to the new particle system
  71650. */
  71651. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71652. }
  71653. }
  71654. declare module "babylonjs/Particles/particleSystemComponent" {
  71655. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71656. import { Effect } from "babylonjs/Materials/effect";
  71657. import "babylonjs/Shaders/particles.vertex";
  71658. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71659. module "babylonjs/Engines/engine" {
  71660. interface Engine {
  71661. /**
  71662. * Create an effect to use with particle systems.
  71663. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71664. * the particle system for which you want to create a custom effect in the last parameter
  71665. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71666. * @param uniformsNames defines a list of attribute names
  71667. * @param samplers defines an array of string used to represent textures
  71668. * @param defines defines the string containing the defines to use to compile the shaders
  71669. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71670. * @param onCompiled defines a function to call when the effect creation is successful
  71671. * @param onError defines a function to call when the effect creation has failed
  71672. * @param particleSystem the particle system you want to create the effect for
  71673. * @returns the new Effect
  71674. */
  71675. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71676. }
  71677. }
  71678. module "babylonjs/Meshes/mesh" {
  71679. interface Mesh {
  71680. /**
  71681. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71682. * @returns an array of IParticleSystem
  71683. */
  71684. getEmittedParticleSystems(): IParticleSystem[];
  71685. /**
  71686. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71687. * @returns an array of IParticleSystem
  71688. */
  71689. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71690. }
  71691. }
  71692. }
  71693. declare module "babylonjs/Particles/pointsCloudSystem" {
  71694. import { Color4 } from "babylonjs/Maths/math";
  71695. import { Mesh } from "babylonjs/Meshes/mesh";
  71696. import { Scene, IDisposable } from "babylonjs/scene";
  71697. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71698. /** Defines the 4 color options */
  71699. export enum PointColor {
  71700. /** color value */
  71701. Color = 2,
  71702. /** uv value */
  71703. UV = 1,
  71704. /** random value */
  71705. Random = 0,
  71706. /** stated value */
  71707. Stated = 3
  71708. }
  71709. /**
  71710. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71711. * 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.
  71712. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71713. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71714. *
  71715. * Full documentation here : TO BE ENTERED
  71716. */
  71717. export class PointsCloudSystem implements IDisposable {
  71718. /**
  71719. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71720. * Example : var p = SPS.particles[i];
  71721. */
  71722. particles: CloudPoint[];
  71723. /**
  71724. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71725. */
  71726. nbParticles: number;
  71727. /**
  71728. * This a counter for your own usage. It's not set by any SPS functions.
  71729. */
  71730. counter: number;
  71731. /**
  71732. * The PCS name. This name is also given to the underlying mesh.
  71733. */
  71734. name: string;
  71735. /**
  71736. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71737. */
  71738. mesh: Mesh;
  71739. /**
  71740. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71741. * Please read :
  71742. */
  71743. vars: any;
  71744. /**
  71745. * @hidden
  71746. */
  71747. _size: number;
  71748. private _scene;
  71749. private _promises;
  71750. private _positions;
  71751. private _indices;
  71752. private _normals;
  71753. private _colors;
  71754. private _uvs;
  71755. private _indices32;
  71756. private _positions32;
  71757. private _colors32;
  71758. private _uvs32;
  71759. private _updatable;
  71760. private _isVisibilityBoxLocked;
  71761. private _alwaysVisible;
  71762. private _groups;
  71763. private _groupCounter;
  71764. private _computeParticleColor;
  71765. private _computeParticleTexture;
  71766. private _computeParticleRotation;
  71767. private _computeBoundingBox;
  71768. private _isReady;
  71769. /**
  71770. * Creates a PCS (Points Cloud System) object
  71771. * @param name (String) is the PCS name, this will be the underlying mesh name
  71772. * @param pointSize (number) is the size for each point
  71773. * @param scene (Scene) is the scene in which the PCS is added
  71774. * @param options defines the options of the PCS e.g.
  71775. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71776. */
  71777. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71778. updatable?: boolean;
  71779. });
  71780. /**
  71781. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71782. * If no points were added to the PCS, the returned mesh is just a single point.
  71783. * @returns a promise for the created mesh
  71784. */
  71785. buildMeshAsync(): Promise<Mesh>;
  71786. /**
  71787. * @hidden
  71788. */
  71789. private _buildMesh;
  71790. private _addParticle;
  71791. private _randomUnitVector;
  71792. private _getColorIndicesForCoord;
  71793. private _setPointsColorOrUV;
  71794. private _colorFromTexture;
  71795. private _calculateDensity;
  71796. /**
  71797. * Adds points to the PCS in random positions within a unit sphere
  71798. * @param nb (positive integer) the number of particles to be created from this model
  71799. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71800. * @returns the number of groups in the system
  71801. */
  71802. addPoints(nb: number, pointFunction?: any): number;
  71803. /**
  71804. * Adds points to the PCS from the surface of the model shape
  71805. * @param mesh is any Mesh object that will be used as a surface model for the points
  71806. * @param nb (positive integer) the number of particles to be created from this model
  71807. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71808. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71809. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71810. * @returns the number of groups in the system
  71811. */
  71812. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71813. /**
  71814. * Adds points to the PCS inside the model shape
  71815. * @param mesh is any Mesh object that will be used as a surface model for the points
  71816. * @param nb (positive integer) the number of particles to be created from this model
  71817. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71818. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71819. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71820. * @returns the number of groups in the system
  71821. */
  71822. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71823. /**
  71824. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71825. * This method calls `updateParticle()` for each particle of the SPS.
  71826. * For an animated SPS, it is usually called within the render loop.
  71827. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71828. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71829. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71830. * @returns the PCS.
  71831. */
  71832. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71833. /**
  71834. * Disposes the PCS.
  71835. */
  71836. dispose(): void;
  71837. /**
  71838. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71839. * doc :
  71840. * @returns the PCS.
  71841. */
  71842. refreshVisibleSize(): PointsCloudSystem;
  71843. /**
  71844. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71845. * @param size the size (float) of the visibility box
  71846. * note : this doesn't lock the PCS mesh bounding box.
  71847. * doc :
  71848. */
  71849. setVisibilityBox(size: number): void;
  71850. /**
  71851. * Gets whether the PCS is always visible or not
  71852. * doc :
  71853. */
  71854. get isAlwaysVisible(): boolean;
  71855. /**
  71856. * Sets the PCS as always visible or not
  71857. * doc :
  71858. */
  71859. set isAlwaysVisible(val: boolean);
  71860. /**
  71861. * Tells to `setParticles()` to compute the particle rotations or not
  71862. * Default value : false. The PCS is faster when it's set to false
  71863. * Note : particle rotations are only applied to parent particles
  71864. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71865. */
  71866. set computeParticleRotation(val: boolean);
  71867. /**
  71868. * Tells to `setParticles()` to compute the particle colors or not.
  71869. * Default value : true. The PCS is faster when it's set to false.
  71870. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71871. */
  71872. set computeParticleColor(val: boolean);
  71873. set computeParticleTexture(val: boolean);
  71874. /**
  71875. * Gets if `setParticles()` computes the particle colors or not.
  71876. * Default value : false. The PCS is faster when it's set to false.
  71877. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71878. */
  71879. get computeParticleColor(): boolean;
  71880. /**
  71881. * Gets if `setParticles()` computes the particle textures or not.
  71882. * Default value : false. The PCS is faster when it's set to false.
  71883. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71884. */
  71885. get computeParticleTexture(): boolean;
  71886. /**
  71887. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71888. */
  71889. set computeBoundingBox(val: boolean);
  71890. /**
  71891. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71892. */
  71893. get computeBoundingBox(): boolean;
  71894. /**
  71895. * This function does nothing. It may be overwritten to set all the particle first values.
  71896. * The PCS doesn't call this function, you may have to call it by your own.
  71897. * doc :
  71898. */
  71899. initParticles(): void;
  71900. /**
  71901. * This function does nothing. It may be overwritten to recycle a particle
  71902. * The PCS doesn't call this function, you can to call it
  71903. * doc :
  71904. * @param particle The particle to recycle
  71905. * @returns the recycled particle
  71906. */
  71907. recycleParticle(particle: CloudPoint): CloudPoint;
  71908. /**
  71909. * Updates a particle : this function should be overwritten by the user.
  71910. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71911. * doc :
  71912. * @example : just set a particle position or velocity and recycle conditions
  71913. * @param particle The particle to update
  71914. * @returns the updated particle
  71915. */
  71916. updateParticle(particle: CloudPoint): CloudPoint;
  71917. /**
  71918. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71919. * This does nothing and may be overwritten by the user.
  71920. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71921. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71922. * @param update the boolean update value actually passed to setParticles()
  71923. */
  71924. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71925. /**
  71926. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71927. * This will be passed three parameters.
  71928. * This does nothing and may be overwritten by the user.
  71929. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71930. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71931. * @param update the boolean update value actually passed to setParticles()
  71932. */
  71933. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71934. }
  71935. }
  71936. declare module "babylonjs/Particles/cloudPoint" {
  71937. import { Nullable } from "babylonjs/types";
  71938. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71939. import { Mesh } from "babylonjs/Meshes/mesh";
  71940. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71941. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71942. /**
  71943. * Represents one particle of a points cloud system.
  71944. */
  71945. export class CloudPoint {
  71946. /**
  71947. * particle global index
  71948. */
  71949. idx: number;
  71950. /**
  71951. * The color of the particle
  71952. */
  71953. color: Nullable<Color4>;
  71954. /**
  71955. * The world space position of the particle.
  71956. */
  71957. position: Vector3;
  71958. /**
  71959. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71960. */
  71961. rotation: Vector3;
  71962. /**
  71963. * The world space rotation quaternion of the particle.
  71964. */
  71965. rotationQuaternion: Nullable<Quaternion>;
  71966. /**
  71967. * The uv of the particle.
  71968. */
  71969. uv: Nullable<Vector2>;
  71970. /**
  71971. * The current speed of the particle.
  71972. */
  71973. velocity: Vector3;
  71974. /**
  71975. * The pivot point in the particle local space.
  71976. */
  71977. pivot: Vector3;
  71978. /**
  71979. * Must the particle be translated from its pivot point in its local space ?
  71980. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71981. * Default : false
  71982. */
  71983. translateFromPivot: boolean;
  71984. /**
  71985. * Index of this particle in the global "positions" array (Internal use)
  71986. * @hidden
  71987. */
  71988. _pos: number;
  71989. /**
  71990. * @hidden Index of this particle in the global "indices" array (Internal use)
  71991. */
  71992. _ind: number;
  71993. /**
  71994. * Group this particle belongs to
  71995. */
  71996. _group: PointsGroup;
  71997. /**
  71998. * Group id of this particle
  71999. */
  72000. groupId: number;
  72001. /**
  72002. * Index of the particle in its group id (Internal use)
  72003. */
  72004. idxInGroup: number;
  72005. /**
  72006. * @hidden Particle BoundingInfo object (Internal use)
  72007. */
  72008. _boundingInfo: BoundingInfo;
  72009. /**
  72010. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72011. */
  72012. _pcs: PointsCloudSystem;
  72013. /**
  72014. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72015. */
  72016. _stillInvisible: boolean;
  72017. /**
  72018. * @hidden Last computed particle rotation matrix
  72019. */
  72020. _rotationMatrix: number[];
  72021. /**
  72022. * Parent particle Id, if any.
  72023. * Default null.
  72024. */
  72025. parentId: Nullable<number>;
  72026. /**
  72027. * @hidden Internal global position in the PCS.
  72028. */
  72029. _globalPosition: Vector3;
  72030. /**
  72031. * Creates a Point Cloud object.
  72032. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72033. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72034. * @param group (PointsGroup) is the group the particle belongs to
  72035. * @param groupId (integer) is the group identifier in the PCS.
  72036. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72037. * @param pcs defines the PCS it is associated to
  72038. */
  72039. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72040. /**
  72041. * get point size
  72042. */
  72043. get size(): Vector3;
  72044. /**
  72045. * Set point size
  72046. */
  72047. set size(scale: Vector3);
  72048. /**
  72049. * Legacy support, changed quaternion to rotationQuaternion
  72050. */
  72051. get quaternion(): Nullable<Quaternion>;
  72052. /**
  72053. * Legacy support, changed quaternion to rotationQuaternion
  72054. */
  72055. set quaternion(q: Nullable<Quaternion>);
  72056. /**
  72057. * Returns a boolean. True if the particle intersects a mesh, else false
  72058. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72059. * @param target is the object (point or mesh) what the intersection is computed against
  72060. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72061. * @returns true if it intersects
  72062. */
  72063. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72064. /**
  72065. * get the rotation matrix of the particle
  72066. * @hidden
  72067. */
  72068. getRotationMatrix(m: Matrix): void;
  72069. }
  72070. /**
  72071. * Represents a group of points in a points cloud system
  72072. * * PCS internal tool, don't use it manually.
  72073. */
  72074. export class PointsGroup {
  72075. /**
  72076. * The group id
  72077. * @hidden
  72078. */
  72079. groupID: number;
  72080. /**
  72081. * image data for group (internal use)
  72082. * @hidden
  72083. */
  72084. _groupImageData: Nullable<ArrayBufferView>;
  72085. /**
  72086. * Image Width (internal use)
  72087. * @hidden
  72088. */
  72089. _groupImgWidth: number;
  72090. /**
  72091. * Image Height (internal use)
  72092. * @hidden
  72093. */
  72094. _groupImgHeight: number;
  72095. /**
  72096. * Custom position function (internal use)
  72097. * @hidden
  72098. */
  72099. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72100. /**
  72101. * density per facet for surface points
  72102. * @hidden
  72103. */
  72104. _groupDensity: number[];
  72105. /**
  72106. * Only when points are colored by texture carries pointer to texture list array
  72107. * @hidden
  72108. */
  72109. _textureNb: number;
  72110. /**
  72111. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72112. * PCS internal tool, don't use it manually.
  72113. * @hidden
  72114. */
  72115. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72116. }
  72117. }
  72118. declare module "babylonjs/Particles/index" {
  72119. export * from "babylonjs/Particles/baseParticleSystem";
  72120. export * from "babylonjs/Particles/EmitterTypes/index";
  72121. export * from "babylonjs/Particles/gpuParticleSystem";
  72122. export * from "babylonjs/Particles/IParticleSystem";
  72123. export * from "babylonjs/Particles/particle";
  72124. export * from "babylonjs/Particles/particleHelper";
  72125. export * from "babylonjs/Particles/particleSystem";
  72126. import "babylonjs/Particles/particleSystemComponent";
  72127. export * from "babylonjs/Particles/particleSystemComponent";
  72128. export * from "babylonjs/Particles/particleSystemSet";
  72129. export * from "babylonjs/Particles/solidParticle";
  72130. export * from "babylonjs/Particles/solidParticleSystem";
  72131. export * from "babylonjs/Particles/cloudPoint";
  72132. export * from "babylonjs/Particles/pointsCloudSystem";
  72133. export * from "babylonjs/Particles/subEmitter";
  72134. }
  72135. declare module "babylonjs/Physics/physicsEngineComponent" {
  72136. import { Nullable } from "babylonjs/types";
  72137. import { Observable, Observer } from "babylonjs/Misc/observable";
  72138. import { Vector3 } from "babylonjs/Maths/math.vector";
  72139. import { Mesh } from "babylonjs/Meshes/mesh";
  72140. import { ISceneComponent } from "babylonjs/sceneComponent";
  72141. import { Scene } from "babylonjs/scene";
  72142. import { Node } from "babylonjs/node";
  72143. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72144. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72145. module "babylonjs/scene" {
  72146. interface Scene {
  72147. /** @hidden (Backing field) */
  72148. _physicsEngine: Nullable<IPhysicsEngine>;
  72149. /** @hidden */
  72150. _physicsTimeAccumulator: number;
  72151. /**
  72152. * Gets the current physics engine
  72153. * @returns a IPhysicsEngine or null if none attached
  72154. */
  72155. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72156. /**
  72157. * Enables physics to the current scene
  72158. * @param gravity defines the scene's gravity for the physics engine
  72159. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72160. * @return a boolean indicating if the physics engine was initialized
  72161. */
  72162. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72163. /**
  72164. * Disables and disposes the physics engine associated with the scene
  72165. */
  72166. disablePhysicsEngine(): void;
  72167. /**
  72168. * Gets a boolean indicating if there is an active physics engine
  72169. * @returns a boolean indicating if there is an active physics engine
  72170. */
  72171. isPhysicsEnabled(): boolean;
  72172. /**
  72173. * Deletes a physics compound impostor
  72174. * @param compound defines the compound to delete
  72175. */
  72176. deleteCompoundImpostor(compound: any): void;
  72177. /**
  72178. * An event triggered when physic simulation is about to be run
  72179. */
  72180. onBeforePhysicsObservable: Observable<Scene>;
  72181. /**
  72182. * An event triggered when physic simulation has been done
  72183. */
  72184. onAfterPhysicsObservable: Observable<Scene>;
  72185. }
  72186. }
  72187. module "babylonjs/Meshes/abstractMesh" {
  72188. interface AbstractMesh {
  72189. /** @hidden */
  72190. _physicsImpostor: Nullable<PhysicsImpostor>;
  72191. /**
  72192. * Gets or sets impostor used for physic simulation
  72193. * @see https://doc.babylonjs.com/features/physics_engine
  72194. */
  72195. physicsImpostor: Nullable<PhysicsImpostor>;
  72196. /**
  72197. * Gets the current physics impostor
  72198. * @see https://doc.babylonjs.com/features/physics_engine
  72199. * @returns a physics impostor or null
  72200. */
  72201. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72202. /** Apply a physic impulse to the mesh
  72203. * @param force defines the force to apply
  72204. * @param contactPoint defines where to apply the force
  72205. * @returns the current mesh
  72206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72207. */
  72208. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72209. /**
  72210. * Creates a physic joint between two meshes
  72211. * @param otherMesh defines the other mesh to use
  72212. * @param pivot1 defines the pivot to use on this mesh
  72213. * @param pivot2 defines the pivot to use on the other mesh
  72214. * @param options defines additional options (can be plugin dependent)
  72215. * @returns the current mesh
  72216. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72217. */
  72218. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72219. /** @hidden */
  72220. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72221. }
  72222. }
  72223. /**
  72224. * Defines the physics engine scene component responsible to manage a physics engine
  72225. */
  72226. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72227. /**
  72228. * The component name helpful to identify the component in the list of scene components.
  72229. */
  72230. readonly name: string;
  72231. /**
  72232. * The scene the component belongs to.
  72233. */
  72234. scene: Scene;
  72235. /**
  72236. * Creates a new instance of the component for the given scene
  72237. * @param scene Defines the scene to register the component in
  72238. */
  72239. constructor(scene: Scene);
  72240. /**
  72241. * Registers the component in a given scene
  72242. */
  72243. register(): void;
  72244. /**
  72245. * Rebuilds the elements related to this component in case of
  72246. * context lost for instance.
  72247. */
  72248. rebuild(): void;
  72249. /**
  72250. * Disposes the component and the associated ressources
  72251. */
  72252. dispose(): void;
  72253. }
  72254. }
  72255. declare module "babylonjs/Physics/physicsHelper" {
  72256. import { Nullable } from "babylonjs/types";
  72257. import { Vector3 } from "babylonjs/Maths/math.vector";
  72258. import { Mesh } from "babylonjs/Meshes/mesh";
  72259. import { Scene } from "babylonjs/scene";
  72260. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72261. /**
  72262. * A helper for physics simulations
  72263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72264. */
  72265. export class PhysicsHelper {
  72266. private _scene;
  72267. private _physicsEngine;
  72268. /**
  72269. * Initializes the Physics helper
  72270. * @param scene Babylon.js scene
  72271. */
  72272. constructor(scene: Scene);
  72273. /**
  72274. * Applies a radial explosion impulse
  72275. * @param origin the origin of the explosion
  72276. * @param radiusOrEventOptions the radius or the options of radial explosion
  72277. * @param strength the explosion strength
  72278. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72279. * @returns A physics radial explosion event, or null
  72280. */
  72281. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72282. /**
  72283. * Applies a radial explosion force
  72284. * @param origin the origin of the explosion
  72285. * @param radiusOrEventOptions the radius or the options of radial explosion
  72286. * @param strength the explosion strength
  72287. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72288. * @returns A physics radial explosion event, or null
  72289. */
  72290. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72291. /**
  72292. * Creates a gravitational field
  72293. * @param origin the origin of the explosion
  72294. * @param radiusOrEventOptions the radius or the options of radial explosion
  72295. * @param strength the explosion strength
  72296. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72297. * @returns A physics gravitational field event, or null
  72298. */
  72299. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72300. /**
  72301. * Creates a physics updraft event
  72302. * @param origin the origin of the updraft
  72303. * @param radiusOrEventOptions the radius or the options of the updraft
  72304. * @param strength the strength of the updraft
  72305. * @param height the height of the updraft
  72306. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72307. * @returns A physics updraft event, or null
  72308. */
  72309. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72310. /**
  72311. * Creates a physics vortex event
  72312. * @param origin the of the vortex
  72313. * @param radiusOrEventOptions the radius or the options of the vortex
  72314. * @param strength the strength of the vortex
  72315. * @param height the height of the vortex
  72316. * @returns a Physics vortex event, or null
  72317. * A physics vortex event or null
  72318. */
  72319. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72320. }
  72321. /**
  72322. * Represents a physics radial explosion event
  72323. */
  72324. class PhysicsRadialExplosionEvent {
  72325. private _scene;
  72326. private _options;
  72327. private _sphere;
  72328. private _dataFetched;
  72329. /**
  72330. * Initializes a radial explosioin event
  72331. * @param _scene BabylonJS scene
  72332. * @param _options The options for the vortex event
  72333. */
  72334. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72335. /**
  72336. * Returns the data related to the radial explosion event (sphere).
  72337. * @returns The radial explosion event data
  72338. */
  72339. getData(): PhysicsRadialExplosionEventData;
  72340. /**
  72341. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72342. * @param impostor A physics imposter
  72343. * @param origin the origin of the explosion
  72344. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72345. */
  72346. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72347. /**
  72348. * Triggers affecterd impostors callbacks
  72349. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72350. */
  72351. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72352. /**
  72353. * Disposes the sphere.
  72354. * @param force Specifies if the sphere should be disposed by force
  72355. */
  72356. dispose(force?: boolean): void;
  72357. /*** Helpers ***/
  72358. private _prepareSphere;
  72359. private _intersectsWithSphere;
  72360. }
  72361. /**
  72362. * Represents a gravitational field event
  72363. */
  72364. class PhysicsGravitationalFieldEvent {
  72365. private _physicsHelper;
  72366. private _scene;
  72367. private _origin;
  72368. private _options;
  72369. private _tickCallback;
  72370. private _sphere;
  72371. private _dataFetched;
  72372. /**
  72373. * Initializes the physics gravitational field event
  72374. * @param _physicsHelper A physics helper
  72375. * @param _scene BabylonJS scene
  72376. * @param _origin The origin position of the gravitational field event
  72377. * @param _options The options for the vortex event
  72378. */
  72379. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72380. /**
  72381. * Returns the data related to the gravitational field event (sphere).
  72382. * @returns A gravitational field event
  72383. */
  72384. getData(): PhysicsGravitationalFieldEventData;
  72385. /**
  72386. * Enables the gravitational field.
  72387. */
  72388. enable(): void;
  72389. /**
  72390. * Disables the gravitational field.
  72391. */
  72392. disable(): void;
  72393. /**
  72394. * Disposes the sphere.
  72395. * @param force The force to dispose from the gravitational field event
  72396. */
  72397. dispose(force?: boolean): void;
  72398. private _tick;
  72399. }
  72400. /**
  72401. * Represents a physics updraft event
  72402. */
  72403. class PhysicsUpdraftEvent {
  72404. private _scene;
  72405. private _origin;
  72406. private _options;
  72407. private _physicsEngine;
  72408. private _originTop;
  72409. private _originDirection;
  72410. private _tickCallback;
  72411. private _cylinder;
  72412. private _cylinderPosition;
  72413. private _dataFetched;
  72414. /**
  72415. * Initializes the physics updraft event
  72416. * @param _scene BabylonJS scene
  72417. * @param _origin The origin position of the updraft
  72418. * @param _options The options for the updraft event
  72419. */
  72420. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72421. /**
  72422. * Returns the data related to the updraft event (cylinder).
  72423. * @returns A physics updraft event
  72424. */
  72425. getData(): PhysicsUpdraftEventData;
  72426. /**
  72427. * Enables the updraft.
  72428. */
  72429. enable(): void;
  72430. /**
  72431. * Disables the updraft.
  72432. */
  72433. disable(): void;
  72434. /**
  72435. * Disposes the cylinder.
  72436. * @param force Specifies if the updraft should be disposed by force
  72437. */
  72438. dispose(force?: boolean): void;
  72439. private getImpostorHitData;
  72440. private _tick;
  72441. /*** Helpers ***/
  72442. private _prepareCylinder;
  72443. private _intersectsWithCylinder;
  72444. }
  72445. /**
  72446. * Represents a physics vortex event
  72447. */
  72448. class PhysicsVortexEvent {
  72449. private _scene;
  72450. private _origin;
  72451. private _options;
  72452. private _physicsEngine;
  72453. private _originTop;
  72454. private _tickCallback;
  72455. private _cylinder;
  72456. private _cylinderPosition;
  72457. private _dataFetched;
  72458. /**
  72459. * Initializes the physics vortex event
  72460. * @param _scene The BabylonJS scene
  72461. * @param _origin The origin position of the vortex
  72462. * @param _options The options for the vortex event
  72463. */
  72464. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72465. /**
  72466. * Returns the data related to the vortex event (cylinder).
  72467. * @returns The physics vortex event data
  72468. */
  72469. getData(): PhysicsVortexEventData;
  72470. /**
  72471. * Enables the vortex.
  72472. */
  72473. enable(): void;
  72474. /**
  72475. * Disables the cortex.
  72476. */
  72477. disable(): void;
  72478. /**
  72479. * Disposes the sphere.
  72480. * @param force
  72481. */
  72482. dispose(force?: boolean): void;
  72483. private getImpostorHitData;
  72484. private _tick;
  72485. /*** Helpers ***/
  72486. private _prepareCylinder;
  72487. private _intersectsWithCylinder;
  72488. }
  72489. /**
  72490. * Options fot the radial explosion event
  72491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72492. */
  72493. export class PhysicsRadialExplosionEventOptions {
  72494. /**
  72495. * The radius of the sphere for the radial explosion.
  72496. */
  72497. radius: number;
  72498. /**
  72499. * The strenth of the explosion.
  72500. */
  72501. strength: number;
  72502. /**
  72503. * The strenght of the force in correspondence to the distance of the affected object
  72504. */
  72505. falloff: PhysicsRadialImpulseFalloff;
  72506. /**
  72507. * Sphere options for the radial explosion.
  72508. */
  72509. sphere: {
  72510. segments: number;
  72511. diameter: number;
  72512. };
  72513. /**
  72514. * Sphere options for the radial explosion.
  72515. */
  72516. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72517. }
  72518. /**
  72519. * Options fot the updraft event
  72520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72521. */
  72522. export class PhysicsUpdraftEventOptions {
  72523. /**
  72524. * The radius of the cylinder for the vortex
  72525. */
  72526. radius: number;
  72527. /**
  72528. * The strenth of the updraft.
  72529. */
  72530. strength: number;
  72531. /**
  72532. * The height of the cylinder for the updraft.
  72533. */
  72534. height: number;
  72535. /**
  72536. * The mode for the the updraft.
  72537. */
  72538. updraftMode: PhysicsUpdraftMode;
  72539. }
  72540. /**
  72541. * Options fot the vortex event
  72542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72543. */
  72544. export class PhysicsVortexEventOptions {
  72545. /**
  72546. * The radius of the cylinder for the vortex
  72547. */
  72548. radius: number;
  72549. /**
  72550. * The strenth of the vortex.
  72551. */
  72552. strength: number;
  72553. /**
  72554. * The height of the cylinder for the vortex.
  72555. */
  72556. height: number;
  72557. /**
  72558. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72559. */
  72560. centripetalForceThreshold: number;
  72561. /**
  72562. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72563. */
  72564. centripetalForceMultiplier: number;
  72565. /**
  72566. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72567. */
  72568. centrifugalForceMultiplier: number;
  72569. /**
  72570. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72571. */
  72572. updraftForceMultiplier: number;
  72573. }
  72574. /**
  72575. * The strenght of the force in correspondence to the distance of the affected object
  72576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72577. */
  72578. export enum PhysicsRadialImpulseFalloff {
  72579. /** Defines that impulse is constant in strength across it's whole radius */
  72580. Constant = 0,
  72581. /** Defines that impulse gets weaker if it's further from the origin */
  72582. Linear = 1
  72583. }
  72584. /**
  72585. * The strength of the force in correspondence to the distance of the affected object
  72586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72587. */
  72588. export enum PhysicsUpdraftMode {
  72589. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72590. Center = 0,
  72591. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72592. Perpendicular = 1
  72593. }
  72594. /**
  72595. * Interface for a physics hit data
  72596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72597. */
  72598. export interface PhysicsHitData {
  72599. /**
  72600. * The force applied at the contact point
  72601. */
  72602. force: Vector3;
  72603. /**
  72604. * The contact point
  72605. */
  72606. contactPoint: Vector3;
  72607. /**
  72608. * The distance from the origin to the contact point
  72609. */
  72610. distanceFromOrigin: number;
  72611. }
  72612. /**
  72613. * Interface for radial explosion event data
  72614. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72615. */
  72616. export interface PhysicsRadialExplosionEventData {
  72617. /**
  72618. * A sphere used for the radial explosion event
  72619. */
  72620. sphere: Mesh;
  72621. }
  72622. /**
  72623. * Interface for gravitational field event data
  72624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72625. */
  72626. export interface PhysicsGravitationalFieldEventData {
  72627. /**
  72628. * A sphere mesh used for the gravitational field event
  72629. */
  72630. sphere: Mesh;
  72631. }
  72632. /**
  72633. * Interface for updraft event data
  72634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72635. */
  72636. export interface PhysicsUpdraftEventData {
  72637. /**
  72638. * A cylinder used for the updraft event
  72639. */
  72640. cylinder: Mesh;
  72641. }
  72642. /**
  72643. * Interface for vortex event data
  72644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72645. */
  72646. export interface PhysicsVortexEventData {
  72647. /**
  72648. * A cylinder used for the vortex event
  72649. */
  72650. cylinder: Mesh;
  72651. }
  72652. /**
  72653. * Interface for an affected physics impostor
  72654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72655. */
  72656. export interface PhysicsAffectedImpostorWithData {
  72657. /**
  72658. * The impostor affected by the effect
  72659. */
  72660. impostor: PhysicsImpostor;
  72661. /**
  72662. * The data about the hit/horce from the explosion
  72663. */
  72664. hitData: PhysicsHitData;
  72665. }
  72666. }
  72667. declare module "babylonjs/Physics/Plugins/index" {
  72668. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72669. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72670. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72671. }
  72672. declare module "babylonjs/Physics/index" {
  72673. export * from "babylonjs/Physics/IPhysicsEngine";
  72674. export * from "babylonjs/Physics/physicsEngine";
  72675. export * from "babylonjs/Physics/physicsEngineComponent";
  72676. export * from "babylonjs/Physics/physicsHelper";
  72677. export * from "babylonjs/Physics/physicsImpostor";
  72678. export * from "babylonjs/Physics/physicsJoint";
  72679. export * from "babylonjs/Physics/Plugins/index";
  72680. }
  72681. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72682. /** @hidden */
  72683. export var blackAndWhitePixelShader: {
  72684. name: string;
  72685. shader: string;
  72686. };
  72687. }
  72688. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72689. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72690. import { Camera } from "babylonjs/Cameras/camera";
  72691. import { Engine } from "babylonjs/Engines/engine";
  72692. import "babylonjs/Shaders/blackAndWhite.fragment";
  72693. import { Nullable } from "babylonjs/types";
  72694. import { Scene } from "babylonjs/scene";
  72695. /**
  72696. * Post process used to render in black and white
  72697. */
  72698. export class BlackAndWhitePostProcess extends PostProcess {
  72699. /**
  72700. * Linear about to convert he result to black and white (default: 1)
  72701. */
  72702. degree: number;
  72703. /**
  72704. * Gets a string identifying the name of the class
  72705. * @returns "BlackAndWhitePostProcess" string
  72706. */
  72707. getClassName(): string;
  72708. /**
  72709. * Creates a black and white post process
  72710. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72711. * @param name The name of the effect.
  72712. * @param options The required width/height ratio to downsize to before computing the render pass.
  72713. * @param camera The camera to apply the render pass to.
  72714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72715. * @param engine The engine which the post process will be applied. (default: current engine)
  72716. * @param reusable If the post process can be reused on the same frame. (default: false)
  72717. */
  72718. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72719. /** @hidden */
  72720. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72721. }
  72722. }
  72723. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72724. import { Nullable } from "babylonjs/types";
  72725. import { Camera } from "babylonjs/Cameras/camera";
  72726. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72727. import { Engine } from "babylonjs/Engines/engine";
  72728. /**
  72729. * This represents a set of one or more post processes in Babylon.
  72730. * A post process can be used to apply a shader to a texture after it is rendered.
  72731. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72732. */
  72733. export class PostProcessRenderEffect {
  72734. private _postProcesses;
  72735. private _getPostProcesses;
  72736. private _singleInstance;
  72737. private _cameras;
  72738. private _indicesForCamera;
  72739. /**
  72740. * Name of the effect
  72741. * @hidden
  72742. */
  72743. _name: string;
  72744. /**
  72745. * Instantiates a post process render effect.
  72746. * A post process can be used to apply a shader to a texture after it is rendered.
  72747. * @param engine The engine the effect is tied to
  72748. * @param name The name of the effect
  72749. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72750. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72751. */
  72752. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72753. /**
  72754. * Checks if all the post processes in the effect are supported.
  72755. */
  72756. get isSupported(): boolean;
  72757. /**
  72758. * Updates the current state of the effect
  72759. * @hidden
  72760. */
  72761. _update(): void;
  72762. /**
  72763. * Attaches the effect on cameras
  72764. * @param cameras The camera to attach to.
  72765. * @hidden
  72766. */
  72767. _attachCameras(cameras: Camera): void;
  72768. /**
  72769. * Attaches the effect on cameras
  72770. * @param cameras The camera to attach to.
  72771. * @hidden
  72772. */
  72773. _attachCameras(cameras: Camera[]): void;
  72774. /**
  72775. * Detaches the effect on cameras
  72776. * @param cameras The camera to detatch from.
  72777. * @hidden
  72778. */
  72779. _detachCameras(cameras: Camera): void;
  72780. /**
  72781. * Detatches the effect on cameras
  72782. * @param cameras The camera to detatch from.
  72783. * @hidden
  72784. */
  72785. _detachCameras(cameras: Camera[]): void;
  72786. /**
  72787. * Enables the effect on given cameras
  72788. * @param cameras The camera to enable.
  72789. * @hidden
  72790. */
  72791. _enable(cameras: Camera): void;
  72792. /**
  72793. * Enables the effect on given cameras
  72794. * @param cameras The camera to enable.
  72795. * @hidden
  72796. */
  72797. _enable(cameras: Nullable<Camera[]>): void;
  72798. /**
  72799. * Disables the effect on the given cameras
  72800. * @param cameras The camera to disable.
  72801. * @hidden
  72802. */
  72803. _disable(cameras: Camera): void;
  72804. /**
  72805. * Disables the effect on the given cameras
  72806. * @param cameras The camera to disable.
  72807. * @hidden
  72808. */
  72809. _disable(cameras: Nullable<Camera[]>): void;
  72810. /**
  72811. * Gets a list of the post processes contained in the effect.
  72812. * @param camera The camera to get the post processes on.
  72813. * @returns The list of the post processes in the effect.
  72814. */
  72815. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72816. }
  72817. }
  72818. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72819. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72820. /** @hidden */
  72821. export var extractHighlightsPixelShader: {
  72822. name: string;
  72823. shader: string;
  72824. };
  72825. }
  72826. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72827. import { Nullable } from "babylonjs/types";
  72828. import { Camera } from "babylonjs/Cameras/camera";
  72829. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72830. import { Engine } from "babylonjs/Engines/engine";
  72831. import "babylonjs/Shaders/extractHighlights.fragment";
  72832. /**
  72833. * 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.
  72834. */
  72835. export class ExtractHighlightsPostProcess extends PostProcess {
  72836. /**
  72837. * The luminance threshold, pixels below this value will be set to black.
  72838. */
  72839. threshold: number;
  72840. /** @hidden */
  72841. _exposure: number;
  72842. /**
  72843. * Post process which has the input texture to be used when performing highlight extraction
  72844. * @hidden
  72845. */
  72846. _inputPostProcess: Nullable<PostProcess>;
  72847. /**
  72848. * Gets a string identifying the name of the class
  72849. * @returns "ExtractHighlightsPostProcess" string
  72850. */
  72851. getClassName(): string;
  72852. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72853. }
  72854. }
  72855. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72856. /** @hidden */
  72857. export var bloomMergePixelShader: {
  72858. name: string;
  72859. shader: string;
  72860. };
  72861. }
  72862. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72863. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72864. import { Nullable } from "babylonjs/types";
  72865. import { Engine } from "babylonjs/Engines/engine";
  72866. import { Camera } from "babylonjs/Cameras/camera";
  72867. import "babylonjs/Shaders/bloomMerge.fragment";
  72868. /**
  72869. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72870. */
  72871. export class BloomMergePostProcess extends PostProcess {
  72872. /** Weight of the bloom to be added to the original input. */
  72873. weight: number;
  72874. /**
  72875. * Gets a string identifying the name of the class
  72876. * @returns "BloomMergePostProcess" string
  72877. */
  72878. getClassName(): string;
  72879. /**
  72880. * Creates a new instance of @see BloomMergePostProcess
  72881. * @param name The name of the effect.
  72882. * @param originalFromInput Post process which's input will be used for the merge.
  72883. * @param blurred Blurred highlights post process which's output will be used.
  72884. * @param weight Weight of the bloom to be added to the original input.
  72885. * @param options The required width/height ratio to downsize to before computing the render pass.
  72886. * @param camera The camera to apply the render pass to.
  72887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72888. * @param engine The engine which the post process will be applied. (default: current engine)
  72889. * @param reusable If the post process can be reused on the same frame. (default: false)
  72890. * @param textureType Type of textures used when performing the post process. (default: 0)
  72891. * @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)
  72892. */
  72893. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72894. /** Weight of the bloom to be added to the original input. */
  72895. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72896. }
  72897. }
  72898. declare module "babylonjs/PostProcesses/bloomEffect" {
  72899. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72900. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72901. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72902. import { Camera } from "babylonjs/Cameras/camera";
  72903. import { Scene } from "babylonjs/scene";
  72904. /**
  72905. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72906. */
  72907. export class BloomEffect extends PostProcessRenderEffect {
  72908. private bloomScale;
  72909. /**
  72910. * @hidden Internal
  72911. */
  72912. _effects: Array<PostProcess>;
  72913. /**
  72914. * @hidden Internal
  72915. */
  72916. _downscale: ExtractHighlightsPostProcess;
  72917. private _blurX;
  72918. private _blurY;
  72919. private _merge;
  72920. /**
  72921. * The luminance threshold to find bright areas of the image to bloom.
  72922. */
  72923. get threshold(): number;
  72924. set threshold(value: number);
  72925. /**
  72926. * The strength of the bloom.
  72927. */
  72928. get weight(): number;
  72929. set weight(value: number);
  72930. /**
  72931. * Specifies the size of the bloom blur kernel, relative to the final output size
  72932. */
  72933. get kernel(): number;
  72934. set kernel(value: number);
  72935. /**
  72936. * Creates a new instance of @see BloomEffect
  72937. * @param scene The scene the effect belongs to.
  72938. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72939. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72940. * @param bloomWeight The the strength of bloom.
  72941. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72942. * @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)
  72943. */
  72944. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72945. /**
  72946. * Disposes each of the internal effects for a given camera.
  72947. * @param camera The camera to dispose the effect on.
  72948. */
  72949. disposeEffects(camera: Camera): void;
  72950. /**
  72951. * @hidden Internal
  72952. */
  72953. _updateEffects(): void;
  72954. /**
  72955. * Internal
  72956. * @returns if all the contained post processes are ready.
  72957. * @hidden
  72958. */
  72959. _isReady(): boolean;
  72960. }
  72961. }
  72962. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72963. /** @hidden */
  72964. export var chromaticAberrationPixelShader: {
  72965. name: string;
  72966. shader: string;
  72967. };
  72968. }
  72969. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72970. import { Vector2 } from "babylonjs/Maths/math.vector";
  72971. import { Nullable } from "babylonjs/types";
  72972. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72973. import { Camera } from "babylonjs/Cameras/camera";
  72974. import { Engine } from "babylonjs/Engines/engine";
  72975. import "babylonjs/Shaders/chromaticAberration.fragment";
  72976. import { Scene } from "babylonjs/scene";
  72977. /**
  72978. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72979. */
  72980. export class ChromaticAberrationPostProcess extends PostProcess {
  72981. /**
  72982. * The amount of seperation of rgb channels (default: 30)
  72983. */
  72984. aberrationAmount: number;
  72985. /**
  72986. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72987. */
  72988. radialIntensity: number;
  72989. /**
  72990. * 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))
  72991. */
  72992. direction: Vector2;
  72993. /**
  72994. * 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))
  72995. */
  72996. centerPosition: Vector2;
  72997. /** The width of the screen to apply the effect on */
  72998. screenWidth: number;
  72999. /** The height of the screen to apply the effect on */
  73000. screenHeight: number;
  73001. /**
  73002. * Gets a string identifying the name of the class
  73003. * @returns "ChromaticAberrationPostProcess" string
  73004. */
  73005. getClassName(): string;
  73006. /**
  73007. * Creates a new instance ChromaticAberrationPostProcess
  73008. * @param name The name of the effect.
  73009. * @param screenWidth The width of the screen to apply the effect on.
  73010. * @param screenHeight The height of the screen to apply the effect on.
  73011. * @param options The required width/height ratio to downsize to before computing the render pass.
  73012. * @param camera The camera to apply the render pass to.
  73013. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73014. * @param engine The engine which the post process will be applied. (default: current engine)
  73015. * @param reusable If the post process can be reused on the same frame. (default: false)
  73016. * @param textureType Type of textures used when performing the post process. (default: 0)
  73017. * @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)
  73018. */
  73019. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73020. /** @hidden */
  73021. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73022. }
  73023. }
  73024. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73025. /** @hidden */
  73026. export var circleOfConfusionPixelShader: {
  73027. name: string;
  73028. shader: string;
  73029. };
  73030. }
  73031. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73032. import { Nullable } from "babylonjs/types";
  73033. import { Engine } from "babylonjs/Engines/engine";
  73034. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73035. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73036. import { Camera } from "babylonjs/Cameras/camera";
  73037. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73038. /**
  73039. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73040. */
  73041. export class CircleOfConfusionPostProcess extends PostProcess {
  73042. /**
  73043. * 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.
  73044. */
  73045. lensSize: number;
  73046. /**
  73047. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73048. */
  73049. fStop: number;
  73050. /**
  73051. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73052. */
  73053. focusDistance: number;
  73054. /**
  73055. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73056. */
  73057. focalLength: number;
  73058. /**
  73059. * Gets a string identifying the name of the class
  73060. * @returns "CircleOfConfusionPostProcess" string
  73061. */
  73062. getClassName(): string;
  73063. private _depthTexture;
  73064. /**
  73065. * Creates a new instance CircleOfConfusionPostProcess
  73066. * @param name The name of the effect.
  73067. * @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.
  73068. * @param options The required width/height ratio to downsize to before computing the render pass.
  73069. * @param camera The camera to apply the render pass to.
  73070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73071. * @param engine The engine which the post process will be applied. (default: current engine)
  73072. * @param reusable If the post process can be reused on the same frame. (default: false)
  73073. * @param textureType Type of textures used when performing the post process. (default: 0)
  73074. * @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)
  73075. */
  73076. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73077. /**
  73078. * 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.
  73079. */
  73080. set depthTexture(value: RenderTargetTexture);
  73081. }
  73082. }
  73083. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73084. /** @hidden */
  73085. export var colorCorrectionPixelShader: {
  73086. name: string;
  73087. shader: string;
  73088. };
  73089. }
  73090. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73091. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73092. import { Engine } from "babylonjs/Engines/engine";
  73093. import { Camera } from "babylonjs/Cameras/camera";
  73094. import "babylonjs/Shaders/colorCorrection.fragment";
  73095. import { Nullable } from "babylonjs/types";
  73096. import { Scene } from "babylonjs/scene";
  73097. /**
  73098. *
  73099. * This post-process allows the modification of rendered colors by using
  73100. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73101. *
  73102. * The object needs to be provided an url to a texture containing the color
  73103. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73104. * Use an image editing software to tweak the LUT to match your needs.
  73105. *
  73106. * For an example of a color LUT, see here:
  73107. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73108. * For explanations on color grading, see here:
  73109. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73110. *
  73111. */
  73112. export class ColorCorrectionPostProcess extends PostProcess {
  73113. private _colorTableTexture;
  73114. /**
  73115. * Gets the color table url used to create the LUT texture
  73116. */
  73117. colorTableUrl: string;
  73118. /**
  73119. * Gets a string identifying the name of the class
  73120. * @returns "ColorCorrectionPostProcess" string
  73121. */
  73122. getClassName(): string;
  73123. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73124. /** @hidden */
  73125. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73126. }
  73127. }
  73128. declare module "babylonjs/Shaders/convolution.fragment" {
  73129. /** @hidden */
  73130. export var convolutionPixelShader: {
  73131. name: string;
  73132. shader: string;
  73133. };
  73134. }
  73135. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73136. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73137. import { Nullable } from "babylonjs/types";
  73138. import { Camera } from "babylonjs/Cameras/camera";
  73139. import { Engine } from "babylonjs/Engines/engine";
  73140. import "babylonjs/Shaders/convolution.fragment";
  73141. import { Scene } from "babylonjs/scene";
  73142. /**
  73143. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73144. * input texture to perform effects such as edge detection or sharpening
  73145. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73146. */
  73147. export class ConvolutionPostProcess extends PostProcess {
  73148. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73149. kernel: number[];
  73150. /**
  73151. * Gets a string identifying the name of the class
  73152. * @returns "ConvolutionPostProcess" string
  73153. */
  73154. getClassName(): string;
  73155. /**
  73156. * Creates a new instance ConvolutionPostProcess
  73157. * @param name The name of the effect.
  73158. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73159. * @param options The required width/height ratio to downsize to before computing the render pass.
  73160. * @param camera The camera to apply the render pass to.
  73161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73162. * @param engine The engine which the post process will be applied. (default: current engine)
  73163. * @param reusable If the post process can be reused on the same frame. (default: false)
  73164. * @param textureType Type of textures used when performing the post process. (default: 0)
  73165. */
  73166. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73167. /** @hidden */
  73168. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73169. /**
  73170. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73171. */
  73172. static EdgeDetect0Kernel: number[];
  73173. /**
  73174. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73175. */
  73176. static EdgeDetect1Kernel: number[];
  73177. /**
  73178. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73179. */
  73180. static EdgeDetect2Kernel: number[];
  73181. /**
  73182. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73183. */
  73184. static SharpenKernel: number[];
  73185. /**
  73186. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73187. */
  73188. static EmbossKernel: number[];
  73189. /**
  73190. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73191. */
  73192. static GaussianKernel: number[];
  73193. }
  73194. }
  73195. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73196. import { Nullable } from "babylonjs/types";
  73197. import { Vector2 } from "babylonjs/Maths/math.vector";
  73198. import { Camera } from "babylonjs/Cameras/camera";
  73199. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73200. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73201. import { Engine } from "babylonjs/Engines/engine";
  73202. import { Scene } from "babylonjs/scene";
  73203. /**
  73204. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73205. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73206. * based on samples that have a large difference in distance than the center pixel.
  73207. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73208. */
  73209. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73210. /**
  73211. * The direction the blur should be applied
  73212. */
  73213. direction: Vector2;
  73214. /**
  73215. * Gets a string identifying the name of the class
  73216. * @returns "DepthOfFieldBlurPostProcess" string
  73217. */
  73218. getClassName(): string;
  73219. /**
  73220. * Creates a new instance CircleOfConfusionPostProcess
  73221. * @param name The name of the effect.
  73222. * @param scene The scene the effect belongs to.
  73223. * @param direction The direction the blur should be applied.
  73224. * @param kernel The size of the kernel used to blur.
  73225. * @param options The required width/height ratio to downsize to before computing the render pass.
  73226. * @param camera The camera to apply the render pass to.
  73227. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73228. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73230. * @param engine The engine which the post process will be applied. (default: current engine)
  73231. * @param reusable If the post process can be reused on the same frame. (default: false)
  73232. * @param textureType Type of textures used when performing the post process. (default: 0)
  73233. * @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)
  73234. */
  73235. 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);
  73236. }
  73237. }
  73238. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73239. /** @hidden */
  73240. export var depthOfFieldMergePixelShader: {
  73241. name: string;
  73242. shader: string;
  73243. };
  73244. }
  73245. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73246. import { Nullable } from "babylonjs/types";
  73247. import { Camera } from "babylonjs/Cameras/camera";
  73248. import { Effect } from "babylonjs/Materials/effect";
  73249. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73250. import { Engine } from "babylonjs/Engines/engine";
  73251. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73252. /**
  73253. * Options to be set when merging outputs from the default pipeline.
  73254. */
  73255. export class DepthOfFieldMergePostProcessOptions {
  73256. /**
  73257. * The original image to merge on top of
  73258. */
  73259. originalFromInput: PostProcess;
  73260. /**
  73261. * Parameters to perform the merge of the depth of field effect
  73262. */
  73263. depthOfField?: {
  73264. circleOfConfusion: PostProcess;
  73265. blurSteps: Array<PostProcess>;
  73266. };
  73267. /**
  73268. * Parameters to perform the merge of bloom effect
  73269. */
  73270. bloom?: {
  73271. blurred: PostProcess;
  73272. weight: number;
  73273. };
  73274. }
  73275. /**
  73276. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73277. */
  73278. export class DepthOfFieldMergePostProcess extends PostProcess {
  73279. private blurSteps;
  73280. /**
  73281. * Gets a string identifying the name of the class
  73282. * @returns "DepthOfFieldMergePostProcess" string
  73283. */
  73284. getClassName(): string;
  73285. /**
  73286. * Creates a new instance of DepthOfFieldMergePostProcess
  73287. * @param name The name of the effect.
  73288. * @param originalFromInput Post process which's input will be used for the merge.
  73289. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73290. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73291. * @param options The required width/height ratio to downsize to before computing the render pass.
  73292. * @param camera The camera to apply the render pass to.
  73293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73294. * @param engine The engine which the post process will be applied. (default: current engine)
  73295. * @param reusable If the post process can be reused on the same frame. (default: false)
  73296. * @param textureType Type of textures used when performing the post process. (default: 0)
  73297. * @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)
  73298. */
  73299. 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);
  73300. /**
  73301. * Updates the effect with the current post process compile time values and recompiles the shader.
  73302. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73303. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73304. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73305. * @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
  73306. * @param onCompiled Called when the shader has been compiled.
  73307. * @param onError Called if there is an error when compiling a shader.
  73308. */
  73309. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73310. }
  73311. }
  73312. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73313. import { Nullable } from "babylonjs/types";
  73314. import { Camera } from "babylonjs/Cameras/camera";
  73315. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73316. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73317. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73318. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73319. import { Scene } from "babylonjs/scene";
  73320. /**
  73321. * Specifies the level of max blur that should be applied when using the depth of field effect
  73322. */
  73323. export enum DepthOfFieldEffectBlurLevel {
  73324. /**
  73325. * Subtle blur
  73326. */
  73327. Low = 0,
  73328. /**
  73329. * Medium blur
  73330. */
  73331. Medium = 1,
  73332. /**
  73333. * Large blur
  73334. */
  73335. High = 2
  73336. }
  73337. /**
  73338. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73339. */
  73340. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73341. private _circleOfConfusion;
  73342. /**
  73343. * @hidden Internal, blurs from high to low
  73344. */
  73345. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73346. private _depthOfFieldBlurY;
  73347. private _dofMerge;
  73348. /**
  73349. * @hidden Internal post processes in depth of field effect
  73350. */
  73351. _effects: Array<PostProcess>;
  73352. /**
  73353. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73354. */
  73355. set focalLength(value: number);
  73356. get focalLength(): number;
  73357. /**
  73358. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73359. */
  73360. set fStop(value: number);
  73361. get fStop(): number;
  73362. /**
  73363. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73364. */
  73365. set focusDistance(value: number);
  73366. get focusDistance(): number;
  73367. /**
  73368. * 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.
  73369. */
  73370. set lensSize(value: number);
  73371. get lensSize(): number;
  73372. /**
  73373. * Creates a new instance DepthOfFieldEffect
  73374. * @param scene The scene the effect belongs to.
  73375. * @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.
  73376. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73377. * @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)
  73378. */
  73379. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73380. /**
  73381. * Get the current class name of the current effet
  73382. * @returns "DepthOfFieldEffect"
  73383. */
  73384. getClassName(): string;
  73385. /**
  73386. * 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.
  73387. */
  73388. set depthTexture(value: RenderTargetTexture);
  73389. /**
  73390. * Disposes each of the internal effects for a given camera.
  73391. * @param camera The camera to dispose the effect on.
  73392. */
  73393. disposeEffects(camera: Camera): void;
  73394. /**
  73395. * @hidden Internal
  73396. */
  73397. _updateEffects(): void;
  73398. /**
  73399. * Internal
  73400. * @returns if all the contained post processes are ready.
  73401. * @hidden
  73402. */
  73403. _isReady(): boolean;
  73404. }
  73405. }
  73406. declare module "babylonjs/Shaders/displayPass.fragment" {
  73407. /** @hidden */
  73408. export var displayPassPixelShader: {
  73409. name: string;
  73410. shader: string;
  73411. };
  73412. }
  73413. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73414. import { Nullable } from "babylonjs/types";
  73415. import { Camera } from "babylonjs/Cameras/camera";
  73416. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73417. import { Engine } from "babylonjs/Engines/engine";
  73418. import "babylonjs/Shaders/displayPass.fragment";
  73419. import { Scene } from "babylonjs/scene";
  73420. /**
  73421. * DisplayPassPostProcess which produces an output the same as it's input
  73422. */
  73423. export class DisplayPassPostProcess extends PostProcess {
  73424. /**
  73425. * Gets a string identifying the name of the class
  73426. * @returns "DisplayPassPostProcess" string
  73427. */
  73428. getClassName(): string;
  73429. /**
  73430. * Creates the DisplayPassPostProcess
  73431. * @param name The name of the effect.
  73432. * @param options The required width/height ratio to downsize to before computing the render pass.
  73433. * @param camera The camera to apply the render pass to.
  73434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73435. * @param engine The engine which the post process will be applied. (default: current engine)
  73436. * @param reusable If the post process can be reused on the same frame. (default: false)
  73437. */
  73438. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73439. /** @hidden */
  73440. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73441. }
  73442. }
  73443. declare module "babylonjs/Shaders/filter.fragment" {
  73444. /** @hidden */
  73445. export var filterPixelShader: {
  73446. name: string;
  73447. shader: string;
  73448. };
  73449. }
  73450. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73451. import { Nullable } from "babylonjs/types";
  73452. import { Matrix } from "babylonjs/Maths/math.vector";
  73453. import { Camera } from "babylonjs/Cameras/camera";
  73454. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73455. import { Engine } from "babylonjs/Engines/engine";
  73456. import "babylonjs/Shaders/filter.fragment";
  73457. import { Scene } from "babylonjs/scene";
  73458. /**
  73459. * Applies a kernel filter to the image
  73460. */
  73461. export class FilterPostProcess extends PostProcess {
  73462. /** The matrix to be applied to the image */
  73463. kernelMatrix: Matrix;
  73464. /**
  73465. * Gets a string identifying the name of the class
  73466. * @returns "FilterPostProcess" string
  73467. */
  73468. getClassName(): string;
  73469. /**
  73470. *
  73471. * @param name The name of the effect.
  73472. * @param kernelMatrix The matrix to be applied to the image
  73473. * @param options The required width/height ratio to downsize to before computing the render pass.
  73474. * @param camera The camera to apply the render pass to.
  73475. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73476. * @param engine The engine which the post process will be applied. (default: current engine)
  73477. * @param reusable If the post process can be reused on the same frame. (default: false)
  73478. */
  73479. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73480. /** @hidden */
  73481. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73482. }
  73483. }
  73484. declare module "babylonjs/Shaders/fxaa.fragment" {
  73485. /** @hidden */
  73486. export var fxaaPixelShader: {
  73487. name: string;
  73488. shader: string;
  73489. };
  73490. }
  73491. declare module "babylonjs/Shaders/fxaa.vertex" {
  73492. /** @hidden */
  73493. export var fxaaVertexShader: {
  73494. name: string;
  73495. shader: string;
  73496. };
  73497. }
  73498. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73499. import { Nullable } from "babylonjs/types";
  73500. import { Camera } from "babylonjs/Cameras/camera";
  73501. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73502. import { Engine } from "babylonjs/Engines/engine";
  73503. import "babylonjs/Shaders/fxaa.fragment";
  73504. import "babylonjs/Shaders/fxaa.vertex";
  73505. import { Scene } from "babylonjs/scene";
  73506. /**
  73507. * Fxaa post process
  73508. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73509. */
  73510. export class FxaaPostProcess extends PostProcess {
  73511. /**
  73512. * Gets a string identifying the name of the class
  73513. * @returns "FxaaPostProcess" string
  73514. */
  73515. getClassName(): string;
  73516. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73517. private _getDefines;
  73518. /** @hidden */
  73519. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73520. }
  73521. }
  73522. declare module "babylonjs/Shaders/grain.fragment" {
  73523. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73524. /** @hidden */
  73525. export var grainPixelShader: {
  73526. name: string;
  73527. shader: string;
  73528. };
  73529. }
  73530. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73531. import { Nullable } from "babylonjs/types";
  73532. import { Camera } from "babylonjs/Cameras/camera";
  73533. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73534. import { Engine } from "babylonjs/Engines/engine";
  73535. import "babylonjs/Shaders/grain.fragment";
  73536. import { Scene } from "babylonjs/scene";
  73537. /**
  73538. * The GrainPostProcess adds noise to the image at mid luminance levels
  73539. */
  73540. export class GrainPostProcess extends PostProcess {
  73541. /**
  73542. * The intensity of the grain added (default: 30)
  73543. */
  73544. intensity: number;
  73545. /**
  73546. * If the grain should be randomized on every frame
  73547. */
  73548. animated: boolean;
  73549. /**
  73550. * Gets a string identifying the name of the class
  73551. * @returns "GrainPostProcess" string
  73552. */
  73553. getClassName(): string;
  73554. /**
  73555. * Creates a new instance of @see GrainPostProcess
  73556. * @param name The name of the effect.
  73557. * @param options The required width/height ratio to downsize to before computing the render pass.
  73558. * @param camera The camera to apply the render pass to.
  73559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73560. * @param engine The engine which the post process will be applied. (default: current engine)
  73561. * @param reusable If the post process can be reused on the same frame. (default: false)
  73562. * @param textureType Type of textures used when performing the post process. (default: 0)
  73563. * @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)
  73564. */
  73565. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73566. /** @hidden */
  73567. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73568. }
  73569. }
  73570. declare module "babylonjs/Shaders/highlights.fragment" {
  73571. /** @hidden */
  73572. export var highlightsPixelShader: {
  73573. name: string;
  73574. shader: string;
  73575. };
  73576. }
  73577. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73578. import { Nullable } from "babylonjs/types";
  73579. import { Camera } from "babylonjs/Cameras/camera";
  73580. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73581. import { Engine } from "babylonjs/Engines/engine";
  73582. import "babylonjs/Shaders/highlights.fragment";
  73583. /**
  73584. * Extracts highlights from the image
  73585. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73586. */
  73587. export class HighlightsPostProcess extends PostProcess {
  73588. /**
  73589. * Gets a string identifying the name of the class
  73590. * @returns "HighlightsPostProcess" string
  73591. */
  73592. getClassName(): string;
  73593. /**
  73594. * Extracts highlights from the image
  73595. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73596. * @param name The name of the effect.
  73597. * @param options The required width/height ratio to downsize to before computing the render pass.
  73598. * @param camera The camera to apply the render pass to.
  73599. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73600. * @param engine The engine which the post process will be applied. (default: current engine)
  73601. * @param reusable If the post process can be reused on the same frame. (default: false)
  73602. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73603. */
  73604. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73605. }
  73606. }
  73607. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73608. /** @hidden */
  73609. export var mrtFragmentDeclaration: {
  73610. name: string;
  73611. shader: string;
  73612. };
  73613. }
  73614. declare module "babylonjs/Shaders/geometry.fragment" {
  73615. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73616. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73617. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73618. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73619. /** @hidden */
  73620. export var geometryPixelShader: {
  73621. name: string;
  73622. shader: string;
  73623. };
  73624. }
  73625. declare module "babylonjs/Shaders/geometry.vertex" {
  73626. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73627. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73628. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73629. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73630. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73631. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73632. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73633. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73634. /** @hidden */
  73635. export var geometryVertexShader: {
  73636. name: string;
  73637. shader: string;
  73638. };
  73639. }
  73640. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73641. import { Matrix } from "babylonjs/Maths/math.vector";
  73642. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73643. import { Mesh } from "babylonjs/Meshes/mesh";
  73644. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73645. import { Effect } from "babylonjs/Materials/effect";
  73646. import { Scene } from "babylonjs/scene";
  73647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73648. import "babylonjs/Shaders/geometry.fragment";
  73649. import "babylonjs/Shaders/geometry.vertex";
  73650. /** @hidden */
  73651. interface ISavedTransformationMatrix {
  73652. world: Matrix;
  73653. viewProjection: Matrix;
  73654. }
  73655. /**
  73656. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73657. */
  73658. export class GeometryBufferRenderer {
  73659. /**
  73660. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73661. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73662. */
  73663. static readonly POSITION_TEXTURE_TYPE: number;
  73664. /**
  73665. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73666. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73667. */
  73668. static readonly VELOCITY_TEXTURE_TYPE: number;
  73669. /**
  73670. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73671. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73672. */
  73673. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73674. /**
  73675. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73676. * in order to compute objects velocities when enableVelocity is set to "true"
  73677. * @hidden
  73678. */
  73679. _previousTransformationMatrices: {
  73680. [index: number]: ISavedTransformationMatrix;
  73681. };
  73682. /**
  73683. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73684. * in order to compute objects velocities when enableVelocity is set to "true"
  73685. * @hidden
  73686. */
  73687. _previousBonesTransformationMatrices: {
  73688. [index: number]: Float32Array;
  73689. };
  73690. /**
  73691. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73692. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73693. */
  73694. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73695. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73696. renderTransparentMeshes: boolean;
  73697. private _scene;
  73698. private _resizeObserver;
  73699. private _multiRenderTarget;
  73700. private _ratio;
  73701. private _enablePosition;
  73702. private _enableVelocity;
  73703. private _enableReflectivity;
  73704. private _positionIndex;
  73705. private _velocityIndex;
  73706. private _reflectivityIndex;
  73707. protected _effect: Effect;
  73708. protected _cachedDefines: string;
  73709. /**
  73710. * Set the render list (meshes to be rendered) used in the G buffer.
  73711. */
  73712. set renderList(meshes: Mesh[]);
  73713. /**
  73714. * Gets wether or not G buffer are supported by the running hardware.
  73715. * This requires draw buffer supports
  73716. */
  73717. get isSupported(): boolean;
  73718. /**
  73719. * Returns the index of the given texture type in the G-Buffer textures array
  73720. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73721. * @returns the index of the given texture type in the G-Buffer textures array
  73722. */
  73723. getTextureIndex(textureType: number): number;
  73724. /**
  73725. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73726. */
  73727. get enablePosition(): boolean;
  73728. /**
  73729. * Sets whether or not objects positions are enabled for the G buffer.
  73730. */
  73731. set enablePosition(enable: boolean);
  73732. /**
  73733. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73734. */
  73735. get enableVelocity(): boolean;
  73736. /**
  73737. * Sets wether or not objects velocities are enabled for the G buffer.
  73738. */
  73739. set enableVelocity(enable: boolean);
  73740. /**
  73741. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73742. */
  73743. get enableReflectivity(): boolean;
  73744. /**
  73745. * Sets wether or not objects roughness are enabled for the G buffer.
  73746. */
  73747. set enableReflectivity(enable: boolean);
  73748. /**
  73749. * Gets the scene associated with the buffer.
  73750. */
  73751. get scene(): Scene;
  73752. /**
  73753. * Gets the ratio used by the buffer during its creation.
  73754. * How big is the buffer related to the main canvas.
  73755. */
  73756. get ratio(): number;
  73757. /** @hidden */
  73758. static _SceneComponentInitialization: (scene: Scene) => void;
  73759. /**
  73760. * Creates a new G Buffer for the scene
  73761. * @param scene The scene the buffer belongs to
  73762. * @param ratio How big is the buffer related to the main canvas.
  73763. */
  73764. constructor(scene: Scene, ratio?: number);
  73765. /**
  73766. * Checks wether everything is ready to render a submesh to the G buffer.
  73767. * @param subMesh the submesh to check readiness for
  73768. * @param useInstances is the mesh drawn using instance or not
  73769. * @returns true if ready otherwise false
  73770. */
  73771. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73772. /**
  73773. * Gets the current underlying G Buffer.
  73774. * @returns the buffer
  73775. */
  73776. getGBuffer(): MultiRenderTarget;
  73777. /**
  73778. * Gets the number of samples used to render the buffer (anti aliasing).
  73779. */
  73780. get samples(): number;
  73781. /**
  73782. * Sets the number of samples used to render the buffer (anti aliasing).
  73783. */
  73784. set samples(value: number);
  73785. /**
  73786. * Disposes the renderer and frees up associated resources.
  73787. */
  73788. dispose(): void;
  73789. protected _createRenderTargets(): void;
  73790. private _copyBonesTransformationMatrices;
  73791. }
  73792. }
  73793. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73794. import { Nullable } from "babylonjs/types";
  73795. import { Scene } from "babylonjs/scene";
  73796. import { ISceneComponent } from "babylonjs/sceneComponent";
  73797. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73798. module "babylonjs/scene" {
  73799. interface Scene {
  73800. /** @hidden (Backing field) */
  73801. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73802. /**
  73803. * Gets or Sets the current geometry buffer associated to the scene.
  73804. */
  73805. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73806. /**
  73807. * Enables a GeometryBufferRender and associates it with the scene
  73808. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73809. * @returns the GeometryBufferRenderer
  73810. */
  73811. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73812. /**
  73813. * Disables the GeometryBufferRender associated with the scene
  73814. */
  73815. disableGeometryBufferRenderer(): void;
  73816. }
  73817. }
  73818. /**
  73819. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73820. * in several rendering techniques.
  73821. */
  73822. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73823. /**
  73824. * The component name helpful to identify the component in the list of scene components.
  73825. */
  73826. readonly name: string;
  73827. /**
  73828. * The scene the component belongs to.
  73829. */
  73830. scene: Scene;
  73831. /**
  73832. * Creates a new instance of the component for the given scene
  73833. * @param scene Defines the scene to register the component in
  73834. */
  73835. constructor(scene: Scene);
  73836. /**
  73837. * Registers the component in a given scene
  73838. */
  73839. register(): void;
  73840. /**
  73841. * Rebuilds the elements related to this component in case of
  73842. * context lost for instance.
  73843. */
  73844. rebuild(): void;
  73845. /**
  73846. * Disposes the component and the associated ressources
  73847. */
  73848. dispose(): void;
  73849. private _gatherRenderTargets;
  73850. }
  73851. }
  73852. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73853. /** @hidden */
  73854. export var motionBlurPixelShader: {
  73855. name: string;
  73856. shader: string;
  73857. };
  73858. }
  73859. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73860. import { Nullable } from "babylonjs/types";
  73861. import { Camera } from "babylonjs/Cameras/camera";
  73862. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73864. import "babylonjs/Animations/animatable";
  73865. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73866. import "babylonjs/Shaders/motionBlur.fragment";
  73867. import { Engine } from "babylonjs/Engines/engine";
  73868. import { Scene } from "babylonjs/scene";
  73869. /**
  73870. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73871. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73872. * As an example, all you have to do is to create the post-process:
  73873. * var mb = new BABYLON.MotionBlurPostProcess(
  73874. * 'mb', // The name of the effect.
  73875. * scene, // The scene containing the objects to blur according to their velocity.
  73876. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73877. * camera // The camera to apply the render pass to.
  73878. * );
  73879. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73880. */
  73881. export class MotionBlurPostProcess extends PostProcess {
  73882. /**
  73883. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73884. */
  73885. motionStrength: number;
  73886. /**
  73887. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73888. */
  73889. get motionBlurSamples(): number;
  73890. /**
  73891. * Sets the number of iterations to be used for motion blur quality
  73892. */
  73893. set motionBlurSamples(samples: number);
  73894. private _motionBlurSamples;
  73895. private _geometryBufferRenderer;
  73896. /**
  73897. * Gets a string identifying the name of the class
  73898. * @returns "MotionBlurPostProcess" string
  73899. */
  73900. getClassName(): string;
  73901. /**
  73902. * Creates a new instance MotionBlurPostProcess
  73903. * @param name The name of the effect.
  73904. * @param scene The scene containing the objects to blur according to their velocity.
  73905. * @param options The required width/height ratio to downsize to before computing the render pass.
  73906. * @param camera The camera to apply the render pass to.
  73907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73908. * @param engine The engine which the post process will be applied. (default: current engine)
  73909. * @param reusable If the post process can be reused on the same frame. (default: false)
  73910. * @param textureType Type of textures used when performing the post process. (default: 0)
  73911. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  73912. */
  73913. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73914. /**
  73915. * Excludes the given skinned mesh from computing bones velocities.
  73916. * 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.
  73917. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73918. */
  73919. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73920. /**
  73921. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73922. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73923. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73924. */
  73925. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73926. /**
  73927. * Disposes the post process.
  73928. * @param camera The camera to dispose the post process on.
  73929. */
  73930. dispose(camera?: Camera): void;
  73931. /** @hidden */
  73932. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73933. }
  73934. }
  73935. declare module "babylonjs/Shaders/refraction.fragment" {
  73936. /** @hidden */
  73937. export var refractionPixelShader: {
  73938. name: string;
  73939. shader: string;
  73940. };
  73941. }
  73942. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73943. import { Color3 } from "babylonjs/Maths/math.color";
  73944. import { Camera } from "babylonjs/Cameras/camera";
  73945. import { Texture } from "babylonjs/Materials/Textures/texture";
  73946. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73947. import { Engine } from "babylonjs/Engines/engine";
  73948. import "babylonjs/Shaders/refraction.fragment";
  73949. import { Scene } from "babylonjs/scene";
  73950. /**
  73951. * Post process which applies a refractin texture
  73952. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73953. */
  73954. export class RefractionPostProcess extends PostProcess {
  73955. private _refTexture;
  73956. private _ownRefractionTexture;
  73957. /** the base color of the refraction (used to taint the rendering) */
  73958. color: Color3;
  73959. /** simulated refraction depth */
  73960. depth: number;
  73961. /** the coefficient of the base color (0 to remove base color tainting) */
  73962. colorLevel: number;
  73963. /** Gets the url used to load the refraction texture */
  73964. refractionTextureUrl: string;
  73965. /**
  73966. * Gets or sets the refraction texture
  73967. * Please note that you are responsible for disposing the texture if you set it manually
  73968. */
  73969. get refractionTexture(): Texture;
  73970. set refractionTexture(value: Texture);
  73971. /**
  73972. * Gets a string identifying the name of the class
  73973. * @returns "RefractionPostProcess" string
  73974. */
  73975. getClassName(): string;
  73976. /**
  73977. * Initializes the RefractionPostProcess
  73978. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73979. * @param name The name of the effect.
  73980. * @param refractionTextureUrl Url of the refraction texture to use
  73981. * @param color the base color of the refraction (used to taint the rendering)
  73982. * @param depth simulated refraction depth
  73983. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73984. * @param camera The camera to apply the render pass to.
  73985. * @param options The required width/height ratio to downsize to before computing the render pass.
  73986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73987. * @param engine The engine which the post process will be applied. (default: current engine)
  73988. * @param reusable If the post process can be reused on the same frame. (default: false)
  73989. */
  73990. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73991. /**
  73992. * Disposes of the post process
  73993. * @param camera Camera to dispose post process on
  73994. */
  73995. dispose(camera: Camera): void;
  73996. /** @hidden */
  73997. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  73998. }
  73999. }
  74000. declare module "babylonjs/Shaders/sharpen.fragment" {
  74001. /** @hidden */
  74002. export var sharpenPixelShader: {
  74003. name: string;
  74004. shader: string;
  74005. };
  74006. }
  74007. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74008. import { Nullable } from "babylonjs/types";
  74009. import { Camera } from "babylonjs/Cameras/camera";
  74010. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74011. import "babylonjs/Shaders/sharpen.fragment";
  74012. import { Engine } from "babylonjs/Engines/engine";
  74013. import { Scene } from "babylonjs/scene";
  74014. /**
  74015. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74016. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74017. */
  74018. export class SharpenPostProcess extends PostProcess {
  74019. /**
  74020. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74021. */
  74022. colorAmount: number;
  74023. /**
  74024. * How much sharpness should be applied (default: 0.3)
  74025. */
  74026. edgeAmount: number;
  74027. /**
  74028. * Gets a string identifying the name of the class
  74029. * @returns "SharpenPostProcess" string
  74030. */
  74031. getClassName(): string;
  74032. /**
  74033. * Creates a new instance ConvolutionPostProcess
  74034. * @param name The name of the effect.
  74035. * @param options The required width/height ratio to downsize to before computing the render pass.
  74036. * @param camera The camera to apply the render pass to.
  74037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74038. * @param engine The engine which the post process will be applied. (default: current engine)
  74039. * @param reusable If the post process can be reused on the same frame. (default: false)
  74040. * @param textureType Type of textures used when performing the post process. (default: 0)
  74041. * @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)
  74042. */
  74043. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74044. /** @hidden */
  74045. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74046. }
  74047. }
  74048. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74049. import { Nullable } from "babylonjs/types";
  74050. import { Camera } from "babylonjs/Cameras/camera";
  74051. import { Engine } from "babylonjs/Engines/engine";
  74052. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74053. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74054. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74055. /**
  74056. * PostProcessRenderPipeline
  74057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74058. */
  74059. export class PostProcessRenderPipeline {
  74060. private engine;
  74061. private _renderEffects;
  74062. private _renderEffectsForIsolatedPass;
  74063. /**
  74064. * List of inspectable custom properties (used by the Inspector)
  74065. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74066. */
  74067. inspectableCustomProperties: IInspectable[];
  74068. /**
  74069. * @hidden
  74070. */
  74071. protected _cameras: Camera[];
  74072. /** @hidden */
  74073. _name: string;
  74074. /**
  74075. * Gets pipeline name
  74076. */
  74077. get name(): string;
  74078. /** Gets the list of attached cameras */
  74079. get cameras(): Camera[];
  74080. /**
  74081. * Initializes a PostProcessRenderPipeline
  74082. * @param engine engine to add the pipeline to
  74083. * @param name name of the pipeline
  74084. */
  74085. constructor(engine: Engine, name: string);
  74086. /**
  74087. * Gets the class name
  74088. * @returns "PostProcessRenderPipeline"
  74089. */
  74090. getClassName(): string;
  74091. /**
  74092. * If all the render effects in the pipeline are supported
  74093. */
  74094. get isSupported(): boolean;
  74095. /**
  74096. * Adds an effect to the pipeline
  74097. * @param renderEffect the effect to add
  74098. */
  74099. addEffect(renderEffect: PostProcessRenderEffect): void;
  74100. /** @hidden */
  74101. _rebuild(): void;
  74102. /** @hidden */
  74103. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74104. /** @hidden */
  74105. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74106. /** @hidden */
  74107. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74108. /** @hidden */
  74109. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74110. /** @hidden */
  74111. _attachCameras(cameras: Camera, unique: boolean): void;
  74112. /** @hidden */
  74113. _attachCameras(cameras: Camera[], unique: boolean): void;
  74114. /** @hidden */
  74115. _detachCameras(cameras: Camera): void;
  74116. /** @hidden */
  74117. _detachCameras(cameras: Nullable<Camera[]>): void;
  74118. /** @hidden */
  74119. _update(): void;
  74120. /** @hidden */
  74121. _reset(): void;
  74122. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74123. /**
  74124. * Sets the required values to the prepass renderer.
  74125. * @param prePassRenderer defines the prepass renderer to setup.
  74126. * @returns true if the pre pass is needed.
  74127. */
  74128. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74129. /**
  74130. * Disposes of the pipeline
  74131. */
  74132. dispose(): void;
  74133. }
  74134. }
  74135. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74136. import { Camera } from "babylonjs/Cameras/camera";
  74137. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74138. /**
  74139. * PostProcessRenderPipelineManager class
  74140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74141. */
  74142. export class PostProcessRenderPipelineManager {
  74143. private _renderPipelines;
  74144. /**
  74145. * Initializes a PostProcessRenderPipelineManager
  74146. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74147. */
  74148. constructor();
  74149. /**
  74150. * Gets the list of supported render pipelines
  74151. */
  74152. get supportedPipelines(): PostProcessRenderPipeline[];
  74153. /**
  74154. * Adds a pipeline to the manager
  74155. * @param renderPipeline The pipeline to add
  74156. */
  74157. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74158. /**
  74159. * Attaches a camera to the pipeline
  74160. * @param renderPipelineName The name of the pipeline to attach to
  74161. * @param cameras the camera to attach
  74162. * @param unique if the camera can be attached multiple times to the pipeline
  74163. */
  74164. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74165. /**
  74166. * Detaches a camera from the pipeline
  74167. * @param renderPipelineName The name of the pipeline to detach from
  74168. * @param cameras the camera to detach
  74169. */
  74170. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74171. /**
  74172. * Enables an effect by name on a pipeline
  74173. * @param renderPipelineName the name of the pipeline to enable the effect in
  74174. * @param renderEffectName the name of the effect to enable
  74175. * @param cameras the cameras that the effect should be enabled on
  74176. */
  74177. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74178. /**
  74179. * Disables an effect by name on a pipeline
  74180. * @param renderPipelineName the name of the pipeline to disable the effect in
  74181. * @param renderEffectName the name of the effect to disable
  74182. * @param cameras the cameras that the effect should be disabled on
  74183. */
  74184. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74185. /**
  74186. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74187. */
  74188. update(): void;
  74189. /** @hidden */
  74190. _rebuild(): void;
  74191. /**
  74192. * Disposes of the manager and pipelines
  74193. */
  74194. dispose(): void;
  74195. }
  74196. }
  74197. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74198. import { ISceneComponent } from "babylonjs/sceneComponent";
  74199. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74200. import { Scene } from "babylonjs/scene";
  74201. module "babylonjs/scene" {
  74202. interface Scene {
  74203. /** @hidden (Backing field) */
  74204. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74205. /**
  74206. * Gets the postprocess render pipeline manager
  74207. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74208. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74209. */
  74210. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74211. }
  74212. }
  74213. /**
  74214. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74215. */
  74216. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74217. /**
  74218. * The component name helpfull to identify the component in the list of scene components.
  74219. */
  74220. readonly name: string;
  74221. /**
  74222. * The scene the component belongs to.
  74223. */
  74224. scene: Scene;
  74225. /**
  74226. * Creates a new instance of the component for the given scene
  74227. * @param scene Defines the scene to register the component in
  74228. */
  74229. constructor(scene: Scene);
  74230. /**
  74231. * Registers the component in a given scene
  74232. */
  74233. register(): void;
  74234. /**
  74235. * Rebuilds the elements related to this component in case of
  74236. * context lost for instance.
  74237. */
  74238. rebuild(): void;
  74239. /**
  74240. * Disposes the component and the associated ressources
  74241. */
  74242. dispose(): void;
  74243. private _gatherRenderTargets;
  74244. }
  74245. }
  74246. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74247. import { Nullable } from "babylonjs/types";
  74248. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74249. import { Camera } from "babylonjs/Cameras/camera";
  74250. import { IDisposable } from "babylonjs/scene";
  74251. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74252. import { Scene } from "babylonjs/scene";
  74253. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74254. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74255. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74256. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74257. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74258. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74259. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74260. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74261. import { Animation } from "babylonjs/Animations/animation";
  74262. /**
  74263. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74264. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74265. */
  74266. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74267. private _scene;
  74268. private _camerasToBeAttached;
  74269. /**
  74270. * ID of the sharpen post process,
  74271. */
  74272. private readonly SharpenPostProcessId;
  74273. /**
  74274. * @ignore
  74275. * ID of the image processing post process;
  74276. */
  74277. readonly ImageProcessingPostProcessId: string;
  74278. /**
  74279. * @ignore
  74280. * ID of the Fast Approximate Anti-Aliasing post process;
  74281. */
  74282. readonly FxaaPostProcessId: string;
  74283. /**
  74284. * ID of the chromatic aberration post process,
  74285. */
  74286. private readonly ChromaticAberrationPostProcessId;
  74287. /**
  74288. * ID of the grain post process
  74289. */
  74290. private readonly GrainPostProcessId;
  74291. /**
  74292. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74293. */
  74294. sharpen: SharpenPostProcess;
  74295. private _sharpenEffect;
  74296. private bloom;
  74297. /**
  74298. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74299. */
  74300. depthOfField: DepthOfFieldEffect;
  74301. /**
  74302. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74303. */
  74304. fxaa: FxaaPostProcess;
  74305. /**
  74306. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74307. */
  74308. imageProcessing: ImageProcessingPostProcess;
  74309. /**
  74310. * Chromatic aberration post process which will shift rgb colors in the image
  74311. */
  74312. chromaticAberration: ChromaticAberrationPostProcess;
  74313. private _chromaticAberrationEffect;
  74314. /**
  74315. * Grain post process which add noise to the image
  74316. */
  74317. grain: GrainPostProcess;
  74318. private _grainEffect;
  74319. /**
  74320. * Glow post process which adds a glow to emissive areas of the image
  74321. */
  74322. private _glowLayer;
  74323. /**
  74324. * Animations which can be used to tweak settings over a period of time
  74325. */
  74326. animations: Animation[];
  74327. private _imageProcessingConfigurationObserver;
  74328. private _sharpenEnabled;
  74329. private _bloomEnabled;
  74330. private _depthOfFieldEnabled;
  74331. private _depthOfFieldBlurLevel;
  74332. private _fxaaEnabled;
  74333. private _imageProcessingEnabled;
  74334. private _defaultPipelineTextureType;
  74335. private _bloomScale;
  74336. private _chromaticAberrationEnabled;
  74337. private _grainEnabled;
  74338. private _buildAllowed;
  74339. /**
  74340. * Gets active scene
  74341. */
  74342. get scene(): Scene;
  74343. /**
  74344. * Enable or disable the sharpen process from the pipeline
  74345. */
  74346. set sharpenEnabled(enabled: boolean);
  74347. get sharpenEnabled(): boolean;
  74348. private _resizeObserver;
  74349. private _hardwareScaleLevel;
  74350. private _bloomKernel;
  74351. /**
  74352. * Specifies the size of the bloom blur kernel, relative to the final output size
  74353. */
  74354. get bloomKernel(): number;
  74355. set bloomKernel(value: number);
  74356. /**
  74357. * Specifies the weight of the bloom in the final rendering
  74358. */
  74359. private _bloomWeight;
  74360. /**
  74361. * Specifies the luma threshold for the area that will be blurred by the bloom
  74362. */
  74363. private _bloomThreshold;
  74364. private _hdr;
  74365. /**
  74366. * The strength of the bloom.
  74367. */
  74368. set bloomWeight(value: number);
  74369. get bloomWeight(): number;
  74370. /**
  74371. * The strength of the bloom.
  74372. */
  74373. set bloomThreshold(value: number);
  74374. get bloomThreshold(): number;
  74375. /**
  74376. * The scale of the bloom, lower value will provide better performance.
  74377. */
  74378. set bloomScale(value: number);
  74379. get bloomScale(): number;
  74380. /**
  74381. * Enable or disable the bloom from the pipeline
  74382. */
  74383. set bloomEnabled(enabled: boolean);
  74384. get bloomEnabled(): boolean;
  74385. private _rebuildBloom;
  74386. /**
  74387. * If the depth of field is enabled.
  74388. */
  74389. get depthOfFieldEnabled(): boolean;
  74390. set depthOfFieldEnabled(enabled: boolean);
  74391. /**
  74392. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74393. */
  74394. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74395. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74396. /**
  74397. * If the anti aliasing is enabled.
  74398. */
  74399. set fxaaEnabled(enabled: boolean);
  74400. get fxaaEnabled(): boolean;
  74401. private _samples;
  74402. /**
  74403. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74404. */
  74405. set samples(sampleCount: number);
  74406. get samples(): number;
  74407. /**
  74408. * If image processing is enabled.
  74409. */
  74410. set imageProcessingEnabled(enabled: boolean);
  74411. get imageProcessingEnabled(): boolean;
  74412. /**
  74413. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74414. */
  74415. set glowLayerEnabled(enabled: boolean);
  74416. get glowLayerEnabled(): boolean;
  74417. /**
  74418. * Gets the glow layer (or null if not defined)
  74419. */
  74420. get glowLayer(): Nullable<GlowLayer>;
  74421. /**
  74422. * Enable or disable the chromaticAberration process from the pipeline
  74423. */
  74424. set chromaticAberrationEnabled(enabled: boolean);
  74425. get chromaticAberrationEnabled(): boolean;
  74426. /**
  74427. * Enable or disable the grain process from the pipeline
  74428. */
  74429. set grainEnabled(enabled: boolean);
  74430. get grainEnabled(): boolean;
  74431. /**
  74432. * @constructor
  74433. * @param name - The rendering pipeline name (default: "")
  74434. * @param hdr - If high dynamic range textures should be used (default: true)
  74435. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74436. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74437. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74438. */
  74439. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74440. /**
  74441. * Get the class name
  74442. * @returns "DefaultRenderingPipeline"
  74443. */
  74444. getClassName(): string;
  74445. /**
  74446. * Force the compilation of the entire pipeline.
  74447. */
  74448. prepare(): void;
  74449. private _hasCleared;
  74450. private _prevPostProcess;
  74451. private _prevPrevPostProcess;
  74452. private _setAutoClearAndTextureSharing;
  74453. private _depthOfFieldSceneObserver;
  74454. private _buildPipeline;
  74455. private _disposePostProcesses;
  74456. /**
  74457. * Adds a camera to the pipeline
  74458. * @param camera the camera to be added
  74459. */
  74460. addCamera(camera: Camera): void;
  74461. /**
  74462. * Removes a camera from the pipeline
  74463. * @param camera the camera to remove
  74464. */
  74465. removeCamera(camera: Camera): void;
  74466. /**
  74467. * Dispose of the pipeline and stop all post processes
  74468. */
  74469. dispose(): void;
  74470. /**
  74471. * Serialize the rendering pipeline (Used when exporting)
  74472. * @returns the serialized object
  74473. */
  74474. serialize(): any;
  74475. /**
  74476. * Parse the serialized pipeline
  74477. * @param source Source pipeline.
  74478. * @param scene The scene to load the pipeline to.
  74479. * @param rootUrl The URL of the serialized pipeline.
  74480. * @returns An instantiated pipeline from the serialized object.
  74481. */
  74482. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74483. }
  74484. }
  74485. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74486. /** @hidden */
  74487. export var lensHighlightsPixelShader: {
  74488. name: string;
  74489. shader: string;
  74490. };
  74491. }
  74492. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74493. /** @hidden */
  74494. export var depthOfFieldPixelShader: {
  74495. name: string;
  74496. shader: string;
  74497. };
  74498. }
  74499. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74500. import { Camera } from "babylonjs/Cameras/camera";
  74501. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74502. import { Scene } from "babylonjs/scene";
  74503. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74504. import "babylonjs/Shaders/chromaticAberration.fragment";
  74505. import "babylonjs/Shaders/lensHighlights.fragment";
  74506. import "babylonjs/Shaders/depthOfField.fragment";
  74507. /**
  74508. * BABYLON.JS Chromatic Aberration GLSL Shader
  74509. * Author: Olivier Guyot
  74510. * Separates very slightly R, G and B colors on the edges of the screen
  74511. * Inspired by Francois Tarlier & Martins Upitis
  74512. */
  74513. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74514. /**
  74515. * @ignore
  74516. * The chromatic aberration PostProcess id in the pipeline
  74517. */
  74518. LensChromaticAberrationEffect: string;
  74519. /**
  74520. * @ignore
  74521. * The highlights enhancing PostProcess id in the pipeline
  74522. */
  74523. HighlightsEnhancingEffect: string;
  74524. /**
  74525. * @ignore
  74526. * The depth-of-field PostProcess id in the pipeline
  74527. */
  74528. LensDepthOfFieldEffect: string;
  74529. private _scene;
  74530. private _depthTexture;
  74531. private _grainTexture;
  74532. private _chromaticAberrationPostProcess;
  74533. private _highlightsPostProcess;
  74534. private _depthOfFieldPostProcess;
  74535. private _edgeBlur;
  74536. private _grainAmount;
  74537. private _chromaticAberration;
  74538. private _distortion;
  74539. private _highlightsGain;
  74540. private _highlightsThreshold;
  74541. private _dofDistance;
  74542. private _dofAperture;
  74543. private _dofDarken;
  74544. private _dofPentagon;
  74545. private _blurNoise;
  74546. /**
  74547. * @constructor
  74548. *
  74549. * Effect parameters are as follow:
  74550. * {
  74551. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74552. * edge_blur: number; // from 0 to x (1 for realism)
  74553. * distortion: number; // from 0 to x (1 for realism)
  74554. * grain_amount: number; // from 0 to 1
  74555. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74556. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74557. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74558. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74559. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74560. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74561. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74562. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74563. * }
  74564. * Note: if an effect parameter is unset, effect is disabled
  74565. *
  74566. * @param name The rendering pipeline name
  74567. * @param parameters - An object containing all parameters (see above)
  74568. * @param scene The scene linked to this pipeline
  74569. * @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)
  74570. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74571. */
  74572. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74573. /**
  74574. * Get the class name
  74575. * @returns "LensRenderingPipeline"
  74576. */
  74577. getClassName(): string;
  74578. /**
  74579. * Gets associated scene
  74580. */
  74581. get scene(): Scene;
  74582. /**
  74583. * Gets or sets the edge blur
  74584. */
  74585. get edgeBlur(): number;
  74586. set edgeBlur(value: number);
  74587. /**
  74588. * Gets or sets the grain amount
  74589. */
  74590. get grainAmount(): number;
  74591. set grainAmount(value: number);
  74592. /**
  74593. * Gets or sets the chromatic aberration amount
  74594. */
  74595. get chromaticAberration(): number;
  74596. set chromaticAberration(value: number);
  74597. /**
  74598. * Gets or sets the depth of field aperture
  74599. */
  74600. get dofAperture(): number;
  74601. set dofAperture(value: number);
  74602. /**
  74603. * Gets or sets the edge distortion
  74604. */
  74605. get edgeDistortion(): number;
  74606. set edgeDistortion(value: number);
  74607. /**
  74608. * Gets or sets the depth of field distortion
  74609. */
  74610. get dofDistortion(): number;
  74611. set dofDistortion(value: number);
  74612. /**
  74613. * Gets or sets the darken out of focus amount
  74614. */
  74615. get darkenOutOfFocus(): number;
  74616. set darkenOutOfFocus(value: number);
  74617. /**
  74618. * Gets or sets a boolean indicating if blur noise is enabled
  74619. */
  74620. get blurNoise(): boolean;
  74621. set blurNoise(value: boolean);
  74622. /**
  74623. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74624. */
  74625. get pentagonBokeh(): boolean;
  74626. set pentagonBokeh(value: boolean);
  74627. /**
  74628. * Gets or sets the highlight grain amount
  74629. */
  74630. get highlightsGain(): number;
  74631. set highlightsGain(value: number);
  74632. /**
  74633. * Gets or sets the highlight threshold
  74634. */
  74635. get highlightsThreshold(): number;
  74636. set highlightsThreshold(value: number);
  74637. /**
  74638. * Sets the amount of blur at the edges
  74639. * @param amount blur amount
  74640. */
  74641. setEdgeBlur(amount: number): void;
  74642. /**
  74643. * Sets edge blur to 0
  74644. */
  74645. disableEdgeBlur(): void;
  74646. /**
  74647. * Sets the amout of grain
  74648. * @param amount Amount of grain
  74649. */
  74650. setGrainAmount(amount: number): void;
  74651. /**
  74652. * Set grain amount to 0
  74653. */
  74654. disableGrain(): void;
  74655. /**
  74656. * Sets the chromatic aberration amount
  74657. * @param amount amount of chromatic aberration
  74658. */
  74659. setChromaticAberration(amount: number): void;
  74660. /**
  74661. * Sets chromatic aberration amount to 0
  74662. */
  74663. disableChromaticAberration(): void;
  74664. /**
  74665. * Sets the EdgeDistortion amount
  74666. * @param amount amount of EdgeDistortion
  74667. */
  74668. setEdgeDistortion(amount: number): void;
  74669. /**
  74670. * Sets edge distortion to 0
  74671. */
  74672. disableEdgeDistortion(): void;
  74673. /**
  74674. * Sets the FocusDistance amount
  74675. * @param amount amount of FocusDistance
  74676. */
  74677. setFocusDistance(amount: number): void;
  74678. /**
  74679. * Disables depth of field
  74680. */
  74681. disableDepthOfField(): void;
  74682. /**
  74683. * Sets the Aperture amount
  74684. * @param amount amount of Aperture
  74685. */
  74686. setAperture(amount: number): void;
  74687. /**
  74688. * Sets the DarkenOutOfFocus amount
  74689. * @param amount amount of DarkenOutOfFocus
  74690. */
  74691. setDarkenOutOfFocus(amount: number): void;
  74692. private _pentagonBokehIsEnabled;
  74693. /**
  74694. * Creates a pentagon bokeh effect
  74695. */
  74696. enablePentagonBokeh(): void;
  74697. /**
  74698. * Disables the pentagon bokeh effect
  74699. */
  74700. disablePentagonBokeh(): void;
  74701. /**
  74702. * Enables noise blur
  74703. */
  74704. enableNoiseBlur(): void;
  74705. /**
  74706. * Disables noise blur
  74707. */
  74708. disableNoiseBlur(): void;
  74709. /**
  74710. * Sets the HighlightsGain amount
  74711. * @param amount amount of HighlightsGain
  74712. */
  74713. setHighlightsGain(amount: number): void;
  74714. /**
  74715. * Sets the HighlightsThreshold amount
  74716. * @param amount amount of HighlightsThreshold
  74717. */
  74718. setHighlightsThreshold(amount: number): void;
  74719. /**
  74720. * Disables highlights
  74721. */
  74722. disableHighlights(): void;
  74723. /**
  74724. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74725. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74726. */
  74727. dispose(disableDepthRender?: boolean): void;
  74728. private _createChromaticAberrationPostProcess;
  74729. private _createHighlightsPostProcess;
  74730. private _createDepthOfFieldPostProcess;
  74731. private _createGrainTexture;
  74732. }
  74733. }
  74734. declare module "babylonjs/Rendering/ssao2Configuration" {
  74735. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74736. /**
  74737. * Contains all parameters needed for the prepass to perform
  74738. * screen space subsurface scattering
  74739. */
  74740. export class SSAO2Configuration implements PrePassEffectConfiguration {
  74741. /**
  74742. * Is subsurface enabled
  74743. */
  74744. enabled: boolean;
  74745. /**
  74746. * Name of the configuration
  74747. */
  74748. name: string;
  74749. /**
  74750. * Textures that should be present in the MRT for this effect to work
  74751. */
  74752. readonly texturesRequired: number[];
  74753. /**
  74754. * Builds a ssao2 configuration object
  74755. * @param scene The scene
  74756. */
  74757. constructor();
  74758. /**
  74759. * Disposes the configuration
  74760. */
  74761. dispose(): void;
  74762. }
  74763. }
  74764. declare module "babylonjs/Shaders/ssao2.fragment" {
  74765. /** @hidden */
  74766. export var ssao2PixelShader: {
  74767. name: string;
  74768. shader: string;
  74769. };
  74770. }
  74771. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74772. /** @hidden */
  74773. export var ssaoCombinePixelShader: {
  74774. name: string;
  74775. shader: string;
  74776. };
  74777. }
  74778. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74779. import { Camera } from "babylonjs/Cameras/camera";
  74780. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74781. import { Scene } from "babylonjs/scene";
  74782. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74783. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74784. import "babylonjs/Shaders/ssao2.fragment";
  74785. import "babylonjs/Shaders/ssaoCombine.fragment";
  74786. /**
  74787. * Render pipeline to produce ssao effect
  74788. */
  74789. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74790. /**
  74791. * @ignore
  74792. * The PassPostProcess id in the pipeline that contains the original scene color
  74793. */
  74794. SSAOOriginalSceneColorEffect: string;
  74795. /**
  74796. * @ignore
  74797. * The SSAO PostProcess id in the pipeline
  74798. */
  74799. SSAORenderEffect: string;
  74800. /**
  74801. * @ignore
  74802. * The horizontal blur PostProcess id in the pipeline
  74803. */
  74804. SSAOBlurHRenderEffect: string;
  74805. /**
  74806. * @ignore
  74807. * The vertical blur PostProcess id in the pipeline
  74808. */
  74809. SSAOBlurVRenderEffect: string;
  74810. /**
  74811. * @ignore
  74812. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74813. */
  74814. SSAOCombineRenderEffect: string;
  74815. /**
  74816. * The output strength of the SSAO post-process. Default value is 1.0.
  74817. */
  74818. totalStrength: number;
  74819. /**
  74820. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74821. */
  74822. maxZ: number;
  74823. /**
  74824. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74825. */
  74826. minZAspect: number;
  74827. private _samples;
  74828. /**
  74829. * Number of samples used for the SSAO calculations. Default value is 8
  74830. */
  74831. set samples(n: number);
  74832. get samples(): number;
  74833. private _textureSamples;
  74834. /**
  74835. * Number of samples to use for antialiasing
  74836. */
  74837. set textureSamples(n: number);
  74838. get textureSamples(): number;
  74839. /**
  74840. * Force rendering the geometry through geometry buffer
  74841. */
  74842. private _forceGeometryBuffer;
  74843. /**
  74844. * Ratio object used for SSAO ratio and blur ratio
  74845. */
  74846. private _ratio;
  74847. /**
  74848. * Dynamically generated sphere sampler.
  74849. */
  74850. private _sampleSphere;
  74851. private _ssao2PrePassConfiguration;
  74852. /**
  74853. * Blur filter offsets
  74854. */
  74855. private _samplerOffsets;
  74856. private _expensiveBlur;
  74857. /**
  74858. * If bilateral blur should be used
  74859. */
  74860. set expensiveBlur(b: boolean);
  74861. get expensiveBlur(): boolean;
  74862. /**
  74863. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74864. */
  74865. radius: number;
  74866. /**
  74867. * The base color of the SSAO post-process
  74868. * The final result is "base + ssao" between [0, 1]
  74869. */
  74870. base: number;
  74871. /**
  74872. * Support test.
  74873. */
  74874. static get IsSupported(): boolean;
  74875. private _scene;
  74876. private _randomTexture;
  74877. private _originalColorPostProcess;
  74878. private _ssaoPostProcess;
  74879. private _blurHPostProcess;
  74880. private _blurVPostProcess;
  74881. private _ssaoCombinePostProcess;
  74882. private _prePassRenderer;
  74883. /**
  74884. * Gets active scene
  74885. */
  74886. get scene(): Scene;
  74887. /**
  74888. * @constructor
  74889. * @param name The rendering pipeline name
  74890. * @param scene The scene linked to this pipeline
  74891. * @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 }
  74892. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74893. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74894. */
  74895. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74896. /**
  74897. * Get the class name
  74898. * @returns "SSAO2RenderingPipeline"
  74899. */
  74900. getClassName(): string;
  74901. /**
  74902. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74903. */
  74904. dispose(disableGeometryBufferRenderer?: boolean): void;
  74905. private _createBlurPostProcess;
  74906. /** @hidden */
  74907. _rebuild(): void;
  74908. private _bits;
  74909. private _radicalInverse_VdC;
  74910. private _hammersley;
  74911. private _hemisphereSample_uniform;
  74912. private _generateHemisphere;
  74913. private _getDefinesForSSAO;
  74914. private _createSSAOPostProcess;
  74915. private _createSSAOCombinePostProcess;
  74916. private _createRandomTexture;
  74917. /**
  74918. * Serialize the rendering pipeline (Used when exporting)
  74919. * @returns the serialized object
  74920. */
  74921. serialize(): any;
  74922. /**
  74923. * Parse the serialized pipeline
  74924. * @param source Source pipeline.
  74925. * @param scene The scene to load the pipeline to.
  74926. * @param rootUrl The URL of the serialized pipeline.
  74927. * @returns An instantiated pipeline from the serialized object.
  74928. */
  74929. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74930. /**
  74931. * Sets the required values to the prepass renderer.
  74932. * @param prePassRenderer defines the prepass renderer to setup
  74933. * @returns true if the pre pass is needed.
  74934. */
  74935. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74936. }
  74937. }
  74938. declare module "babylonjs/Shaders/ssao.fragment" {
  74939. /** @hidden */
  74940. export var ssaoPixelShader: {
  74941. name: string;
  74942. shader: string;
  74943. };
  74944. }
  74945. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74946. import { Camera } from "babylonjs/Cameras/camera";
  74947. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74948. import { Scene } from "babylonjs/scene";
  74949. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74950. import "babylonjs/Shaders/ssao.fragment";
  74951. import "babylonjs/Shaders/ssaoCombine.fragment";
  74952. /**
  74953. * Render pipeline to produce ssao effect
  74954. */
  74955. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74956. /**
  74957. * @ignore
  74958. * The PassPostProcess id in the pipeline that contains the original scene color
  74959. */
  74960. SSAOOriginalSceneColorEffect: string;
  74961. /**
  74962. * @ignore
  74963. * The SSAO PostProcess id in the pipeline
  74964. */
  74965. SSAORenderEffect: string;
  74966. /**
  74967. * @ignore
  74968. * The horizontal blur PostProcess id in the pipeline
  74969. */
  74970. SSAOBlurHRenderEffect: string;
  74971. /**
  74972. * @ignore
  74973. * The vertical blur PostProcess id in the pipeline
  74974. */
  74975. SSAOBlurVRenderEffect: string;
  74976. /**
  74977. * @ignore
  74978. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74979. */
  74980. SSAOCombineRenderEffect: string;
  74981. /**
  74982. * The output strength of the SSAO post-process. Default value is 1.0.
  74983. */
  74984. totalStrength: number;
  74985. /**
  74986. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74987. */
  74988. radius: number;
  74989. /**
  74990. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74991. * Must not be equal to fallOff and superior to fallOff.
  74992. * Default value is 0.0075
  74993. */
  74994. area: number;
  74995. /**
  74996. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74997. * Must not be equal to area and inferior to area.
  74998. * Default value is 0.000001
  74999. */
  75000. fallOff: number;
  75001. /**
  75002. * The base color of the SSAO post-process
  75003. * The final result is "base + ssao" between [0, 1]
  75004. */
  75005. base: number;
  75006. private _scene;
  75007. private _depthTexture;
  75008. private _randomTexture;
  75009. private _originalColorPostProcess;
  75010. private _ssaoPostProcess;
  75011. private _blurHPostProcess;
  75012. private _blurVPostProcess;
  75013. private _ssaoCombinePostProcess;
  75014. private _firstUpdate;
  75015. /**
  75016. * Gets active scene
  75017. */
  75018. get scene(): Scene;
  75019. /**
  75020. * @constructor
  75021. * @param name - The rendering pipeline name
  75022. * @param scene - The scene linked to this pipeline
  75023. * @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 }
  75024. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75025. */
  75026. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75027. /**
  75028. * Get the class name
  75029. * @returns "SSAORenderingPipeline"
  75030. */
  75031. getClassName(): string;
  75032. /**
  75033. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75034. */
  75035. dispose(disableDepthRender?: boolean): void;
  75036. private _createBlurPostProcess;
  75037. /** @hidden */
  75038. _rebuild(): void;
  75039. private _createSSAOPostProcess;
  75040. private _createSSAOCombinePostProcess;
  75041. private _createRandomTexture;
  75042. }
  75043. }
  75044. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75045. /** @hidden */
  75046. export var screenSpaceReflectionPixelShader: {
  75047. name: string;
  75048. shader: string;
  75049. };
  75050. }
  75051. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75052. import { Nullable } from "babylonjs/types";
  75053. import { Camera } from "babylonjs/Cameras/camera";
  75054. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75055. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75056. import { Engine } from "babylonjs/Engines/engine";
  75057. import { Scene } from "babylonjs/scene";
  75058. /**
  75059. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75060. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75061. */
  75062. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75063. /**
  75064. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75065. */
  75066. threshold: number;
  75067. /**
  75068. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75069. */
  75070. strength: number;
  75071. /**
  75072. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75073. */
  75074. reflectionSpecularFalloffExponent: number;
  75075. /**
  75076. * 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]
  75077. */
  75078. step: number;
  75079. /**
  75080. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75081. */
  75082. roughnessFactor: number;
  75083. private _geometryBufferRenderer;
  75084. private _enableSmoothReflections;
  75085. private _reflectionSamples;
  75086. private _smoothSteps;
  75087. /**
  75088. * Gets a string identifying the name of the class
  75089. * @returns "ScreenSpaceReflectionPostProcess" string
  75090. */
  75091. getClassName(): string;
  75092. /**
  75093. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75094. * @param name The name of the effect.
  75095. * @param scene The scene containing the objects to calculate reflections.
  75096. * @param options The required width/height ratio to downsize to before computing the render pass.
  75097. * @param camera The camera to apply the render pass to.
  75098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75099. * @param engine The engine which the post process will be applied. (default: current engine)
  75100. * @param reusable If the post process can be reused on the same frame. (default: false)
  75101. * @param textureType Type of textures used when performing the post process. (default: 0)
  75102. * @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)
  75103. */
  75104. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75105. /**
  75106. * Gets wether or not smoothing reflections is enabled.
  75107. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75108. */
  75109. get enableSmoothReflections(): boolean;
  75110. /**
  75111. * Sets wether or not smoothing reflections is enabled.
  75112. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75113. */
  75114. set enableSmoothReflections(enabled: boolean);
  75115. /**
  75116. * Gets the number of samples taken while computing reflections. More samples count is high,
  75117. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75118. */
  75119. get reflectionSamples(): number;
  75120. /**
  75121. * Sets the number of samples taken while computing reflections. More samples count is high,
  75122. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75123. */
  75124. set reflectionSamples(samples: number);
  75125. /**
  75126. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75127. * more the post-process will require GPU power and can generate a drop in FPS.
  75128. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75129. */
  75130. get smoothSteps(): number;
  75131. set smoothSteps(steps: number);
  75132. private _updateEffectDefines;
  75133. /** @hidden */
  75134. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75135. }
  75136. }
  75137. declare module "babylonjs/Shaders/standard.fragment" {
  75138. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75139. /** @hidden */
  75140. export var standardPixelShader: {
  75141. name: string;
  75142. shader: string;
  75143. };
  75144. }
  75145. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75146. import { Nullable } from "babylonjs/types";
  75147. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75148. import { Camera } from "babylonjs/Cameras/camera";
  75149. import { Texture } from "babylonjs/Materials/Textures/texture";
  75150. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75151. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75152. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75153. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75154. import { IDisposable } from "babylonjs/scene";
  75155. import { SpotLight } from "babylonjs/Lights/spotLight";
  75156. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75157. import { Scene } from "babylonjs/scene";
  75158. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75159. import { Animation } from "babylonjs/Animations/animation";
  75160. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75161. import "babylonjs/Shaders/standard.fragment";
  75162. /**
  75163. * Standard rendering pipeline
  75164. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75165. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75166. */
  75167. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75168. /**
  75169. * Public members
  75170. */
  75171. /**
  75172. * Post-process which contains the original scene color before the pipeline applies all the effects
  75173. */
  75174. originalPostProcess: Nullable<PostProcess>;
  75175. /**
  75176. * Post-process used to down scale an image x4
  75177. */
  75178. downSampleX4PostProcess: Nullable<PostProcess>;
  75179. /**
  75180. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75181. */
  75182. brightPassPostProcess: Nullable<PostProcess>;
  75183. /**
  75184. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75185. */
  75186. blurHPostProcesses: PostProcess[];
  75187. /**
  75188. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75189. */
  75190. blurVPostProcesses: PostProcess[];
  75191. /**
  75192. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75193. */
  75194. textureAdderPostProcess: Nullable<PostProcess>;
  75195. /**
  75196. * Post-process used to create volumetric lighting effect
  75197. */
  75198. volumetricLightPostProcess: Nullable<PostProcess>;
  75199. /**
  75200. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75201. */
  75202. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75203. /**
  75204. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75205. */
  75206. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75207. /**
  75208. * Post-process used to merge the volumetric light effect and the real scene color
  75209. */
  75210. volumetricLightMergePostProces: Nullable<PostProcess>;
  75211. /**
  75212. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75213. */
  75214. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75215. /**
  75216. * Base post-process used to calculate the average luminance of the final image for HDR
  75217. */
  75218. luminancePostProcess: Nullable<PostProcess>;
  75219. /**
  75220. * Post-processes used to create down sample post-processes in order to get
  75221. * the average luminance of the final image for HDR
  75222. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75223. */
  75224. luminanceDownSamplePostProcesses: PostProcess[];
  75225. /**
  75226. * Post-process used to create a HDR effect (light adaptation)
  75227. */
  75228. hdrPostProcess: Nullable<PostProcess>;
  75229. /**
  75230. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75231. */
  75232. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75233. /**
  75234. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75235. */
  75236. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75237. /**
  75238. * Post-process used to merge the final HDR post-process and the real scene color
  75239. */
  75240. hdrFinalPostProcess: Nullable<PostProcess>;
  75241. /**
  75242. * Post-process used to create a lens flare effect
  75243. */
  75244. lensFlarePostProcess: Nullable<PostProcess>;
  75245. /**
  75246. * Post-process that merges the result of the lens flare post-process and the real scene color
  75247. */
  75248. lensFlareComposePostProcess: Nullable<PostProcess>;
  75249. /**
  75250. * Post-process used to create a motion blur effect
  75251. */
  75252. motionBlurPostProcess: Nullable<PostProcess>;
  75253. /**
  75254. * Post-process used to create a depth of field effect
  75255. */
  75256. depthOfFieldPostProcess: Nullable<PostProcess>;
  75257. /**
  75258. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75259. */
  75260. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75261. /**
  75262. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75263. */
  75264. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75265. /**
  75266. * Represents the brightness threshold in order to configure the illuminated surfaces
  75267. */
  75268. brightThreshold: number;
  75269. /**
  75270. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75271. */
  75272. blurWidth: number;
  75273. /**
  75274. * Sets if the blur for highlighted surfaces must be only horizontal
  75275. */
  75276. horizontalBlur: boolean;
  75277. /**
  75278. * Gets the overall exposure used by the pipeline
  75279. */
  75280. get exposure(): number;
  75281. /**
  75282. * Sets the overall exposure used by the pipeline
  75283. */
  75284. set exposure(value: number);
  75285. /**
  75286. * Texture used typically to simulate "dirty" on camera lens
  75287. */
  75288. lensTexture: Nullable<Texture>;
  75289. /**
  75290. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75291. */
  75292. volumetricLightCoefficient: number;
  75293. /**
  75294. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75295. */
  75296. volumetricLightPower: number;
  75297. /**
  75298. * Used the set the blur intensity to smooth the volumetric lights
  75299. */
  75300. volumetricLightBlurScale: number;
  75301. /**
  75302. * Light (spot or directional) used to generate the volumetric lights rays
  75303. * The source light must have a shadow generate so the pipeline can get its
  75304. * depth map
  75305. */
  75306. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75307. /**
  75308. * For eye adaptation, represents the minimum luminance the eye can see
  75309. */
  75310. hdrMinimumLuminance: number;
  75311. /**
  75312. * For eye adaptation, represents the decrease luminance speed
  75313. */
  75314. hdrDecreaseRate: number;
  75315. /**
  75316. * For eye adaptation, represents the increase luminance speed
  75317. */
  75318. hdrIncreaseRate: number;
  75319. /**
  75320. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75321. */
  75322. get hdrAutoExposure(): boolean;
  75323. /**
  75324. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75325. */
  75326. set hdrAutoExposure(value: boolean);
  75327. /**
  75328. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75329. */
  75330. lensColorTexture: Nullable<Texture>;
  75331. /**
  75332. * The overall strengh for the lens flare effect
  75333. */
  75334. lensFlareStrength: number;
  75335. /**
  75336. * Dispersion coefficient for lens flare ghosts
  75337. */
  75338. lensFlareGhostDispersal: number;
  75339. /**
  75340. * Main lens flare halo width
  75341. */
  75342. lensFlareHaloWidth: number;
  75343. /**
  75344. * Based on the lens distortion effect, defines how much the lens flare result
  75345. * is distorted
  75346. */
  75347. lensFlareDistortionStrength: number;
  75348. /**
  75349. * Configures the blur intensity used for for lens flare (halo)
  75350. */
  75351. lensFlareBlurWidth: number;
  75352. /**
  75353. * Lens star texture must be used to simulate rays on the flares and is available
  75354. * in the documentation
  75355. */
  75356. lensStarTexture: Nullable<Texture>;
  75357. /**
  75358. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75359. * flare effect by taking account of the dirt texture
  75360. */
  75361. lensFlareDirtTexture: Nullable<Texture>;
  75362. /**
  75363. * Represents the focal length for the depth of field effect
  75364. */
  75365. depthOfFieldDistance: number;
  75366. /**
  75367. * Represents the blur intensity for the blurred part of the depth of field effect
  75368. */
  75369. depthOfFieldBlurWidth: number;
  75370. /**
  75371. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75372. */
  75373. get motionStrength(): number;
  75374. /**
  75375. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75376. */
  75377. set motionStrength(strength: number);
  75378. /**
  75379. * Gets wether or not the motion blur post-process is object based or screen based.
  75380. */
  75381. get objectBasedMotionBlur(): boolean;
  75382. /**
  75383. * Sets wether or not the motion blur post-process should be object based or screen based
  75384. */
  75385. set objectBasedMotionBlur(value: boolean);
  75386. /**
  75387. * List of animations for the pipeline (IAnimatable implementation)
  75388. */
  75389. animations: Animation[];
  75390. /**
  75391. * Private members
  75392. */
  75393. private _scene;
  75394. private _currentDepthOfFieldSource;
  75395. private _basePostProcess;
  75396. private _fixedExposure;
  75397. private _currentExposure;
  75398. private _hdrAutoExposure;
  75399. private _hdrCurrentLuminance;
  75400. private _motionStrength;
  75401. private _isObjectBasedMotionBlur;
  75402. private _floatTextureType;
  75403. private _camerasToBeAttached;
  75404. private _ratio;
  75405. private _bloomEnabled;
  75406. private _depthOfFieldEnabled;
  75407. private _vlsEnabled;
  75408. private _lensFlareEnabled;
  75409. private _hdrEnabled;
  75410. private _motionBlurEnabled;
  75411. private _fxaaEnabled;
  75412. private _screenSpaceReflectionsEnabled;
  75413. private _motionBlurSamples;
  75414. private _volumetricLightStepsCount;
  75415. private _samples;
  75416. /**
  75417. * @ignore
  75418. * Specifies if the bloom pipeline is enabled
  75419. */
  75420. get BloomEnabled(): boolean;
  75421. set BloomEnabled(enabled: boolean);
  75422. /**
  75423. * @ignore
  75424. * Specifies if the depth of field pipeline is enabed
  75425. */
  75426. get DepthOfFieldEnabled(): boolean;
  75427. set DepthOfFieldEnabled(enabled: boolean);
  75428. /**
  75429. * @ignore
  75430. * Specifies if the lens flare pipeline is enabed
  75431. */
  75432. get LensFlareEnabled(): boolean;
  75433. set LensFlareEnabled(enabled: boolean);
  75434. /**
  75435. * @ignore
  75436. * Specifies if the HDR pipeline is enabled
  75437. */
  75438. get HDREnabled(): boolean;
  75439. set HDREnabled(enabled: boolean);
  75440. /**
  75441. * @ignore
  75442. * Specifies if the volumetric lights scattering effect is enabled
  75443. */
  75444. get VLSEnabled(): boolean;
  75445. set VLSEnabled(enabled: boolean);
  75446. /**
  75447. * @ignore
  75448. * Specifies if the motion blur effect is enabled
  75449. */
  75450. get MotionBlurEnabled(): boolean;
  75451. set MotionBlurEnabled(enabled: boolean);
  75452. /**
  75453. * Specifies if anti-aliasing is enabled
  75454. */
  75455. get fxaaEnabled(): boolean;
  75456. set fxaaEnabled(enabled: boolean);
  75457. /**
  75458. * Specifies if screen space reflections are enabled.
  75459. */
  75460. get screenSpaceReflectionsEnabled(): boolean;
  75461. set screenSpaceReflectionsEnabled(enabled: boolean);
  75462. /**
  75463. * Specifies the number of steps used to calculate the volumetric lights
  75464. * Typically in interval [50, 200]
  75465. */
  75466. get volumetricLightStepsCount(): number;
  75467. set volumetricLightStepsCount(count: number);
  75468. /**
  75469. * Specifies the number of samples used for the motion blur effect
  75470. * Typically in interval [16, 64]
  75471. */
  75472. get motionBlurSamples(): number;
  75473. set motionBlurSamples(samples: number);
  75474. /**
  75475. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75476. */
  75477. get samples(): number;
  75478. set samples(sampleCount: number);
  75479. /**
  75480. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75481. * @constructor
  75482. * @param name The rendering pipeline name
  75483. * @param scene The scene linked to this pipeline
  75484. * @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)
  75485. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75486. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75487. */
  75488. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75489. private _buildPipeline;
  75490. private _createDownSampleX4PostProcess;
  75491. private _createBrightPassPostProcess;
  75492. private _createBlurPostProcesses;
  75493. private _createTextureAdderPostProcess;
  75494. private _createVolumetricLightPostProcess;
  75495. private _createLuminancePostProcesses;
  75496. private _createHdrPostProcess;
  75497. private _createLensFlarePostProcess;
  75498. private _createDepthOfFieldPostProcess;
  75499. private _createMotionBlurPostProcess;
  75500. private _getDepthTexture;
  75501. private _disposePostProcesses;
  75502. /**
  75503. * Dispose of the pipeline and stop all post processes
  75504. */
  75505. dispose(): void;
  75506. /**
  75507. * Serialize the rendering pipeline (Used when exporting)
  75508. * @returns the serialized object
  75509. */
  75510. serialize(): any;
  75511. /**
  75512. * Parse the serialized pipeline
  75513. * @param source Source pipeline.
  75514. * @param scene The scene to load the pipeline to.
  75515. * @param rootUrl The URL of the serialized pipeline.
  75516. * @returns An instantiated pipeline from the serialized object.
  75517. */
  75518. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75519. /**
  75520. * Luminance steps
  75521. */
  75522. static LuminanceSteps: number;
  75523. }
  75524. }
  75525. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75526. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75527. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75528. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75529. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75530. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75531. }
  75532. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75533. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75534. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75535. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75536. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75537. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75538. }
  75539. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75540. /** @hidden */
  75541. export var stereoscopicInterlacePixelShader: {
  75542. name: string;
  75543. shader: string;
  75544. };
  75545. }
  75546. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75547. import { Camera } from "babylonjs/Cameras/camera";
  75548. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75549. import { Engine } from "babylonjs/Engines/engine";
  75550. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75551. /**
  75552. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75553. */
  75554. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75555. private _stepSize;
  75556. private _passedProcess;
  75557. /**
  75558. * Gets a string identifying the name of the class
  75559. * @returns "StereoscopicInterlacePostProcessI" string
  75560. */
  75561. getClassName(): string;
  75562. /**
  75563. * Initializes a StereoscopicInterlacePostProcessI
  75564. * @param name The name of the effect.
  75565. * @param rigCameras The rig cameras to be appled to the post process
  75566. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75567. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75569. * @param engine The engine which the post process will be applied. (default: current engine)
  75570. * @param reusable If the post process can be reused on the same frame. (default: false)
  75571. */
  75572. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75573. }
  75574. /**
  75575. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75576. */
  75577. export class StereoscopicInterlacePostProcess extends PostProcess {
  75578. private _stepSize;
  75579. private _passedProcess;
  75580. /**
  75581. * Gets a string identifying the name of the class
  75582. * @returns "StereoscopicInterlacePostProcess" string
  75583. */
  75584. getClassName(): string;
  75585. /**
  75586. * Initializes a StereoscopicInterlacePostProcess
  75587. * @param name The name of the effect.
  75588. * @param rigCameras The rig cameras to be appled to the post process
  75589. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75591. * @param engine The engine which the post process will be applied. (default: current engine)
  75592. * @param reusable If the post process can be reused on the same frame. (default: false)
  75593. */
  75594. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75595. }
  75596. }
  75597. declare module "babylonjs/Shaders/tonemap.fragment" {
  75598. /** @hidden */
  75599. export var tonemapPixelShader: {
  75600. name: string;
  75601. shader: string;
  75602. };
  75603. }
  75604. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75605. import { Camera } from "babylonjs/Cameras/camera";
  75606. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75607. import "babylonjs/Shaders/tonemap.fragment";
  75608. import { Engine } from "babylonjs/Engines/engine";
  75609. /** Defines operator used for tonemapping */
  75610. export enum TonemappingOperator {
  75611. /** Hable */
  75612. Hable = 0,
  75613. /** Reinhard */
  75614. Reinhard = 1,
  75615. /** HejiDawson */
  75616. HejiDawson = 2,
  75617. /** Photographic */
  75618. Photographic = 3
  75619. }
  75620. /**
  75621. * Defines a post process to apply tone mapping
  75622. */
  75623. export class TonemapPostProcess extends PostProcess {
  75624. private _operator;
  75625. /** Defines the required exposure adjustement */
  75626. exposureAdjustment: number;
  75627. /**
  75628. * Gets a string identifying the name of the class
  75629. * @returns "TonemapPostProcess" string
  75630. */
  75631. getClassName(): string;
  75632. /**
  75633. * Creates a new TonemapPostProcess
  75634. * @param name defines the name of the postprocess
  75635. * @param _operator defines the operator to use
  75636. * @param exposureAdjustment defines the required exposure adjustement
  75637. * @param camera defines the camera to use (can be null)
  75638. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75639. * @param engine defines the hosting engine (can be ignore if camera is set)
  75640. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75641. */
  75642. constructor(name: string, _operator: TonemappingOperator,
  75643. /** Defines the required exposure adjustement */
  75644. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75645. }
  75646. }
  75647. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75648. /** @hidden */
  75649. export var volumetricLightScatteringPixelShader: {
  75650. name: string;
  75651. shader: string;
  75652. };
  75653. }
  75654. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75655. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75656. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75657. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75658. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75659. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75660. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75661. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75662. /** @hidden */
  75663. export var volumetricLightScatteringPassVertexShader: {
  75664. name: string;
  75665. shader: string;
  75666. };
  75667. }
  75668. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75669. /** @hidden */
  75670. export var volumetricLightScatteringPassPixelShader: {
  75671. name: string;
  75672. shader: string;
  75673. };
  75674. }
  75675. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75676. import { Vector3 } from "babylonjs/Maths/math.vector";
  75677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75678. import { Mesh } from "babylonjs/Meshes/mesh";
  75679. import { Camera } from "babylonjs/Cameras/camera";
  75680. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75681. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75682. import { Scene } from "babylonjs/scene";
  75683. import "babylonjs/Meshes/Builders/planeBuilder";
  75684. import "babylonjs/Shaders/depth.vertex";
  75685. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75686. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75687. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75688. import { Engine } from "babylonjs/Engines/engine";
  75689. /**
  75690. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75691. */
  75692. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75693. private _volumetricLightScatteringPass;
  75694. private _volumetricLightScatteringRTT;
  75695. private _viewPort;
  75696. private _screenCoordinates;
  75697. private _cachedDefines;
  75698. /**
  75699. * If not undefined, the mesh position is computed from the attached node position
  75700. */
  75701. attachedNode: {
  75702. position: Vector3;
  75703. };
  75704. /**
  75705. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75706. */
  75707. customMeshPosition: Vector3;
  75708. /**
  75709. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75710. */
  75711. useCustomMeshPosition: boolean;
  75712. /**
  75713. * If the post-process should inverse the light scattering direction
  75714. */
  75715. invert: boolean;
  75716. /**
  75717. * The internal mesh used by the post-process
  75718. */
  75719. mesh: Mesh;
  75720. /**
  75721. * @hidden
  75722. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75723. */
  75724. get useDiffuseColor(): boolean;
  75725. set useDiffuseColor(useDiffuseColor: boolean);
  75726. /**
  75727. * Array containing the excluded meshes not rendered in the internal pass
  75728. */
  75729. excludedMeshes: AbstractMesh[];
  75730. /**
  75731. * Controls the overall intensity of the post-process
  75732. */
  75733. exposure: number;
  75734. /**
  75735. * Dissipates each sample's contribution in range [0, 1]
  75736. */
  75737. decay: number;
  75738. /**
  75739. * Controls the overall intensity of each sample
  75740. */
  75741. weight: number;
  75742. /**
  75743. * Controls the density of each sample
  75744. */
  75745. density: number;
  75746. /**
  75747. * @constructor
  75748. * @param name The post-process name
  75749. * @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)
  75750. * @param camera The camera that the post-process will be attached to
  75751. * @param mesh The mesh used to create the light scattering
  75752. * @param samples The post-process quality, default 100
  75753. * @param samplingModeThe post-process filtering mode
  75754. * @param engine The babylon engine
  75755. * @param reusable If the post-process is reusable
  75756. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75757. */
  75758. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75759. /**
  75760. * Returns the string "VolumetricLightScatteringPostProcess"
  75761. * @returns "VolumetricLightScatteringPostProcess"
  75762. */
  75763. getClassName(): string;
  75764. private _isReady;
  75765. /**
  75766. * Sets the new light position for light scattering effect
  75767. * @param position The new custom light position
  75768. */
  75769. setCustomMeshPosition(position: Vector3): void;
  75770. /**
  75771. * Returns the light position for light scattering effect
  75772. * @return Vector3 The custom light position
  75773. */
  75774. getCustomMeshPosition(): Vector3;
  75775. /**
  75776. * Disposes the internal assets and detaches the post-process from the camera
  75777. */
  75778. dispose(camera: Camera): void;
  75779. /**
  75780. * Returns the render target texture used by the post-process
  75781. * @return the render target texture used by the post-process
  75782. */
  75783. getPass(): RenderTargetTexture;
  75784. private _meshExcluded;
  75785. private _createPass;
  75786. private _updateMeshScreenCoordinates;
  75787. /**
  75788. * Creates a default mesh for the Volumeric Light Scattering post-process
  75789. * @param name The mesh name
  75790. * @param scene The scene where to create the mesh
  75791. * @return the default mesh
  75792. */
  75793. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75794. }
  75795. }
  75796. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75797. /** @hidden */
  75798. export var screenSpaceCurvaturePixelShader: {
  75799. name: string;
  75800. shader: string;
  75801. };
  75802. }
  75803. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75804. import { Nullable } from "babylonjs/types";
  75805. import { Camera } from "babylonjs/Cameras/camera";
  75806. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75807. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75808. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75809. import { Engine } from "babylonjs/Engines/engine";
  75810. import { Scene } from "babylonjs/scene";
  75811. /**
  75812. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75813. */
  75814. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75815. /**
  75816. * Defines how much ridge the curvature effect displays.
  75817. */
  75818. ridge: number;
  75819. /**
  75820. * Defines how much valley the curvature effect displays.
  75821. */
  75822. valley: number;
  75823. private _geometryBufferRenderer;
  75824. /**
  75825. * Gets a string identifying the name of the class
  75826. * @returns "ScreenSpaceCurvaturePostProcess" string
  75827. */
  75828. getClassName(): string;
  75829. /**
  75830. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75831. * @param name The name of the effect.
  75832. * @param scene The scene containing the objects to blur according to their velocity.
  75833. * @param options The required width/height ratio to downsize to before computing the render pass.
  75834. * @param camera The camera to apply the render pass to.
  75835. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75836. * @param engine The engine which the post process will be applied. (default: current engine)
  75837. * @param reusable If the post process can be reused on the same frame. (default: false)
  75838. * @param textureType Type of textures used when performing the post process. (default: 0)
  75839. * @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)
  75840. */
  75841. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75842. /**
  75843. * Support test.
  75844. */
  75845. static get IsSupported(): boolean;
  75846. /** @hidden */
  75847. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75848. }
  75849. }
  75850. declare module "babylonjs/PostProcesses/index" {
  75851. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75852. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75853. export * from "babylonjs/PostProcesses/bloomEffect";
  75854. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75855. export * from "babylonjs/PostProcesses/blurPostProcess";
  75856. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75857. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75858. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75859. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75860. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75861. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75862. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75863. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75864. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75865. export * from "babylonjs/PostProcesses/filterPostProcess";
  75866. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75867. export * from "babylonjs/PostProcesses/grainPostProcess";
  75868. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75869. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75870. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75871. export * from "babylonjs/PostProcesses/passPostProcess";
  75872. export * from "babylonjs/PostProcesses/postProcess";
  75873. export * from "babylonjs/PostProcesses/postProcessManager";
  75874. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75875. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75876. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75877. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75878. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75879. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75880. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75881. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75882. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75883. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75884. }
  75885. declare module "babylonjs/Probes/index" {
  75886. export * from "babylonjs/Probes/reflectionProbe";
  75887. }
  75888. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75889. import { Scene } from "babylonjs/scene";
  75890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75891. import { SmartArray } from "babylonjs/Misc/smartArray";
  75892. import { ISceneComponent } from "babylonjs/sceneComponent";
  75893. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75894. import "babylonjs/Meshes/Builders/boxBuilder";
  75895. import "babylonjs/Shaders/color.fragment";
  75896. import "babylonjs/Shaders/color.vertex";
  75897. import { Color3 } from "babylonjs/Maths/math.color";
  75898. import { Observable } from "babylonjs/Misc/observable";
  75899. module "babylonjs/scene" {
  75900. interface Scene {
  75901. /** @hidden (Backing field) */
  75902. _boundingBoxRenderer: BoundingBoxRenderer;
  75903. /** @hidden (Backing field) */
  75904. _forceShowBoundingBoxes: boolean;
  75905. /**
  75906. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75907. */
  75908. forceShowBoundingBoxes: boolean;
  75909. /**
  75910. * Gets the bounding box renderer associated with the scene
  75911. * @returns a BoundingBoxRenderer
  75912. */
  75913. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75914. }
  75915. }
  75916. module "babylonjs/Meshes/abstractMesh" {
  75917. interface AbstractMesh {
  75918. /** @hidden (Backing field) */
  75919. _showBoundingBox: boolean;
  75920. /**
  75921. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75922. */
  75923. showBoundingBox: boolean;
  75924. }
  75925. }
  75926. /**
  75927. * Component responsible of rendering the bounding box of the meshes in a scene.
  75928. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75929. */
  75930. export class BoundingBoxRenderer implements ISceneComponent {
  75931. /**
  75932. * The component name helpfull to identify the component in the list of scene components.
  75933. */
  75934. readonly name: string;
  75935. /**
  75936. * The scene the component belongs to.
  75937. */
  75938. scene: Scene;
  75939. /**
  75940. * Color of the bounding box lines placed in front of an object
  75941. */
  75942. frontColor: Color3;
  75943. /**
  75944. * Color of the bounding box lines placed behind an object
  75945. */
  75946. backColor: Color3;
  75947. /**
  75948. * Defines if the renderer should show the back lines or not
  75949. */
  75950. showBackLines: boolean;
  75951. /**
  75952. * Observable raised before rendering a bounding box
  75953. */
  75954. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75955. /**
  75956. * Observable raised after rendering a bounding box
  75957. */
  75958. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75959. /**
  75960. * @hidden
  75961. */
  75962. renderList: SmartArray<BoundingBox>;
  75963. private _colorShader;
  75964. private _vertexBuffers;
  75965. private _indexBuffer;
  75966. private _fillIndexBuffer;
  75967. private _fillIndexData;
  75968. /**
  75969. * Instantiates a new bounding box renderer in a scene.
  75970. * @param scene the scene the renderer renders in
  75971. */
  75972. constructor(scene: Scene);
  75973. /**
  75974. * Registers the component in a given scene
  75975. */
  75976. register(): void;
  75977. private _evaluateSubMesh;
  75978. private _activeMesh;
  75979. private _prepareRessources;
  75980. private _createIndexBuffer;
  75981. /**
  75982. * Rebuilds the elements related to this component in case of
  75983. * context lost for instance.
  75984. */
  75985. rebuild(): void;
  75986. /**
  75987. * @hidden
  75988. */
  75989. reset(): void;
  75990. /**
  75991. * Render the bounding boxes of a specific rendering group
  75992. * @param renderingGroupId defines the rendering group to render
  75993. */
  75994. render(renderingGroupId: number): void;
  75995. /**
  75996. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75997. * @param mesh Define the mesh to render the occlusion bounding box for
  75998. */
  75999. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76000. /**
  76001. * Dispose and release the resources attached to this renderer.
  76002. */
  76003. dispose(): void;
  76004. }
  76005. }
  76006. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76007. import { Nullable } from "babylonjs/types";
  76008. import { Scene } from "babylonjs/scene";
  76009. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76010. import { Camera } from "babylonjs/Cameras/camera";
  76011. import { ISceneComponent } from "babylonjs/sceneComponent";
  76012. module "babylonjs/scene" {
  76013. interface Scene {
  76014. /** @hidden (Backing field) */
  76015. _depthRenderer: {
  76016. [id: string]: DepthRenderer;
  76017. };
  76018. /**
  76019. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76020. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76021. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76022. * @returns the created depth renderer
  76023. */
  76024. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  76025. /**
  76026. * Disables a depth renderer for a given camera
  76027. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76028. */
  76029. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76030. }
  76031. }
  76032. /**
  76033. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76034. * in several rendering techniques.
  76035. */
  76036. export class DepthRendererSceneComponent implements ISceneComponent {
  76037. /**
  76038. * The component name helpfull to identify the component in the list of scene components.
  76039. */
  76040. readonly name: string;
  76041. /**
  76042. * The scene the component belongs to.
  76043. */
  76044. scene: Scene;
  76045. /**
  76046. * Creates a new instance of the component for the given scene
  76047. * @param scene Defines the scene to register the component in
  76048. */
  76049. constructor(scene: Scene);
  76050. /**
  76051. * Registers the component in a given scene
  76052. */
  76053. register(): void;
  76054. /**
  76055. * Rebuilds the elements related to this component in case of
  76056. * context lost for instance.
  76057. */
  76058. rebuild(): void;
  76059. /**
  76060. * Disposes the component and the associated ressources
  76061. */
  76062. dispose(): void;
  76063. private _gatherRenderTargets;
  76064. private _gatherActiveCameraRenderTargets;
  76065. }
  76066. }
  76067. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76068. import { Nullable } from "babylonjs/types";
  76069. import { Scene } from "babylonjs/scene";
  76070. import { ISceneComponent } from "babylonjs/sceneComponent";
  76071. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76072. module "babylonjs/abstractScene" {
  76073. interface AbstractScene {
  76074. /** @hidden (Backing field) */
  76075. _prePassRenderer: Nullable<PrePassRenderer>;
  76076. /**
  76077. * Gets or Sets the current prepass renderer associated to the scene.
  76078. */
  76079. prePassRenderer: Nullable<PrePassRenderer>;
  76080. /**
  76081. * Enables the prepass and associates it with the scene
  76082. * @returns the PrePassRenderer
  76083. */
  76084. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76085. /**
  76086. * Disables the prepass associated with the scene
  76087. */
  76088. disablePrePassRenderer(): void;
  76089. }
  76090. }
  76091. /**
  76092. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76093. * in several rendering techniques.
  76094. */
  76095. export class PrePassRendererSceneComponent implements ISceneComponent {
  76096. /**
  76097. * The component name helpful to identify the component in the list of scene components.
  76098. */
  76099. readonly name: string;
  76100. /**
  76101. * The scene the component belongs to.
  76102. */
  76103. scene: Scene;
  76104. /**
  76105. * Creates a new instance of the component for the given scene
  76106. * @param scene Defines the scene to register the component in
  76107. */
  76108. constructor(scene: Scene);
  76109. /**
  76110. * Registers the component in a given scene
  76111. */
  76112. register(): void;
  76113. private _beforeCameraDraw;
  76114. private _afterCameraDraw;
  76115. private _beforeClearStage;
  76116. /**
  76117. * Rebuilds the elements related to this component in case of
  76118. * context lost for instance.
  76119. */
  76120. rebuild(): void;
  76121. /**
  76122. * Disposes the component and the associated ressources
  76123. */
  76124. dispose(): void;
  76125. }
  76126. }
  76127. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76128. /** @hidden */
  76129. export var fibonacci: {
  76130. name: string;
  76131. shader: string;
  76132. };
  76133. }
  76134. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76135. /** @hidden */
  76136. export var diffusionProfile: {
  76137. name: string;
  76138. shader: string;
  76139. };
  76140. }
  76141. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76142. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76143. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76144. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76145. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76146. /** @hidden */
  76147. export var subSurfaceScatteringPixelShader: {
  76148. name: string;
  76149. shader: string;
  76150. };
  76151. }
  76152. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76153. import { Nullable } from "babylonjs/types";
  76154. import { Camera } from "babylonjs/Cameras/camera";
  76155. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76156. import { Engine } from "babylonjs/Engines/engine";
  76157. import { Scene } from "babylonjs/scene";
  76158. import "babylonjs/Shaders/imageProcessing.fragment";
  76159. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76160. import "babylonjs/Shaders/postprocess.vertex";
  76161. /**
  76162. * Sub surface scattering post process
  76163. */
  76164. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76165. /**
  76166. * Gets a string identifying the name of the class
  76167. * @returns "SubSurfaceScatteringPostProcess" string
  76168. */
  76169. getClassName(): string;
  76170. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76171. }
  76172. }
  76173. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76174. import { Scene } from "babylonjs/scene";
  76175. import { Color3 } from "babylonjs/Maths/math.color";
  76176. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76177. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76178. /**
  76179. * Contains all parameters needed for the prepass to perform
  76180. * screen space subsurface scattering
  76181. */
  76182. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76183. /** @hidden */
  76184. static _SceneComponentInitialization: (scene: Scene) => void;
  76185. private _ssDiffusionS;
  76186. private _ssFilterRadii;
  76187. private _ssDiffusionD;
  76188. /**
  76189. * Post process to attach for screen space subsurface scattering
  76190. */
  76191. postProcess: SubSurfaceScatteringPostProcess;
  76192. /**
  76193. * Diffusion profile color for subsurface scattering
  76194. */
  76195. get ssDiffusionS(): number[];
  76196. /**
  76197. * Diffusion profile max color channel value for subsurface scattering
  76198. */
  76199. get ssDiffusionD(): number[];
  76200. /**
  76201. * Diffusion profile filter radius for subsurface scattering
  76202. */
  76203. get ssFilterRadii(): number[];
  76204. /**
  76205. * Is subsurface enabled
  76206. */
  76207. enabled: boolean;
  76208. /**
  76209. * Name of the configuration
  76210. */
  76211. name: string;
  76212. /**
  76213. * Diffusion profile colors for subsurface scattering
  76214. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76215. * See ...
  76216. * Note that you can only store up to 5 of them
  76217. */
  76218. ssDiffusionProfileColors: Color3[];
  76219. /**
  76220. * Defines the ratio real world => scene units.
  76221. * Used for subsurface scattering
  76222. */
  76223. metersPerUnit: number;
  76224. /**
  76225. * Textures that should be present in the MRT for this effect to work
  76226. */
  76227. readonly texturesRequired: number[];
  76228. private _scene;
  76229. /**
  76230. * Builds a subsurface configuration object
  76231. * @param scene The scene
  76232. */
  76233. constructor(scene: Scene);
  76234. /**
  76235. * Adds a new diffusion profile.
  76236. * Useful for more realistic subsurface scattering on diverse materials.
  76237. * @param color The color of the diffusion profile. Should be the average color of the material.
  76238. * @return The index of the diffusion profile for the material subsurface configuration
  76239. */
  76240. addDiffusionProfile(color: Color3): number;
  76241. /**
  76242. * Creates the sss post process
  76243. * @return The created post process
  76244. */
  76245. createPostProcess(): SubSurfaceScatteringPostProcess;
  76246. /**
  76247. * Deletes all diffusion profiles.
  76248. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76249. */
  76250. clearAllDiffusionProfiles(): void;
  76251. /**
  76252. * Disposes this object
  76253. */
  76254. dispose(): void;
  76255. /**
  76256. * @hidden
  76257. * https://zero-radiance.github.io/post/sampling-diffusion/
  76258. *
  76259. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76260. * ------------------------------------------------------------------------------------
  76261. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76262. * PDF[r, phi, s] = r * R[r, phi, s]
  76263. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76264. * ------------------------------------------------------------------------------------
  76265. * We importance sample the color channel with the widest scattering distance.
  76266. */
  76267. getDiffusionProfileParameters(color: Color3): number;
  76268. /**
  76269. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76270. * 'u' is the random number (the value of the CDF): [0, 1).
  76271. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76272. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76273. */
  76274. private _sampleBurleyDiffusionProfile;
  76275. }
  76276. }
  76277. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76278. import { Nullable } from "babylonjs/types";
  76279. import { Scene } from "babylonjs/scene";
  76280. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76281. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76282. import { AbstractScene } from "babylonjs/abstractScene";
  76283. module "babylonjs/abstractScene" {
  76284. interface AbstractScene {
  76285. /** @hidden (Backing field) */
  76286. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76287. /**
  76288. * Gets or Sets the current prepass renderer associated to the scene.
  76289. */
  76290. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76291. /**
  76292. * Enables the subsurface effect for prepass
  76293. * @returns the SubSurfaceConfiguration
  76294. */
  76295. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76296. /**
  76297. * Disables the subsurface effect for prepass
  76298. */
  76299. disableSubSurfaceForPrePass(): void;
  76300. }
  76301. }
  76302. /**
  76303. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76304. * in several rendering techniques.
  76305. */
  76306. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76307. /**
  76308. * The component name helpful to identify the component in the list of scene components.
  76309. */
  76310. readonly name: string;
  76311. /**
  76312. * The scene the component belongs to.
  76313. */
  76314. scene: Scene;
  76315. /**
  76316. * Creates a new instance of the component for the given scene
  76317. * @param scene Defines the scene to register the component in
  76318. */
  76319. constructor(scene: Scene);
  76320. /**
  76321. * Registers the component in a given scene
  76322. */
  76323. register(): void;
  76324. /**
  76325. * Serializes the component data to the specified json object
  76326. * @param serializationObject The object to serialize to
  76327. */
  76328. serialize(serializationObject: any): void;
  76329. /**
  76330. * Adds all the elements from the container to the scene
  76331. * @param container the container holding the elements
  76332. */
  76333. addFromContainer(container: AbstractScene): void;
  76334. /**
  76335. * Removes all the elements in the container from the scene
  76336. * @param container contains the elements to remove
  76337. * @param dispose if the removed element should be disposed (default: false)
  76338. */
  76339. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76340. /**
  76341. * Rebuilds the elements related to this component in case of
  76342. * context lost for instance.
  76343. */
  76344. rebuild(): void;
  76345. /**
  76346. * Disposes the component and the associated ressources
  76347. */
  76348. dispose(): void;
  76349. }
  76350. }
  76351. declare module "babylonjs/Shaders/outline.fragment" {
  76352. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76353. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76354. /** @hidden */
  76355. export var outlinePixelShader: {
  76356. name: string;
  76357. shader: string;
  76358. };
  76359. }
  76360. declare module "babylonjs/Shaders/outline.vertex" {
  76361. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76362. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76363. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76364. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76365. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76366. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76367. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76368. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76369. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76370. /** @hidden */
  76371. export var outlineVertexShader: {
  76372. name: string;
  76373. shader: string;
  76374. };
  76375. }
  76376. declare module "babylonjs/Rendering/outlineRenderer" {
  76377. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76378. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76379. import { Scene } from "babylonjs/scene";
  76380. import { ISceneComponent } from "babylonjs/sceneComponent";
  76381. import "babylonjs/Shaders/outline.fragment";
  76382. import "babylonjs/Shaders/outline.vertex";
  76383. module "babylonjs/scene" {
  76384. interface Scene {
  76385. /** @hidden */
  76386. _outlineRenderer: OutlineRenderer;
  76387. /**
  76388. * Gets the outline renderer associated with the scene
  76389. * @returns a OutlineRenderer
  76390. */
  76391. getOutlineRenderer(): OutlineRenderer;
  76392. }
  76393. }
  76394. module "babylonjs/Meshes/abstractMesh" {
  76395. interface AbstractMesh {
  76396. /** @hidden (Backing field) */
  76397. _renderOutline: boolean;
  76398. /**
  76399. * Gets or sets a boolean indicating if the outline must be rendered as well
  76400. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76401. */
  76402. renderOutline: boolean;
  76403. /** @hidden (Backing field) */
  76404. _renderOverlay: boolean;
  76405. /**
  76406. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76407. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76408. */
  76409. renderOverlay: boolean;
  76410. }
  76411. }
  76412. /**
  76413. * This class is responsible to draw bothe outline/overlay of meshes.
  76414. * It should not be used directly but through the available method on mesh.
  76415. */
  76416. export class OutlineRenderer implements ISceneComponent {
  76417. /**
  76418. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76419. */
  76420. private static _StencilReference;
  76421. /**
  76422. * The name of the component. Each component must have a unique name.
  76423. */
  76424. name: string;
  76425. /**
  76426. * The scene the component belongs to.
  76427. */
  76428. scene: Scene;
  76429. /**
  76430. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76431. */
  76432. zOffset: number;
  76433. private _engine;
  76434. private _effect;
  76435. private _cachedDefines;
  76436. private _savedDepthWrite;
  76437. /**
  76438. * Instantiates a new outline renderer. (There could be only one per scene).
  76439. * @param scene Defines the scene it belongs to
  76440. */
  76441. constructor(scene: Scene);
  76442. /**
  76443. * Register the component to one instance of a scene.
  76444. */
  76445. register(): void;
  76446. /**
  76447. * Rebuilds the elements related to this component in case of
  76448. * context lost for instance.
  76449. */
  76450. rebuild(): void;
  76451. /**
  76452. * Disposes the component and the associated ressources.
  76453. */
  76454. dispose(): void;
  76455. /**
  76456. * Renders the outline in the canvas.
  76457. * @param subMesh Defines the sumesh to render
  76458. * @param batch Defines the batch of meshes in case of instances
  76459. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76460. */
  76461. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76462. /**
  76463. * Returns whether or not the outline renderer is ready for a given submesh.
  76464. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76465. * @param subMesh Defines the submesh to check readyness for
  76466. * @param useInstances Defines wheter wee are trying to render instances or not
  76467. * @returns true if ready otherwise false
  76468. */
  76469. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76470. private _beforeRenderingMesh;
  76471. private _afterRenderingMesh;
  76472. }
  76473. }
  76474. declare module "babylonjs/Rendering/index" {
  76475. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76476. export * from "babylonjs/Rendering/depthRenderer";
  76477. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76478. export * from "babylonjs/Rendering/edgesRenderer";
  76479. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76480. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76481. export * from "babylonjs/Rendering/prePassRenderer";
  76482. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76483. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76484. export * from "babylonjs/Rendering/outlineRenderer";
  76485. export * from "babylonjs/Rendering/renderingGroup";
  76486. export * from "babylonjs/Rendering/renderingManager";
  76487. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76488. }
  76489. declare module "babylonjs/Sprites/ISprites" {
  76490. /**
  76491. * Defines the basic options interface of a Sprite Frame Source Size.
  76492. */
  76493. export interface ISpriteJSONSpriteSourceSize {
  76494. /**
  76495. * number of the original width of the Frame
  76496. */
  76497. w: number;
  76498. /**
  76499. * number of the original height of the Frame
  76500. */
  76501. h: number;
  76502. }
  76503. /**
  76504. * Defines the basic options interface of a Sprite Frame Data.
  76505. */
  76506. export interface ISpriteJSONSpriteFrameData {
  76507. /**
  76508. * number of the x offset of the Frame
  76509. */
  76510. x: number;
  76511. /**
  76512. * number of the y offset of the Frame
  76513. */
  76514. y: number;
  76515. /**
  76516. * number of the width of the Frame
  76517. */
  76518. w: number;
  76519. /**
  76520. * number of the height of the Frame
  76521. */
  76522. h: number;
  76523. }
  76524. /**
  76525. * Defines the basic options interface of a JSON Sprite.
  76526. */
  76527. export interface ISpriteJSONSprite {
  76528. /**
  76529. * string name of the Frame
  76530. */
  76531. filename: string;
  76532. /**
  76533. * ISpriteJSONSpriteFrame basic object of the frame data
  76534. */
  76535. frame: ISpriteJSONSpriteFrameData;
  76536. /**
  76537. * boolean to flag is the frame was rotated.
  76538. */
  76539. rotated: boolean;
  76540. /**
  76541. * boolean to flag is the frame was trimmed.
  76542. */
  76543. trimmed: boolean;
  76544. /**
  76545. * ISpriteJSONSpriteFrame basic object of the source data
  76546. */
  76547. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76548. /**
  76549. * ISpriteJSONSpriteFrame basic object of the source data
  76550. */
  76551. sourceSize: ISpriteJSONSpriteSourceSize;
  76552. }
  76553. /**
  76554. * Defines the basic options interface of a JSON atlas.
  76555. */
  76556. export interface ISpriteJSONAtlas {
  76557. /**
  76558. * Array of objects that contain the frame data.
  76559. */
  76560. frames: Array<ISpriteJSONSprite>;
  76561. /**
  76562. * object basic object containing the sprite meta data.
  76563. */
  76564. meta?: object;
  76565. }
  76566. }
  76567. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76568. /** @hidden */
  76569. export var spriteMapPixelShader: {
  76570. name: string;
  76571. shader: string;
  76572. };
  76573. }
  76574. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76575. /** @hidden */
  76576. export var spriteMapVertexShader: {
  76577. name: string;
  76578. shader: string;
  76579. };
  76580. }
  76581. declare module "babylonjs/Sprites/spriteMap" {
  76582. import { IDisposable, Scene } from "babylonjs/scene";
  76583. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76584. import { Texture } from "babylonjs/Materials/Textures/texture";
  76585. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76586. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76587. import "babylonjs/Meshes/Builders/planeBuilder";
  76588. import "babylonjs/Shaders/spriteMap.fragment";
  76589. import "babylonjs/Shaders/spriteMap.vertex";
  76590. /**
  76591. * Defines the basic options interface of a SpriteMap
  76592. */
  76593. export interface ISpriteMapOptions {
  76594. /**
  76595. * Vector2 of the number of cells in the grid.
  76596. */
  76597. stageSize?: Vector2;
  76598. /**
  76599. * Vector2 of the size of the output plane in World Units.
  76600. */
  76601. outputSize?: Vector2;
  76602. /**
  76603. * Vector3 of the position of the output plane in World Units.
  76604. */
  76605. outputPosition?: Vector3;
  76606. /**
  76607. * Vector3 of the rotation of the output plane.
  76608. */
  76609. outputRotation?: Vector3;
  76610. /**
  76611. * number of layers that the system will reserve in resources.
  76612. */
  76613. layerCount?: number;
  76614. /**
  76615. * number of max animation frames a single cell will reserve in resources.
  76616. */
  76617. maxAnimationFrames?: number;
  76618. /**
  76619. * number cell index of the base tile when the system compiles.
  76620. */
  76621. baseTile?: number;
  76622. /**
  76623. * boolean flip the sprite after its been repositioned by the framing data.
  76624. */
  76625. flipU?: boolean;
  76626. /**
  76627. * Vector3 scalar of the global RGB values of the SpriteMap.
  76628. */
  76629. colorMultiply?: Vector3;
  76630. }
  76631. /**
  76632. * Defines the IDisposable interface in order to be cleanable from resources.
  76633. */
  76634. export interface ISpriteMap extends IDisposable {
  76635. /**
  76636. * String name of the SpriteMap.
  76637. */
  76638. name: string;
  76639. /**
  76640. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76641. */
  76642. atlasJSON: ISpriteJSONAtlas;
  76643. /**
  76644. * Texture of the SpriteMap.
  76645. */
  76646. spriteSheet: Texture;
  76647. /**
  76648. * The parameters to initialize the SpriteMap with.
  76649. */
  76650. options: ISpriteMapOptions;
  76651. }
  76652. /**
  76653. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76654. */
  76655. export class SpriteMap implements ISpriteMap {
  76656. /** The Name of the spriteMap */
  76657. name: string;
  76658. /** The JSON file with the frame and meta data */
  76659. atlasJSON: ISpriteJSONAtlas;
  76660. /** The systems Sprite Sheet Texture */
  76661. spriteSheet: Texture;
  76662. /** Arguments passed with the Constructor */
  76663. options: ISpriteMapOptions;
  76664. /** Public Sprite Storage array, parsed from atlasJSON */
  76665. sprites: Array<ISpriteJSONSprite>;
  76666. /** Returns the Number of Sprites in the System */
  76667. get spriteCount(): number;
  76668. /** Returns the Position of Output Plane*/
  76669. get position(): Vector3;
  76670. /** Returns the Position of Output Plane*/
  76671. set position(v: Vector3);
  76672. /** Returns the Rotation of Output Plane*/
  76673. get rotation(): Vector3;
  76674. /** Returns the Rotation of Output Plane*/
  76675. set rotation(v: Vector3);
  76676. /** Sets the AnimationMap*/
  76677. get animationMap(): RawTexture;
  76678. /** Sets the AnimationMap*/
  76679. set animationMap(v: RawTexture);
  76680. /** Scene that the SpriteMap was created in */
  76681. private _scene;
  76682. /** Texture Buffer of Float32 that holds tile frame data*/
  76683. private _frameMap;
  76684. /** Texture Buffers of Float32 that holds tileMap data*/
  76685. private _tileMaps;
  76686. /** Texture Buffer of Float32 that holds Animation Data*/
  76687. private _animationMap;
  76688. /** Custom ShaderMaterial Central to the System*/
  76689. private _material;
  76690. /** Custom ShaderMaterial Central to the System*/
  76691. private _output;
  76692. /** Systems Time Ticker*/
  76693. private _time;
  76694. /**
  76695. * Creates a new SpriteMap
  76696. * @param name defines the SpriteMaps Name
  76697. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76698. * @param spriteSheet is the Texture that the Sprites are on.
  76699. * @param options a basic deployment configuration
  76700. * @param scene The Scene that the map is deployed on
  76701. */
  76702. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76703. /**
  76704. * Returns tileID location
  76705. * @returns Vector2 the cell position ID
  76706. */
  76707. getTileID(): Vector2;
  76708. /**
  76709. * Gets the UV location of the mouse over the SpriteMap.
  76710. * @returns Vector2 the UV position of the mouse interaction
  76711. */
  76712. getMousePosition(): Vector2;
  76713. /**
  76714. * Creates the "frame" texture Buffer
  76715. * -------------------------------------
  76716. * Structure of frames
  76717. * "filename": "Falling-Water-2.png",
  76718. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76719. * "rotated": true,
  76720. * "trimmed": true,
  76721. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76722. * "sourceSize": {"w":32,"h":32}
  76723. * @returns RawTexture of the frameMap
  76724. */
  76725. private _createFrameBuffer;
  76726. /**
  76727. * Creates the tileMap texture Buffer
  76728. * @param buffer normally and array of numbers, or a false to generate from scratch
  76729. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76730. * @returns RawTexture of the tileMap
  76731. */
  76732. private _createTileBuffer;
  76733. /**
  76734. * Modifies the data of the tileMaps
  76735. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76736. * @param pos is the iVector2 Coordinates of the Tile
  76737. * @param tile The SpriteIndex of the new Tile
  76738. */
  76739. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76740. /**
  76741. * Creates the animationMap texture Buffer
  76742. * @param buffer normally and array of numbers, or a false to generate from scratch
  76743. * @returns RawTexture of the animationMap
  76744. */
  76745. private _createTileAnimationBuffer;
  76746. /**
  76747. * Modifies the data of the animationMap
  76748. * @param cellID is the Index of the Sprite
  76749. * @param _frame is the target Animation frame
  76750. * @param toCell is the Target Index of the next frame of the animation
  76751. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76752. * @param speed is a global scalar of the time variable on the map.
  76753. */
  76754. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76755. /**
  76756. * Exports the .tilemaps file
  76757. */
  76758. saveTileMaps(): void;
  76759. /**
  76760. * Imports the .tilemaps file
  76761. * @param url of the .tilemaps file
  76762. */
  76763. loadTileMaps(url: string): void;
  76764. /**
  76765. * Release associated resources
  76766. */
  76767. dispose(): void;
  76768. }
  76769. }
  76770. declare module "babylonjs/Sprites/spritePackedManager" {
  76771. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76772. import { Scene } from "babylonjs/scene";
  76773. /**
  76774. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76775. * @see https://doc.babylonjs.com/babylon101/sprites
  76776. */
  76777. export class SpritePackedManager extends SpriteManager {
  76778. /** defines the packed manager's name */
  76779. name: string;
  76780. /**
  76781. * Creates a new sprite manager from a packed sprite sheet
  76782. * @param name defines the manager's name
  76783. * @param imgUrl defines the sprite sheet url
  76784. * @param capacity defines the maximum allowed number of sprites
  76785. * @param scene defines the hosting scene
  76786. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76787. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76788. * @param samplingMode defines the smapling mode to use with spritesheet
  76789. * @param fromPacked set to true; do not alter
  76790. */
  76791. constructor(
  76792. /** defines the packed manager's name */
  76793. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76794. }
  76795. }
  76796. declare module "babylonjs/Sprites/index" {
  76797. export * from "babylonjs/Sprites/sprite";
  76798. export * from "babylonjs/Sprites/ISprites";
  76799. export * from "babylonjs/Sprites/spriteManager";
  76800. export * from "babylonjs/Sprites/spriteMap";
  76801. export * from "babylonjs/Sprites/spritePackedManager";
  76802. export * from "babylonjs/Sprites/spriteSceneComponent";
  76803. }
  76804. declare module "babylonjs/States/index" {
  76805. export * from "babylonjs/States/alphaCullingState";
  76806. export * from "babylonjs/States/depthCullingState";
  76807. export * from "babylonjs/States/stencilState";
  76808. }
  76809. declare module "babylonjs/Misc/assetsManager" {
  76810. import { Scene } from "babylonjs/scene";
  76811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76812. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76813. import { Skeleton } from "babylonjs/Bones/skeleton";
  76814. import { Observable } from "babylonjs/Misc/observable";
  76815. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76816. import { Texture } from "babylonjs/Materials/Textures/texture";
  76817. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76818. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76819. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76820. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76821. import { AssetContainer } from "babylonjs/assetContainer";
  76822. /**
  76823. * Defines the list of states available for a task inside a AssetsManager
  76824. */
  76825. export enum AssetTaskState {
  76826. /**
  76827. * Initialization
  76828. */
  76829. INIT = 0,
  76830. /**
  76831. * Running
  76832. */
  76833. RUNNING = 1,
  76834. /**
  76835. * Done
  76836. */
  76837. DONE = 2,
  76838. /**
  76839. * Error
  76840. */
  76841. ERROR = 3
  76842. }
  76843. /**
  76844. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76845. */
  76846. export abstract class AbstractAssetTask {
  76847. /**
  76848. * Task name
  76849. */ name: string;
  76850. /**
  76851. * Callback called when the task is successful
  76852. */
  76853. onSuccess: (task: any) => void;
  76854. /**
  76855. * Callback called when the task is not successful
  76856. */
  76857. onError: (task: any, message?: string, exception?: any) => void;
  76858. /**
  76859. * Creates a new AssetsManager
  76860. * @param name defines the name of the task
  76861. */
  76862. constructor(
  76863. /**
  76864. * Task name
  76865. */ name: string);
  76866. private _isCompleted;
  76867. private _taskState;
  76868. private _errorObject;
  76869. /**
  76870. * Get if the task is completed
  76871. */
  76872. get isCompleted(): boolean;
  76873. /**
  76874. * Gets the current state of the task
  76875. */
  76876. get taskState(): AssetTaskState;
  76877. /**
  76878. * Gets the current error object (if task is in error)
  76879. */
  76880. get errorObject(): {
  76881. message?: string;
  76882. exception?: any;
  76883. };
  76884. /**
  76885. * Internal only
  76886. * @hidden
  76887. */
  76888. _setErrorObject(message?: string, exception?: any): void;
  76889. /**
  76890. * Execute the current task
  76891. * @param scene defines the scene where you want your assets to be loaded
  76892. * @param onSuccess is a callback called when the task is successfully executed
  76893. * @param onError is a callback called if an error occurs
  76894. */
  76895. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76896. /**
  76897. * Execute the current task
  76898. * @param scene defines the scene where you want your assets to be loaded
  76899. * @param onSuccess is a callback called when the task is successfully executed
  76900. * @param onError is a callback called if an error occurs
  76901. */
  76902. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76903. /**
  76904. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76905. * This can be used with failed tasks that have the reason for failure fixed.
  76906. */
  76907. reset(): void;
  76908. private onErrorCallback;
  76909. private onDoneCallback;
  76910. }
  76911. /**
  76912. * Define the interface used by progress events raised during assets loading
  76913. */
  76914. export interface IAssetsProgressEvent {
  76915. /**
  76916. * Defines the number of remaining tasks to process
  76917. */
  76918. remainingCount: number;
  76919. /**
  76920. * Defines the total number of tasks
  76921. */
  76922. totalCount: number;
  76923. /**
  76924. * Defines the task that was just processed
  76925. */
  76926. task: AbstractAssetTask;
  76927. }
  76928. /**
  76929. * Class used to share progress information about assets loading
  76930. */
  76931. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76932. /**
  76933. * Defines the number of remaining tasks to process
  76934. */
  76935. remainingCount: number;
  76936. /**
  76937. * Defines the total number of tasks
  76938. */
  76939. totalCount: number;
  76940. /**
  76941. * Defines the task that was just processed
  76942. */
  76943. task: AbstractAssetTask;
  76944. /**
  76945. * Creates a AssetsProgressEvent
  76946. * @param remainingCount defines the number of remaining tasks to process
  76947. * @param totalCount defines the total number of tasks
  76948. * @param task defines the task that was just processed
  76949. */
  76950. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76951. }
  76952. /**
  76953. * Define a task used by AssetsManager to load assets into a container
  76954. */
  76955. export class ContainerAssetTask extends AbstractAssetTask {
  76956. /**
  76957. * Defines the name of the task
  76958. */
  76959. name: string;
  76960. /**
  76961. * Defines the list of mesh's names you want to load
  76962. */
  76963. meshesNames: any;
  76964. /**
  76965. * Defines the root url to use as a base to load your meshes and associated resources
  76966. */
  76967. rootUrl: string;
  76968. /**
  76969. * Defines the filename or File of the scene to load from
  76970. */
  76971. sceneFilename: string | File;
  76972. /**
  76973. * Get the loaded asset container
  76974. */
  76975. loadedContainer: AssetContainer;
  76976. /**
  76977. * Gets the list of loaded meshes
  76978. */
  76979. loadedMeshes: Array<AbstractMesh>;
  76980. /**
  76981. * Gets the list of loaded particle systems
  76982. */
  76983. loadedParticleSystems: Array<IParticleSystem>;
  76984. /**
  76985. * Gets the list of loaded skeletons
  76986. */
  76987. loadedSkeletons: Array<Skeleton>;
  76988. /**
  76989. * Gets the list of loaded animation groups
  76990. */
  76991. loadedAnimationGroups: Array<AnimationGroup>;
  76992. /**
  76993. * Callback called when the task is successful
  76994. */
  76995. onSuccess: (task: ContainerAssetTask) => void;
  76996. /**
  76997. * Callback called when the task is successful
  76998. */
  76999. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77000. /**
  77001. * Creates a new ContainerAssetTask
  77002. * @param name defines the name of the task
  77003. * @param meshesNames defines the list of mesh's names you want to load
  77004. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77005. * @param sceneFilename defines the filename or File of the scene to load from
  77006. */
  77007. constructor(
  77008. /**
  77009. * Defines the name of the task
  77010. */
  77011. name: string,
  77012. /**
  77013. * Defines the list of mesh's names you want to load
  77014. */
  77015. meshesNames: any,
  77016. /**
  77017. * Defines the root url to use as a base to load your meshes and associated resources
  77018. */
  77019. rootUrl: string,
  77020. /**
  77021. * Defines the filename or File of the scene to load from
  77022. */
  77023. sceneFilename: string | File);
  77024. /**
  77025. * Execute the current task
  77026. * @param scene defines the scene where you want your assets to be loaded
  77027. * @param onSuccess is a callback called when the task is successfully executed
  77028. * @param onError is a callback called if an error occurs
  77029. */
  77030. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77031. }
  77032. /**
  77033. * Define a task used by AssetsManager to load meshes
  77034. */
  77035. export class MeshAssetTask extends AbstractAssetTask {
  77036. /**
  77037. * Defines the name of the task
  77038. */
  77039. name: string;
  77040. /**
  77041. * Defines the list of mesh's names you want to load
  77042. */
  77043. meshesNames: any;
  77044. /**
  77045. * Defines the root url to use as a base to load your meshes and associated resources
  77046. */
  77047. rootUrl: string;
  77048. /**
  77049. * Defines the filename or File of the scene to load from
  77050. */
  77051. sceneFilename: string | File;
  77052. /**
  77053. * Gets the list of loaded meshes
  77054. */
  77055. loadedMeshes: Array<AbstractMesh>;
  77056. /**
  77057. * Gets the list of loaded particle systems
  77058. */
  77059. loadedParticleSystems: Array<IParticleSystem>;
  77060. /**
  77061. * Gets the list of loaded skeletons
  77062. */
  77063. loadedSkeletons: Array<Skeleton>;
  77064. /**
  77065. * Gets the list of loaded animation groups
  77066. */
  77067. loadedAnimationGroups: Array<AnimationGroup>;
  77068. /**
  77069. * Callback called when the task is successful
  77070. */
  77071. onSuccess: (task: MeshAssetTask) => void;
  77072. /**
  77073. * Callback called when the task is successful
  77074. */
  77075. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77076. /**
  77077. * Creates a new MeshAssetTask
  77078. * @param name defines the name of the task
  77079. * @param meshesNames defines the list of mesh's names you want to load
  77080. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77081. * @param sceneFilename defines the filename or File of the scene to load from
  77082. */
  77083. constructor(
  77084. /**
  77085. * Defines the name of the task
  77086. */
  77087. name: string,
  77088. /**
  77089. * Defines the list of mesh's names you want to load
  77090. */
  77091. meshesNames: any,
  77092. /**
  77093. * Defines the root url to use as a base to load your meshes and associated resources
  77094. */
  77095. rootUrl: string,
  77096. /**
  77097. * Defines the filename or File of the scene to load from
  77098. */
  77099. sceneFilename: string | File);
  77100. /**
  77101. * Execute the current task
  77102. * @param scene defines the scene where you want your assets to be loaded
  77103. * @param onSuccess is a callback called when the task is successfully executed
  77104. * @param onError is a callback called if an error occurs
  77105. */
  77106. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77107. }
  77108. /**
  77109. * Define a task used by AssetsManager to load text content
  77110. */
  77111. export class TextFileAssetTask extends AbstractAssetTask {
  77112. /**
  77113. * Defines the name of the task
  77114. */
  77115. name: string;
  77116. /**
  77117. * Defines the location of the file to load
  77118. */
  77119. url: string;
  77120. /**
  77121. * Gets the loaded text string
  77122. */
  77123. text: string;
  77124. /**
  77125. * Callback called when the task is successful
  77126. */
  77127. onSuccess: (task: TextFileAssetTask) => void;
  77128. /**
  77129. * Callback called when the task is successful
  77130. */
  77131. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77132. /**
  77133. * Creates a new TextFileAssetTask object
  77134. * @param name defines the name of the task
  77135. * @param url defines the location of the file to load
  77136. */
  77137. constructor(
  77138. /**
  77139. * Defines the name of the task
  77140. */
  77141. name: string,
  77142. /**
  77143. * Defines the location of the file to load
  77144. */
  77145. url: string);
  77146. /**
  77147. * Execute the current task
  77148. * @param scene defines the scene where you want your assets to be loaded
  77149. * @param onSuccess is a callback called when the task is successfully executed
  77150. * @param onError is a callback called if an error occurs
  77151. */
  77152. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77153. }
  77154. /**
  77155. * Define a task used by AssetsManager to load binary data
  77156. */
  77157. export class BinaryFileAssetTask extends AbstractAssetTask {
  77158. /**
  77159. * Defines the name of the task
  77160. */
  77161. name: string;
  77162. /**
  77163. * Defines the location of the file to load
  77164. */
  77165. url: string;
  77166. /**
  77167. * Gets the lodaded data (as an array buffer)
  77168. */
  77169. data: ArrayBuffer;
  77170. /**
  77171. * Callback called when the task is successful
  77172. */
  77173. onSuccess: (task: BinaryFileAssetTask) => void;
  77174. /**
  77175. * Callback called when the task is successful
  77176. */
  77177. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77178. /**
  77179. * Creates a new BinaryFileAssetTask object
  77180. * @param name defines the name of the new task
  77181. * @param url defines the location of the file to load
  77182. */
  77183. constructor(
  77184. /**
  77185. * Defines the name of the task
  77186. */
  77187. name: string,
  77188. /**
  77189. * Defines the location of the file to load
  77190. */
  77191. url: string);
  77192. /**
  77193. * Execute the current task
  77194. * @param scene defines the scene where you want your assets to be loaded
  77195. * @param onSuccess is a callback called when the task is successfully executed
  77196. * @param onError is a callback called if an error occurs
  77197. */
  77198. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77199. }
  77200. /**
  77201. * Define a task used by AssetsManager to load images
  77202. */
  77203. export class ImageAssetTask extends AbstractAssetTask {
  77204. /**
  77205. * Defines the name of the task
  77206. */
  77207. name: string;
  77208. /**
  77209. * Defines the location of the image to load
  77210. */
  77211. url: string;
  77212. /**
  77213. * Gets the loaded images
  77214. */
  77215. image: HTMLImageElement;
  77216. /**
  77217. * Callback called when the task is successful
  77218. */
  77219. onSuccess: (task: ImageAssetTask) => void;
  77220. /**
  77221. * Callback called when the task is successful
  77222. */
  77223. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77224. /**
  77225. * Creates a new ImageAssetTask
  77226. * @param name defines the name of the task
  77227. * @param url defines the location of the image to load
  77228. */
  77229. constructor(
  77230. /**
  77231. * Defines the name of the task
  77232. */
  77233. name: string,
  77234. /**
  77235. * Defines the location of the image to load
  77236. */
  77237. url: string);
  77238. /**
  77239. * Execute the current task
  77240. * @param scene defines the scene where you want your assets to be loaded
  77241. * @param onSuccess is a callback called when the task is successfully executed
  77242. * @param onError is a callback called if an error occurs
  77243. */
  77244. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77245. }
  77246. /**
  77247. * Defines the interface used by texture loading tasks
  77248. */
  77249. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77250. /**
  77251. * Gets the loaded texture
  77252. */
  77253. texture: TEX;
  77254. }
  77255. /**
  77256. * Define a task used by AssetsManager to load 2D textures
  77257. */
  77258. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77259. /**
  77260. * Defines the name of the task
  77261. */
  77262. name: string;
  77263. /**
  77264. * Defines the location of the file to load
  77265. */
  77266. url: string;
  77267. /**
  77268. * Defines if mipmap should not be generated (default is false)
  77269. */
  77270. noMipmap?: boolean | undefined;
  77271. /**
  77272. * Defines if texture must be inverted on Y axis (default is true)
  77273. */
  77274. invertY: boolean;
  77275. /**
  77276. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77277. */
  77278. samplingMode: number;
  77279. /**
  77280. * Gets the loaded texture
  77281. */
  77282. texture: Texture;
  77283. /**
  77284. * Callback called when the task is successful
  77285. */
  77286. onSuccess: (task: TextureAssetTask) => void;
  77287. /**
  77288. * Callback called when the task is successful
  77289. */
  77290. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77291. /**
  77292. * Creates a new TextureAssetTask object
  77293. * @param name defines the name of the task
  77294. * @param url defines the location of the file to load
  77295. * @param noMipmap defines if mipmap should not be generated (default is false)
  77296. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77297. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77298. */
  77299. constructor(
  77300. /**
  77301. * Defines the name of the task
  77302. */
  77303. name: string,
  77304. /**
  77305. * Defines the location of the file to load
  77306. */
  77307. url: string,
  77308. /**
  77309. * Defines if mipmap should not be generated (default is false)
  77310. */
  77311. noMipmap?: boolean | undefined,
  77312. /**
  77313. * Defines if texture must be inverted on Y axis (default is true)
  77314. */
  77315. invertY?: boolean,
  77316. /**
  77317. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77318. */
  77319. samplingMode?: number);
  77320. /**
  77321. * Execute the current task
  77322. * @param scene defines the scene where you want your assets to be loaded
  77323. * @param onSuccess is a callback called when the task is successfully executed
  77324. * @param onError is a callback called if an error occurs
  77325. */
  77326. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77327. }
  77328. /**
  77329. * Define a task used by AssetsManager to load cube textures
  77330. */
  77331. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77332. /**
  77333. * Defines the name of the task
  77334. */
  77335. name: string;
  77336. /**
  77337. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77338. */
  77339. url: string;
  77340. /**
  77341. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77342. */
  77343. extensions?: string[] | undefined;
  77344. /**
  77345. * Defines if mipmaps should not be generated (default is false)
  77346. */
  77347. noMipmap?: boolean | undefined;
  77348. /**
  77349. * Defines the explicit list of files (undefined by default)
  77350. */
  77351. files?: string[] | undefined;
  77352. /**
  77353. * Gets the loaded texture
  77354. */
  77355. texture: CubeTexture;
  77356. /**
  77357. * Callback called when the task is successful
  77358. */
  77359. onSuccess: (task: CubeTextureAssetTask) => void;
  77360. /**
  77361. * Callback called when the task is successful
  77362. */
  77363. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77364. /**
  77365. * Creates a new CubeTextureAssetTask
  77366. * @param name defines the name of the task
  77367. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77368. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77369. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77370. * @param files defines the explicit list of files (undefined by default)
  77371. */
  77372. constructor(
  77373. /**
  77374. * Defines the name of the task
  77375. */
  77376. name: string,
  77377. /**
  77378. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77379. */
  77380. url: string,
  77381. /**
  77382. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77383. */
  77384. extensions?: string[] | undefined,
  77385. /**
  77386. * Defines if mipmaps should not be generated (default is false)
  77387. */
  77388. noMipmap?: boolean | undefined,
  77389. /**
  77390. * Defines the explicit list of files (undefined by default)
  77391. */
  77392. files?: string[] | undefined);
  77393. /**
  77394. * Execute the current task
  77395. * @param scene defines the scene where you want your assets to be loaded
  77396. * @param onSuccess is a callback called when the task is successfully executed
  77397. * @param onError is a callback called if an error occurs
  77398. */
  77399. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77400. }
  77401. /**
  77402. * Define a task used by AssetsManager to load HDR cube textures
  77403. */
  77404. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77405. /**
  77406. * Defines the name of the task
  77407. */
  77408. name: string;
  77409. /**
  77410. * Defines the location of the file to load
  77411. */
  77412. url: string;
  77413. /**
  77414. * Defines the desired size (the more it increases the longer the generation will be)
  77415. */
  77416. size: number;
  77417. /**
  77418. * Defines if mipmaps should not be generated (default is false)
  77419. */
  77420. noMipmap: boolean;
  77421. /**
  77422. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77423. */
  77424. generateHarmonics: boolean;
  77425. /**
  77426. * 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)
  77427. */
  77428. gammaSpace: boolean;
  77429. /**
  77430. * Internal Use Only
  77431. */
  77432. reserved: boolean;
  77433. /**
  77434. * Gets the loaded texture
  77435. */
  77436. texture: HDRCubeTexture;
  77437. /**
  77438. * Callback called when the task is successful
  77439. */
  77440. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77441. /**
  77442. * Callback called when the task is successful
  77443. */
  77444. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77445. /**
  77446. * Creates a new HDRCubeTextureAssetTask object
  77447. * @param name defines the name of the task
  77448. * @param url defines the location of the file to load
  77449. * @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.
  77450. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77451. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77452. * @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)
  77453. * @param reserved Internal use only
  77454. */
  77455. constructor(
  77456. /**
  77457. * Defines the name of the task
  77458. */
  77459. name: string,
  77460. /**
  77461. * Defines the location of the file to load
  77462. */
  77463. url: string,
  77464. /**
  77465. * Defines the desired size (the more it increases the longer the generation will be)
  77466. */
  77467. size: number,
  77468. /**
  77469. * Defines if mipmaps should not be generated (default is false)
  77470. */
  77471. noMipmap?: boolean,
  77472. /**
  77473. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77474. */
  77475. generateHarmonics?: boolean,
  77476. /**
  77477. * 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)
  77478. */
  77479. gammaSpace?: boolean,
  77480. /**
  77481. * Internal Use Only
  77482. */
  77483. reserved?: boolean);
  77484. /**
  77485. * Execute the current task
  77486. * @param scene defines the scene where you want your assets to be loaded
  77487. * @param onSuccess is a callback called when the task is successfully executed
  77488. * @param onError is a callback called if an error occurs
  77489. */
  77490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77491. }
  77492. /**
  77493. * Define a task used by AssetsManager to load Equirectangular cube textures
  77494. */
  77495. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77496. /**
  77497. * Defines the name of the task
  77498. */
  77499. name: string;
  77500. /**
  77501. * Defines the location of the file to load
  77502. */
  77503. url: string;
  77504. /**
  77505. * Defines the desired size (the more it increases the longer the generation will be)
  77506. */
  77507. size: number;
  77508. /**
  77509. * Defines if mipmaps should not be generated (default is false)
  77510. */
  77511. noMipmap: boolean;
  77512. /**
  77513. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77514. * but the standard material would require them in Gamma space) (default is true)
  77515. */
  77516. gammaSpace: boolean;
  77517. /**
  77518. * Gets the loaded texture
  77519. */
  77520. texture: EquiRectangularCubeTexture;
  77521. /**
  77522. * Callback called when the task is successful
  77523. */
  77524. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77525. /**
  77526. * Callback called when the task is successful
  77527. */
  77528. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77529. /**
  77530. * Creates a new EquiRectangularCubeTextureAssetTask object
  77531. * @param name defines the name of the task
  77532. * @param url defines the location of the file to load
  77533. * @param size defines the desired size (the more it increases the longer the generation will be)
  77534. * If the size is omitted this implies you are using a preprocessed cubemap.
  77535. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77536. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77537. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77538. * (default is true)
  77539. */
  77540. constructor(
  77541. /**
  77542. * Defines the name of the task
  77543. */
  77544. name: string,
  77545. /**
  77546. * Defines the location of the file to load
  77547. */
  77548. url: string,
  77549. /**
  77550. * Defines the desired size (the more it increases the longer the generation will be)
  77551. */
  77552. size: number,
  77553. /**
  77554. * Defines if mipmaps should not be generated (default is false)
  77555. */
  77556. noMipmap?: boolean,
  77557. /**
  77558. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77559. * but the standard material would require them in Gamma space) (default is true)
  77560. */
  77561. gammaSpace?: boolean);
  77562. /**
  77563. * Execute the current task
  77564. * @param scene defines the scene where you want your assets to be loaded
  77565. * @param onSuccess is a callback called when the task is successfully executed
  77566. * @param onError is a callback called if an error occurs
  77567. */
  77568. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77569. }
  77570. /**
  77571. * This class can be used to easily import assets into a scene
  77572. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77573. */
  77574. export class AssetsManager {
  77575. private _scene;
  77576. private _isLoading;
  77577. protected _tasks: AbstractAssetTask[];
  77578. protected _waitingTasksCount: number;
  77579. protected _totalTasksCount: number;
  77580. /**
  77581. * Callback called when all tasks are processed
  77582. */
  77583. onFinish: (tasks: AbstractAssetTask[]) => void;
  77584. /**
  77585. * Callback called when a task is successful
  77586. */
  77587. onTaskSuccess: (task: AbstractAssetTask) => void;
  77588. /**
  77589. * Callback called when a task had an error
  77590. */
  77591. onTaskError: (task: AbstractAssetTask) => void;
  77592. /**
  77593. * Callback called when a task is done (whatever the result is)
  77594. */
  77595. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77596. /**
  77597. * Observable called when all tasks are processed
  77598. */
  77599. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77600. /**
  77601. * Observable called when a task had an error
  77602. */
  77603. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77604. /**
  77605. * Observable called when all tasks were executed
  77606. */
  77607. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77608. /**
  77609. * Observable called when a task is done (whatever the result is)
  77610. */
  77611. onProgressObservable: Observable<IAssetsProgressEvent>;
  77612. /**
  77613. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77614. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77615. */
  77616. useDefaultLoadingScreen: boolean;
  77617. /**
  77618. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77619. * when all assets have been downloaded.
  77620. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77621. */
  77622. autoHideLoadingUI: boolean;
  77623. /**
  77624. * Creates a new AssetsManager
  77625. * @param scene defines the scene to work on
  77626. */
  77627. constructor(scene: Scene);
  77628. /**
  77629. * Add a ContainerAssetTask to the list of active tasks
  77630. * @param taskName defines the name of the new task
  77631. * @param meshesNames defines the name of meshes to load
  77632. * @param rootUrl defines the root url to use to locate files
  77633. * @param sceneFilename defines the filename of the scene file
  77634. * @returns a new ContainerAssetTask object
  77635. */
  77636. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77637. /**
  77638. * Add a MeshAssetTask to the list of active tasks
  77639. * @param taskName defines the name of the new task
  77640. * @param meshesNames defines the name of meshes to load
  77641. * @param rootUrl defines the root url to use to locate files
  77642. * @param sceneFilename defines the filename of the scene file
  77643. * @returns a new MeshAssetTask object
  77644. */
  77645. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77646. /**
  77647. * Add a TextFileAssetTask to the list of active tasks
  77648. * @param taskName defines the name of the new task
  77649. * @param url defines the url of the file to load
  77650. * @returns a new TextFileAssetTask object
  77651. */
  77652. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77653. /**
  77654. * Add a BinaryFileAssetTask to the list of active tasks
  77655. * @param taskName defines the name of the new task
  77656. * @param url defines the url of the file to load
  77657. * @returns a new BinaryFileAssetTask object
  77658. */
  77659. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77660. /**
  77661. * Add a ImageAssetTask to the list of active tasks
  77662. * @param taskName defines the name of the new task
  77663. * @param url defines the url of the file to load
  77664. * @returns a new ImageAssetTask object
  77665. */
  77666. addImageTask(taskName: string, url: string): ImageAssetTask;
  77667. /**
  77668. * Add a TextureAssetTask to the list of active tasks
  77669. * @param taskName defines the name of the new task
  77670. * @param url defines the url of the file to load
  77671. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77672. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77673. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77674. * @returns a new TextureAssetTask object
  77675. */
  77676. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77677. /**
  77678. * Add a CubeTextureAssetTask to the list of active tasks
  77679. * @param taskName defines the name of the new task
  77680. * @param url defines the url of the file to load
  77681. * @param extensions defines the extension to use to load the cube map (can be null)
  77682. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77683. * @param files defines the list of files to load (can be null)
  77684. * @returns a new CubeTextureAssetTask object
  77685. */
  77686. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77687. /**
  77688. *
  77689. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77690. * @param taskName defines the name of the new task
  77691. * @param url defines the url of the file to load
  77692. * @param size defines the size you want for the cubemap (can be null)
  77693. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77694. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77695. * @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)
  77696. * @param reserved Internal use only
  77697. * @returns a new HDRCubeTextureAssetTask object
  77698. */
  77699. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77700. /**
  77701. *
  77702. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77703. * @param taskName defines the name of the new task
  77704. * @param url defines the url of the file to load
  77705. * @param size defines the size you want for the cubemap (can be null)
  77706. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77707. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77708. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77709. * @returns a new EquiRectangularCubeTextureAssetTask object
  77710. */
  77711. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77712. /**
  77713. * Remove a task from the assets manager.
  77714. * @param task the task to remove
  77715. */
  77716. removeTask(task: AbstractAssetTask): void;
  77717. private _decreaseWaitingTasksCount;
  77718. private _runTask;
  77719. /**
  77720. * Reset the AssetsManager and remove all tasks
  77721. * @return the current instance of the AssetsManager
  77722. */
  77723. reset(): AssetsManager;
  77724. /**
  77725. * Start the loading process
  77726. * @return the current instance of the AssetsManager
  77727. */
  77728. load(): AssetsManager;
  77729. /**
  77730. * Start the loading process as an async operation
  77731. * @return a promise returning the list of failed tasks
  77732. */
  77733. loadAsync(): Promise<void>;
  77734. }
  77735. }
  77736. declare module "babylonjs/Misc/deferred" {
  77737. /**
  77738. * Wrapper class for promise with external resolve and reject.
  77739. */
  77740. export class Deferred<T> {
  77741. /**
  77742. * The promise associated with this deferred object.
  77743. */
  77744. readonly promise: Promise<T>;
  77745. private _resolve;
  77746. private _reject;
  77747. /**
  77748. * The resolve method of the promise associated with this deferred object.
  77749. */
  77750. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77751. /**
  77752. * The reject method of the promise associated with this deferred object.
  77753. */
  77754. get reject(): (reason?: any) => void;
  77755. /**
  77756. * Constructor for this deferred object.
  77757. */
  77758. constructor();
  77759. }
  77760. }
  77761. declare module "babylonjs/Misc/meshExploder" {
  77762. import { Mesh } from "babylonjs/Meshes/mesh";
  77763. /**
  77764. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77765. */
  77766. export class MeshExploder {
  77767. private _centerMesh;
  77768. private _meshes;
  77769. private _meshesOrigins;
  77770. private _toCenterVectors;
  77771. private _scaledDirection;
  77772. private _newPosition;
  77773. private _centerPosition;
  77774. /**
  77775. * Explodes meshes from a center mesh.
  77776. * @param meshes The meshes to explode.
  77777. * @param centerMesh The mesh to be center of explosion.
  77778. */
  77779. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77780. private _setCenterMesh;
  77781. /**
  77782. * Get class name
  77783. * @returns "MeshExploder"
  77784. */
  77785. getClassName(): string;
  77786. /**
  77787. * "Exploded meshes"
  77788. * @returns Array of meshes with the centerMesh at index 0.
  77789. */
  77790. getMeshes(): Array<Mesh>;
  77791. /**
  77792. * Explodes meshes giving a specific direction
  77793. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77794. */
  77795. explode(direction?: number): void;
  77796. }
  77797. }
  77798. declare module "babylonjs/Misc/filesInput" {
  77799. import { Engine } from "babylonjs/Engines/engine";
  77800. import { Scene } from "babylonjs/scene";
  77801. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77802. import { Nullable } from "babylonjs/types";
  77803. /**
  77804. * Class used to help managing file picking and drag'n'drop
  77805. */
  77806. export class FilesInput {
  77807. /**
  77808. * List of files ready to be loaded
  77809. */
  77810. static get FilesToLoad(): {
  77811. [key: string]: File;
  77812. };
  77813. /**
  77814. * Callback called when a file is processed
  77815. */
  77816. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77817. private _engine;
  77818. private _currentScene;
  77819. private _sceneLoadedCallback;
  77820. private _progressCallback;
  77821. private _additionalRenderLoopLogicCallback;
  77822. private _textureLoadingCallback;
  77823. private _startingProcessingFilesCallback;
  77824. private _onReloadCallback;
  77825. private _errorCallback;
  77826. private _elementToMonitor;
  77827. private _sceneFileToLoad;
  77828. private _filesToLoad;
  77829. /**
  77830. * Creates a new FilesInput
  77831. * @param engine defines the rendering engine
  77832. * @param scene defines the hosting scene
  77833. * @param sceneLoadedCallback callback called when scene is loaded
  77834. * @param progressCallback callback called to track progress
  77835. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77836. * @param textureLoadingCallback callback called when a texture is loading
  77837. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77838. * @param onReloadCallback callback called when a reload is requested
  77839. * @param errorCallback callback call if an error occurs
  77840. */
  77841. 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>);
  77842. private _dragEnterHandler;
  77843. private _dragOverHandler;
  77844. private _dropHandler;
  77845. /**
  77846. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77847. * @param elementToMonitor defines the DOM element to track
  77848. */
  77849. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77850. /** Gets the current list of files to load */
  77851. get filesToLoad(): File[];
  77852. /**
  77853. * Release all associated resources
  77854. */
  77855. dispose(): void;
  77856. private renderFunction;
  77857. private drag;
  77858. private drop;
  77859. private _traverseFolder;
  77860. private _processFiles;
  77861. /**
  77862. * Load files from a drop event
  77863. * @param event defines the drop event to use as source
  77864. */
  77865. loadFiles(event: any): void;
  77866. private _processReload;
  77867. /**
  77868. * Reload the current scene from the loaded files
  77869. */
  77870. reload(): void;
  77871. }
  77872. }
  77873. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77874. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77875. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77876. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77877. }
  77878. declare module "babylonjs/Misc/sceneOptimizer" {
  77879. import { Scene, IDisposable } from "babylonjs/scene";
  77880. import { Observable } from "babylonjs/Misc/observable";
  77881. /**
  77882. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77883. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77884. */
  77885. export class SceneOptimization {
  77886. /**
  77887. * Defines the priority of this optimization (0 by default which means first in the list)
  77888. */
  77889. priority: number;
  77890. /**
  77891. * Gets a string describing the action executed by the current optimization
  77892. * @returns description string
  77893. */
  77894. getDescription(): string;
  77895. /**
  77896. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77897. * @param scene defines the current scene where to apply this optimization
  77898. * @param optimizer defines the current optimizer
  77899. * @returns true if everything that can be done was applied
  77900. */
  77901. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77902. /**
  77903. * Creates the SceneOptimization object
  77904. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77905. * @param desc defines the description associated with the optimization
  77906. */
  77907. constructor(
  77908. /**
  77909. * Defines the priority of this optimization (0 by default which means first in the list)
  77910. */
  77911. priority?: number);
  77912. }
  77913. /**
  77914. * Defines an optimization used to reduce the size of render target textures
  77915. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77916. */
  77917. export class TextureOptimization extends SceneOptimization {
  77918. /**
  77919. * Defines the priority of this optimization (0 by default which means first in the list)
  77920. */
  77921. priority: number;
  77922. /**
  77923. * 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
  77924. */
  77925. maximumSize: number;
  77926. /**
  77927. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77928. */
  77929. step: number;
  77930. /**
  77931. * Gets a string describing the action executed by the current optimization
  77932. * @returns description string
  77933. */
  77934. getDescription(): string;
  77935. /**
  77936. * Creates the TextureOptimization object
  77937. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77938. * @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
  77939. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77940. */
  77941. constructor(
  77942. /**
  77943. * Defines the priority of this optimization (0 by default which means first in the list)
  77944. */
  77945. priority?: number,
  77946. /**
  77947. * 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
  77948. */
  77949. maximumSize?: number,
  77950. /**
  77951. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77952. */
  77953. step?: number);
  77954. /**
  77955. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77956. * @param scene defines the current scene where to apply this optimization
  77957. * @param optimizer defines the current optimizer
  77958. * @returns true if everything that can be done was applied
  77959. */
  77960. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77961. }
  77962. /**
  77963. * Defines an optimization used to increase or decrease the rendering resolution
  77964. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77965. */
  77966. export class HardwareScalingOptimization extends SceneOptimization {
  77967. /**
  77968. * Defines the priority of this optimization (0 by default which means first in the list)
  77969. */
  77970. priority: number;
  77971. /**
  77972. * Defines the maximum scale to use (2 by default)
  77973. */
  77974. maximumScale: number;
  77975. /**
  77976. * Defines the step to use between two passes (0.5 by default)
  77977. */
  77978. step: number;
  77979. private _currentScale;
  77980. private _directionOffset;
  77981. /**
  77982. * Gets a string describing the action executed by the current optimization
  77983. * @return description string
  77984. */
  77985. getDescription(): string;
  77986. /**
  77987. * Creates the HardwareScalingOptimization object
  77988. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77989. * @param maximumScale defines the maximum scale to use (2 by default)
  77990. * @param step defines the step to use between two passes (0.5 by default)
  77991. */
  77992. constructor(
  77993. /**
  77994. * Defines the priority of this optimization (0 by default which means first in the list)
  77995. */
  77996. priority?: number,
  77997. /**
  77998. * Defines the maximum scale to use (2 by default)
  77999. */
  78000. maximumScale?: number,
  78001. /**
  78002. * Defines the step to use between two passes (0.5 by default)
  78003. */
  78004. step?: number);
  78005. /**
  78006. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78007. * @param scene defines the current scene where to apply this optimization
  78008. * @param optimizer defines the current optimizer
  78009. * @returns true if everything that can be done was applied
  78010. */
  78011. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78012. }
  78013. /**
  78014. * Defines an optimization used to remove shadows
  78015. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78016. */
  78017. export class ShadowsOptimization extends SceneOptimization {
  78018. /**
  78019. * Gets a string describing the action executed by the current optimization
  78020. * @return description string
  78021. */
  78022. getDescription(): string;
  78023. /**
  78024. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78025. * @param scene defines the current scene where to apply this optimization
  78026. * @param optimizer defines the current optimizer
  78027. * @returns true if everything that can be done was applied
  78028. */
  78029. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78030. }
  78031. /**
  78032. * Defines an optimization used to turn post-processes off
  78033. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78034. */
  78035. export class PostProcessesOptimization extends SceneOptimization {
  78036. /**
  78037. * Gets a string describing the action executed by the current optimization
  78038. * @return description string
  78039. */
  78040. getDescription(): string;
  78041. /**
  78042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78043. * @param scene defines the current scene where to apply this optimization
  78044. * @param optimizer defines the current optimizer
  78045. * @returns true if everything that can be done was applied
  78046. */
  78047. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78048. }
  78049. /**
  78050. * Defines an optimization used to turn lens flares off
  78051. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78052. */
  78053. export class LensFlaresOptimization extends SceneOptimization {
  78054. /**
  78055. * Gets a string describing the action executed by the current optimization
  78056. * @return description string
  78057. */
  78058. getDescription(): string;
  78059. /**
  78060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78061. * @param scene defines the current scene where to apply this optimization
  78062. * @param optimizer defines the current optimizer
  78063. * @returns true if everything that can be done was applied
  78064. */
  78065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78066. }
  78067. /**
  78068. * Defines an optimization based on user defined callback.
  78069. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78070. */
  78071. export class CustomOptimization extends SceneOptimization {
  78072. /**
  78073. * Callback called to apply the custom optimization.
  78074. */
  78075. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78076. /**
  78077. * Callback called to get custom description
  78078. */
  78079. onGetDescription: () => string;
  78080. /**
  78081. * Gets a string describing the action executed by the current optimization
  78082. * @returns description string
  78083. */
  78084. getDescription(): string;
  78085. /**
  78086. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78087. * @param scene defines the current scene where to apply this optimization
  78088. * @param optimizer defines the current optimizer
  78089. * @returns true if everything that can be done was applied
  78090. */
  78091. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78092. }
  78093. /**
  78094. * Defines an optimization used to turn particles off
  78095. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78096. */
  78097. export class ParticlesOptimization extends SceneOptimization {
  78098. /**
  78099. * Gets a string describing the action executed by the current optimization
  78100. * @return description string
  78101. */
  78102. getDescription(): string;
  78103. /**
  78104. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78105. * @param scene defines the current scene where to apply this optimization
  78106. * @param optimizer defines the current optimizer
  78107. * @returns true if everything that can be done was applied
  78108. */
  78109. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78110. }
  78111. /**
  78112. * Defines an optimization used to turn render targets off
  78113. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78114. */
  78115. export class RenderTargetsOptimization extends SceneOptimization {
  78116. /**
  78117. * Gets a string describing the action executed by the current optimization
  78118. * @return description string
  78119. */
  78120. getDescription(): string;
  78121. /**
  78122. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78123. * @param scene defines the current scene where to apply this optimization
  78124. * @param optimizer defines the current optimizer
  78125. * @returns true if everything that can be done was applied
  78126. */
  78127. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78128. }
  78129. /**
  78130. * Defines an optimization used to merge meshes with compatible materials
  78131. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78132. */
  78133. export class MergeMeshesOptimization extends SceneOptimization {
  78134. private static _UpdateSelectionTree;
  78135. /**
  78136. * Gets or sets a boolean which defines if optimization octree has to be updated
  78137. */
  78138. static get UpdateSelectionTree(): boolean;
  78139. /**
  78140. * Gets or sets a boolean which defines if optimization octree has to be updated
  78141. */
  78142. static set UpdateSelectionTree(value: boolean);
  78143. /**
  78144. * Gets a string describing the action executed by the current optimization
  78145. * @return description string
  78146. */
  78147. getDescription(): string;
  78148. private _canBeMerged;
  78149. /**
  78150. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78151. * @param scene defines the current scene where to apply this optimization
  78152. * @param optimizer defines the current optimizer
  78153. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78154. * @returns true if everything that can be done was applied
  78155. */
  78156. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78157. }
  78158. /**
  78159. * Defines a list of options used by SceneOptimizer
  78160. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78161. */
  78162. export class SceneOptimizerOptions {
  78163. /**
  78164. * Defines the target frame rate to reach (60 by default)
  78165. */
  78166. targetFrameRate: number;
  78167. /**
  78168. * Defines the interval between two checkes (2000ms by default)
  78169. */
  78170. trackerDuration: number;
  78171. /**
  78172. * Gets the list of optimizations to apply
  78173. */
  78174. optimizations: SceneOptimization[];
  78175. /**
  78176. * Creates a new list of options used by SceneOptimizer
  78177. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78178. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78179. */
  78180. constructor(
  78181. /**
  78182. * Defines the target frame rate to reach (60 by default)
  78183. */
  78184. targetFrameRate?: number,
  78185. /**
  78186. * Defines the interval between two checkes (2000ms by default)
  78187. */
  78188. trackerDuration?: number);
  78189. /**
  78190. * Add a new optimization
  78191. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78192. * @returns the current SceneOptimizerOptions
  78193. */
  78194. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78195. /**
  78196. * Add a new custom optimization
  78197. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78198. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78199. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78200. * @returns the current SceneOptimizerOptions
  78201. */
  78202. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78203. /**
  78204. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78205. * @param targetFrameRate defines the target frame rate (60 by default)
  78206. * @returns a SceneOptimizerOptions object
  78207. */
  78208. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78209. /**
  78210. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78211. * @param targetFrameRate defines the target frame rate (60 by default)
  78212. * @returns a SceneOptimizerOptions object
  78213. */
  78214. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78215. /**
  78216. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78217. * @param targetFrameRate defines the target frame rate (60 by default)
  78218. * @returns a SceneOptimizerOptions object
  78219. */
  78220. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78221. }
  78222. /**
  78223. * Class used to run optimizations in order to reach a target frame rate
  78224. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78225. */
  78226. export class SceneOptimizer implements IDisposable {
  78227. private _isRunning;
  78228. private _options;
  78229. private _scene;
  78230. private _currentPriorityLevel;
  78231. private _targetFrameRate;
  78232. private _trackerDuration;
  78233. private _currentFrameRate;
  78234. private _sceneDisposeObserver;
  78235. private _improvementMode;
  78236. /**
  78237. * Defines an observable called when the optimizer reaches the target frame rate
  78238. */
  78239. onSuccessObservable: Observable<SceneOptimizer>;
  78240. /**
  78241. * Defines an observable called when the optimizer enables an optimization
  78242. */
  78243. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78244. /**
  78245. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78246. */
  78247. onFailureObservable: Observable<SceneOptimizer>;
  78248. /**
  78249. * Gets a boolean indicating if the optimizer is in improvement mode
  78250. */
  78251. get isInImprovementMode(): boolean;
  78252. /**
  78253. * Gets the current priority level (0 at start)
  78254. */
  78255. get currentPriorityLevel(): number;
  78256. /**
  78257. * Gets the current frame rate checked by the SceneOptimizer
  78258. */
  78259. get currentFrameRate(): number;
  78260. /**
  78261. * Gets or sets the current target frame rate (60 by default)
  78262. */
  78263. get targetFrameRate(): number;
  78264. /**
  78265. * Gets or sets the current target frame rate (60 by default)
  78266. */
  78267. set targetFrameRate(value: number);
  78268. /**
  78269. * Gets or sets the current interval between two checks (every 2000ms by default)
  78270. */
  78271. get trackerDuration(): number;
  78272. /**
  78273. * Gets or sets the current interval between two checks (every 2000ms by default)
  78274. */
  78275. set trackerDuration(value: number);
  78276. /**
  78277. * Gets the list of active optimizations
  78278. */
  78279. get optimizations(): SceneOptimization[];
  78280. /**
  78281. * Creates a new SceneOptimizer
  78282. * @param scene defines the scene to work on
  78283. * @param options defines the options to use with the SceneOptimizer
  78284. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78285. * @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)
  78286. */
  78287. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78288. /**
  78289. * Stops the current optimizer
  78290. */
  78291. stop(): void;
  78292. /**
  78293. * Reset the optimizer to initial step (current priority level = 0)
  78294. */
  78295. reset(): void;
  78296. /**
  78297. * Start the optimizer. By default it will try to reach a specific framerate
  78298. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78299. */
  78300. start(): void;
  78301. private _checkCurrentState;
  78302. /**
  78303. * Release all resources
  78304. */
  78305. dispose(): void;
  78306. /**
  78307. * Helper function to create a SceneOptimizer with one single line of code
  78308. * @param scene defines the scene to work on
  78309. * @param options defines the options to use with the SceneOptimizer
  78310. * @param onSuccess defines a callback to call on success
  78311. * @param onFailure defines a callback to call on failure
  78312. * @returns the new SceneOptimizer object
  78313. */
  78314. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78315. }
  78316. }
  78317. declare module "babylonjs/Misc/sceneSerializer" {
  78318. import { Scene } from "babylonjs/scene";
  78319. /**
  78320. * Class used to serialize a scene into a string
  78321. */
  78322. export class SceneSerializer {
  78323. /**
  78324. * Clear cache used by a previous serialization
  78325. */
  78326. static ClearCache(): void;
  78327. /**
  78328. * Serialize a scene into a JSON compatible object
  78329. * @param scene defines the scene to serialize
  78330. * @returns a JSON compatible object
  78331. */
  78332. static Serialize(scene: Scene): any;
  78333. /**
  78334. * Serialize a mesh into a JSON compatible object
  78335. * @param toSerialize defines the mesh to serialize
  78336. * @param withParents defines if parents must be serialized as well
  78337. * @param withChildren defines if children must be serialized as well
  78338. * @returns a JSON compatible object
  78339. */
  78340. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78341. }
  78342. }
  78343. declare module "babylonjs/Misc/textureTools" {
  78344. import { Texture } from "babylonjs/Materials/Textures/texture";
  78345. /**
  78346. * Class used to host texture specific utilities
  78347. */
  78348. export class TextureTools {
  78349. /**
  78350. * Uses the GPU to create a copy texture rescaled at a given size
  78351. * @param texture Texture to copy from
  78352. * @param width defines the desired width
  78353. * @param height defines the desired height
  78354. * @param useBilinearMode defines if bilinear mode has to be used
  78355. * @return the generated texture
  78356. */
  78357. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78358. }
  78359. }
  78360. declare module "babylonjs/Misc/videoRecorder" {
  78361. import { Nullable } from "babylonjs/types";
  78362. import { Engine } from "babylonjs/Engines/engine";
  78363. /**
  78364. * This represents the different options available for the video capture.
  78365. */
  78366. export interface VideoRecorderOptions {
  78367. /** Defines the mime type of the video. */
  78368. mimeType: string;
  78369. /** Defines the FPS the video should be recorded at. */
  78370. fps: number;
  78371. /** Defines the chunk size for the recording data. */
  78372. recordChunckSize: number;
  78373. /** The audio tracks to attach to the recording. */
  78374. audioTracks?: MediaStreamTrack[];
  78375. }
  78376. /**
  78377. * This can help with recording videos from BabylonJS.
  78378. * This is based on the available WebRTC functionalities of the browser.
  78379. *
  78380. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78381. */
  78382. export class VideoRecorder {
  78383. private static readonly _defaultOptions;
  78384. /**
  78385. * Returns whether or not the VideoRecorder is available in your browser.
  78386. * @param engine Defines the Babylon Engine.
  78387. * @returns true if supported otherwise false.
  78388. */
  78389. static IsSupported(engine: Engine): boolean;
  78390. private readonly _options;
  78391. private _canvas;
  78392. private _mediaRecorder;
  78393. private _recordedChunks;
  78394. private _fileName;
  78395. private _resolve;
  78396. private _reject;
  78397. /**
  78398. * True when a recording is already in progress.
  78399. */
  78400. get isRecording(): boolean;
  78401. /**
  78402. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78403. * @param engine Defines the BabylonJS Engine you wish to record.
  78404. * @param options Defines options that can be used to customize the capture.
  78405. */
  78406. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78407. /**
  78408. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78409. */
  78410. stopRecording(): void;
  78411. /**
  78412. * Starts recording the canvas for a max duration specified in parameters.
  78413. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78414. * If null no automatic download will start and you can rely on the promise to get the data back.
  78415. * @param maxDuration Defines the maximum recording time in seconds.
  78416. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78417. * @return A promise callback at the end of the recording with the video data in Blob.
  78418. */
  78419. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78420. /**
  78421. * Releases internal resources used during the recording.
  78422. */
  78423. dispose(): void;
  78424. private _handleDataAvailable;
  78425. private _handleError;
  78426. private _handleStop;
  78427. }
  78428. }
  78429. declare module "babylonjs/Misc/screenshotTools" {
  78430. import { Camera } from "babylonjs/Cameras/camera";
  78431. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78432. import { Engine } from "babylonjs/Engines/engine";
  78433. /**
  78434. * Class containing a set of static utilities functions for screenshots
  78435. */
  78436. export class ScreenshotTools {
  78437. /**
  78438. * Captures a screenshot of the current rendering
  78439. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78440. * @param engine defines the rendering engine
  78441. * @param camera defines the source camera
  78442. * @param size This parameter can be set to a single number or to an object with the
  78443. * following (optional) properties: precision, width, height. If a single number is passed,
  78444. * it will be used for both width and height. If an object is passed, the screenshot size
  78445. * will be derived from the parameters. The precision property is a multiplier allowing
  78446. * rendering at a higher or lower resolution
  78447. * @param successCallback defines the callback receives a single parameter which contains the
  78448. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78449. * src parameter of an <img> to display it
  78450. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78451. * Check your browser for supported MIME types
  78452. */
  78453. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78454. /**
  78455. * Captures a screenshot of the current rendering
  78456. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78457. * @param engine defines the rendering engine
  78458. * @param camera defines the source camera
  78459. * @param size This parameter can be set to a single number or to an object with the
  78460. * following (optional) properties: precision, width, height. If a single number is passed,
  78461. * it will be used for both width and height. If an object is passed, the screenshot size
  78462. * will be derived from the parameters. The precision property is a multiplier allowing
  78463. * rendering at a higher or lower resolution
  78464. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78465. * Check your browser for supported MIME types
  78466. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78467. * to the src parameter of an <img> to display it
  78468. */
  78469. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78470. /**
  78471. * Generates an image screenshot from the specified camera.
  78472. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78473. * @param engine The engine to use for rendering
  78474. * @param camera The camera to use for rendering
  78475. * @param size This parameter can be set to a single number or to an object with the
  78476. * following (optional) properties: precision, width, height. If a single number is passed,
  78477. * it will be used for both width and height. If an object is passed, the screenshot size
  78478. * will be derived from the parameters. The precision property is a multiplier allowing
  78479. * rendering at a higher or lower resolution
  78480. * @param successCallback The callback receives a single parameter which contains the
  78481. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78482. * src parameter of an <img> to display it
  78483. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78484. * Check your browser for supported MIME types
  78485. * @param samples Texture samples (default: 1)
  78486. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78487. * @param fileName A name for for the downloaded file.
  78488. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78489. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78490. */
  78491. 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;
  78492. /**
  78493. * Generates an image screenshot from the specified camera.
  78494. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78495. * @param engine The engine to use for rendering
  78496. * @param camera The camera to use for rendering
  78497. * @param size This parameter can be set to a single number or to an object with the
  78498. * following (optional) properties: precision, width, height. If a single number is passed,
  78499. * it will be used for both width and height. If an object is passed, the screenshot size
  78500. * will be derived from the parameters. The precision property is a multiplier allowing
  78501. * rendering at a higher or lower resolution
  78502. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78503. * Check your browser for supported MIME types
  78504. * @param samples Texture samples (default: 1)
  78505. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78506. * @param fileName A name for for the downloaded file.
  78507. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78508. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78509. * to the src parameter of an <img> to display it
  78510. */
  78511. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78512. /**
  78513. * Gets height and width for screenshot size
  78514. * @private
  78515. */
  78516. private static _getScreenshotSize;
  78517. }
  78518. }
  78519. declare module "babylonjs/Misc/dataReader" {
  78520. /**
  78521. * Interface for a data buffer
  78522. */
  78523. export interface IDataBuffer {
  78524. /**
  78525. * Reads bytes from the data buffer.
  78526. * @param byteOffset The byte offset to read
  78527. * @param byteLength The byte length to read
  78528. * @returns A promise that resolves when the bytes are read
  78529. */
  78530. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78531. /**
  78532. * The byte length of the buffer.
  78533. */
  78534. readonly byteLength: number;
  78535. }
  78536. /**
  78537. * Utility class for reading from a data buffer
  78538. */
  78539. export class DataReader {
  78540. /**
  78541. * The data buffer associated with this data reader.
  78542. */
  78543. readonly buffer: IDataBuffer;
  78544. /**
  78545. * The current byte offset from the beginning of the data buffer.
  78546. */
  78547. byteOffset: number;
  78548. private _dataView;
  78549. private _dataByteOffset;
  78550. /**
  78551. * Constructor
  78552. * @param buffer The buffer to read
  78553. */
  78554. constructor(buffer: IDataBuffer);
  78555. /**
  78556. * Loads the given byte length.
  78557. * @param byteLength The byte length to load
  78558. * @returns A promise that resolves when the load is complete
  78559. */
  78560. loadAsync(byteLength: number): Promise<void>;
  78561. /**
  78562. * Read a unsigned 32-bit integer from the currently loaded data range.
  78563. * @returns The 32-bit integer read
  78564. */
  78565. readUint32(): number;
  78566. /**
  78567. * Read a byte array from the currently loaded data range.
  78568. * @param byteLength The byte length to read
  78569. * @returns The byte array read
  78570. */
  78571. readUint8Array(byteLength: number): Uint8Array;
  78572. /**
  78573. * Read a string from the currently loaded data range.
  78574. * @param byteLength The byte length to read
  78575. * @returns The string read
  78576. */
  78577. readString(byteLength: number): string;
  78578. /**
  78579. * Skips the given byte length the currently loaded data range.
  78580. * @param byteLength The byte length to skip
  78581. */
  78582. skipBytes(byteLength: number): void;
  78583. }
  78584. }
  78585. declare module "babylonjs/Misc/dataStorage" {
  78586. /**
  78587. * Class for storing data to local storage if available or in-memory storage otherwise
  78588. */
  78589. export class DataStorage {
  78590. private static _Storage;
  78591. private static _GetStorage;
  78592. /**
  78593. * Reads a string from the data storage
  78594. * @param key The key to read
  78595. * @param defaultValue The value if the key doesn't exist
  78596. * @returns The string value
  78597. */
  78598. static ReadString(key: string, defaultValue: string): string;
  78599. /**
  78600. * Writes a string to the data storage
  78601. * @param key The key to write
  78602. * @param value The value to write
  78603. */
  78604. static WriteString(key: string, value: string): void;
  78605. /**
  78606. * Reads a boolean from the data storage
  78607. * @param key The key to read
  78608. * @param defaultValue The value if the key doesn't exist
  78609. * @returns The boolean value
  78610. */
  78611. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78612. /**
  78613. * Writes a boolean to the data storage
  78614. * @param key The key to write
  78615. * @param value The value to write
  78616. */
  78617. static WriteBoolean(key: string, value: boolean): void;
  78618. /**
  78619. * Reads a number from the data storage
  78620. * @param key The key to read
  78621. * @param defaultValue The value if the key doesn't exist
  78622. * @returns The number value
  78623. */
  78624. static ReadNumber(key: string, defaultValue: number): number;
  78625. /**
  78626. * Writes a number to the data storage
  78627. * @param key The key to write
  78628. * @param value The value to write
  78629. */
  78630. static WriteNumber(key: string, value: number): void;
  78631. }
  78632. }
  78633. declare module "babylonjs/Misc/sceneRecorder" {
  78634. import { Scene } from "babylonjs/scene";
  78635. /**
  78636. * Class used to record delta files between 2 scene states
  78637. */
  78638. export class SceneRecorder {
  78639. private _trackedScene;
  78640. private _savedJSON;
  78641. /**
  78642. * Track a given scene. This means the current scene state will be considered the original state
  78643. * @param scene defines the scene to track
  78644. */
  78645. track(scene: Scene): void;
  78646. /**
  78647. * Get the delta between current state and original state
  78648. * @returns a string containing the delta
  78649. */
  78650. getDelta(): any;
  78651. private _compareArray;
  78652. private _compareObjects;
  78653. private _compareCollections;
  78654. private static GetShadowGeneratorById;
  78655. /**
  78656. * Apply a given delta to a given scene
  78657. * @param deltaJSON defines the JSON containing the delta
  78658. * @param scene defines the scene to apply the delta to
  78659. */
  78660. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78661. private static _ApplyPropertiesToEntity;
  78662. private static _ApplyDeltaForEntity;
  78663. }
  78664. }
  78665. declare module "babylonjs/Misc/trajectoryClassifier" {
  78666. import { DeepImmutable, Nullable } from "babylonjs/types";
  78667. import { Vector3 } from "babylonjs/Maths/math.vector";
  78668. /**
  78669. * A 3D trajectory consisting of an order list of vectors describing a
  78670. * path of motion through 3D space.
  78671. */
  78672. export class Trajectory {
  78673. private _points;
  78674. private readonly _segmentLength;
  78675. /**
  78676. * Serialize to JSON.
  78677. * @returns serialized JSON string
  78678. */
  78679. serialize(): string;
  78680. /**
  78681. * Deserialize from JSON.
  78682. * @param json serialized JSON string
  78683. * @returns deserialized Trajectory
  78684. */
  78685. static Deserialize(json: string): Trajectory;
  78686. /**
  78687. * Create a new empty Trajectory.
  78688. * @param segmentLength radius of discretization for Trajectory points
  78689. */
  78690. constructor(segmentLength?: number);
  78691. /**
  78692. * Get the length of the Trajectory.
  78693. * @returns length of the Trajectory
  78694. */
  78695. getLength(): number;
  78696. /**
  78697. * Append a new point to the Trajectory.
  78698. * NOTE: This implementation has many allocations.
  78699. * @param point point to append to the Trajectory
  78700. */
  78701. add(point: DeepImmutable<Vector3>): void;
  78702. /**
  78703. * Create a new Trajectory with a segment length chosen to make it
  78704. * probable that the new Trajectory will have a specified number of
  78705. * segments. This operation is imprecise.
  78706. * @param targetResolution number of segments desired
  78707. * @returns new Trajectory with approximately the requested number of segments
  78708. */
  78709. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78710. /**
  78711. * Convert Trajectory segments into tokenized representation. This
  78712. * representation is an array of numbers where each nth number is the
  78713. * index of the token which is most similar to the nth segment of the
  78714. * Trajectory.
  78715. * @param tokens list of vectors which serve as discrete tokens
  78716. * @returns list of indices of most similar token per segment
  78717. */
  78718. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78719. private static _forwardDir;
  78720. private static _inverseFromVec;
  78721. private static _upDir;
  78722. private static _fromToVec;
  78723. private static _lookMatrix;
  78724. /**
  78725. * Transform the rotation (i.e., direction) of a segment to isolate
  78726. * the relative transformation represented by the segment. This operation
  78727. * may or may not succeed due to singularities in the equations that define
  78728. * motion relativity in this context.
  78729. * @param priorVec the origin of the prior segment
  78730. * @param fromVec the origin of the current segment
  78731. * @param toVec the destination of the current segment
  78732. * @param result reference to output variable
  78733. * @returns whether or not transformation was successful
  78734. */
  78735. private static _transformSegmentDirToRef;
  78736. private static _bestMatch;
  78737. private static _score;
  78738. private static _bestScore;
  78739. /**
  78740. * Determine which token vector is most similar to the
  78741. * segment vector.
  78742. * @param segment segment vector
  78743. * @param tokens token vector list
  78744. * @returns index of the most similar token to the segment
  78745. */
  78746. private static _tokenizeSegment;
  78747. }
  78748. /**
  78749. * Class representing a set of known, named trajectories to which Trajectories can be
  78750. * added and using which Trajectories can be recognized.
  78751. */
  78752. export class TrajectoryClassifier {
  78753. private _maximumAllowableMatchCost;
  78754. private _vector3Alphabet;
  78755. private _levenshteinAlphabet;
  78756. private _nameToDescribedTrajectory;
  78757. /**
  78758. * Serialize to JSON.
  78759. * @returns JSON serialization
  78760. */
  78761. serialize(): string;
  78762. /**
  78763. * Deserialize from JSON.
  78764. * @param json JSON serialization
  78765. * @returns deserialized TrajectorySet
  78766. */
  78767. static Deserialize(json: string): TrajectoryClassifier;
  78768. /**
  78769. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78770. * VERY naive, need to be generating these things from known
  78771. * sets. Better version later, probably eliminating this one.
  78772. * @returns auto-generated TrajectorySet
  78773. */
  78774. static Generate(): TrajectoryClassifier;
  78775. private constructor();
  78776. /**
  78777. * Add a new Trajectory to the set with a given name.
  78778. * @param trajectory new Trajectory to be added
  78779. * @param classification name to which to add the Trajectory
  78780. */
  78781. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78782. /**
  78783. * Remove a known named trajectory and all Trajectories associated with it.
  78784. * @param classification name to remove
  78785. * @returns whether anything was removed
  78786. */
  78787. deleteClassification(classification: string): boolean;
  78788. /**
  78789. * Attempt to recognize a Trajectory from among all the classifications
  78790. * already known to the classifier.
  78791. * @param trajectory Trajectory to be recognized
  78792. * @returns classification of Trajectory if recognized, null otherwise
  78793. */
  78794. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78795. }
  78796. }
  78797. declare module "babylonjs/Misc/index" {
  78798. export * from "babylonjs/Misc/andOrNotEvaluator";
  78799. export * from "babylonjs/Misc/assetsManager";
  78800. export * from "babylonjs/Misc/basis";
  78801. export * from "babylonjs/Misc/dds";
  78802. export * from "babylonjs/Misc/decorators";
  78803. export * from "babylonjs/Misc/deferred";
  78804. export * from "babylonjs/Misc/environmentTextureTools";
  78805. export * from "babylonjs/Misc/meshExploder";
  78806. export * from "babylonjs/Misc/filesInput";
  78807. export * from "babylonjs/Misc/HighDynamicRange/index";
  78808. export * from "babylonjs/Misc/khronosTextureContainer";
  78809. export * from "babylonjs/Misc/observable";
  78810. export * from "babylonjs/Misc/performanceMonitor";
  78811. export * from "babylonjs/Misc/promise";
  78812. export * from "babylonjs/Misc/sceneOptimizer";
  78813. export * from "babylonjs/Misc/sceneSerializer";
  78814. export * from "babylonjs/Misc/smartArray";
  78815. export * from "babylonjs/Misc/stringDictionary";
  78816. export * from "babylonjs/Misc/tags";
  78817. export * from "babylonjs/Misc/textureTools";
  78818. export * from "babylonjs/Misc/tga";
  78819. export * from "babylonjs/Misc/tools";
  78820. export * from "babylonjs/Misc/videoRecorder";
  78821. export * from "babylonjs/Misc/virtualJoystick";
  78822. export * from "babylonjs/Misc/workerPool";
  78823. export * from "babylonjs/Misc/logger";
  78824. export * from "babylonjs/Misc/typeStore";
  78825. export * from "babylonjs/Misc/filesInputStore";
  78826. export * from "babylonjs/Misc/deepCopier";
  78827. export * from "babylonjs/Misc/pivotTools";
  78828. export * from "babylonjs/Misc/precisionDate";
  78829. export * from "babylonjs/Misc/screenshotTools";
  78830. export * from "babylonjs/Misc/typeStore";
  78831. export * from "babylonjs/Misc/webRequest";
  78832. export * from "babylonjs/Misc/iInspectable";
  78833. export * from "babylonjs/Misc/brdfTextureTools";
  78834. export * from "babylonjs/Misc/rgbdTextureTools";
  78835. export * from "babylonjs/Misc/gradients";
  78836. export * from "babylonjs/Misc/perfCounter";
  78837. export * from "babylonjs/Misc/fileRequest";
  78838. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78839. export * from "babylonjs/Misc/retryStrategy";
  78840. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78841. export * from "babylonjs/Misc/canvasGenerator";
  78842. export * from "babylonjs/Misc/fileTools";
  78843. export * from "babylonjs/Misc/stringTools";
  78844. export * from "babylonjs/Misc/dataReader";
  78845. export * from "babylonjs/Misc/minMaxReducer";
  78846. export * from "babylonjs/Misc/depthReducer";
  78847. export * from "babylonjs/Misc/dataStorage";
  78848. export * from "babylonjs/Misc/sceneRecorder";
  78849. export * from "babylonjs/Misc/khronosTextureContainer2";
  78850. export * from "babylonjs/Misc/trajectoryClassifier";
  78851. }
  78852. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78853. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78854. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78855. import { Observable } from "babylonjs/Misc/observable";
  78856. import { Matrix } from "babylonjs/Maths/math.vector";
  78857. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78858. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78859. /**
  78860. * An interface for all Hit test features
  78861. */
  78862. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78863. /**
  78864. * Triggered when new babylon (transformed) hit test results are available
  78865. */
  78866. onHitTestResultObservable: Observable<T[]>;
  78867. }
  78868. /**
  78869. * Options used for hit testing
  78870. */
  78871. export interface IWebXRLegacyHitTestOptions {
  78872. /**
  78873. * Only test when user interacted with the scene. Default - hit test every frame
  78874. */
  78875. testOnPointerDownOnly?: boolean;
  78876. /**
  78877. * The node to use to transform the local results to world coordinates
  78878. */
  78879. worldParentNode?: TransformNode;
  78880. }
  78881. /**
  78882. * Interface defining the babylon result of raycasting/hit-test
  78883. */
  78884. export interface IWebXRLegacyHitResult {
  78885. /**
  78886. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78887. */
  78888. transformationMatrix: Matrix;
  78889. /**
  78890. * The native hit test result
  78891. */
  78892. xrHitResult: XRHitResult | XRHitTestResult;
  78893. }
  78894. /**
  78895. * The currently-working hit-test module.
  78896. * Hit test (or Ray-casting) is used to interact with the real world.
  78897. * For further information read here - https://github.com/immersive-web/hit-test
  78898. */
  78899. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78900. /**
  78901. * options to use when constructing this feature
  78902. */
  78903. readonly options: IWebXRLegacyHitTestOptions;
  78904. private _direction;
  78905. private _mat;
  78906. private _onSelectEnabled;
  78907. private _origin;
  78908. /**
  78909. * The module's name
  78910. */
  78911. static readonly Name: string;
  78912. /**
  78913. * The (Babylon) version of this module.
  78914. * This is an integer representing the implementation version.
  78915. * This number does not correspond to the WebXR specs version
  78916. */
  78917. static readonly Version: number;
  78918. /**
  78919. * Populated with the last native XR Hit Results
  78920. */
  78921. lastNativeXRHitResults: XRHitResult[];
  78922. /**
  78923. * Triggered when new babylon (transformed) hit test results are available
  78924. */
  78925. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78926. /**
  78927. * Creates a new instance of the (legacy version) hit test feature
  78928. * @param _xrSessionManager an instance of WebXRSessionManager
  78929. * @param options options to use when constructing this feature
  78930. */
  78931. constructor(_xrSessionManager: WebXRSessionManager,
  78932. /**
  78933. * options to use when constructing this feature
  78934. */
  78935. options?: IWebXRLegacyHitTestOptions);
  78936. /**
  78937. * execute a hit test with an XR Ray
  78938. *
  78939. * @param xrSession a native xrSession that will execute this hit test
  78940. * @param xrRay the ray (position and direction) to use for ray-casting
  78941. * @param referenceSpace native XR reference space to use for the hit-test
  78942. * @param filter filter function that will filter the results
  78943. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78944. */
  78945. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78946. /**
  78947. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78948. * @param event the (select) event to use to select with
  78949. * @param referenceSpace the reference space to use for this hit test
  78950. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78951. */
  78952. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78953. /**
  78954. * attach this feature
  78955. * Will usually be called by the features manager
  78956. *
  78957. * @returns true if successful.
  78958. */
  78959. attach(): boolean;
  78960. /**
  78961. * detach this feature.
  78962. * Will usually be called by the features manager
  78963. *
  78964. * @returns true if successful.
  78965. */
  78966. detach(): boolean;
  78967. /**
  78968. * Dispose this feature and all of the resources attached
  78969. */
  78970. dispose(): void;
  78971. protected _onXRFrame(frame: XRFrame): void;
  78972. private _onHitTestResults;
  78973. private _onSelect;
  78974. }
  78975. }
  78976. declare module "babylonjs/XR/features/WebXRHitTest" {
  78977. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78978. import { Observable } from "babylonjs/Misc/observable";
  78979. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78980. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78981. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  78982. /**
  78983. * Options used for hit testing (version 2)
  78984. */
  78985. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78986. /**
  78987. * Do not create a permanent hit test. Will usually be used when only
  78988. * transient inputs are needed.
  78989. */
  78990. disablePermanentHitTest?: boolean;
  78991. /**
  78992. * Enable transient (for example touch-based) hit test inspections
  78993. */
  78994. enableTransientHitTest?: boolean;
  78995. /**
  78996. * Offset ray for the permanent hit test
  78997. */
  78998. offsetRay?: Vector3;
  78999. /**
  79000. * Offset ray for the transient hit test
  79001. */
  79002. transientOffsetRay?: Vector3;
  79003. /**
  79004. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79005. */
  79006. useReferenceSpace?: boolean;
  79007. /**
  79008. * Override the default entity type(s) of the hit-test result
  79009. */
  79010. entityTypes?: XRHitTestTrackableType[];
  79011. }
  79012. /**
  79013. * Interface defining the babylon result of hit-test
  79014. */
  79015. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79016. /**
  79017. * The input source that generated this hit test (if transient)
  79018. */
  79019. inputSource?: XRInputSource;
  79020. /**
  79021. * Is this a transient hit test
  79022. */
  79023. isTransient?: boolean;
  79024. /**
  79025. * Position of the hit test result
  79026. */
  79027. position: Vector3;
  79028. /**
  79029. * Rotation of the hit test result
  79030. */
  79031. rotationQuaternion: Quaternion;
  79032. /**
  79033. * The native hit test result
  79034. */
  79035. xrHitResult: XRHitTestResult;
  79036. }
  79037. /**
  79038. * The currently-working hit-test module.
  79039. * Hit test (or Ray-casting) is used to interact with the real world.
  79040. * For further information read here - https://github.com/immersive-web/hit-test
  79041. *
  79042. * Tested on chrome (mobile) 80.
  79043. */
  79044. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79045. /**
  79046. * options to use when constructing this feature
  79047. */
  79048. readonly options: IWebXRHitTestOptions;
  79049. private _tmpMat;
  79050. private _tmpPos;
  79051. private _tmpQuat;
  79052. private _transientXrHitTestSource;
  79053. private _xrHitTestSource;
  79054. private initHitTestSource;
  79055. /**
  79056. * The module's name
  79057. */
  79058. static readonly Name: string;
  79059. /**
  79060. * The (Babylon) version of this module.
  79061. * This is an integer representing the implementation version.
  79062. * This number does not correspond to the WebXR specs version
  79063. */
  79064. static readonly Version: number;
  79065. /**
  79066. * When set to true, each hit test will have its own position/rotation objects
  79067. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79068. * the developers will clone them or copy them as they see fit.
  79069. */
  79070. autoCloneTransformation: boolean;
  79071. /**
  79072. * Triggered when new babylon (transformed) hit test results are available
  79073. * Note - this will be called when results come back from the device. It can be an empty array!!
  79074. */
  79075. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79076. /**
  79077. * Use this to temporarily pause hit test checks.
  79078. */
  79079. paused: boolean;
  79080. /**
  79081. * Creates a new instance of the hit test feature
  79082. * @param _xrSessionManager an instance of WebXRSessionManager
  79083. * @param options options to use when constructing this feature
  79084. */
  79085. constructor(_xrSessionManager: WebXRSessionManager,
  79086. /**
  79087. * options to use when constructing this feature
  79088. */
  79089. options?: IWebXRHitTestOptions);
  79090. /**
  79091. * attach this feature
  79092. * Will usually be called by the features manager
  79093. *
  79094. * @returns true if successful.
  79095. */
  79096. attach(): boolean;
  79097. /**
  79098. * detach this feature.
  79099. * Will usually be called by the features manager
  79100. *
  79101. * @returns true if successful.
  79102. */
  79103. detach(): boolean;
  79104. /**
  79105. * Dispose this feature and all of the resources attached
  79106. */
  79107. dispose(): void;
  79108. protected _onXRFrame(frame: XRFrame): void;
  79109. private _processWebXRHitTestResult;
  79110. }
  79111. }
  79112. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79113. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79114. import { Observable } from "babylonjs/Misc/observable";
  79115. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79116. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79117. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79118. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79119. /**
  79120. * Configuration options of the anchor system
  79121. */
  79122. export interface IWebXRAnchorSystemOptions {
  79123. /**
  79124. * a node that will be used to convert local to world coordinates
  79125. */
  79126. worldParentNode?: TransformNode;
  79127. /**
  79128. * If set to true a reference of the created anchors will be kept until the next session starts
  79129. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79130. */
  79131. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79132. }
  79133. /**
  79134. * A babylon container for an XR Anchor
  79135. */
  79136. export interface IWebXRAnchor {
  79137. /**
  79138. * A babylon-assigned ID for this anchor
  79139. */
  79140. id: number;
  79141. /**
  79142. * Transformation matrix to apply to an object attached to this anchor
  79143. */
  79144. transformationMatrix: Matrix;
  79145. /**
  79146. * The native anchor object
  79147. */
  79148. xrAnchor: XRAnchor;
  79149. /**
  79150. * if defined, this object will be constantly updated by the anchor's position and rotation
  79151. */
  79152. attachedNode?: TransformNode;
  79153. }
  79154. /**
  79155. * An implementation of the anchor system for WebXR.
  79156. * For further information see https://github.com/immersive-web/anchors/
  79157. */
  79158. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79159. private _options;
  79160. private _lastFrameDetected;
  79161. private _trackedAnchors;
  79162. private _referenceSpaceForFrameAnchors;
  79163. private _futureAnchors;
  79164. /**
  79165. * The module's name
  79166. */
  79167. static readonly Name: string;
  79168. /**
  79169. * The (Babylon) version of this module.
  79170. * This is an integer representing the implementation version.
  79171. * This number does not correspond to the WebXR specs version
  79172. */
  79173. static readonly Version: number;
  79174. /**
  79175. * Observers registered here will be executed when a new anchor was added to the session
  79176. */
  79177. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79178. /**
  79179. * Observers registered here will be executed when an anchor was removed from the session
  79180. */
  79181. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79182. /**
  79183. * Observers registered here will be executed when an existing anchor updates
  79184. * This can execute N times every frame
  79185. */
  79186. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79187. /**
  79188. * Set the reference space to use for anchor creation, when not using a hit test.
  79189. * Will default to the session's reference space if not defined
  79190. */
  79191. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79192. /**
  79193. * constructs a new anchor system
  79194. * @param _xrSessionManager an instance of WebXRSessionManager
  79195. * @param _options configuration object for this feature
  79196. */
  79197. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79198. private _tmpVector;
  79199. private _tmpQuaternion;
  79200. private _populateTmpTransformation;
  79201. /**
  79202. * Create a new anchor point using a hit test result at a specific point in the scene
  79203. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79204. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79205. *
  79206. * @param hitTestResult The hit test result to use for this anchor creation
  79207. * @param position an optional position offset for this anchor
  79208. * @param rotationQuaternion an optional rotation offset for this anchor
  79209. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79210. */
  79211. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79212. /**
  79213. * Add a new anchor at a specific position and rotation
  79214. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79215. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79216. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79217. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79218. *
  79219. * @param position the position in which to add an anchor
  79220. * @param rotationQuaternion an optional rotation for the anchor transformation
  79221. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79222. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79223. */
  79224. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79225. /**
  79226. * detach this feature.
  79227. * Will usually be called by the features manager
  79228. *
  79229. * @returns true if successful.
  79230. */
  79231. detach(): boolean;
  79232. /**
  79233. * Dispose this feature and all of the resources attached
  79234. */
  79235. dispose(): void;
  79236. protected _onXRFrame(frame: XRFrame): void;
  79237. /**
  79238. * avoiding using Array.find for global support.
  79239. * @param xrAnchor the plane to find in the array
  79240. */
  79241. private _findIndexInAnchorArray;
  79242. private _updateAnchorWithXRFrame;
  79243. private _createAnchorAtTransformation;
  79244. }
  79245. }
  79246. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79247. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79248. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79249. import { Observable } from "babylonjs/Misc/observable";
  79250. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79251. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79252. /**
  79253. * Options used in the plane detector module
  79254. */
  79255. export interface IWebXRPlaneDetectorOptions {
  79256. /**
  79257. * The node to use to transform the local results to world coordinates
  79258. */
  79259. worldParentNode?: TransformNode;
  79260. /**
  79261. * If set to true a reference of the created planes will be kept until the next session starts
  79262. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79263. */
  79264. doNotRemovePlanesOnSessionEnded?: boolean;
  79265. }
  79266. /**
  79267. * A babylon interface for a WebXR plane.
  79268. * A Plane is actually a polygon, built from N points in space
  79269. *
  79270. * Supported in chrome 79, not supported in canary 81 ATM
  79271. */
  79272. export interface IWebXRPlane {
  79273. /**
  79274. * a babylon-assigned ID for this polygon
  79275. */
  79276. id: number;
  79277. /**
  79278. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79279. */
  79280. polygonDefinition: Array<Vector3>;
  79281. /**
  79282. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79283. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79284. */
  79285. transformationMatrix: Matrix;
  79286. /**
  79287. * the native xr-plane object
  79288. */
  79289. xrPlane: XRPlane;
  79290. }
  79291. /**
  79292. * The plane detector is used to detect planes in the real world when in AR
  79293. * For more information see https://github.com/immersive-web/real-world-geometry/
  79294. */
  79295. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79296. private _options;
  79297. private _detectedPlanes;
  79298. private _enabled;
  79299. private _lastFrameDetected;
  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. * Observers registered here will be executed when a new plane was added to the session
  79312. */
  79313. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79314. /**
  79315. * Observers registered here will be executed when a plane is no longer detected in the session
  79316. */
  79317. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79318. /**
  79319. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79320. * This can execute N times every frame
  79321. */
  79322. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79323. /**
  79324. * construct a new Plane Detector
  79325. * @param _xrSessionManager an instance of xr Session manager
  79326. * @param _options configuration to use when constructing this feature
  79327. */
  79328. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79329. /**
  79330. * detach this feature.
  79331. * Will usually be called by the features manager
  79332. *
  79333. * @returns true if successful.
  79334. */
  79335. detach(): boolean;
  79336. /**
  79337. * Dispose this feature and all of the resources attached
  79338. */
  79339. dispose(): void;
  79340. protected _onXRFrame(frame: XRFrame): void;
  79341. private _init;
  79342. private _updatePlaneWithXRPlane;
  79343. /**
  79344. * avoiding using Array.find for global support.
  79345. * @param xrPlane the plane to find in the array
  79346. */
  79347. private findIndexInPlaneArray;
  79348. }
  79349. }
  79350. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79351. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79353. import { Observable } from "babylonjs/Misc/observable";
  79354. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79355. /**
  79356. * Options interface for the background remover plugin
  79357. */
  79358. export interface IWebXRBackgroundRemoverOptions {
  79359. /**
  79360. * Further background meshes to disable when entering AR
  79361. */
  79362. backgroundMeshes?: AbstractMesh[];
  79363. /**
  79364. * flags to configure the removal of the environment helper.
  79365. * If not set, the entire background will be removed. If set, flags should be set as well.
  79366. */
  79367. environmentHelperRemovalFlags?: {
  79368. /**
  79369. * Should the skybox be removed (default false)
  79370. */
  79371. skyBox?: boolean;
  79372. /**
  79373. * Should the ground be removed (default false)
  79374. */
  79375. ground?: boolean;
  79376. };
  79377. /**
  79378. * don't disable the environment helper
  79379. */
  79380. ignoreEnvironmentHelper?: boolean;
  79381. }
  79382. /**
  79383. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79384. */
  79385. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79386. /**
  79387. * read-only options to be used in this module
  79388. */
  79389. readonly options: IWebXRBackgroundRemoverOptions;
  79390. /**
  79391. * The module's name
  79392. */
  79393. static readonly Name: string;
  79394. /**
  79395. * The (Babylon) version of this module.
  79396. * This is an integer representing the implementation version.
  79397. * This number does not correspond to the WebXR specs version
  79398. */
  79399. static readonly Version: number;
  79400. /**
  79401. * registered observers will be triggered when the background state changes
  79402. */
  79403. onBackgroundStateChangedObservable: Observable<boolean>;
  79404. /**
  79405. * constructs a new background remover module
  79406. * @param _xrSessionManager the session manager for this module
  79407. * @param options read-only options to be used in this module
  79408. */
  79409. constructor(_xrSessionManager: WebXRSessionManager,
  79410. /**
  79411. * read-only options to be used in this module
  79412. */
  79413. options?: IWebXRBackgroundRemoverOptions);
  79414. /**
  79415. * attach this feature
  79416. * Will usually be called by the features manager
  79417. *
  79418. * @returns true if successful.
  79419. */
  79420. attach(): boolean;
  79421. /**
  79422. * detach this feature.
  79423. * Will usually be called by the features manager
  79424. *
  79425. * @returns true if successful.
  79426. */
  79427. detach(): boolean;
  79428. /**
  79429. * Dispose this feature and all of the resources attached
  79430. */
  79431. dispose(): void;
  79432. protected _onXRFrame(_xrFrame: XRFrame): void;
  79433. private _setBackgroundState;
  79434. }
  79435. }
  79436. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79437. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79438. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79439. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79440. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79441. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79442. import { Nullable } from "babylonjs/types";
  79443. /**
  79444. * Options for the controller physics feature
  79445. */
  79446. export class IWebXRControllerPhysicsOptions {
  79447. /**
  79448. * Should the headset get its own impostor
  79449. */
  79450. enableHeadsetImpostor?: boolean;
  79451. /**
  79452. * Optional parameters for the headset impostor
  79453. */
  79454. headsetImpostorParams?: {
  79455. /**
  79456. * The type of impostor to create. Default is sphere
  79457. */
  79458. impostorType: number;
  79459. /**
  79460. * the size of the impostor. Defaults to 10cm
  79461. */
  79462. impostorSize?: number | {
  79463. width: number;
  79464. height: number;
  79465. depth: number;
  79466. };
  79467. /**
  79468. * Friction definitions
  79469. */
  79470. friction?: number;
  79471. /**
  79472. * Restitution
  79473. */
  79474. restitution?: number;
  79475. };
  79476. /**
  79477. * The physics properties of the future impostors
  79478. */
  79479. physicsProperties?: {
  79480. /**
  79481. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79482. * Note that this requires a physics engine that supports mesh impostors!
  79483. */
  79484. useControllerMesh?: boolean;
  79485. /**
  79486. * The type of impostor to create. Default is sphere
  79487. */
  79488. impostorType?: number;
  79489. /**
  79490. * the size of the impostor. Defaults to 10cm
  79491. */
  79492. impostorSize?: number | {
  79493. width: number;
  79494. height: number;
  79495. depth: number;
  79496. };
  79497. /**
  79498. * Friction definitions
  79499. */
  79500. friction?: number;
  79501. /**
  79502. * Restitution
  79503. */
  79504. restitution?: number;
  79505. };
  79506. /**
  79507. * the xr input to use with this pointer selection
  79508. */
  79509. xrInput: WebXRInput;
  79510. }
  79511. /**
  79512. * Add physics impostor to your webxr controllers,
  79513. * including naive calculation of their linear and angular velocity
  79514. */
  79515. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79516. private readonly _options;
  79517. private _attachController;
  79518. private _controllers;
  79519. private _debugMode;
  79520. private _delta;
  79521. private _headsetImpostor?;
  79522. private _headsetMesh?;
  79523. private _lastTimestamp;
  79524. private _tmpQuaternion;
  79525. private _tmpVector;
  79526. /**
  79527. * The module's name
  79528. */
  79529. static readonly Name: string;
  79530. /**
  79531. * The (Babylon) version of this module.
  79532. * This is an integer representing the implementation version.
  79533. * This number does not correspond to the webxr specs version
  79534. */
  79535. static readonly Version: number;
  79536. /**
  79537. * Construct a new Controller Physics Feature
  79538. * @param _xrSessionManager the corresponding xr session manager
  79539. * @param _options options to create this feature with
  79540. */
  79541. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79542. /**
  79543. * @hidden
  79544. * enable debugging - will show console outputs and the impostor mesh
  79545. */
  79546. _enablePhysicsDebug(): void;
  79547. /**
  79548. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79549. * @param xrController the controller to add
  79550. */
  79551. addController(xrController: WebXRInputSource): void;
  79552. /**
  79553. * attach this feature
  79554. * Will usually be called by the features manager
  79555. *
  79556. * @returns true if successful.
  79557. */
  79558. attach(): boolean;
  79559. /**
  79560. * detach this feature.
  79561. * Will usually be called by the features manager
  79562. *
  79563. * @returns true if successful.
  79564. */
  79565. detach(): boolean;
  79566. /**
  79567. * Get the headset impostor, if enabled
  79568. * @returns the impostor
  79569. */
  79570. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79571. /**
  79572. * Get the physics impostor of a specific controller.
  79573. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79574. * @param controller the controller or the controller id of which to get the impostor
  79575. * @returns the impostor or null
  79576. */
  79577. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79578. /**
  79579. * Update the physics properties provided in the constructor
  79580. * @param newProperties the new properties object
  79581. */
  79582. setPhysicsProperties(newProperties: {
  79583. impostorType?: number;
  79584. impostorSize?: number | {
  79585. width: number;
  79586. height: number;
  79587. depth: number;
  79588. };
  79589. friction?: number;
  79590. restitution?: number;
  79591. }): void;
  79592. protected _onXRFrame(_xrFrame: any): void;
  79593. private _detachController;
  79594. }
  79595. }
  79596. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79597. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79598. import { Observable } from "babylonjs/Misc/observable";
  79599. import { Vector3 } from "babylonjs/Maths/math.vector";
  79600. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79601. /**
  79602. * A babylon interface for a "WebXR" feature point.
  79603. * Represents the position and confidence value of a given feature point.
  79604. */
  79605. export interface IWebXRFeaturePoint {
  79606. /**
  79607. * Represents the position of the feature point in world space.
  79608. */
  79609. position: Vector3;
  79610. /**
  79611. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79612. */
  79613. confidenceValue: number;
  79614. }
  79615. /**
  79616. * The feature point system is used to detect feature points from real world geometry.
  79617. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79618. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79619. */
  79620. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79621. private _enabled;
  79622. private _featurePointCloud;
  79623. /**
  79624. * The module's name
  79625. */
  79626. static readonly Name: string;
  79627. /**
  79628. * The (Babylon) version of this module.
  79629. * This is an integer representing the implementation version.
  79630. * This number does not correspond to the WebXR specs version
  79631. */
  79632. static readonly Version: number;
  79633. /**
  79634. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79635. * Will notify the observers about which feature points have been added.
  79636. */
  79637. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79638. /**
  79639. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79640. * Will notify the observers about which feature points have been updated.
  79641. */
  79642. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79643. /**
  79644. * The current feature point cloud maintained across frames.
  79645. */
  79646. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79647. /**
  79648. * construct the feature point system
  79649. * @param _xrSessionManager an instance of xr Session manager
  79650. */
  79651. constructor(_xrSessionManager: WebXRSessionManager);
  79652. /**
  79653. * Detach this feature.
  79654. * Will usually be called by the features manager
  79655. *
  79656. * @returns true if successful.
  79657. */
  79658. detach(): boolean;
  79659. /**
  79660. * Dispose this feature and all of the resources attached
  79661. */
  79662. dispose(): void;
  79663. /**
  79664. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79665. */
  79666. protected _onXRFrame(frame: XRFrame): void;
  79667. /**
  79668. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79669. */
  79670. private _init;
  79671. }
  79672. }
  79673. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79674. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79675. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79677. import { Mesh } from "babylonjs/Meshes/mesh";
  79678. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79679. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79680. import { Nullable } from "babylonjs/types";
  79681. import { IDisposable } from "babylonjs/scene";
  79682. import { Observable } from "babylonjs/Misc/observable";
  79683. /**
  79684. * Configuration interface for the hand tracking feature
  79685. */
  79686. export interface IWebXRHandTrackingOptions {
  79687. /**
  79688. * The xrInput that will be used as source for new hands
  79689. */
  79690. xrInput: WebXRInput;
  79691. /**
  79692. * Configuration object for the joint meshes
  79693. */
  79694. jointMeshes?: {
  79695. /**
  79696. * Should the meshes created be invisible (defaults to false)
  79697. */
  79698. invisible?: boolean;
  79699. /**
  79700. * A source mesh to be used to create instances. Defaults to a sphere.
  79701. * This mesh will be the source for all other (25) meshes.
  79702. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79703. */
  79704. sourceMesh?: Mesh;
  79705. /**
  79706. * Should the source mesh stay visible. Defaults to false
  79707. */
  79708. keepOriginalVisible?: boolean;
  79709. /**
  79710. * Scale factor for all instances (defaults to 2)
  79711. */
  79712. scaleFactor?: number;
  79713. /**
  79714. * Should each instance have its own physics impostor
  79715. */
  79716. enablePhysics?: boolean;
  79717. /**
  79718. * If enabled, override default physics properties
  79719. */
  79720. physicsProps?: {
  79721. friction?: number;
  79722. restitution?: number;
  79723. impostorType?: number;
  79724. };
  79725. /**
  79726. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79727. */
  79728. handMesh?: AbstractMesh;
  79729. };
  79730. }
  79731. /**
  79732. * Parts of the hands divided to writs and finger names
  79733. */
  79734. export const enum HandPart {
  79735. /**
  79736. * HandPart - Wrist
  79737. */
  79738. WRIST = "wrist",
  79739. /**
  79740. * HandPart - The THumb
  79741. */
  79742. THUMB = "thumb",
  79743. /**
  79744. * HandPart - Index finger
  79745. */
  79746. INDEX = "index",
  79747. /**
  79748. * HandPart - Middle finger
  79749. */
  79750. MIDDLE = "middle",
  79751. /**
  79752. * HandPart - Ring finger
  79753. */
  79754. RING = "ring",
  79755. /**
  79756. * HandPart - Little finger
  79757. */
  79758. LITTLE = "little"
  79759. }
  79760. /**
  79761. * Representing a single hand (with its corresponding native XRHand object)
  79762. */
  79763. export class WebXRHand implements IDisposable {
  79764. /** the controller to which the hand correlates */
  79765. readonly xrController: WebXRInputSource;
  79766. /** the meshes to be used to track the hand joints */
  79767. readonly trackedMeshes: AbstractMesh[];
  79768. /**
  79769. * Hand-parts definition (key is HandPart)
  79770. */
  79771. handPartsDefinition: {
  79772. [key: string]: number[];
  79773. };
  79774. /**
  79775. * Populate the HandPartsDefinition object.
  79776. * This is called as a side effect since certain browsers don't have XRHand defined.
  79777. */
  79778. private generateHandPartsDefinition;
  79779. /**
  79780. * Construct a new hand object
  79781. * @param xrController the controller to which the hand correlates
  79782. * @param trackedMeshes the meshes to be used to track the hand joints
  79783. */
  79784. constructor(
  79785. /** the controller to which the hand correlates */
  79786. xrController: WebXRInputSource,
  79787. /** the meshes to be used to track the hand joints */
  79788. trackedMeshes: AbstractMesh[]);
  79789. /**
  79790. * Update this hand from the latest xr frame
  79791. * @param xrFrame xrFrame to update from
  79792. * @param referenceSpace The current viewer reference space
  79793. * @param scaleFactor optional scale factor for the meshes
  79794. */
  79795. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79796. /**
  79797. * Get meshes of part of the hand
  79798. * @param part the part of hand to get
  79799. * @returns An array of meshes that correlate to the hand part requested
  79800. */
  79801. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79802. /**
  79803. * Dispose this Hand object
  79804. */
  79805. dispose(): void;
  79806. }
  79807. /**
  79808. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79809. */
  79810. export class WebXRHandTracking extends WebXRAbstractFeature {
  79811. /**
  79812. * options to use when constructing this feature
  79813. */
  79814. readonly options: IWebXRHandTrackingOptions;
  79815. private static _idCounter;
  79816. /**
  79817. * The module's name
  79818. */
  79819. static readonly Name: string;
  79820. /**
  79821. * The (Babylon) version of this module.
  79822. * This is an integer representing the implementation version.
  79823. * This number does not correspond to the WebXR specs version
  79824. */
  79825. static readonly Version: number;
  79826. /**
  79827. * This observable will notify registered observers when a new hand object was added and initialized
  79828. */
  79829. onHandAddedObservable: Observable<WebXRHand>;
  79830. /**
  79831. * This observable will notify its observers right before the hand object is disposed
  79832. */
  79833. onHandRemovedObservable: Observable<WebXRHand>;
  79834. private _hands;
  79835. /**
  79836. * Creates a new instance of the hit test feature
  79837. * @param _xrSessionManager an instance of WebXRSessionManager
  79838. * @param options options to use when constructing this feature
  79839. */
  79840. constructor(_xrSessionManager: WebXRSessionManager,
  79841. /**
  79842. * options to use when constructing this feature
  79843. */
  79844. options: IWebXRHandTrackingOptions);
  79845. /**
  79846. * Check if the needed objects are defined.
  79847. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79848. */
  79849. isCompatible(): boolean;
  79850. /**
  79851. * attach this feature
  79852. * Will usually be called by the features manager
  79853. *
  79854. * @returns true if successful.
  79855. */
  79856. attach(): boolean;
  79857. /**
  79858. * detach this feature.
  79859. * Will usually be called by the features manager
  79860. *
  79861. * @returns true if successful.
  79862. */
  79863. detach(): boolean;
  79864. /**
  79865. * Dispose this feature and all of the resources attached
  79866. */
  79867. dispose(): void;
  79868. /**
  79869. * Get the hand object according to the controller id
  79870. * @param controllerId the controller id to which we want to get the hand
  79871. * @returns null if not found or the WebXRHand object if found
  79872. */
  79873. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79874. /**
  79875. * Get a hand object according to the requested handedness
  79876. * @param handedness the handedness to request
  79877. * @returns null if not found or the WebXRHand object if found
  79878. */
  79879. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79880. protected _onXRFrame(_xrFrame: XRFrame): void;
  79881. private _attachHand;
  79882. private _detachHand;
  79883. }
  79884. }
  79885. declare module "babylonjs/XR/features/index" {
  79886. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79887. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79888. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79889. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79890. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79891. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79892. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79893. export * from "babylonjs/XR/features/WebXRHitTest";
  79894. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79895. export * from "babylonjs/XR/features/WebXRHandTracking";
  79896. }
  79897. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79898. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79900. import { Scene } from "babylonjs/scene";
  79901. /**
  79902. * The motion controller class for all microsoft mixed reality controllers
  79903. */
  79904. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79905. protected readonly _mapping: {
  79906. defaultButton: {
  79907. valueNodeName: string;
  79908. unpressedNodeName: string;
  79909. pressedNodeName: string;
  79910. };
  79911. defaultAxis: {
  79912. valueNodeName: string;
  79913. minNodeName: string;
  79914. maxNodeName: string;
  79915. };
  79916. buttons: {
  79917. "xr-standard-trigger": {
  79918. rootNodeName: string;
  79919. componentProperty: string;
  79920. states: string[];
  79921. };
  79922. "xr-standard-squeeze": {
  79923. rootNodeName: string;
  79924. componentProperty: string;
  79925. states: string[];
  79926. };
  79927. "xr-standard-touchpad": {
  79928. rootNodeName: string;
  79929. labelAnchorNodeName: string;
  79930. touchPointNodeName: string;
  79931. };
  79932. "xr-standard-thumbstick": {
  79933. rootNodeName: string;
  79934. componentProperty: string;
  79935. states: string[];
  79936. };
  79937. };
  79938. axes: {
  79939. "xr-standard-touchpad": {
  79940. "x-axis": {
  79941. rootNodeName: string;
  79942. };
  79943. "y-axis": {
  79944. rootNodeName: string;
  79945. };
  79946. };
  79947. "xr-standard-thumbstick": {
  79948. "x-axis": {
  79949. rootNodeName: string;
  79950. };
  79951. "y-axis": {
  79952. rootNodeName: string;
  79953. };
  79954. };
  79955. };
  79956. };
  79957. /**
  79958. * The base url used to load the left and right controller models
  79959. */
  79960. static MODEL_BASE_URL: string;
  79961. /**
  79962. * The name of the left controller model file
  79963. */
  79964. static MODEL_LEFT_FILENAME: string;
  79965. /**
  79966. * The name of the right controller model file
  79967. */
  79968. static MODEL_RIGHT_FILENAME: string;
  79969. profileId: string;
  79970. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79971. protected _getFilenameAndPath(): {
  79972. filename: string;
  79973. path: string;
  79974. };
  79975. protected _getModelLoadingConstraints(): boolean;
  79976. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79977. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79978. protected _updateModel(): void;
  79979. }
  79980. }
  79981. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  79982. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79984. import { Scene } from "babylonjs/scene";
  79985. /**
  79986. * The motion controller class for oculus touch (quest, rift).
  79987. * This class supports legacy mapping as well the standard xr mapping
  79988. */
  79989. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  79990. private _forceLegacyControllers;
  79991. private _modelRootNode;
  79992. /**
  79993. * The base url used to load the left and right controller models
  79994. */
  79995. static MODEL_BASE_URL: string;
  79996. /**
  79997. * The name of the left controller model file
  79998. */
  79999. static MODEL_LEFT_FILENAME: string;
  80000. /**
  80001. * The name of the right controller model file
  80002. */
  80003. static MODEL_RIGHT_FILENAME: string;
  80004. /**
  80005. * Base Url for the Quest controller model.
  80006. */
  80007. static QUEST_MODEL_BASE_URL: string;
  80008. profileId: string;
  80009. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80010. protected _getFilenameAndPath(): {
  80011. filename: string;
  80012. path: string;
  80013. };
  80014. protected _getModelLoadingConstraints(): boolean;
  80015. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80016. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80017. protected _updateModel(): void;
  80018. /**
  80019. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80020. * between the touch and touch 2.
  80021. */
  80022. private _isQuest;
  80023. }
  80024. }
  80025. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80026. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80027. import { Scene } from "babylonjs/scene";
  80028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80029. /**
  80030. * The motion controller class for the standard HTC-Vive controllers
  80031. */
  80032. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80033. private _modelRootNode;
  80034. /**
  80035. * The base url used to load the left and right controller models
  80036. */
  80037. static MODEL_BASE_URL: string;
  80038. /**
  80039. * File name for the controller model.
  80040. */
  80041. static MODEL_FILENAME: string;
  80042. profileId: string;
  80043. /**
  80044. * Create a new Vive motion controller object
  80045. * @param scene the scene to use to create this controller
  80046. * @param gamepadObject the corresponding gamepad object
  80047. * @param handedness the handedness of the controller
  80048. */
  80049. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80050. protected _getFilenameAndPath(): {
  80051. filename: string;
  80052. path: string;
  80053. };
  80054. protected _getModelLoadingConstraints(): boolean;
  80055. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80056. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80057. protected _updateModel(): void;
  80058. }
  80059. }
  80060. declare module "babylonjs/XR/motionController/index" {
  80061. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80062. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80063. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80064. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80065. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80066. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80067. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80068. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80069. }
  80070. declare module "babylonjs/XR/index" {
  80071. export * from "babylonjs/XR/webXRCamera";
  80072. export * from "babylonjs/XR/webXREnterExitUI";
  80073. export * from "babylonjs/XR/webXRExperienceHelper";
  80074. export * from "babylonjs/XR/webXRInput";
  80075. export * from "babylonjs/XR/webXRInputSource";
  80076. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80077. export * from "babylonjs/XR/webXRTypes";
  80078. export * from "babylonjs/XR/webXRSessionManager";
  80079. export * from "babylonjs/XR/webXRDefaultExperience";
  80080. export * from "babylonjs/XR/webXRFeaturesManager";
  80081. export * from "babylonjs/XR/features/index";
  80082. export * from "babylonjs/XR/motionController/index";
  80083. }
  80084. declare module "babylonjs/index" {
  80085. export * from "babylonjs/abstractScene";
  80086. export * from "babylonjs/Actions/index";
  80087. export * from "babylonjs/Animations/index";
  80088. export * from "babylonjs/assetContainer";
  80089. export * from "babylonjs/Audio/index";
  80090. export * from "babylonjs/Behaviors/index";
  80091. export * from "babylonjs/Bones/index";
  80092. export * from "babylonjs/Cameras/index";
  80093. export * from "babylonjs/Collisions/index";
  80094. export * from "babylonjs/Culling/index";
  80095. export * from "babylonjs/Debug/index";
  80096. export * from "babylonjs/DeviceInput/index";
  80097. export * from "babylonjs/Engines/index";
  80098. export * from "babylonjs/Events/index";
  80099. export * from "babylonjs/Gamepads/index";
  80100. export * from "babylonjs/Gizmos/index";
  80101. export * from "babylonjs/Helpers/index";
  80102. export * from "babylonjs/Instrumentation/index";
  80103. export * from "babylonjs/Layers/index";
  80104. export * from "babylonjs/LensFlares/index";
  80105. export * from "babylonjs/Lights/index";
  80106. export * from "babylonjs/Loading/index";
  80107. export * from "babylonjs/Materials/index";
  80108. export * from "babylonjs/Maths/index";
  80109. export * from "babylonjs/Meshes/index";
  80110. export * from "babylonjs/Morph/index";
  80111. export * from "babylonjs/Navigation/index";
  80112. export * from "babylonjs/node";
  80113. export * from "babylonjs/Offline/index";
  80114. export * from "babylonjs/Particles/index";
  80115. export * from "babylonjs/Physics/index";
  80116. export * from "babylonjs/PostProcesses/index";
  80117. export * from "babylonjs/Probes/index";
  80118. export * from "babylonjs/Rendering/index";
  80119. export * from "babylonjs/scene";
  80120. export * from "babylonjs/sceneComponent";
  80121. export * from "babylonjs/Sprites/index";
  80122. export * from "babylonjs/States/index";
  80123. export * from "babylonjs/Misc/index";
  80124. export * from "babylonjs/XR/index";
  80125. export * from "babylonjs/types";
  80126. }
  80127. declare module "babylonjs/Animations/pathCursor" {
  80128. import { Vector3 } from "babylonjs/Maths/math.vector";
  80129. import { Path2 } from "babylonjs/Maths/math.path";
  80130. /**
  80131. * A cursor which tracks a point on a path
  80132. */
  80133. export class PathCursor {
  80134. private path;
  80135. /**
  80136. * Stores path cursor callbacks for when an onchange event is triggered
  80137. */
  80138. private _onchange;
  80139. /**
  80140. * The value of the path cursor
  80141. */
  80142. value: number;
  80143. /**
  80144. * The animation array of the path cursor
  80145. */
  80146. animations: Animation[];
  80147. /**
  80148. * Initializes the path cursor
  80149. * @param path The path to track
  80150. */
  80151. constructor(path: Path2);
  80152. /**
  80153. * Gets the cursor point on the path
  80154. * @returns A point on the path cursor at the cursor location
  80155. */
  80156. getPoint(): Vector3;
  80157. /**
  80158. * Moves the cursor ahead by the step amount
  80159. * @param step The amount to move the cursor forward
  80160. * @returns This path cursor
  80161. */
  80162. moveAhead(step?: number): PathCursor;
  80163. /**
  80164. * Moves the cursor behind by the step amount
  80165. * @param step The amount to move the cursor back
  80166. * @returns This path cursor
  80167. */
  80168. moveBack(step?: number): PathCursor;
  80169. /**
  80170. * Moves the cursor by the step amount
  80171. * If the step amount is greater than one, an exception is thrown
  80172. * @param step The amount to move the cursor
  80173. * @returns This path cursor
  80174. */
  80175. move(step: number): PathCursor;
  80176. /**
  80177. * Ensures that the value is limited between zero and one
  80178. * @returns This path cursor
  80179. */
  80180. private ensureLimits;
  80181. /**
  80182. * Runs onchange callbacks on change (used by the animation engine)
  80183. * @returns This path cursor
  80184. */
  80185. private raiseOnChange;
  80186. /**
  80187. * Executes a function on change
  80188. * @param f A path cursor onchange callback
  80189. * @returns This path cursor
  80190. */
  80191. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80192. }
  80193. }
  80194. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80195. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80196. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80197. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80198. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80199. }
  80200. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80201. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80202. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80203. }
  80204. declare module "babylonjs/Engines/Processors/index" {
  80205. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80206. export * from "babylonjs/Engines/Processors/Expressions/index";
  80207. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80208. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80209. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80210. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80211. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80212. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80213. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80214. }
  80215. declare module "babylonjs/Legacy/legacy" {
  80216. import * as Babylon from "babylonjs/index";
  80217. export * from "babylonjs/index";
  80218. }
  80219. declare module "babylonjs/Shaders/blur.fragment" {
  80220. /** @hidden */
  80221. export var blurPixelShader: {
  80222. name: string;
  80223. shader: string;
  80224. };
  80225. }
  80226. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80227. /** @hidden */
  80228. export var pointCloudVertexDeclaration: {
  80229. name: string;
  80230. shader: string;
  80231. };
  80232. }
  80233. declare module "babylonjs" {
  80234. export * from "babylonjs/Legacy/legacy";
  80235. }
  80236. declare module BABYLON {
  80237. /** Alias type for value that can be null */
  80238. export type Nullable<T> = T | null;
  80239. /**
  80240. * Alias type for number that are floats
  80241. * @ignorenaming
  80242. */
  80243. export type float = number;
  80244. /**
  80245. * Alias type for number that are doubles.
  80246. * @ignorenaming
  80247. */
  80248. export type double = number;
  80249. /**
  80250. * Alias type for number that are integer
  80251. * @ignorenaming
  80252. */
  80253. export type int = number;
  80254. /** Alias type for number array or Float32Array */
  80255. export type FloatArray = number[] | Float32Array;
  80256. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80257. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80258. /**
  80259. * Alias for types that can be used by a Buffer or VertexBuffer.
  80260. */
  80261. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80262. /**
  80263. * Alias type for primitive types
  80264. * @ignorenaming
  80265. */
  80266. type Primitive = undefined | null | boolean | string | number | Function;
  80267. /**
  80268. * Type modifier to make all the properties of an object Readonly
  80269. */
  80270. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80271. /**
  80272. * Type modifier to make all the properties of an object Readonly recursively
  80273. */
  80274. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80275. /**
  80276. * Type modifier to make object properties readonly.
  80277. */
  80278. export type DeepImmutableObject<T> = {
  80279. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80280. };
  80281. /** @hidden */
  80282. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80283. }
  80284. }
  80285. declare module BABYLON {
  80286. /**
  80287. * A class serves as a medium between the observable and its observers
  80288. */
  80289. export class EventState {
  80290. /**
  80291. * Create a new EventState
  80292. * @param mask defines the mask associated with this state
  80293. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80294. * @param target defines the original target of the state
  80295. * @param currentTarget defines the current target of the state
  80296. */
  80297. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80298. /**
  80299. * Initialize the current event state
  80300. * @param mask defines the mask associated with this state
  80301. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80302. * @param target defines the original target of the state
  80303. * @param currentTarget defines the current target of the state
  80304. * @returns the current event state
  80305. */
  80306. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80307. /**
  80308. * An Observer can set this property to true to prevent subsequent observers of being notified
  80309. */
  80310. skipNextObservers: boolean;
  80311. /**
  80312. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80313. */
  80314. mask: number;
  80315. /**
  80316. * The object that originally notified the event
  80317. */
  80318. target?: any;
  80319. /**
  80320. * The current object in the bubbling phase
  80321. */
  80322. currentTarget?: any;
  80323. /**
  80324. * This will be populated with the return value of the last function that was executed.
  80325. * If it is the first function in the callback chain it will be the event data.
  80326. */
  80327. lastReturnValue?: any;
  80328. }
  80329. /**
  80330. * Represent an Observer registered to a given Observable object.
  80331. */
  80332. export class Observer<T> {
  80333. /**
  80334. * Defines the callback to call when the observer is notified
  80335. */
  80336. callback: (eventData: T, eventState: EventState) => void;
  80337. /**
  80338. * Defines the mask of the observer (used to filter notifications)
  80339. */
  80340. mask: number;
  80341. /**
  80342. * Defines the current scope used to restore the JS context
  80343. */
  80344. scope: any;
  80345. /** @hidden */
  80346. _willBeUnregistered: boolean;
  80347. /**
  80348. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80349. */
  80350. unregisterOnNextCall: boolean;
  80351. /**
  80352. * Creates a new observer
  80353. * @param callback defines the callback to call when the observer is notified
  80354. * @param mask defines the mask of the observer (used to filter notifications)
  80355. * @param scope defines the current scope used to restore the JS context
  80356. */
  80357. constructor(
  80358. /**
  80359. * Defines the callback to call when the observer is notified
  80360. */
  80361. callback: (eventData: T, eventState: EventState) => void,
  80362. /**
  80363. * Defines the mask of the observer (used to filter notifications)
  80364. */
  80365. mask: number,
  80366. /**
  80367. * Defines the current scope used to restore the JS context
  80368. */
  80369. scope?: any);
  80370. }
  80371. /**
  80372. * Represent a list of observers registered to multiple Observables object.
  80373. */
  80374. export class MultiObserver<T> {
  80375. private _observers;
  80376. private _observables;
  80377. /**
  80378. * Release associated resources
  80379. */
  80380. dispose(): void;
  80381. /**
  80382. * Raise a callback when one of the observable will notify
  80383. * @param observables defines a list of observables to watch
  80384. * @param callback defines the callback to call on notification
  80385. * @param mask defines the mask used to filter notifications
  80386. * @param scope defines the current scope used to restore the JS context
  80387. * @returns the new MultiObserver
  80388. */
  80389. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80390. }
  80391. /**
  80392. * The Observable class is a simple implementation of the Observable pattern.
  80393. *
  80394. * 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.
  80395. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80396. * 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).
  80397. * 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.
  80398. */
  80399. export class Observable<T> {
  80400. private _observers;
  80401. private _eventState;
  80402. private _onObserverAdded;
  80403. /**
  80404. * Gets the list of observers
  80405. */
  80406. get observers(): Array<Observer<T>>;
  80407. /**
  80408. * Creates a new observable
  80409. * @param onObserverAdded defines a callback to call when a new observer is added
  80410. */
  80411. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80412. /**
  80413. * Create a new Observer with the specified callback
  80414. * @param callback the callback that will be executed for that Observer
  80415. * @param mask the mask used to filter observers
  80416. * @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.
  80417. * @param scope optional scope for the callback to be called from
  80418. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80419. * @returns the new observer created for the callback
  80420. */
  80421. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80422. /**
  80423. * Create a new Observer with the specified callback and unregisters after the next notification
  80424. * @param callback the callback that will be executed for that Observer
  80425. * @returns the new observer created for the callback
  80426. */
  80427. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80428. /**
  80429. * Remove an Observer from the Observable object
  80430. * @param observer the instance of the Observer to remove
  80431. * @returns false if it doesn't belong to this Observable
  80432. */
  80433. remove(observer: Nullable<Observer<T>>): boolean;
  80434. /**
  80435. * Remove a callback from the Observable object
  80436. * @param callback the callback to remove
  80437. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80438. * @returns false if it doesn't belong to this Observable
  80439. */
  80440. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80441. private _deferUnregister;
  80442. private _remove;
  80443. /**
  80444. * Moves the observable to the top of the observer list making it get called first when notified
  80445. * @param observer the observer to move
  80446. */
  80447. makeObserverTopPriority(observer: Observer<T>): void;
  80448. /**
  80449. * Moves the observable to the bottom of the observer list making it get called last when notified
  80450. * @param observer the observer to move
  80451. */
  80452. makeObserverBottomPriority(observer: Observer<T>): void;
  80453. /**
  80454. * Notify all Observers by calling their respective callback with the given data
  80455. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80456. * @param eventData defines the data to send to all observers
  80457. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80458. * @param target defines the original target of the state
  80459. * @param currentTarget defines the current target of the state
  80460. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80461. */
  80462. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80463. /**
  80464. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80465. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80466. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80467. * and it is crucial that all callbacks will be executed.
  80468. * The order of the callbacks is kept, callbacks are not executed parallel.
  80469. *
  80470. * @param eventData The data to be sent to each callback
  80471. * @param mask is used to filter observers defaults to -1
  80472. * @param target defines the callback target (see EventState)
  80473. * @param currentTarget defines he current object in the bubbling phase
  80474. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80475. */
  80476. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80477. /**
  80478. * Notify a specific observer
  80479. * @param observer defines the observer to notify
  80480. * @param eventData defines the data to be sent to each callback
  80481. * @param mask is used to filter observers defaults to -1
  80482. */
  80483. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80484. /**
  80485. * Gets a boolean indicating if the observable has at least one observer
  80486. * @returns true is the Observable has at least one Observer registered
  80487. */
  80488. hasObservers(): boolean;
  80489. /**
  80490. * Clear the list of observers
  80491. */
  80492. clear(): void;
  80493. /**
  80494. * Clone the current observable
  80495. * @returns a new observable
  80496. */
  80497. clone(): Observable<T>;
  80498. /**
  80499. * Does this observable handles observer registered with a given mask
  80500. * @param mask defines the mask to be tested
  80501. * @return whether or not one observer registered with the given mask is handeled
  80502. **/
  80503. hasSpecificMask(mask?: number): boolean;
  80504. }
  80505. }
  80506. declare module BABYLON {
  80507. /**
  80508. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80509. * Babylon.js
  80510. */
  80511. export class DomManagement {
  80512. /**
  80513. * Checks if the window object exists
  80514. * @returns true if the window object exists
  80515. */
  80516. static IsWindowObjectExist(): boolean;
  80517. /**
  80518. * Checks if the navigator object exists
  80519. * @returns true if the navigator object exists
  80520. */
  80521. static IsNavigatorAvailable(): boolean;
  80522. /**
  80523. * Check if the document object exists
  80524. * @returns true if the document object exists
  80525. */
  80526. static IsDocumentAvailable(): boolean;
  80527. /**
  80528. * Extracts text content from a DOM element hierarchy
  80529. * @param element defines the root element
  80530. * @returns a string
  80531. */
  80532. static GetDOMTextContent(element: HTMLElement): string;
  80533. }
  80534. }
  80535. declare module BABYLON {
  80536. /**
  80537. * Logger used througouht the application to allow configuration of
  80538. * the log level required for the messages.
  80539. */
  80540. export class Logger {
  80541. /**
  80542. * No log
  80543. */
  80544. static readonly NoneLogLevel: number;
  80545. /**
  80546. * Only message logs
  80547. */
  80548. static readonly MessageLogLevel: number;
  80549. /**
  80550. * Only warning logs
  80551. */
  80552. static readonly WarningLogLevel: number;
  80553. /**
  80554. * Only error logs
  80555. */
  80556. static readonly ErrorLogLevel: number;
  80557. /**
  80558. * All logs
  80559. */
  80560. static readonly AllLogLevel: number;
  80561. private static _LogCache;
  80562. /**
  80563. * Gets a value indicating the number of loading errors
  80564. * @ignorenaming
  80565. */
  80566. static errorsCount: number;
  80567. /**
  80568. * Callback called when a new log is added
  80569. */
  80570. static OnNewCacheEntry: (entry: string) => void;
  80571. private static _AddLogEntry;
  80572. private static _FormatMessage;
  80573. private static _LogDisabled;
  80574. private static _LogEnabled;
  80575. private static _WarnDisabled;
  80576. private static _WarnEnabled;
  80577. private static _ErrorDisabled;
  80578. private static _ErrorEnabled;
  80579. /**
  80580. * Log a message to the console
  80581. */
  80582. static Log: (message: string) => void;
  80583. /**
  80584. * Write a warning message to the console
  80585. */
  80586. static Warn: (message: string) => void;
  80587. /**
  80588. * Write an error message to the console
  80589. */
  80590. static Error: (message: string) => void;
  80591. /**
  80592. * Gets current log cache (list of logs)
  80593. */
  80594. static get LogCache(): string;
  80595. /**
  80596. * Clears the log cache
  80597. */
  80598. static ClearLogCache(): void;
  80599. /**
  80600. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80601. */
  80602. static set LogLevels(level: number);
  80603. }
  80604. }
  80605. declare module BABYLON {
  80606. /** @hidden */
  80607. export class _TypeStore {
  80608. /** @hidden */
  80609. static RegisteredTypes: {
  80610. [key: string]: Object;
  80611. };
  80612. /** @hidden */
  80613. static GetClass(fqdn: string): any;
  80614. }
  80615. }
  80616. declare module BABYLON {
  80617. /**
  80618. * Helper to manipulate strings
  80619. */
  80620. export class StringTools {
  80621. /**
  80622. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80623. * @param str Source string
  80624. * @param suffix Suffix to search for in the source string
  80625. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80626. */
  80627. static EndsWith(str: string, suffix: string): boolean;
  80628. /**
  80629. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80630. * @param str Source string
  80631. * @param suffix Suffix to search for in the source string
  80632. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80633. */
  80634. static StartsWith(str: string, suffix: string): boolean;
  80635. /**
  80636. * Decodes a buffer into a string
  80637. * @param buffer The buffer to decode
  80638. * @returns The decoded string
  80639. */
  80640. static Decode(buffer: Uint8Array | Uint16Array): string;
  80641. /**
  80642. * Encode a buffer to a base64 string
  80643. * @param buffer defines the buffer to encode
  80644. * @returns the encoded string
  80645. */
  80646. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80647. /**
  80648. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80649. * @param num the number to convert and pad
  80650. * @param length the expected length of the string
  80651. * @returns the padded string
  80652. */
  80653. static PadNumber(num: number, length: number): string;
  80654. }
  80655. }
  80656. declare module BABYLON {
  80657. /**
  80658. * Class containing a set of static utilities functions for deep copy.
  80659. */
  80660. export class DeepCopier {
  80661. /**
  80662. * Tries to copy an object by duplicating every property
  80663. * @param source defines the source object
  80664. * @param destination defines the target object
  80665. * @param doNotCopyList defines a list of properties to avoid
  80666. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80667. */
  80668. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80669. }
  80670. }
  80671. declare module BABYLON {
  80672. /**
  80673. * Class containing a set of static utilities functions for precision date
  80674. */
  80675. export class PrecisionDate {
  80676. /**
  80677. * Gets either window.performance.now() if supported or Date.now() else
  80678. */
  80679. static get Now(): number;
  80680. }
  80681. }
  80682. declare module BABYLON {
  80683. /** @hidden */
  80684. export class _DevTools {
  80685. static WarnImport(name: string): string;
  80686. }
  80687. }
  80688. declare module BABYLON {
  80689. /**
  80690. * Interface used to define the mechanism to get data from the network
  80691. */
  80692. export interface IWebRequest {
  80693. /**
  80694. * Returns client's response url
  80695. */
  80696. responseURL: string;
  80697. /**
  80698. * Returns client's status
  80699. */
  80700. status: number;
  80701. /**
  80702. * Returns client's status as a text
  80703. */
  80704. statusText: string;
  80705. }
  80706. }
  80707. declare module BABYLON {
  80708. /**
  80709. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80710. */
  80711. export class WebRequest implements IWebRequest {
  80712. private _xhr;
  80713. /**
  80714. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80715. * i.e. when loading files, where the server/service expects an Authorization header
  80716. */
  80717. static CustomRequestHeaders: {
  80718. [key: string]: string;
  80719. };
  80720. /**
  80721. * Add callback functions in this array to update all the requests before they get sent to the network
  80722. */
  80723. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80724. private _injectCustomRequestHeaders;
  80725. /**
  80726. * Gets or sets a function to be called when loading progress changes
  80727. */
  80728. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80729. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80730. /**
  80731. * Returns client's state
  80732. */
  80733. get readyState(): number;
  80734. /**
  80735. * Returns client's status
  80736. */
  80737. get status(): number;
  80738. /**
  80739. * Returns client's status as a text
  80740. */
  80741. get statusText(): string;
  80742. /**
  80743. * Returns client's response
  80744. */
  80745. get response(): any;
  80746. /**
  80747. * Returns client's response url
  80748. */
  80749. get responseURL(): string;
  80750. /**
  80751. * Returns client's response as text
  80752. */
  80753. get responseText(): string;
  80754. /**
  80755. * Gets or sets the expected response type
  80756. */
  80757. get responseType(): XMLHttpRequestResponseType;
  80758. set responseType(value: XMLHttpRequestResponseType);
  80759. /** @hidden */
  80760. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80761. /** @hidden */
  80762. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80763. /**
  80764. * Cancels any network activity
  80765. */
  80766. abort(): void;
  80767. /**
  80768. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80769. * @param body defines an optional request body
  80770. */
  80771. send(body?: Document | BodyInit | null): void;
  80772. /**
  80773. * Sets the request method, request URL
  80774. * @param method defines the method to use (GET, POST, etc..)
  80775. * @param url defines the url to connect with
  80776. */
  80777. open(method: string, url: string): void;
  80778. /**
  80779. * Sets the value of a request header.
  80780. * @param name The name of the header whose value is to be set
  80781. * @param value The value to set as the body of the header
  80782. */
  80783. setRequestHeader(name: string, value: string): void;
  80784. /**
  80785. * Get the string containing the text of a particular header's value.
  80786. * @param name The name of the header
  80787. * @returns The string containing the text of the given header name
  80788. */
  80789. getResponseHeader(name: string): Nullable<string>;
  80790. }
  80791. }
  80792. declare module BABYLON {
  80793. /**
  80794. * File request interface
  80795. */
  80796. export interface IFileRequest {
  80797. /**
  80798. * Raised when the request is complete (success or error).
  80799. */
  80800. onCompleteObservable: Observable<IFileRequest>;
  80801. /**
  80802. * Aborts the request for a file.
  80803. */
  80804. abort: () => void;
  80805. }
  80806. }
  80807. declare module BABYLON {
  80808. /**
  80809. * Define options used to create a render target texture
  80810. */
  80811. export class RenderTargetCreationOptions {
  80812. /**
  80813. * Specifies is mipmaps must be generated
  80814. */
  80815. generateMipMaps?: boolean;
  80816. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80817. generateDepthBuffer?: boolean;
  80818. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80819. generateStencilBuffer?: boolean;
  80820. /** Defines texture type (int by default) */
  80821. type?: number;
  80822. /** Defines sampling mode (trilinear by default) */
  80823. samplingMode?: number;
  80824. /** Defines format (RGBA by default) */
  80825. format?: number;
  80826. }
  80827. }
  80828. declare module BABYLON {
  80829. /** Defines the cross module used constants to avoid circular dependncies */
  80830. export class Constants {
  80831. /** Defines that alpha blending is disabled */
  80832. static readonly ALPHA_DISABLE: number;
  80833. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80834. static readonly ALPHA_ADD: number;
  80835. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80836. static readonly ALPHA_COMBINE: number;
  80837. /** Defines that alpha blending is DEST - SRC * DEST */
  80838. static readonly ALPHA_SUBTRACT: number;
  80839. /** Defines that alpha blending is SRC * DEST */
  80840. static readonly ALPHA_MULTIPLY: number;
  80841. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80842. static readonly ALPHA_MAXIMIZED: number;
  80843. /** Defines that alpha blending is SRC + DEST */
  80844. static readonly ALPHA_ONEONE: number;
  80845. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80846. static readonly ALPHA_PREMULTIPLIED: number;
  80847. /**
  80848. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80849. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80850. */
  80851. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80852. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80853. static readonly ALPHA_INTERPOLATE: number;
  80854. /**
  80855. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80856. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80857. */
  80858. static readonly ALPHA_SCREENMODE: number;
  80859. /**
  80860. * Defines that alpha blending is SRC + DST
  80861. * Alpha will be set to SRC ALPHA + DST ALPHA
  80862. */
  80863. static readonly ALPHA_ONEONE_ONEONE: number;
  80864. /**
  80865. * Defines that alpha blending is SRC * DST ALPHA + DST
  80866. * Alpha will be set to 0
  80867. */
  80868. static readonly ALPHA_ALPHATOCOLOR: number;
  80869. /**
  80870. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80871. */
  80872. static readonly ALPHA_REVERSEONEMINUS: number;
  80873. /**
  80874. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80875. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80876. */
  80877. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80878. /**
  80879. * Defines that alpha blending is SRC + DST
  80880. * Alpha will be set to SRC ALPHA
  80881. */
  80882. static readonly ALPHA_ONEONE_ONEZERO: number;
  80883. /**
  80884. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80885. * Alpha will be set to DST ALPHA
  80886. */
  80887. static readonly ALPHA_EXCLUSION: number;
  80888. /** Defines that alpha blending equation a SUM */
  80889. static readonly ALPHA_EQUATION_ADD: number;
  80890. /** Defines that alpha blending equation a SUBSTRACTION */
  80891. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80892. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80893. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80894. /** Defines that alpha blending equation a MAX operation */
  80895. static readonly ALPHA_EQUATION_MAX: number;
  80896. /** Defines that alpha blending equation a MIN operation */
  80897. static readonly ALPHA_EQUATION_MIN: number;
  80898. /**
  80899. * Defines that alpha blending equation a DARKEN operation:
  80900. * It takes the min of the src and sums the alpha channels.
  80901. */
  80902. static readonly ALPHA_EQUATION_DARKEN: number;
  80903. /** Defines that the ressource is not delayed*/
  80904. static readonly DELAYLOADSTATE_NONE: number;
  80905. /** Defines that the ressource was successfully delay loaded */
  80906. static readonly DELAYLOADSTATE_LOADED: number;
  80907. /** Defines that the ressource is currently delay loading */
  80908. static readonly DELAYLOADSTATE_LOADING: number;
  80909. /** Defines that the ressource is delayed and has not started loading */
  80910. static readonly DELAYLOADSTATE_NOTLOADED: number;
  80911. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  80912. static readonly NEVER: number;
  80913. /** 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 */
  80914. static readonly ALWAYS: number;
  80915. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  80916. static readonly LESS: number;
  80917. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  80918. static readonly EQUAL: number;
  80919. /** 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 */
  80920. static readonly LEQUAL: number;
  80921. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  80922. static readonly GREATER: number;
  80923. /** 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 */
  80924. static readonly GEQUAL: number;
  80925. /** 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 */
  80926. static readonly NOTEQUAL: number;
  80927. /** Passed to stencilOperation to specify that stencil value must be kept */
  80928. static readonly KEEP: number;
  80929. /** Passed to stencilOperation to specify that stencil value must be replaced */
  80930. static readonly REPLACE: number;
  80931. /** Passed to stencilOperation to specify that stencil value must be incremented */
  80932. static readonly INCR: number;
  80933. /** Passed to stencilOperation to specify that stencil value must be decremented */
  80934. static readonly DECR: number;
  80935. /** Passed to stencilOperation to specify that stencil value must be inverted */
  80936. static readonly INVERT: number;
  80937. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  80938. static readonly INCR_WRAP: number;
  80939. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  80940. static readonly DECR_WRAP: number;
  80941. /** Texture is not repeating outside of 0..1 UVs */
  80942. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  80943. /** Texture is repeating outside of 0..1 UVs */
  80944. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  80945. /** Texture is repeating and mirrored */
  80946. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  80947. /** ALPHA */
  80948. static readonly TEXTUREFORMAT_ALPHA: number;
  80949. /** LUMINANCE */
  80950. static readonly TEXTUREFORMAT_LUMINANCE: number;
  80951. /** LUMINANCE_ALPHA */
  80952. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  80953. /** RGB */
  80954. static readonly TEXTUREFORMAT_RGB: number;
  80955. /** RGBA */
  80956. static readonly TEXTUREFORMAT_RGBA: number;
  80957. /** RED */
  80958. static readonly TEXTUREFORMAT_RED: number;
  80959. /** RED (2nd reference) */
  80960. static readonly TEXTUREFORMAT_R: number;
  80961. /** RG */
  80962. static readonly TEXTUREFORMAT_RG: number;
  80963. /** RED_INTEGER */
  80964. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  80965. /** RED_INTEGER (2nd reference) */
  80966. static readonly TEXTUREFORMAT_R_INTEGER: number;
  80967. /** RG_INTEGER */
  80968. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  80969. /** RGB_INTEGER */
  80970. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  80971. /** RGBA_INTEGER */
  80972. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  80973. /** UNSIGNED_BYTE */
  80974. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  80975. /** UNSIGNED_BYTE (2nd reference) */
  80976. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  80977. /** FLOAT */
  80978. static readonly TEXTURETYPE_FLOAT: number;
  80979. /** HALF_FLOAT */
  80980. static readonly TEXTURETYPE_HALF_FLOAT: number;
  80981. /** BYTE */
  80982. static readonly TEXTURETYPE_BYTE: number;
  80983. /** SHORT */
  80984. static readonly TEXTURETYPE_SHORT: number;
  80985. /** UNSIGNED_SHORT */
  80986. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  80987. /** INT */
  80988. static readonly TEXTURETYPE_INT: number;
  80989. /** UNSIGNED_INT */
  80990. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  80991. /** UNSIGNED_SHORT_4_4_4_4 */
  80992. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  80993. /** UNSIGNED_SHORT_5_5_5_1 */
  80994. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  80995. /** UNSIGNED_SHORT_5_6_5 */
  80996. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  80997. /** UNSIGNED_INT_2_10_10_10_REV */
  80998. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  80999. /** UNSIGNED_INT_24_8 */
  81000. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81001. /** UNSIGNED_INT_10F_11F_11F_REV */
  81002. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81003. /** UNSIGNED_INT_5_9_9_9_REV */
  81004. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81005. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81006. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81007. /** nearest is mag = nearest and min = nearest and no mip */
  81008. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81009. /** mag = nearest and min = nearest and mip = none */
  81010. static readonly TEXTURE_NEAREST_NEAREST: number;
  81011. /** Bilinear is mag = linear and min = linear and no mip */
  81012. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81013. /** mag = linear and min = linear and mip = none */
  81014. static readonly TEXTURE_LINEAR_LINEAR: number;
  81015. /** Trilinear is mag = linear and min = linear and mip = linear */
  81016. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81017. /** Trilinear is mag = linear and min = linear and mip = linear */
  81018. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81019. /** mag = nearest and min = nearest and mip = nearest */
  81020. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81021. /** mag = nearest and min = linear and mip = nearest */
  81022. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81023. /** mag = nearest and min = linear and mip = linear */
  81024. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81025. /** mag = nearest and min = linear and mip = none */
  81026. static readonly TEXTURE_NEAREST_LINEAR: number;
  81027. /** nearest is mag = nearest and min = nearest and mip = linear */
  81028. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81029. /** mag = linear and min = nearest and mip = nearest */
  81030. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81031. /** mag = linear and min = nearest and mip = linear */
  81032. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81033. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81034. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81035. /** mag = linear and min = nearest and mip = none */
  81036. static readonly TEXTURE_LINEAR_NEAREST: number;
  81037. /** Explicit coordinates mode */
  81038. static readonly TEXTURE_EXPLICIT_MODE: number;
  81039. /** Spherical coordinates mode */
  81040. static readonly TEXTURE_SPHERICAL_MODE: number;
  81041. /** Planar coordinates mode */
  81042. static readonly TEXTURE_PLANAR_MODE: number;
  81043. /** Cubic coordinates mode */
  81044. static readonly TEXTURE_CUBIC_MODE: number;
  81045. /** Projection coordinates mode */
  81046. static readonly TEXTURE_PROJECTION_MODE: number;
  81047. /** Skybox coordinates mode */
  81048. static readonly TEXTURE_SKYBOX_MODE: number;
  81049. /** Inverse Cubic coordinates mode */
  81050. static readonly TEXTURE_INVCUBIC_MODE: number;
  81051. /** Equirectangular coordinates mode */
  81052. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81053. /** Equirectangular Fixed coordinates mode */
  81054. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81055. /** Equirectangular Fixed Mirrored coordinates mode */
  81056. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81057. /** Offline (baking) quality for texture filtering */
  81058. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81059. /** High quality for texture filtering */
  81060. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81061. /** Medium quality for texture filtering */
  81062. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81063. /** Low quality for texture filtering */
  81064. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81065. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81066. static readonly SCALEMODE_FLOOR: number;
  81067. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81068. static readonly SCALEMODE_NEAREST: number;
  81069. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81070. static readonly SCALEMODE_CEILING: number;
  81071. /**
  81072. * The dirty texture flag value
  81073. */
  81074. static readonly MATERIAL_TextureDirtyFlag: number;
  81075. /**
  81076. * The dirty light flag value
  81077. */
  81078. static readonly MATERIAL_LightDirtyFlag: number;
  81079. /**
  81080. * The dirty fresnel flag value
  81081. */
  81082. static readonly MATERIAL_FresnelDirtyFlag: number;
  81083. /**
  81084. * The dirty attribute flag value
  81085. */
  81086. static readonly MATERIAL_AttributesDirtyFlag: number;
  81087. /**
  81088. * The dirty misc flag value
  81089. */
  81090. static readonly MATERIAL_MiscDirtyFlag: number;
  81091. /**
  81092. * The all dirty flag value
  81093. */
  81094. static readonly MATERIAL_AllDirtyFlag: number;
  81095. /**
  81096. * Returns the triangle fill mode
  81097. */
  81098. static readonly MATERIAL_TriangleFillMode: number;
  81099. /**
  81100. * Returns the wireframe mode
  81101. */
  81102. static readonly MATERIAL_WireFrameFillMode: number;
  81103. /**
  81104. * Returns the point fill mode
  81105. */
  81106. static readonly MATERIAL_PointFillMode: number;
  81107. /**
  81108. * Returns the point list draw mode
  81109. */
  81110. static readonly MATERIAL_PointListDrawMode: number;
  81111. /**
  81112. * Returns the line list draw mode
  81113. */
  81114. static readonly MATERIAL_LineListDrawMode: number;
  81115. /**
  81116. * Returns the line loop draw mode
  81117. */
  81118. static readonly MATERIAL_LineLoopDrawMode: number;
  81119. /**
  81120. * Returns the line strip draw mode
  81121. */
  81122. static readonly MATERIAL_LineStripDrawMode: number;
  81123. /**
  81124. * Returns the triangle strip draw mode
  81125. */
  81126. static readonly MATERIAL_TriangleStripDrawMode: number;
  81127. /**
  81128. * Returns the triangle fan draw mode
  81129. */
  81130. static readonly MATERIAL_TriangleFanDrawMode: number;
  81131. /**
  81132. * Stores the clock-wise side orientation
  81133. */
  81134. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81135. /**
  81136. * Stores the counter clock-wise side orientation
  81137. */
  81138. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81139. /**
  81140. * Nothing
  81141. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81142. */
  81143. static readonly ACTION_NothingTrigger: number;
  81144. /**
  81145. * On pick
  81146. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81147. */
  81148. static readonly ACTION_OnPickTrigger: number;
  81149. /**
  81150. * On left pick
  81151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81152. */
  81153. static readonly ACTION_OnLeftPickTrigger: number;
  81154. /**
  81155. * On right pick
  81156. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81157. */
  81158. static readonly ACTION_OnRightPickTrigger: number;
  81159. /**
  81160. * On center pick
  81161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81162. */
  81163. static readonly ACTION_OnCenterPickTrigger: number;
  81164. /**
  81165. * On pick down
  81166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81167. */
  81168. static readonly ACTION_OnPickDownTrigger: number;
  81169. /**
  81170. * On double pick
  81171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81172. */
  81173. static readonly ACTION_OnDoublePickTrigger: number;
  81174. /**
  81175. * On pick up
  81176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81177. */
  81178. static readonly ACTION_OnPickUpTrigger: number;
  81179. /**
  81180. * On pick out.
  81181. * This trigger will only be raised if you also declared a OnPickDown
  81182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81183. */
  81184. static readonly ACTION_OnPickOutTrigger: number;
  81185. /**
  81186. * On long press
  81187. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81188. */
  81189. static readonly ACTION_OnLongPressTrigger: number;
  81190. /**
  81191. * On pointer over
  81192. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81193. */
  81194. static readonly ACTION_OnPointerOverTrigger: number;
  81195. /**
  81196. * On pointer out
  81197. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81198. */
  81199. static readonly ACTION_OnPointerOutTrigger: number;
  81200. /**
  81201. * On every frame
  81202. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81203. */
  81204. static readonly ACTION_OnEveryFrameTrigger: number;
  81205. /**
  81206. * On intersection enter
  81207. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81208. */
  81209. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81210. /**
  81211. * On intersection exit
  81212. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81213. */
  81214. static readonly ACTION_OnIntersectionExitTrigger: number;
  81215. /**
  81216. * On key down
  81217. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81218. */
  81219. static readonly ACTION_OnKeyDownTrigger: number;
  81220. /**
  81221. * On key up
  81222. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81223. */
  81224. static readonly ACTION_OnKeyUpTrigger: number;
  81225. /**
  81226. * Billboard mode will only apply to Y axis
  81227. */
  81228. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81229. /**
  81230. * Billboard mode will apply to all axes
  81231. */
  81232. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81233. /**
  81234. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81235. */
  81236. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81237. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81238. * Test order :
  81239. * Is the bounding sphere outside the frustum ?
  81240. * If not, are the bounding box vertices outside the frustum ?
  81241. * It not, then the cullable object is in the frustum.
  81242. */
  81243. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81244. /** Culling strategy : Bounding Sphere Only.
  81245. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81246. * It's also less accurate than the standard because some not visible objects can still be selected.
  81247. * Test : is the bounding sphere outside the frustum ?
  81248. * If not, then the cullable object is in the frustum.
  81249. */
  81250. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81251. /** Culling strategy : Optimistic Inclusion.
  81252. * This in an inclusion test first, then the standard exclusion test.
  81253. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81254. * 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.
  81255. * Anyway, it's as accurate as the standard strategy.
  81256. * Test :
  81257. * Is the cullable object bounding sphere center in the frustum ?
  81258. * If not, apply the default culling strategy.
  81259. */
  81260. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81261. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81262. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81263. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81264. * 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.
  81265. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81266. * Test :
  81267. * Is the cullable object bounding sphere center in the frustum ?
  81268. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81269. */
  81270. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81271. /**
  81272. * No logging while loading
  81273. */
  81274. static readonly SCENELOADER_NO_LOGGING: number;
  81275. /**
  81276. * Minimal logging while loading
  81277. */
  81278. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81279. /**
  81280. * Summary logging while loading
  81281. */
  81282. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81283. /**
  81284. * Detailled logging while loading
  81285. */
  81286. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81287. /**
  81288. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81289. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81290. */
  81291. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81292. /**
  81293. * Constant used to retrieve the position texture index in the textures array in the prepass
  81294. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81295. */
  81296. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81297. /**
  81298. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81299. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81300. */
  81301. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81302. /**
  81303. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81304. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81305. */
  81306. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81307. /**
  81308. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81309. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81310. */
  81311. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81312. /**
  81313. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81314. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81315. */
  81316. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81317. /**
  81318. * Constant used to retrieve albedo index in the textures array in the prepass
  81319. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81320. */
  81321. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81322. }
  81323. }
  81324. declare module BABYLON {
  81325. /**
  81326. * This represents the required contract to create a new type of texture loader.
  81327. */
  81328. export interface IInternalTextureLoader {
  81329. /**
  81330. * Defines wether the loader supports cascade loading the different faces.
  81331. */
  81332. supportCascades: boolean;
  81333. /**
  81334. * This returns if the loader support the current file information.
  81335. * @param extension defines the file extension of the file being loaded
  81336. * @param mimeType defines the optional mime type of the file being loaded
  81337. * @returns true if the loader can load the specified file
  81338. */
  81339. canLoad(extension: string, mimeType?: string): boolean;
  81340. /**
  81341. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81342. * @param data contains the texture data
  81343. * @param texture defines the BabylonJS internal texture
  81344. * @param createPolynomials will be true if polynomials have been requested
  81345. * @param onLoad defines the callback to trigger once the texture is ready
  81346. * @param onError defines the callback to trigger in case of error
  81347. */
  81348. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81349. /**
  81350. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81351. * @param data contains the texture data
  81352. * @param texture defines the BabylonJS internal texture
  81353. * @param callback defines the method to call once ready to upload
  81354. */
  81355. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81356. }
  81357. }
  81358. declare module BABYLON {
  81359. /**
  81360. * Class used to store and describe the pipeline context associated with an effect
  81361. */
  81362. export interface IPipelineContext {
  81363. /**
  81364. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81365. */
  81366. isAsync: boolean;
  81367. /**
  81368. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81369. */
  81370. isReady: boolean;
  81371. /** @hidden */
  81372. _getVertexShaderCode(): string | null;
  81373. /** @hidden */
  81374. _getFragmentShaderCode(): string | null;
  81375. /** @hidden */
  81376. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81377. }
  81378. }
  81379. declare module BABYLON {
  81380. /**
  81381. * Class used to store gfx data (like WebGLBuffer)
  81382. */
  81383. export class DataBuffer {
  81384. /**
  81385. * Gets or sets the number of objects referencing this buffer
  81386. */
  81387. references: number;
  81388. /** Gets or sets the size of the underlying buffer */
  81389. capacity: number;
  81390. /**
  81391. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81392. */
  81393. is32Bits: boolean;
  81394. /**
  81395. * Gets the underlying buffer
  81396. */
  81397. get underlyingResource(): any;
  81398. }
  81399. }
  81400. declare module BABYLON {
  81401. /** @hidden */
  81402. export interface IShaderProcessor {
  81403. attributeProcessor?: (attribute: string) => string;
  81404. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81405. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81406. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81407. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81408. lineProcessor?: (line: string, isFragment: boolean) => string;
  81409. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81410. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81411. }
  81412. }
  81413. declare module BABYLON {
  81414. /** @hidden */
  81415. export interface ProcessingOptions {
  81416. defines: string[];
  81417. indexParameters: any;
  81418. isFragment: boolean;
  81419. shouldUseHighPrecisionShader: boolean;
  81420. supportsUniformBuffers: boolean;
  81421. shadersRepository: string;
  81422. includesShadersStore: {
  81423. [key: string]: string;
  81424. };
  81425. processor?: IShaderProcessor;
  81426. version: string;
  81427. platformName: string;
  81428. lookForClosingBracketForUniformBuffer?: boolean;
  81429. }
  81430. }
  81431. declare module BABYLON {
  81432. /** @hidden */
  81433. export class ShaderCodeNode {
  81434. line: string;
  81435. children: ShaderCodeNode[];
  81436. additionalDefineKey?: string;
  81437. additionalDefineValue?: string;
  81438. isValid(preprocessors: {
  81439. [key: string]: string;
  81440. }): boolean;
  81441. process(preprocessors: {
  81442. [key: string]: string;
  81443. }, options: ProcessingOptions): string;
  81444. }
  81445. }
  81446. declare module BABYLON {
  81447. /** @hidden */
  81448. export class ShaderCodeCursor {
  81449. private _lines;
  81450. lineIndex: number;
  81451. get currentLine(): string;
  81452. get canRead(): boolean;
  81453. set lines(value: string[]);
  81454. }
  81455. }
  81456. declare module BABYLON {
  81457. /** @hidden */
  81458. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81459. process(preprocessors: {
  81460. [key: string]: string;
  81461. }, options: ProcessingOptions): string;
  81462. }
  81463. }
  81464. declare module BABYLON {
  81465. /** @hidden */
  81466. export class ShaderDefineExpression {
  81467. isTrue(preprocessors: {
  81468. [key: string]: string;
  81469. }): boolean;
  81470. private static _OperatorPriority;
  81471. private static _Stack;
  81472. static postfixToInfix(postfix: string[]): string;
  81473. static infixToPostfix(infix: string): string[];
  81474. }
  81475. }
  81476. declare module BABYLON {
  81477. /** @hidden */
  81478. export class ShaderCodeTestNode extends ShaderCodeNode {
  81479. testExpression: ShaderDefineExpression;
  81480. isValid(preprocessors: {
  81481. [key: string]: string;
  81482. }): boolean;
  81483. }
  81484. }
  81485. declare module BABYLON {
  81486. /** @hidden */
  81487. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81488. define: string;
  81489. not: boolean;
  81490. constructor(define: string, not?: boolean);
  81491. isTrue(preprocessors: {
  81492. [key: string]: string;
  81493. }): boolean;
  81494. }
  81495. }
  81496. declare module BABYLON {
  81497. /** @hidden */
  81498. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81499. leftOperand: ShaderDefineExpression;
  81500. rightOperand: ShaderDefineExpression;
  81501. isTrue(preprocessors: {
  81502. [key: string]: string;
  81503. }): boolean;
  81504. }
  81505. }
  81506. declare module BABYLON {
  81507. /** @hidden */
  81508. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81509. leftOperand: ShaderDefineExpression;
  81510. rightOperand: ShaderDefineExpression;
  81511. isTrue(preprocessors: {
  81512. [key: string]: string;
  81513. }): boolean;
  81514. }
  81515. }
  81516. declare module BABYLON {
  81517. /** @hidden */
  81518. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81519. define: string;
  81520. operand: string;
  81521. testValue: string;
  81522. constructor(define: string, operand: string, testValue: string);
  81523. isTrue(preprocessors: {
  81524. [key: string]: string;
  81525. }): boolean;
  81526. }
  81527. }
  81528. declare module BABYLON {
  81529. /**
  81530. * Class used to enable access to offline support
  81531. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81532. */
  81533. export interface IOfflineProvider {
  81534. /**
  81535. * Gets a boolean indicating if scene must be saved in the database
  81536. */
  81537. enableSceneOffline: boolean;
  81538. /**
  81539. * Gets a boolean indicating if textures must be saved in the database
  81540. */
  81541. enableTexturesOffline: boolean;
  81542. /**
  81543. * Open the offline support and make it available
  81544. * @param successCallback defines the callback to call on success
  81545. * @param errorCallback defines the callback to call on error
  81546. */
  81547. open(successCallback: () => void, errorCallback: () => void): void;
  81548. /**
  81549. * Loads an image from the offline support
  81550. * @param url defines the url to load from
  81551. * @param image defines the target DOM image
  81552. */
  81553. loadImage(url: string, image: HTMLImageElement): void;
  81554. /**
  81555. * Loads a file from offline support
  81556. * @param url defines the URL to load from
  81557. * @param sceneLoaded defines a callback to call on success
  81558. * @param progressCallBack defines a callback to call when progress changed
  81559. * @param errorCallback defines a callback to call on error
  81560. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81561. */
  81562. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81563. }
  81564. }
  81565. declare module BABYLON {
  81566. /**
  81567. * Class used to help managing file picking and drag'n'drop
  81568. * File Storage
  81569. */
  81570. export class FilesInputStore {
  81571. /**
  81572. * List of files ready to be loaded
  81573. */
  81574. static FilesToLoad: {
  81575. [key: string]: File;
  81576. };
  81577. }
  81578. }
  81579. declare module BABYLON {
  81580. /**
  81581. * Class used to define a retry strategy when error happens while loading assets
  81582. */
  81583. export class RetryStrategy {
  81584. /**
  81585. * Function used to defines an exponential back off strategy
  81586. * @param maxRetries defines the maximum number of retries (3 by default)
  81587. * @param baseInterval defines the interval between retries
  81588. * @returns the strategy function to use
  81589. */
  81590. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81591. }
  81592. }
  81593. declare module BABYLON {
  81594. /**
  81595. * @ignore
  81596. * Application error to support additional information when loading a file
  81597. */
  81598. export abstract class BaseError extends Error {
  81599. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81600. }
  81601. }
  81602. declare module BABYLON {
  81603. /** @ignore */
  81604. export class LoadFileError extends BaseError {
  81605. request?: WebRequest;
  81606. file?: File;
  81607. /**
  81608. * Creates a new LoadFileError
  81609. * @param message defines the message of the error
  81610. * @param request defines the optional web request
  81611. * @param file defines the optional file
  81612. */
  81613. constructor(message: string, object?: WebRequest | File);
  81614. }
  81615. /** @ignore */
  81616. export class RequestFileError extends BaseError {
  81617. request: WebRequest;
  81618. /**
  81619. * Creates a new LoadFileError
  81620. * @param message defines the message of the error
  81621. * @param request defines the optional web request
  81622. */
  81623. constructor(message: string, request: WebRequest);
  81624. }
  81625. /** @ignore */
  81626. export class ReadFileError extends BaseError {
  81627. file: File;
  81628. /**
  81629. * Creates a new ReadFileError
  81630. * @param message defines the message of the error
  81631. * @param file defines the optional file
  81632. */
  81633. constructor(message: string, file: File);
  81634. }
  81635. /**
  81636. * @hidden
  81637. */
  81638. export class FileTools {
  81639. /**
  81640. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81641. */
  81642. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81643. /**
  81644. * Gets or sets the base URL to use to load assets
  81645. */
  81646. static BaseUrl: string;
  81647. /**
  81648. * Default behaviour for cors in the application.
  81649. * It can be a string if the expected behavior is identical in the entire app.
  81650. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81651. */
  81652. static CorsBehavior: string | ((url: string | string[]) => string);
  81653. /**
  81654. * Gets or sets a function used to pre-process url before using them to load assets
  81655. */
  81656. static PreprocessUrl: (url: string) => string;
  81657. /**
  81658. * Removes unwanted characters from an url
  81659. * @param url defines the url to clean
  81660. * @returns the cleaned url
  81661. */
  81662. private static _CleanUrl;
  81663. /**
  81664. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81665. * @param url define the url we are trying
  81666. * @param element define the dom element where to configure the cors policy
  81667. */
  81668. static SetCorsBehavior(url: string | string[], element: {
  81669. crossOrigin: string | null;
  81670. }): void;
  81671. /**
  81672. * Loads an image as an HTMLImageElement.
  81673. * @param input url string, ArrayBuffer, or Blob to load
  81674. * @param onLoad callback called when the image successfully loads
  81675. * @param onError callback called when the image fails to load
  81676. * @param offlineProvider offline provider for caching
  81677. * @param mimeType optional mime type
  81678. * @returns the HTMLImageElement of the loaded image
  81679. */
  81680. 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>;
  81681. /**
  81682. * Reads a file from a File object
  81683. * @param file defines the file to load
  81684. * @param onSuccess defines the callback to call when data is loaded
  81685. * @param onProgress defines the callback to call during loading process
  81686. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81687. * @param onError defines the callback to call when an error occurs
  81688. * @returns a file request object
  81689. */
  81690. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81691. /**
  81692. * Loads a file from a url
  81693. * @param url url to load
  81694. * @param onSuccess callback called when the file successfully loads
  81695. * @param onProgress callback called while file is loading (if the server supports this mode)
  81696. * @param offlineProvider defines the offline provider for caching
  81697. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81698. * @param onError callback called when the file fails to load
  81699. * @returns a file request object
  81700. */
  81701. 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;
  81702. /**
  81703. * Loads a file
  81704. * @param url url to load
  81705. * @param onSuccess callback called when the file successfully loads
  81706. * @param onProgress callback called while file is loading (if the server supports this mode)
  81707. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81708. * @param onError callback called when the file fails to load
  81709. * @param onOpened callback called when the web request is opened
  81710. * @returns a file request object
  81711. */
  81712. 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;
  81713. /**
  81714. * Checks if the loaded document was accessed via `file:`-Protocol.
  81715. * @returns boolean
  81716. */
  81717. static IsFileURL(): boolean;
  81718. }
  81719. }
  81720. declare module BABYLON {
  81721. /** @hidden */
  81722. export class ShaderProcessor {
  81723. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81724. private static _ProcessPrecision;
  81725. private static _ExtractOperation;
  81726. private static _BuildSubExpression;
  81727. private static _BuildExpression;
  81728. private static _MoveCursorWithinIf;
  81729. private static _MoveCursor;
  81730. private static _EvaluatePreProcessors;
  81731. private static _PreparePreProcessors;
  81732. private static _ProcessShaderConversion;
  81733. private static _ProcessIncludes;
  81734. /**
  81735. * Loads a file from a url
  81736. * @param url url to load
  81737. * @param onSuccess callback called when the file successfully loads
  81738. * @param onProgress callback called while file is loading (if the server supports this mode)
  81739. * @param offlineProvider defines the offline provider for caching
  81740. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81741. * @param onError callback called when the file fails to load
  81742. * @returns a file request object
  81743. * @hidden
  81744. */
  81745. 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;
  81746. }
  81747. }
  81748. declare module BABYLON {
  81749. /**
  81750. * @hidden
  81751. */
  81752. export interface IColor4Like {
  81753. r: float;
  81754. g: float;
  81755. b: float;
  81756. a: float;
  81757. }
  81758. /**
  81759. * @hidden
  81760. */
  81761. export interface IColor3Like {
  81762. r: float;
  81763. g: float;
  81764. b: float;
  81765. }
  81766. /**
  81767. * @hidden
  81768. */
  81769. export interface IVector4Like {
  81770. x: float;
  81771. y: float;
  81772. z: float;
  81773. w: float;
  81774. }
  81775. /**
  81776. * @hidden
  81777. */
  81778. export interface IVector3Like {
  81779. x: float;
  81780. y: float;
  81781. z: float;
  81782. }
  81783. /**
  81784. * @hidden
  81785. */
  81786. export interface IVector2Like {
  81787. x: float;
  81788. y: float;
  81789. }
  81790. /**
  81791. * @hidden
  81792. */
  81793. export interface IMatrixLike {
  81794. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81795. updateFlag: int;
  81796. }
  81797. /**
  81798. * @hidden
  81799. */
  81800. export interface IViewportLike {
  81801. x: float;
  81802. y: float;
  81803. width: float;
  81804. height: float;
  81805. }
  81806. /**
  81807. * @hidden
  81808. */
  81809. export interface IPlaneLike {
  81810. normal: IVector3Like;
  81811. d: float;
  81812. normalize(): void;
  81813. }
  81814. }
  81815. declare module BABYLON {
  81816. /**
  81817. * Interface used to define common properties for effect fallbacks
  81818. */
  81819. export interface IEffectFallbacks {
  81820. /**
  81821. * Removes the defines that should be removed when falling back.
  81822. * @param currentDefines defines the current define statements for the shader.
  81823. * @param effect defines the current effect we try to compile
  81824. * @returns The resulting defines with defines of the current rank removed.
  81825. */
  81826. reduce(currentDefines: string, effect: Effect): string;
  81827. /**
  81828. * Removes the fallback from the bound mesh.
  81829. */
  81830. unBindMesh(): void;
  81831. /**
  81832. * Checks to see if more fallbacks are still availible.
  81833. */
  81834. hasMoreFallbacks: boolean;
  81835. }
  81836. }
  81837. declare module BABYLON {
  81838. /**
  81839. * Class used to evalaute queries containing `and` and `or` operators
  81840. */
  81841. export class AndOrNotEvaluator {
  81842. /**
  81843. * Evaluate a query
  81844. * @param query defines the query to evaluate
  81845. * @param evaluateCallback defines the callback used to filter result
  81846. * @returns true if the query matches
  81847. */
  81848. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81849. private static _HandleParenthesisContent;
  81850. private static _SimplifyNegation;
  81851. }
  81852. }
  81853. declare module BABYLON {
  81854. /**
  81855. * Class used to store custom tags
  81856. */
  81857. export class Tags {
  81858. /**
  81859. * Adds support for tags on the given object
  81860. * @param obj defines the object to use
  81861. */
  81862. static EnableFor(obj: any): void;
  81863. /**
  81864. * Removes tags support
  81865. * @param obj defines the object to use
  81866. */
  81867. static DisableFor(obj: any): void;
  81868. /**
  81869. * Gets a boolean indicating if the given object has tags
  81870. * @param obj defines the object to use
  81871. * @returns a boolean
  81872. */
  81873. static HasTags(obj: any): boolean;
  81874. /**
  81875. * Gets the tags available on a given object
  81876. * @param obj defines the object to use
  81877. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81878. * @returns the tags
  81879. */
  81880. static GetTags(obj: any, asString?: boolean): any;
  81881. /**
  81882. * Adds tags to an object
  81883. * @param obj defines the object to use
  81884. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81885. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81886. */
  81887. static AddTagsTo(obj: any, tagsString: string): void;
  81888. /**
  81889. * @hidden
  81890. */
  81891. static _AddTagTo(obj: any, tag: string): void;
  81892. /**
  81893. * Removes specific tags from a specific object
  81894. * @param obj defines the object to use
  81895. * @param tagsString defines the tags to remove
  81896. */
  81897. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81898. /**
  81899. * @hidden
  81900. */
  81901. static _RemoveTagFrom(obj: any, tag: string): void;
  81902. /**
  81903. * Defines if tags hosted on an object match a given query
  81904. * @param obj defines the object to use
  81905. * @param tagsQuery defines the tag query
  81906. * @returns a boolean
  81907. */
  81908. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  81909. }
  81910. }
  81911. declare module BABYLON {
  81912. /**
  81913. * Scalar computation library
  81914. */
  81915. export class Scalar {
  81916. /**
  81917. * Two pi constants convenient for computation.
  81918. */
  81919. static TwoPi: number;
  81920. /**
  81921. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81922. * @param a number
  81923. * @param b number
  81924. * @param epsilon (default = 1.401298E-45)
  81925. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81926. */
  81927. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81928. /**
  81929. * Returns a string : the upper case translation of the number i to hexadecimal.
  81930. * @param i number
  81931. * @returns the upper case translation of the number i to hexadecimal.
  81932. */
  81933. static ToHex(i: number): string;
  81934. /**
  81935. * Returns -1 if value is negative and +1 is value is positive.
  81936. * @param value the value
  81937. * @returns the value itself if it's equal to zero.
  81938. */
  81939. static Sign(value: number): number;
  81940. /**
  81941. * Returns the value itself if it's between min and max.
  81942. * Returns min if the value is lower than min.
  81943. * Returns max if the value is greater than max.
  81944. * @param value the value to clmap
  81945. * @param min the min value to clamp to (default: 0)
  81946. * @param max the max value to clamp to (default: 1)
  81947. * @returns the clamped value
  81948. */
  81949. static Clamp(value: number, min?: number, max?: number): number;
  81950. /**
  81951. * the log2 of value.
  81952. * @param value the value to compute log2 of
  81953. * @returns the log2 of value.
  81954. */
  81955. static Log2(value: number): number;
  81956. /**
  81957. * Loops the value, so that it is never larger than length and never smaller than 0.
  81958. *
  81959. * This is similar to the modulo operator but it works with floating point numbers.
  81960. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  81961. * With t = 5 and length = 2.5, the result would be 0.0.
  81962. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  81963. * @param value the value
  81964. * @param length the length
  81965. * @returns the looped value
  81966. */
  81967. static Repeat(value: number, length: number): number;
  81968. /**
  81969. * Normalize the value between 0.0 and 1.0 using min and max values
  81970. * @param value value to normalize
  81971. * @param min max to normalize between
  81972. * @param max min to normalize between
  81973. * @returns the normalized value
  81974. */
  81975. static Normalize(value: number, min: number, max: number): number;
  81976. /**
  81977. * Denormalize the value from 0.0 and 1.0 using min and max values
  81978. * @param normalized value to denormalize
  81979. * @param min max to denormalize between
  81980. * @param max min to denormalize between
  81981. * @returns the denormalized value
  81982. */
  81983. static Denormalize(normalized: number, min: number, max: number): number;
  81984. /**
  81985. * Calculates the shortest difference between two given angles given in degrees.
  81986. * @param current current angle in degrees
  81987. * @param target target angle in degrees
  81988. * @returns the delta
  81989. */
  81990. static DeltaAngle(current: number, target: number): number;
  81991. /**
  81992. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  81993. * @param tx value
  81994. * @param length length
  81995. * @returns The returned value will move back and forth between 0 and length
  81996. */
  81997. static PingPong(tx: number, length: number): number;
  81998. /**
  81999. * Interpolates between min and max with smoothing at the limits.
  82000. *
  82001. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82002. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82003. * @param from from
  82004. * @param to to
  82005. * @param tx value
  82006. * @returns the smooth stepped value
  82007. */
  82008. static SmoothStep(from: number, to: number, tx: number): number;
  82009. /**
  82010. * Moves a value current towards target.
  82011. *
  82012. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82013. * Negative values of maxDelta pushes the value away from target.
  82014. * @param current current value
  82015. * @param target target value
  82016. * @param maxDelta max distance to move
  82017. * @returns resulting value
  82018. */
  82019. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82020. /**
  82021. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82022. *
  82023. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82024. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82025. * @param current current value
  82026. * @param target target value
  82027. * @param maxDelta max distance to move
  82028. * @returns resulting angle
  82029. */
  82030. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82031. /**
  82032. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82033. * @param start start value
  82034. * @param end target value
  82035. * @param amount amount to lerp between
  82036. * @returns the lerped value
  82037. */
  82038. static Lerp(start: number, end: number, amount: number): number;
  82039. /**
  82040. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82041. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82042. * @param start start value
  82043. * @param end target value
  82044. * @param amount amount to lerp between
  82045. * @returns the lerped value
  82046. */
  82047. static LerpAngle(start: number, end: number, amount: number): number;
  82048. /**
  82049. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82050. * @param a start value
  82051. * @param b target value
  82052. * @param value value between a and b
  82053. * @returns the inverseLerp value
  82054. */
  82055. static InverseLerp(a: number, b: number, value: number): number;
  82056. /**
  82057. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82058. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82059. * @param value1 spline value
  82060. * @param tangent1 spline value
  82061. * @param value2 spline value
  82062. * @param tangent2 spline value
  82063. * @param amount input value
  82064. * @returns hermite result
  82065. */
  82066. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82067. /**
  82068. * Returns a random float number between and min and max values
  82069. * @param min min value of random
  82070. * @param max max value of random
  82071. * @returns random value
  82072. */
  82073. static RandomRange(min: number, max: number): number;
  82074. /**
  82075. * This function returns percentage of a number in a given range.
  82076. *
  82077. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82078. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82079. * @param number to convert to percentage
  82080. * @param min min range
  82081. * @param max max range
  82082. * @returns the percentage
  82083. */
  82084. static RangeToPercent(number: number, min: number, max: number): number;
  82085. /**
  82086. * This function returns number that corresponds to the percentage in a given range.
  82087. *
  82088. * PercentToRange(0.34,0,100) will return 34.
  82089. * @param percent to convert to number
  82090. * @param min min range
  82091. * @param max max range
  82092. * @returns the number
  82093. */
  82094. static PercentToRange(percent: number, min: number, max: number): number;
  82095. /**
  82096. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82097. * @param angle The angle to normalize in radian.
  82098. * @return The converted angle.
  82099. */
  82100. static NormalizeRadians(angle: number): number;
  82101. }
  82102. }
  82103. declare module BABYLON {
  82104. /**
  82105. * Constant used to convert a value to gamma space
  82106. * @ignorenaming
  82107. */
  82108. export const ToGammaSpace: number;
  82109. /**
  82110. * Constant used to convert a value to linear space
  82111. * @ignorenaming
  82112. */
  82113. export const ToLinearSpace = 2.2;
  82114. /**
  82115. * Constant used to define the minimal number value in Babylon.js
  82116. * @ignorenaming
  82117. */
  82118. let Epsilon: number;
  82119. }
  82120. declare module BABYLON {
  82121. /**
  82122. * Class used to represent a viewport on screen
  82123. */
  82124. export class Viewport {
  82125. /** viewport left coordinate */
  82126. x: number;
  82127. /** viewport top coordinate */
  82128. y: number;
  82129. /**viewport width */
  82130. width: number;
  82131. /** viewport height */
  82132. height: number;
  82133. /**
  82134. * Creates a Viewport object located at (x, y) and sized (width, height)
  82135. * @param x defines viewport left coordinate
  82136. * @param y defines viewport top coordinate
  82137. * @param width defines the viewport width
  82138. * @param height defines the viewport height
  82139. */
  82140. constructor(
  82141. /** viewport left coordinate */
  82142. x: number,
  82143. /** viewport top coordinate */
  82144. y: number,
  82145. /**viewport width */
  82146. width: number,
  82147. /** viewport height */
  82148. height: number);
  82149. /**
  82150. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82151. * @param renderWidth defines the rendering width
  82152. * @param renderHeight defines the rendering height
  82153. * @returns a new Viewport
  82154. */
  82155. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82156. /**
  82157. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82158. * @param renderWidth defines the rendering width
  82159. * @param renderHeight defines the rendering height
  82160. * @param ref defines the target viewport
  82161. * @returns the current viewport
  82162. */
  82163. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82164. /**
  82165. * Returns a new Viewport copied from the current one
  82166. * @returns a new Viewport
  82167. */
  82168. clone(): Viewport;
  82169. }
  82170. }
  82171. declare module BABYLON {
  82172. /**
  82173. * Class containing a set of static utilities functions for arrays.
  82174. */
  82175. export class ArrayTools {
  82176. /**
  82177. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82178. * @param size the number of element to construct and put in the array
  82179. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82180. * @returns a new array filled with new objects
  82181. */
  82182. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82183. }
  82184. }
  82185. declare module BABYLON {
  82186. /**
  82187. * Represents a plane by the equation ax + by + cz + d = 0
  82188. */
  82189. export class Plane {
  82190. private static _TmpMatrix;
  82191. /**
  82192. * Normal of the plane (a,b,c)
  82193. */
  82194. normal: Vector3;
  82195. /**
  82196. * d component of the plane
  82197. */
  82198. d: number;
  82199. /**
  82200. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82201. * @param a a component of the plane
  82202. * @param b b component of the plane
  82203. * @param c c component of the plane
  82204. * @param d d component of the plane
  82205. */
  82206. constructor(a: number, b: number, c: number, d: number);
  82207. /**
  82208. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82209. */
  82210. asArray(): number[];
  82211. /**
  82212. * @returns a new plane copied from the current Plane.
  82213. */
  82214. clone(): Plane;
  82215. /**
  82216. * @returns the string "Plane".
  82217. */
  82218. getClassName(): string;
  82219. /**
  82220. * @returns the Plane hash code.
  82221. */
  82222. getHashCode(): number;
  82223. /**
  82224. * Normalize the current Plane in place.
  82225. * @returns the updated Plane.
  82226. */
  82227. normalize(): Plane;
  82228. /**
  82229. * Applies a transformation the plane and returns the result
  82230. * @param transformation the transformation matrix to be applied to the plane
  82231. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82232. */
  82233. transform(transformation: DeepImmutable<Matrix>): Plane;
  82234. /**
  82235. * Compute the dot product between the point and the plane normal
  82236. * @param point point to calculate the dot product with
  82237. * @returns the dot product (float) of the point coordinates and the plane normal.
  82238. */
  82239. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82240. /**
  82241. * Updates the current Plane from the plane defined by the three given points.
  82242. * @param point1 one of the points used to contruct the plane
  82243. * @param point2 one of the points used to contruct the plane
  82244. * @param point3 one of the points used to contruct the plane
  82245. * @returns the updated Plane.
  82246. */
  82247. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82248. /**
  82249. * Checks if the plane is facing a given direction
  82250. * @param direction the direction to check if the plane is facing
  82251. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82252. * @returns True is the vector "direction" is the same side than the plane normal.
  82253. */
  82254. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82255. /**
  82256. * Calculates the distance to a point
  82257. * @param point point to calculate distance to
  82258. * @returns the signed distance (float) from the given point to the Plane.
  82259. */
  82260. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82261. /**
  82262. * Creates a plane from an array
  82263. * @param array the array to create a plane from
  82264. * @returns a new Plane from the given array.
  82265. */
  82266. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82267. /**
  82268. * Creates a plane from three points
  82269. * @param point1 point used to create the plane
  82270. * @param point2 point used to create the plane
  82271. * @param point3 point used to create the plane
  82272. * @returns a new Plane defined by the three given points.
  82273. */
  82274. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82275. /**
  82276. * Creates a plane from an origin point and a normal
  82277. * @param origin origin of the plane to be constructed
  82278. * @param normal normal of the plane to be constructed
  82279. * @returns a new Plane the normal vector to this plane at the given origin point.
  82280. * Note : the vector "normal" is updated because normalized.
  82281. */
  82282. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82283. /**
  82284. * Calculates the distance from a plane and a point
  82285. * @param origin origin of the plane to be constructed
  82286. * @param normal normal of the plane to be constructed
  82287. * @param point point to calculate distance to
  82288. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82289. */
  82290. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82291. }
  82292. }
  82293. declare module BABYLON {
  82294. /** @hidden */
  82295. export class PerformanceConfigurator {
  82296. /** @hidden */
  82297. static MatrixUse64Bits: boolean;
  82298. /** @hidden */
  82299. static MatrixTrackPrecisionChange: boolean;
  82300. /** @hidden */
  82301. static MatrixCurrentType: any;
  82302. /** @hidden */
  82303. static MatrixTrackedMatrices: Array<any> | null;
  82304. /** @hidden */
  82305. static SetMatrixPrecision(use64bits: boolean): void;
  82306. }
  82307. }
  82308. declare module BABYLON {
  82309. /**
  82310. * Class representing a vector containing 2 coordinates
  82311. */
  82312. export class Vector2 {
  82313. /** defines the first coordinate */
  82314. x: number;
  82315. /** defines the second coordinate */
  82316. y: number;
  82317. /**
  82318. * Creates a new Vector2 from the given x and y coordinates
  82319. * @param x defines the first coordinate
  82320. * @param y defines the second coordinate
  82321. */
  82322. constructor(
  82323. /** defines the first coordinate */
  82324. x?: number,
  82325. /** defines the second coordinate */
  82326. y?: number);
  82327. /**
  82328. * Gets a string with the Vector2 coordinates
  82329. * @returns a string with the Vector2 coordinates
  82330. */
  82331. toString(): string;
  82332. /**
  82333. * Gets class name
  82334. * @returns the string "Vector2"
  82335. */
  82336. getClassName(): string;
  82337. /**
  82338. * Gets current vector hash code
  82339. * @returns the Vector2 hash code as a number
  82340. */
  82341. getHashCode(): number;
  82342. /**
  82343. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82344. * @param array defines the source array
  82345. * @param index defines the offset in source array
  82346. * @returns the current Vector2
  82347. */
  82348. toArray(array: FloatArray, index?: number): Vector2;
  82349. /**
  82350. * Update the current vector from an array
  82351. * @param array defines the destination array
  82352. * @param index defines the offset in the destination array
  82353. * @returns the current Vector3
  82354. */
  82355. fromArray(array: FloatArray, index?: number): Vector2;
  82356. /**
  82357. * Copy the current vector to an array
  82358. * @returns a new array with 2 elements: the Vector2 coordinates.
  82359. */
  82360. asArray(): number[];
  82361. /**
  82362. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82363. * @param source defines the source Vector2
  82364. * @returns the current updated Vector2
  82365. */
  82366. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82367. /**
  82368. * Sets the Vector2 coordinates with the given floats
  82369. * @param x defines the first coordinate
  82370. * @param y defines the second coordinate
  82371. * @returns the current updated Vector2
  82372. */
  82373. copyFromFloats(x: number, y: number): Vector2;
  82374. /**
  82375. * Sets the Vector2 coordinates with the given floats
  82376. * @param x defines the first coordinate
  82377. * @param y defines the second coordinate
  82378. * @returns the current updated Vector2
  82379. */
  82380. set(x: number, y: number): Vector2;
  82381. /**
  82382. * Add another vector with the current one
  82383. * @param otherVector defines the other vector
  82384. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82385. */
  82386. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82387. /**
  82388. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82389. * @param otherVector defines the other vector
  82390. * @param result defines the target vector
  82391. * @returns the unmodified current Vector2
  82392. */
  82393. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82394. /**
  82395. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82396. * @param otherVector defines the other vector
  82397. * @returns the current updated Vector2
  82398. */
  82399. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82400. /**
  82401. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82402. * @param otherVector defines the other vector
  82403. * @returns a new Vector2
  82404. */
  82405. addVector3(otherVector: Vector3): Vector2;
  82406. /**
  82407. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82408. * @param otherVector defines the other vector
  82409. * @returns a new Vector2
  82410. */
  82411. subtract(otherVector: Vector2): Vector2;
  82412. /**
  82413. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82414. * @param otherVector defines the other vector
  82415. * @param result defines the target vector
  82416. * @returns the unmodified current Vector2
  82417. */
  82418. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82419. /**
  82420. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82421. * @param otherVector defines the other vector
  82422. * @returns the current updated Vector2
  82423. */
  82424. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82425. /**
  82426. * Multiplies in place the current Vector2 coordinates by the given ones
  82427. * @param otherVector defines the other vector
  82428. * @returns the current updated Vector2
  82429. */
  82430. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82431. /**
  82432. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82433. * @param otherVector defines the other vector
  82434. * @returns a new Vector2
  82435. */
  82436. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82437. /**
  82438. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82439. * @param otherVector defines the other vector
  82440. * @param result defines the target vector
  82441. * @returns the unmodified current Vector2
  82442. */
  82443. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82444. /**
  82445. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82446. * @param x defines the first coordinate
  82447. * @param y defines the second coordinate
  82448. * @returns a new Vector2
  82449. */
  82450. multiplyByFloats(x: number, y: number): Vector2;
  82451. /**
  82452. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82453. * @param otherVector defines the other vector
  82454. * @returns a new Vector2
  82455. */
  82456. divide(otherVector: Vector2): Vector2;
  82457. /**
  82458. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82459. * @param otherVector defines the other vector
  82460. * @param result defines the target vector
  82461. * @returns the unmodified current Vector2
  82462. */
  82463. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82464. /**
  82465. * Divides the current Vector2 coordinates by the given ones
  82466. * @param otherVector defines the other vector
  82467. * @returns the current updated Vector2
  82468. */
  82469. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82470. /**
  82471. * Gets a new Vector2 with current Vector2 negated coordinates
  82472. * @returns a new Vector2
  82473. */
  82474. negate(): Vector2;
  82475. /**
  82476. * Negate this vector in place
  82477. * @returns this
  82478. */
  82479. negateInPlace(): Vector2;
  82480. /**
  82481. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82482. * @param result defines the Vector3 object where to store the result
  82483. * @returns the current Vector2
  82484. */
  82485. negateToRef(result: Vector2): Vector2;
  82486. /**
  82487. * Multiply the Vector2 coordinates by scale
  82488. * @param scale defines the scaling factor
  82489. * @returns the current updated Vector2
  82490. */
  82491. scaleInPlace(scale: number): Vector2;
  82492. /**
  82493. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82494. * @param scale defines the scaling factor
  82495. * @returns a new Vector2
  82496. */
  82497. scale(scale: number): Vector2;
  82498. /**
  82499. * Scale the current Vector2 values by a factor to a given Vector2
  82500. * @param scale defines the scale factor
  82501. * @param result defines the Vector2 object where to store the result
  82502. * @returns the unmodified current Vector2
  82503. */
  82504. scaleToRef(scale: number, result: Vector2): Vector2;
  82505. /**
  82506. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82507. * @param scale defines the scale factor
  82508. * @param result defines the Vector2 object where to store the result
  82509. * @returns the unmodified current Vector2
  82510. */
  82511. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82512. /**
  82513. * Gets a boolean if two vectors are equals
  82514. * @param otherVector defines the other vector
  82515. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82516. */
  82517. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82518. /**
  82519. * Gets a boolean if two vectors are equals (using an epsilon value)
  82520. * @param otherVector defines the other vector
  82521. * @param epsilon defines the minimal distance to consider equality
  82522. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82523. */
  82524. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82525. /**
  82526. * Gets a new Vector2 from current Vector2 floored values
  82527. * @returns a new Vector2
  82528. */
  82529. floor(): Vector2;
  82530. /**
  82531. * Gets a new Vector2 from current Vector2 floored values
  82532. * @returns a new Vector2
  82533. */
  82534. fract(): Vector2;
  82535. /**
  82536. * Gets the length of the vector
  82537. * @returns the vector length (float)
  82538. */
  82539. length(): number;
  82540. /**
  82541. * Gets the vector squared length
  82542. * @returns the vector squared length (float)
  82543. */
  82544. lengthSquared(): number;
  82545. /**
  82546. * Normalize the vector
  82547. * @returns the current updated Vector2
  82548. */
  82549. normalize(): Vector2;
  82550. /**
  82551. * Gets a new Vector2 copied from the Vector2
  82552. * @returns a new Vector2
  82553. */
  82554. clone(): Vector2;
  82555. /**
  82556. * Gets a new Vector2(0, 0)
  82557. * @returns a new Vector2
  82558. */
  82559. static Zero(): Vector2;
  82560. /**
  82561. * Gets a new Vector2(1, 1)
  82562. * @returns a new Vector2
  82563. */
  82564. static One(): Vector2;
  82565. /**
  82566. * Gets a new Vector2 set from the given index element of the given array
  82567. * @param array defines the data source
  82568. * @param offset defines the offset in the data source
  82569. * @returns a new Vector2
  82570. */
  82571. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82572. /**
  82573. * Sets "result" from the given index element of the given array
  82574. * @param array defines the data source
  82575. * @param offset defines the offset in the data source
  82576. * @param result defines the target vector
  82577. */
  82578. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82579. /**
  82580. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82581. * @param value1 defines 1st point of control
  82582. * @param value2 defines 2nd point of control
  82583. * @param value3 defines 3rd point of control
  82584. * @param value4 defines 4th point of control
  82585. * @param amount defines the interpolation factor
  82586. * @returns a new Vector2
  82587. */
  82588. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82589. /**
  82590. * 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".
  82591. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82592. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82593. * @param value defines the value to clamp
  82594. * @param min defines the lower limit
  82595. * @param max defines the upper limit
  82596. * @returns a new Vector2
  82597. */
  82598. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82599. /**
  82600. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82601. * @param value1 defines the 1st control point
  82602. * @param tangent1 defines the outgoing tangent
  82603. * @param value2 defines the 2nd control point
  82604. * @param tangent2 defines the incoming tangent
  82605. * @param amount defines the interpolation factor
  82606. * @returns a new Vector2
  82607. */
  82608. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82609. /**
  82610. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82611. * @param start defines the start vector
  82612. * @param end defines the end vector
  82613. * @param amount defines the interpolation factor
  82614. * @returns a new Vector2
  82615. */
  82616. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82617. /**
  82618. * Gets the dot product of the vector "left" and the vector "right"
  82619. * @param left defines first vector
  82620. * @param right defines second vector
  82621. * @returns the dot product (float)
  82622. */
  82623. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82624. /**
  82625. * Returns a new Vector2 equal to the normalized given vector
  82626. * @param vector defines the vector to normalize
  82627. * @returns a new Vector2
  82628. */
  82629. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82630. /**
  82631. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82632. * @param left defines 1st vector
  82633. * @param right defines 2nd vector
  82634. * @returns a new Vector2
  82635. */
  82636. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82637. /**
  82638. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82639. * @param left defines 1st vector
  82640. * @param right defines 2nd vector
  82641. * @returns a new Vector2
  82642. */
  82643. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82644. /**
  82645. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82646. * @param vector defines the vector to transform
  82647. * @param transformation defines the matrix to apply
  82648. * @returns a new Vector2
  82649. */
  82650. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82651. /**
  82652. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82653. * @param vector defines the vector to transform
  82654. * @param transformation defines the matrix to apply
  82655. * @param result defines the target vector
  82656. */
  82657. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82658. /**
  82659. * Determines if a given vector is included in a triangle
  82660. * @param p defines the vector to test
  82661. * @param p0 defines 1st triangle point
  82662. * @param p1 defines 2nd triangle point
  82663. * @param p2 defines 3rd triangle point
  82664. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82665. */
  82666. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82667. /**
  82668. * Gets the distance between the vectors "value1" and "value2"
  82669. * @param value1 defines first vector
  82670. * @param value2 defines second vector
  82671. * @returns the distance between vectors
  82672. */
  82673. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82674. /**
  82675. * Returns the squared distance between the vectors "value1" and "value2"
  82676. * @param value1 defines first vector
  82677. * @param value2 defines second vector
  82678. * @returns the squared distance between vectors
  82679. */
  82680. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82681. /**
  82682. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82683. * @param value1 defines first vector
  82684. * @param value2 defines second vector
  82685. * @returns a new Vector2
  82686. */
  82687. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82688. /**
  82689. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82690. * @param p defines the middle point
  82691. * @param segA defines one point of the segment
  82692. * @param segB defines the other point of the segment
  82693. * @returns the shortest distance
  82694. */
  82695. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82696. }
  82697. /**
  82698. * Class used to store (x,y,z) vector representation
  82699. * A Vector3 is the main object used in 3D geometry
  82700. * It can represent etiher the coordinates of a point the space, either a direction
  82701. * Reminder: js uses a left handed forward facing system
  82702. */
  82703. export class Vector3 {
  82704. private static _UpReadOnly;
  82705. private static _ZeroReadOnly;
  82706. /** @hidden */
  82707. _x: number;
  82708. /** @hidden */
  82709. _y: number;
  82710. /** @hidden */
  82711. _z: number;
  82712. /** @hidden */
  82713. _isDirty: boolean;
  82714. /** Gets or sets the x coordinate */
  82715. get x(): number;
  82716. set x(value: number);
  82717. /** Gets or sets the y coordinate */
  82718. get y(): number;
  82719. set y(value: number);
  82720. /** Gets or sets the z coordinate */
  82721. get z(): number;
  82722. set z(value: number);
  82723. /**
  82724. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82725. * @param x defines the first coordinates (on X axis)
  82726. * @param y defines the second coordinates (on Y axis)
  82727. * @param z defines the third coordinates (on Z axis)
  82728. */
  82729. constructor(x?: number, y?: number, z?: number);
  82730. /**
  82731. * Creates a string representation of the Vector3
  82732. * @returns a string with the Vector3 coordinates.
  82733. */
  82734. toString(): string;
  82735. /**
  82736. * Gets the class name
  82737. * @returns the string "Vector3"
  82738. */
  82739. getClassName(): string;
  82740. /**
  82741. * Creates the Vector3 hash code
  82742. * @returns a number which tends to be unique between Vector3 instances
  82743. */
  82744. getHashCode(): number;
  82745. /**
  82746. * Creates an array containing three elements : the coordinates of the Vector3
  82747. * @returns a new array of numbers
  82748. */
  82749. asArray(): number[];
  82750. /**
  82751. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82752. * @param array defines the destination array
  82753. * @param index defines the offset in the destination array
  82754. * @returns the current Vector3
  82755. */
  82756. toArray(array: FloatArray, index?: number): Vector3;
  82757. /**
  82758. * Update the current vector from an array
  82759. * @param array defines the destination array
  82760. * @param index defines the offset in the destination array
  82761. * @returns the current Vector3
  82762. */
  82763. fromArray(array: FloatArray, index?: number): Vector3;
  82764. /**
  82765. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82766. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82767. */
  82768. toQuaternion(): Quaternion;
  82769. /**
  82770. * Adds the given vector to the current Vector3
  82771. * @param otherVector defines the second operand
  82772. * @returns the current updated Vector3
  82773. */
  82774. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82775. /**
  82776. * Adds the given coordinates to the current Vector3
  82777. * @param x defines the x coordinate of the operand
  82778. * @param y defines the y coordinate of the operand
  82779. * @param z defines the z coordinate of the operand
  82780. * @returns the current updated Vector3
  82781. */
  82782. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82783. /**
  82784. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82785. * @param otherVector defines the second operand
  82786. * @returns the resulting Vector3
  82787. */
  82788. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82789. /**
  82790. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82791. * @param otherVector defines the second operand
  82792. * @param result defines the Vector3 object where to store the result
  82793. * @returns the current Vector3
  82794. */
  82795. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82796. /**
  82797. * Subtract the given vector from the current Vector3
  82798. * @param otherVector defines the second operand
  82799. * @returns the current updated Vector3
  82800. */
  82801. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82802. /**
  82803. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82804. * @param otherVector defines the second operand
  82805. * @returns the resulting Vector3
  82806. */
  82807. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82808. /**
  82809. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82810. * @param otherVector defines the second operand
  82811. * @param result defines the Vector3 object where to store the result
  82812. * @returns the current Vector3
  82813. */
  82814. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82815. /**
  82816. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82817. * @param x defines the x coordinate of the operand
  82818. * @param y defines the y coordinate of the operand
  82819. * @param z defines the z coordinate of the operand
  82820. * @returns the resulting Vector3
  82821. */
  82822. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82823. /**
  82824. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82825. * @param x defines the x coordinate of the operand
  82826. * @param y defines the y coordinate of the operand
  82827. * @param z defines the z coordinate of the operand
  82828. * @param result defines the Vector3 object where to store the result
  82829. * @returns the current Vector3
  82830. */
  82831. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82832. /**
  82833. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82834. * @returns a new Vector3
  82835. */
  82836. negate(): Vector3;
  82837. /**
  82838. * Negate this vector in place
  82839. * @returns this
  82840. */
  82841. negateInPlace(): Vector3;
  82842. /**
  82843. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82844. * @param result defines the Vector3 object where to store the result
  82845. * @returns the current Vector3
  82846. */
  82847. negateToRef(result: Vector3): Vector3;
  82848. /**
  82849. * Multiplies the Vector3 coordinates by the float "scale"
  82850. * @param scale defines the multiplier factor
  82851. * @returns the current updated Vector3
  82852. */
  82853. scaleInPlace(scale: number): Vector3;
  82854. /**
  82855. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82856. * @param scale defines the multiplier factor
  82857. * @returns a new Vector3
  82858. */
  82859. scale(scale: number): Vector3;
  82860. /**
  82861. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82862. * @param scale defines the multiplier factor
  82863. * @param result defines the Vector3 object where to store the result
  82864. * @returns the current Vector3
  82865. */
  82866. scaleToRef(scale: number, result: Vector3): Vector3;
  82867. /**
  82868. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82869. * @param scale defines the scale factor
  82870. * @param result defines the Vector3 object where to store the result
  82871. * @returns the unmodified current Vector3
  82872. */
  82873. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82874. /**
  82875. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82876. * @param origin defines the origin of the projection ray
  82877. * @param plane defines the plane to project to
  82878. * @returns the projected vector3
  82879. */
  82880. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82881. /**
  82882. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82883. * @param origin defines the origin of the projection ray
  82884. * @param plane defines the plane to project to
  82885. * @param result defines the Vector3 where to store the result
  82886. */
  82887. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82888. /**
  82889. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82890. * @param otherVector defines the second operand
  82891. * @returns true if both vectors are equals
  82892. */
  82893. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82894. /**
  82895. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82896. * @param otherVector defines the second operand
  82897. * @param epsilon defines the minimal distance to define values as equals
  82898. * @returns true if both vectors are distant less than epsilon
  82899. */
  82900. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82901. /**
  82902. * Returns true if the current Vector3 coordinates equals the given floats
  82903. * @param x defines the x coordinate of the operand
  82904. * @param y defines the y coordinate of the operand
  82905. * @param z defines the z coordinate of the operand
  82906. * @returns true if both vectors are equals
  82907. */
  82908. equalsToFloats(x: number, y: number, z: number): boolean;
  82909. /**
  82910. * Multiplies the current Vector3 coordinates by the given ones
  82911. * @param otherVector defines the second operand
  82912. * @returns the current updated Vector3
  82913. */
  82914. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82915. /**
  82916. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  82917. * @param otherVector defines the second operand
  82918. * @returns the new Vector3
  82919. */
  82920. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  82921. /**
  82922. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  82923. * @param otherVector defines the second operand
  82924. * @param result defines the Vector3 object where to store the result
  82925. * @returns the current Vector3
  82926. */
  82927. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82928. /**
  82929. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  82930. * @param x defines the x coordinate of the operand
  82931. * @param y defines the y coordinate of the operand
  82932. * @param z defines the z coordinate of the operand
  82933. * @returns the new Vector3
  82934. */
  82935. multiplyByFloats(x: number, y: number, z: number): Vector3;
  82936. /**
  82937. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  82938. * @param otherVector defines the second operand
  82939. * @returns the new Vector3
  82940. */
  82941. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  82942. /**
  82943. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  82944. * @param otherVector defines the second operand
  82945. * @param result defines the Vector3 object where to store the result
  82946. * @returns the current Vector3
  82947. */
  82948. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82949. /**
  82950. * Divides the current Vector3 coordinates by the given ones.
  82951. * @param otherVector defines the second operand
  82952. * @returns the current updated Vector3
  82953. */
  82954. divideInPlace(otherVector: Vector3): Vector3;
  82955. /**
  82956. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  82957. * @param other defines the second operand
  82958. * @returns the current updated Vector3
  82959. */
  82960. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82961. /**
  82962. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  82963. * @param other defines the second operand
  82964. * @returns the current updated Vector3
  82965. */
  82966. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82967. /**
  82968. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  82969. * @param x defines the x coordinate of the operand
  82970. * @param y defines the y coordinate of the operand
  82971. * @param z defines the z coordinate of the operand
  82972. * @returns the current updated Vector3
  82973. */
  82974. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82975. /**
  82976. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  82977. * @param x defines the x coordinate of the operand
  82978. * @param y defines the y coordinate of the operand
  82979. * @param z defines the z coordinate of the operand
  82980. * @returns the current updated Vector3
  82981. */
  82982. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82983. /**
  82984. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  82985. * Check if is non uniform within a certain amount of decimal places to account for this
  82986. * @param epsilon the amount the values can differ
  82987. * @returns if the the vector is non uniform to a certain number of decimal places
  82988. */
  82989. isNonUniformWithinEpsilon(epsilon: number): boolean;
  82990. /**
  82991. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  82992. */
  82993. get isNonUniform(): boolean;
  82994. /**
  82995. * Gets a new Vector3 from current Vector3 floored values
  82996. * @returns a new Vector3
  82997. */
  82998. floor(): Vector3;
  82999. /**
  83000. * Gets a new Vector3 from current Vector3 floored values
  83001. * @returns a new Vector3
  83002. */
  83003. fract(): Vector3;
  83004. /**
  83005. * Gets the length of the Vector3
  83006. * @returns the length of the Vector3
  83007. */
  83008. length(): number;
  83009. /**
  83010. * Gets the squared length of the Vector3
  83011. * @returns squared length of the Vector3
  83012. */
  83013. lengthSquared(): number;
  83014. /**
  83015. * Normalize the current Vector3.
  83016. * Please note that this is an in place operation.
  83017. * @returns the current updated Vector3
  83018. */
  83019. normalize(): Vector3;
  83020. /**
  83021. * Reorders the x y z properties of the vector in place
  83022. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83023. * @returns the current updated vector
  83024. */
  83025. reorderInPlace(order: string): this;
  83026. /**
  83027. * Rotates the vector around 0,0,0 by a quaternion
  83028. * @param quaternion the rotation quaternion
  83029. * @param result vector to store the result
  83030. * @returns the resulting vector
  83031. */
  83032. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83033. /**
  83034. * Rotates a vector around a given point
  83035. * @param quaternion the rotation quaternion
  83036. * @param point the point to rotate around
  83037. * @param result vector to store the result
  83038. * @returns the resulting vector
  83039. */
  83040. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83041. /**
  83042. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83043. * The cross product is then orthogonal to both current and "other"
  83044. * @param other defines the right operand
  83045. * @returns the cross product
  83046. */
  83047. cross(other: Vector3): Vector3;
  83048. /**
  83049. * Normalize the current Vector3 with the given input length.
  83050. * Please note that this is an in place operation.
  83051. * @param len the length of the vector
  83052. * @returns the current updated Vector3
  83053. */
  83054. normalizeFromLength(len: number): Vector3;
  83055. /**
  83056. * Normalize the current Vector3 to a new vector
  83057. * @returns the new Vector3
  83058. */
  83059. normalizeToNew(): Vector3;
  83060. /**
  83061. * Normalize the current Vector3 to the reference
  83062. * @param reference define the Vector3 to update
  83063. * @returns the updated Vector3
  83064. */
  83065. normalizeToRef(reference: Vector3): Vector3;
  83066. /**
  83067. * Creates a new Vector3 copied from the current Vector3
  83068. * @returns the new Vector3
  83069. */
  83070. clone(): Vector3;
  83071. /**
  83072. * Copies the given vector coordinates to the current Vector3 ones
  83073. * @param source defines the source Vector3
  83074. * @returns the current updated Vector3
  83075. */
  83076. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83077. /**
  83078. * Copies the given floats to the current Vector3 coordinates
  83079. * @param x defines the x coordinate of the operand
  83080. * @param y defines the y coordinate of the operand
  83081. * @param z defines the z coordinate of the operand
  83082. * @returns the current updated Vector3
  83083. */
  83084. copyFromFloats(x: number, y: number, z: number): Vector3;
  83085. /**
  83086. * Copies the given floats to the current Vector3 coordinates
  83087. * @param x defines the x coordinate of the operand
  83088. * @param y defines the y coordinate of the operand
  83089. * @param z defines the z coordinate of the operand
  83090. * @returns the current updated Vector3
  83091. */
  83092. set(x: number, y: number, z: number): Vector3;
  83093. /**
  83094. * Copies the given float to the current Vector3 coordinates
  83095. * @param v defines the x, y and z coordinates of the operand
  83096. * @returns the current updated Vector3
  83097. */
  83098. setAll(v: number): Vector3;
  83099. /**
  83100. * Get the clip factor between two vectors
  83101. * @param vector0 defines the first operand
  83102. * @param vector1 defines the second operand
  83103. * @param axis defines the axis to use
  83104. * @param size defines the size along the axis
  83105. * @returns the clip factor
  83106. */
  83107. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83108. /**
  83109. * Get angle between two vectors
  83110. * @param vector0 angle between vector0 and vector1
  83111. * @param vector1 angle between vector0 and vector1
  83112. * @param normal direction of the normal
  83113. * @return the angle between vector0 and vector1
  83114. */
  83115. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83116. /**
  83117. * Returns a new Vector3 set from the index "offset" of the given array
  83118. * @param array defines the source array
  83119. * @param offset defines the offset in the source array
  83120. * @returns the new Vector3
  83121. */
  83122. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83123. /**
  83124. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83125. * @param array defines the source array
  83126. * @param offset defines the offset in the source array
  83127. * @returns the new Vector3
  83128. * @deprecated Please use FromArray instead.
  83129. */
  83130. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83131. /**
  83132. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83133. * @param array defines the source array
  83134. * @param offset defines the offset in the source array
  83135. * @param result defines the Vector3 where to store the result
  83136. */
  83137. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83138. /**
  83139. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83140. * @param array defines the source array
  83141. * @param offset defines the offset in the source array
  83142. * @param result defines the Vector3 where to store the result
  83143. * @deprecated Please use FromArrayToRef instead.
  83144. */
  83145. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83146. /**
  83147. * Sets the given vector "result" with the given floats.
  83148. * @param x defines the x coordinate of the source
  83149. * @param y defines the y coordinate of the source
  83150. * @param z defines the z coordinate of the source
  83151. * @param result defines the Vector3 where to store the result
  83152. */
  83153. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83154. /**
  83155. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83156. * @returns a new empty Vector3
  83157. */
  83158. static Zero(): Vector3;
  83159. /**
  83160. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83161. * @returns a new unit Vector3
  83162. */
  83163. static One(): Vector3;
  83164. /**
  83165. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83166. * @returns a new up Vector3
  83167. */
  83168. static Up(): Vector3;
  83169. /**
  83170. * Gets a up Vector3 that must not be updated
  83171. */
  83172. static get UpReadOnly(): DeepImmutable<Vector3>;
  83173. /**
  83174. * Gets a zero Vector3 that must not be updated
  83175. */
  83176. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83177. /**
  83178. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83179. * @returns a new down Vector3
  83180. */
  83181. static Down(): Vector3;
  83182. /**
  83183. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83184. * @param rightHandedSystem is the scene right-handed (negative z)
  83185. * @returns a new forward Vector3
  83186. */
  83187. static Forward(rightHandedSystem?: boolean): Vector3;
  83188. /**
  83189. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83190. * @param rightHandedSystem is the scene right-handed (negative-z)
  83191. * @returns a new forward Vector3
  83192. */
  83193. static Backward(rightHandedSystem?: boolean): Vector3;
  83194. /**
  83195. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83196. * @returns a new right Vector3
  83197. */
  83198. static Right(): Vector3;
  83199. /**
  83200. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83201. * @returns a new left Vector3
  83202. */
  83203. static Left(): Vector3;
  83204. /**
  83205. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83206. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83207. * @param vector defines the Vector3 to transform
  83208. * @param transformation defines the transformation matrix
  83209. * @returns the transformed Vector3
  83210. */
  83211. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83212. /**
  83213. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83214. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83215. * @param vector defines the Vector3 to transform
  83216. * @param transformation defines the transformation matrix
  83217. * @param result defines the Vector3 where to store the result
  83218. */
  83219. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83220. /**
  83221. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83222. * This method computes tranformed coordinates only, not transformed direction vectors
  83223. * @param x define the x coordinate of the source vector
  83224. * @param y define the y coordinate of the source vector
  83225. * @param z define the z coordinate of the source vector
  83226. * @param transformation defines the transformation matrix
  83227. * @param result defines the Vector3 where to store the result
  83228. */
  83229. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83230. /**
  83231. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83232. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83233. * @param vector defines the Vector3 to transform
  83234. * @param transformation defines the transformation matrix
  83235. * @returns the new Vector3
  83236. */
  83237. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83238. /**
  83239. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83240. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83241. * @param vector defines the Vector3 to transform
  83242. * @param transformation defines the transformation matrix
  83243. * @param result defines the Vector3 where to store the result
  83244. */
  83245. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83246. /**
  83247. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83248. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83249. * @param x define the x coordinate of the source vector
  83250. * @param y define the y coordinate of the source vector
  83251. * @param z define the z coordinate of the source vector
  83252. * @param transformation defines the transformation matrix
  83253. * @param result defines the Vector3 where to store the result
  83254. */
  83255. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83256. /**
  83257. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83258. * @param value1 defines the first control point
  83259. * @param value2 defines the second control point
  83260. * @param value3 defines the third control point
  83261. * @param value4 defines the fourth control point
  83262. * @param amount defines the amount on the spline to use
  83263. * @returns the new Vector3
  83264. */
  83265. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83266. /**
  83267. * 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"
  83268. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83269. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83270. * @param value defines the current value
  83271. * @param min defines the lower range value
  83272. * @param max defines the upper range value
  83273. * @returns the new Vector3
  83274. */
  83275. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83276. /**
  83277. * 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"
  83278. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83279. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83280. * @param value defines the current value
  83281. * @param min defines the lower range value
  83282. * @param max defines the upper range value
  83283. * @param result defines the Vector3 where to store the result
  83284. */
  83285. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83286. /**
  83287. * Checks if a given vector is inside a specific range
  83288. * @param v defines the vector to test
  83289. * @param min defines the minimum range
  83290. * @param max defines the maximum range
  83291. */
  83292. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83293. /**
  83294. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83295. * @param value1 defines the first control point
  83296. * @param tangent1 defines the first tangent vector
  83297. * @param value2 defines the second control point
  83298. * @param tangent2 defines the second tangent vector
  83299. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83300. * @returns the new Vector3
  83301. */
  83302. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83303. /**
  83304. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83305. * @param start defines the start value
  83306. * @param end defines the end value
  83307. * @param amount max defines amount between both (between 0 and 1)
  83308. * @returns the new Vector3
  83309. */
  83310. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83311. /**
  83312. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83313. * @param start defines the start value
  83314. * @param end defines the end value
  83315. * @param amount max defines amount between both (between 0 and 1)
  83316. * @param result defines the Vector3 where to store the result
  83317. */
  83318. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83319. /**
  83320. * Returns the dot product (float) between the vectors "left" and "right"
  83321. * @param left defines the left operand
  83322. * @param right defines the right operand
  83323. * @returns the dot product
  83324. */
  83325. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83326. /**
  83327. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83328. * The cross product is then orthogonal to both "left" and "right"
  83329. * @param left defines the left operand
  83330. * @param right defines the right operand
  83331. * @returns the cross product
  83332. */
  83333. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83334. /**
  83335. * Sets the given vector "result" with the cross product of "left" and "right"
  83336. * The cross product is then orthogonal to both "left" and "right"
  83337. * @param left defines the left operand
  83338. * @param right defines the right operand
  83339. * @param result defines the Vector3 where to store the result
  83340. */
  83341. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83342. /**
  83343. * Returns a new Vector3 as the normalization of the given vector
  83344. * @param vector defines the Vector3 to normalize
  83345. * @returns the new Vector3
  83346. */
  83347. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83348. /**
  83349. * Sets the given vector "result" with the normalization of the given first vector
  83350. * @param vector defines the Vector3 to normalize
  83351. * @param result defines the Vector3 where to store the result
  83352. */
  83353. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83354. /**
  83355. * Project a Vector3 onto screen space
  83356. * @param vector defines the Vector3 to project
  83357. * @param world defines the world matrix to use
  83358. * @param transform defines the transform (view x projection) matrix to use
  83359. * @param viewport defines the screen viewport to use
  83360. * @returns the new Vector3
  83361. */
  83362. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83363. /** @hidden */
  83364. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83365. /**
  83366. * Unproject from screen space to object space
  83367. * @param source defines the screen space Vector3 to use
  83368. * @param viewportWidth defines the current width of the viewport
  83369. * @param viewportHeight defines the current height of the viewport
  83370. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83371. * @param transform defines the transform (view x projection) matrix to use
  83372. * @returns the new Vector3
  83373. */
  83374. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83375. /**
  83376. * Unproject from screen space to object space
  83377. * @param source defines the screen space Vector3 to use
  83378. * @param viewportWidth defines the current width of the viewport
  83379. * @param viewportHeight defines the current height of the viewport
  83380. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83381. * @param view defines the view matrix to use
  83382. * @param projection defines the projection matrix to use
  83383. * @returns the new Vector3
  83384. */
  83385. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83386. /**
  83387. * Unproject from screen space to object space
  83388. * @param source defines the screen space Vector3 to use
  83389. * @param viewportWidth defines the current width of the viewport
  83390. * @param viewportHeight defines the current height of the viewport
  83391. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83392. * @param view defines the view matrix to use
  83393. * @param projection defines the projection matrix to use
  83394. * @param result defines the Vector3 where to store the result
  83395. */
  83396. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83397. /**
  83398. * Unproject from screen space to object space
  83399. * @param sourceX defines the screen space x coordinate to use
  83400. * @param sourceY defines the screen space y coordinate to use
  83401. * @param sourceZ defines the screen space z coordinate to use
  83402. * @param viewportWidth defines the current width of the viewport
  83403. * @param viewportHeight defines the current height of the viewport
  83404. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83405. * @param view defines the view matrix to use
  83406. * @param projection defines the projection matrix to use
  83407. * @param result defines the Vector3 where to store the result
  83408. */
  83409. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83410. /**
  83411. * Gets the minimal coordinate values between two Vector3
  83412. * @param left defines the first operand
  83413. * @param right defines the second operand
  83414. * @returns the new Vector3
  83415. */
  83416. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83417. /**
  83418. * Gets the maximal coordinate values between two Vector3
  83419. * @param left defines the first operand
  83420. * @param right defines the second operand
  83421. * @returns the new Vector3
  83422. */
  83423. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83424. /**
  83425. * Returns the distance between the vectors "value1" and "value2"
  83426. * @param value1 defines the first operand
  83427. * @param value2 defines the second operand
  83428. * @returns the distance
  83429. */
  83430. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83431. /**
  83432. * Returns the squared distance between the vectors "value1" and "value2"
  83433. * @param value1 defines the first operand
  83434. * @param value2 defines the second operand
  83435. * @returns the squared distance
  83436. */
  83437. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83438. /**
  83439. * Returns a new Vector3 located at the center between "value1" and "value2"
  83440. * @param value1 defines the first operand
  83441. * @param value2 defines the second operand
  83442. * @returns the new Vector3
  83443. */
  83444. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83445. /**
  83446. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83447. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83448. * to something in order to rotate it from its local system to the given target system
  83449. * Note: axis1, axis2 and axis3 are normalized during this operation
  83450. * @param axis1 defines the first axis
  83451. * @param axis2 defines the second axis
  83452. * @param axis3 defines the third axis
  83453. * @returns a new Vector3
  83454. */
  83455. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83456. /**
  83457. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83458. * @param axis1 defines the first axis
  83459. * @param axis2 defines the second axis
  83460. * @param axis3 defines the third axis
  83461. * @param ref defines the Vector3 where to store the result
  83462. */
  83463. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83464. }
  83465. /**
  83466. * Vector4 class created for EulerAngle class conversion to Quaternion
  83467. */
  83468. export class Vector4 {
  83469. /** x value of the vector */
  83470. x: number;
  83471. /** y value of the vector */
  83472. y: number;
  83473. /** z value of the vector */
  83474. z: number;
  83475. /** w value of the vector */
  83476. w: number;
  83477. /**
  83478. * Creates a Vector4 object from the given floats.
  83479. * @param x x value of the vector
  83480. * @param y y value of the vector
  83481. * @param z z value of the vector
  83482. * @param w w value of the vector
  83483. */
  83484. constructor(
  83485. /** x value of the vector */
  83486. x: number,
  83487. /** y value of the vector */
  83488. y: number,
  83489. /** z value of the vector */
  83490. z: number,
  83491. /** w value of the vector */
  83492. w: number);
  83493. /**
  83494. * Returns the string with the Vector4 coordinates.
  83495. * @returns a string containing all the vector values
  83496. */
  83497. toString(): string;
  83498. /**
  83499. * Returns the string "Vector4".
  83500. * @returns "Vector4"
  83501. */
  83502. getClassName(): string;
  83503. /**
  83504. * Returns the Vector4 hash code.
  83505. * @returns a unique hash code
  83506. */
  83507. getHashCode(): number;
  83508. /**
  83509. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83510. * @returns the resulting array
  83511. */
  83512. asArray(): number[];
  83513. /**
  83514. * Populates the given array from the given index with the Vector4 coordinates.
  83515. * @param array array to populate
  83516. * @param index index of the array to start at (default: 0)
  83517. * @returns the Vector4.
  83518. */
  83519. toArray(array: FloatArray, index?: number): Vector4;
  83520. /**
  83521. * Update the current vector from an array
  83522. * @param array defines the destination array
  83523. * @param index defines the offset in the destination array
  83524. * @returns the current Vector3
  83525. */
  83526. fromArray(array: FloatArray, index?: number): Vector4;
  83527. /**
  83528. * Adds the given vector to the current Vector4.
  83529. * @param otherVector the vector to add
  83530. * @returns the updated Vector4.
  83531. */
  83532. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83533. /**
  83534. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83535. * @param otherVector the vector to add
  83536. * @returns the resulting vector
  83537. */
  83538. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83539. /**
  83540. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83541. * @param otherVector the vector to add
  83542. * @param result the vector to store the result
  83543. * @returns the current Vector4.
  83544. */
  83545. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83546. /**
  83547. * Subtract in place the given vector from the current Vector4.
  83548. * @param otherVector the vector to subtract
  83549. * @returns the updated Vector4.
  83550. */
  83551. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83552. /**
  83553. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83554. * @param otherVector the vector to add
  83555. * @returns the new vector with the result
  83556. */
  83557. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83558. /**
  83559. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83560. * @param otherVector the vector to subtract
  83561. * @param result the vector to store the result
  83562. * @returns the current Vector4.
  83563. */
  83564. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83565. /**
  83566. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83567. */
  83568. /**
  83569. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83570. * @param x value to subtract
  83571. * @param y value to subtract
  83572. * @param z value to subtract
  83573. * @param w value to subtract
  83574. * @returns new vector containing the result
  83575. */
  83576. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83577. /**
  83578. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83579. * @param x value to subtract
  83580. * @param y value to subtract
  83581. * @param z value to subtract
  83582. * @param w value to subtract
  83583. * @param result the vector to store the result in
  83584. * @returns the current Vector4.
  83585. */
  83586. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83587. /**
  83588. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83589. * @returns a new vector with the negated values
  83590. */
  83591. negate(): Vector4;
  83592. /**
  83593. * Negate this vector in place
  83594. * @returns this
  83595. */
  83596. negateInPlace(): Vector4;
  83597. /**
  83598. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83599. * @param result defines the Vector3 object where to store the result
  83600. * @returns the current Vector4
  83601. */
  83602. negateToRef(result: Vector4): Vector4;
  83603. /**
  83604. * Multiplies the current Vector4 coordinates by scale (float).
  83605. * @param scale the number to scale with
  83606. * @returns the updated Vector4.
  83607. */
  83608. scaleInPlace(scale: number): Vector4;
  83609. /**
  83610. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83611. * @param scale the number to scale with
  83612. * @returns a new vector with the result
  83613. */
  83614. scale(scale: number): Vector4;
  83615. /**
  83616. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83617. * @param scale the number to scale with
  83618. * @param result a vector to store the result in
  83619. * @returns the current Vector4.
  83620. */
  83621. scaleToRef(scale: number, result: Vector4): Vector4;
  83622. /**
  83623. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83624. * @param scale defines the scale factor
  83625. * @param result defines the Vector4 object where to store the result
  83626. * @returns the unmodified current Vector4
  83627. */
  83628. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83629. /**
  83630. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83631. * @param otherVector the vector to compare against
  83632. * @returns true if they are equal
  83633. */
  83634. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83635. /**
  83636. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83637. * @param otherVector vector to compare against
  83638. * @param epsilon (Default: very small number)
  83639. * @returns true if they are equal
  83640. */
  83641. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83642. /**
  83643. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83644. * @param x x value to compare against
  83645. * @param y y value to compare against
  83646. * @param z z value to compare against
  83647. * @param w w value to compare against
  83648. * @returns true if equal
  83649. */
  83650. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83651. /**
  83652. * Multiplies in place the current Vector4 by the given one.
  83653. * @param otherVector vector to multiple with
  83654. * @returns the updated Vector4.
  83655. */
  83656. multiplyInPlace(otherVector: Vector4): Vector4;
  83657. /**
  83658. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83659. * @param otherVector vector to multiple with
  83660. * @returns resulting new vector
  83661. */
  83662. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83663. /**
  83664. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83665. * @param otherVector vector to multiple with
  83666. * @param result vector to store the result
  83667. * @returns the current Vector4.
  83668. */
  83669. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83670. /**
  83671. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83672. * @param x x value multiply with
  83673. * @param y y value multiply with
  83674. * @param z z value multiply with
  83675. * @param w w value multiply with
  83676. * @returns resulting new vector
  83677. */
  83678. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83679. /**
  83680. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83681. * @param otherVector vector to devide with
  83682. * @returns resulting new vector
  83683. */
  83684. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83685. /**
  83686. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83687. * @param otherVector vector to devide with
  83688. * @param result vector to store the result
  83689. * @returns the current Vector4.
  83690. */
  83691. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83692. /**
  83693. * Divides the current Vector3 coordinates by the given ones.
  83694. * @param otherVector vector to devide with
  83695. * @returns the updated Vector3.
  83696. */
  83697. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83698. /**
  83699. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83700. * @param other defines the second operand
  83701. * @returns the current updated Vector4
  83702. */
  83703. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83704. /**
  83705. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83706. * @param other defines the second operand
  83707. * @returns the current updated Vector4
  83708. */
  83709. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83710. /**
  83711. * Gets a new Vector4 from current Vector4 floored values
  83712. * @returns a new Vector4
  83713. */
  83714. floor(): Vector4;
  83715. /**
  83716. * Gets a new Vector4 from current Vector3 floored values
  83717. * @returns a new Vector4
  83718. */
  83719. fract(): Vector4;
  83720. /**
  83721. * Returns the Vector4 length (float).
  83722. * @returns the length
  83723. */
  83724. length(): number;
  83725. /**
  83726. * Returns the Vector4 squared length (float).
  83727. * @returns the length squared
  83728. */
  83729. lengthSquared(): number;
  83730. /**
  83731. * Normalizes in place the Vector4.
  83732. * @returns the updated Vector4.
  83733. */
  83734. normalize(): Vector4;
  83735. /**
  83736. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83737. * @returns this converted to a new vector3
  83738. */
  83739. toVector3(): Vector3;
  83740. /**
  83741. * Returns a new Vector4 copied from the current one.
  83742. * @returns the new cloned vector
  83743. */
  83744. clone(): Vector4;
  83745. /**
  83746. * Updates the current Vector4 with the given one coordinates.
  83747. * @param source the source vector to copy from
  83748. * @returns the updated Vector4.
  83749. */
  83750. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83751. /**
  83752. * Updates the current Vector4 coordinates with the given floats.
  83753. * @param x float to copy from
  83754. * @param y float to copy from
  83755. * @param z float to copy from
  83756. * @param w float to copy from
  83757. * @returns the updated Vector4.
  83758. */
  83759. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83760. /**
  83761. * Updates the current Vector4 coordinates with the given floats.
  83762. * @param x float to set from
  83763. * @param y float to set from
  83764. * @param z float to set from
  83765. * @param w float to set from
  83766. * @returns the updated Vector4.
  83767. */
  83768. set(x: number, y: number, z: number, w: number): Vector4;
  83769. /**
  83770. * Copies the given float to the current Vector3 coordinates
  83771. * @param v defines the x, y, z and w coordinates of the operand
  83772. * @returns the current updated Vector3
  83773. */
  83774. setAll(v: number): Vector4;
  83775. /**
  83776. * Returns a new Vector4 set from the starting index of the given array.
  83777. * @param array the array to pull values from
  83778. * @param offset the offset into the array to start at
  83779. * @returns the new vector
  83780. */
  83781. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83782. /**
  83783. * Updates the given vector "result" from the starting index of the given array.
  83784. * @param array the array to pull values from
  83785. * @param offset the offset into the array to start at
  83786. * @param result the vector to store the result in
  83787. */
  83788. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83789. /**
  83790. * Updates the given vector "result" from the starting index of the given Float32Array.
  83791. * @param array the array to pull values from
  83792. * @param offset the offset into the array to start at
  83793. * @param result the vector to store the result in
  83794. */
  83795. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83796. /**
  83797. * Updates the given vector "result" coordinates from the given floats.
  83798. * @param x float to set from
  83799. * @param y float to set from
  83800. * @param z float to set from
  83801. * @param w float to set from
  83802. * @param result the vector to the floats in
  83803. */
  83804. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83805. /**
  83806. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83807. * @returns the new vector
  83808. */
  83809. static Zero(): Vector4;
  83810. /**
  83811. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83812. * @returns the new vector
  83813. */
  83814. static One(): Vector4;
  83815. /**
  83816. * Returns a new normalized Vector4 from the given one.
  83817. * @param vector the vector to normalize
  83818. * @returns the vector
  83819. */
  83820. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83821. /**
  83822. * Updates the given vector "result" from the normalization of the given one.
  83823. * @param vector the vector to normalize
  83824. * @param result the vector to store the result in
  83825. */
  83826. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83827. /**
  83828. * Returns a vector with the minimum values from the left and right vectors
  83829. * @param left left vector to minimize
  83830. * @param right right vector to minimize
  83831. * @returns a new vector with the minimum of the left and right vector values
  83832. */
  83833. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83834. /**
  83835. * Returns a vector with the maximum values from the left and right vectors
  83836. * @param left left vector to maximize
  83837. * @param right right vector to maximize
  83838. * @returns a new vector with the maximum of the left and right vector values
  83839. */
  83840. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83841. /**
  83842. * Returns the distance (float) between the vectors "value1" and "value2".
  83843. * @param value1 value to calulate the distance between
  83844. * @param value2 value to calulate the distance between
  83845. * @return the distance between the two vectors
  83846. */
  83847. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83848. /**
  83849. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83850. * @param value1 value to calulate the distance between
  83851. * @param value2 value to calulate the distance between
  83852. * @return the distance between the two vectors squared
  83853. */
  83854. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83855. /**
  83856. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83857. * @param value1 value to calulate the center between
  83858. * @param value2 value to calulate the center between
  83859. * @return the center between the two vectors
  83860. */
  83861. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83862. /**
  83863. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83864. * This methods computes transformed normalized direction vectors only.
  83865. * @param vector the vector to transform
  83866. * @param transformation the transformation matrix to apply
  83867. * @returns the new vector
  83868. */
  83869. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83870. /**
  83871. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83872. * This methods computes transformed normalized direction vectors only.
  83873. * @param vector the vector to transform
  83874. * @param transformation the transformation matrix to apply
  83875. * @param result the vector to store the result in
  83876. */
  83877. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83878. /**
  83879. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83880. * This methods computes transformed normalized direction vectors only.
  83881. * @param x value to transform
  83882. * @param y value to transform
  83883. * @param z value to transform
  83884. * @param w value to transform
  83885. * @param transformation the transformation matrix to apply
  83886. * @param result the vector to store the results in
  83887. */
  83888. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83889. /**
  83890. * Creates a new Vector4 from a Vector3
  83891. * @param source defines the source data
  83892. * @param w defines the 4th component (default is 0)
  83893. * @returns a new Vector4
  83894. */
  83895. static FromVector3(source: Vector3, w?: number): Vector4;
  83896. }
  83897. /**
  83898. * Class used to store quaternion data
  83899. * @see https://en.wikipedia.org/wiki/Quaternion
  83900. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83901. */
  83902. export class Quaternion {
  83903. /** @hidden */
  83904. _x: number;
  83905. /** @hidden */
  83906. _y: number;
  83907. /** @hidden */
  83908. _z: number;
  83909. /** @hidden */
  83910. _w: number;
  83911. /** @hidden */
  83912. _isDirty: boolean;
  83913. /** Gets or sets the x coordinate */
  83914. get x(): number;
  83915. set x(value: number);
  83916. /** Gets or sets the y coordinate */
  83917. get y(): number;
  83918. set y(value: number);
  83919. /** Gets or sets the z coordinate */
  83920. get z(): number;
  83921. set z(value: number);
  83922. /** Gets or sets the w coordinate */
  83923. get w(): number;
  83924. set w(value: number);
  83925. /**
  83926. * Creates a new Quaternion from the given floats
  83927. * @param x defines the first component (0 by default)
  83928. * @param y defines the second component (0 by default)
  83929. * @param z defines the third component (0 by default)
  83930. * @param w defines the fourth component (1.0 by default)
  83931. */
  83932. constructor(x?: number, y?: number, z?: number, w?: number);
  83933. /**
  83934. * Gets a string representation for the current quaternion
  83935. * @returns a string with the Quaternion coordinates
  83936. */
  83937. toString(): string;
  83938. /**
  83939. * Gets the class name of the quaternion
  83940. * @returns the string "Quaternion"
  83941. */
  83942. getClassName(): string;
  83943. /**
  83944. * Gets a hash code for this quaternion
  83945. * @returns the quaternion hash code
  83946. */
  83947. getHashCode(): number;
  83948. /**
  83949. * Copy the quaternion to an array
  83950. * @returns a new array populated with 4 elements from the quaternion coordinates
  83951. */
  83952. asArray(): number[];
  83953. /**
  83954. * Check if two quaternions are equals
  83955. * @param otherQuaternion defines the second operand
  83956. * @return true if the current quaternion and the given one coordinates are strictly equals
  83957. */
  83958. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  83959. /**
  83960. * Gets a boolean if two quaternions are equals (using an epsilon value)
  83961. * @param otherQuaternion defines the other quaternion
  83962. * @param epsilon defines the minimal distance to consider equality
  83963. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  83964. */
  83965. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  83966. /**
  83967. * Clone the current quaternion
  83968. * @returns a new quaternion copied from the current one
  83969. */
  83970. clone(): Quaternion;
  83971. /**
  83972. * Copy a quaternion to the current one
  83973. * @param other defines the other quaternion
  83974. * @returns the updated current quaternion
  83975. */
  83976. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  83977. /**
  83978. * Updates the current quaternion with the given float coordinates
  83979. * @param x defines the x coordinate
  83980. * @param y defines the y coordinate
  83981. * @param z defines the z coordinate
  83982. * @param w defines the w coordinate
  83983. * @returns the updated current quaternion
  83984. */
  83985. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  83986. /**
  83987. * Updates the current quaternion from the given float coordinates
  83988. * @param x defines the x coordinate
  83989. * @param y defines the y coordinate
  83990. * @param z defines the z coordinate
  83991. * @param w defines the w coordinate
  83992. * @returns the updated current quaternion
  83993. */
  83994. set(x: number, y: number, z: number, w: number): Quaternion;
  83995. /**
  83996. * Adds two quaternions
  83997. * @param other defines the second operand
  83998. * @returns a new quaternion as the addition result of the given one and the current quaternion
  83999. */
  84000. add(other: DeepImmutable<Quaternion>): Quaternion;
  84001. /**
  84002. * Add a quaternion to the current one
  84003. * @param other defines the quaternion to add
  84004. * @returns the current quaternion
  84005. */
  84006. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84007. /**
  84008. * Subtract two quaternions
  84009. * @param other defines the second operand
  84010. * @returns a new quaternion as the subtraction result of the given one from the current one
  84011. */
  84012. subtract(other: Quaternion): Quaternion;
  84013. /**
  84014. * Multiplies the current quaternion by a scale factor
  84015. * @param value defines the scale factor
  84016. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84017. */
  84018. scale(value: number): Quaternion;
  84019. /**
  84020. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84021. * @param scale defines the scale factor
  84022. * @param result defines the Quaternion object where to store the result
  84023. * @returns the unmodified current quaternion
  84024. */
  84025. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84026. /**
  84027. * Multiplies in place the current quaternion by a scale factor
  84028. * @param value defines the scale factor
  84029. * @returns the current modified quaternion
  84030. */
  84031. scaleInPlace(value: number): Quaternion;
  84032. /**
  84033. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84034. * @param scale defines the scale factor
  84035. * @param result defines the Quaternion object where to store the result
  84036. * @returns the unmodified current quaternion
  84037. */
  84038. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84039. /**
  84040. * Multiplies two quaternions
  84041. * @param q1 defines the second operand
  84042. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84043. */
  84044. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84045. /**
  84046. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84047. * @param q1 defines the second operand
  84048. * @param result defines the target quaternion
  84049. * @returns the current quaternion
  84050. */
  84051. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84052. /**
  84053. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84054. * @param q1 defines the second operand
  84055. * @returns the currentupdated quaternion
  84056. */
  84057. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84058. /**
  84059. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84060. * @param ref defines the target quaternion
  84061. * @returns the current quaternion
  84062. */
  84063. conjugateToRef(ref: Quaternion): Quaternion;
  84064. /**
  84065. * Conjugates in place (1-q) the current quaternion
  84066. * @returns the current updated quaternion
  84067. */
  84068. conjugateInPlace(): Quaternion;
  84069. /**
  84070. * Conjugates in place (1-q) the current quaternion
  84071. * @returns a new quaternion
  84072. */
  84073. conjugate(): Quaternion;
  84074. /**
  84075. * Gets length of current quaternion
  84076. * @returns the quaternion length (float)
  84077. */
  84078. length(): number;
  84079. /**
  84080. * Normalize in place the current quaternion
  84081. * @returns the current updated quaternion
  84082. */
  84083. normalize(): Quaternion;
  84084. /**
  84085. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84086. * @param order is a reserved parameter and is ignore for now
  84087. * @returns a new Vector3 containing the Euler angles
  84088. */
  84089. toEulerAngles(order?: string): Vector3;
  84090. /**
  84091. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84092. * @param result defines the vector which will be filled with the Euler angles
  84093. * @param order is a reserved parameter and is ignore for now
  84094. * @returns the current unchanged quaternion
  84095. */
  84096. toEulerAnglesToRef(result: Vector3): Quaternion;
  84097. /**
  84098. * Updates the given rotation matrix with the current quaternion values
  84099. * @param result defines the target matrix
  84100. * @returns the current unchanged quaternion
  84101. */
  84102. toRotationMatrix(result: Matrix): Quaternion;
  84103. /**
  84104. * Updates the current quaternion from the given rotation matrix values
  84105. * @param matrix defines the source matrix
  84106. * @returns the current updated quaternion
  84107. */
  84108. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84109. /**
  84110. * Creates a new quaternion from a rotation matrix
  84111. * @param matrix defines the source matrix
  84112. * @returns a new quaternion created from the given rotation matrix values
  84113. */
  84114. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84115. /**
  84116. * Updates the given quaternion with the given rotation matrix values
  84117. * @param matrix defines the source matrix
  84118. * @param result defines the target quaternion
  84119. */
  84120. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84121. /**
  84122. * Returns the dot product (float) between the quaternions "left" and "right"
  84123. * @param left defines the left operand
  84124. * @param right defines the right operand
  84125. * @returns the dot product
  84126. */
  84127. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84128. /**
  84129. * Checks if the two quaternions are close to each other
  84130. * @param quat0 defines the first quaternion to check
  84131. * @param quat1 defines the second quaternion to check
  84132. * @returns true if the two quaternions are close to each other
  84133. */
  84134. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84135. /**
  84136. * Creates an empty quaternion
  84137. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84138. */
  84139. static Zero(): Quaternion;
  84140. /**
  84141. * Inverse a given quaternion
  84142. * @param q defines the source quaternion
  84143. * @returns a new quaternion as the inverted current quaternion
  84144. */
  84145. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84146. /**
  84147. * Inverse a given quaternion
  84148. * @param q defines the source quaternion
  84149. * @param result the quaternion the result will be stored in
  84150. * @returns the result quaternion
  84151. */
  84152. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84153. /**
  84154. * Creates an identity quaternion
  84155. * @returns the identity quaternion
  84156. */
  84157. static Identity(): Quaternion;
  84158. /**
  84159. * Gets a boolean indicating if the given quaternion is identity
  84160. * @param quaternion defines the quaternion to check
  84161. * @returns true if the quaternion is identity
  84162. */
  84163. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84164. /**
  84165. * Creates a quaternion from a rotation around an axis
  84166. * @param axis defines the axis to use
  84167. * @param angle defines the angle to use
  84168. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84169. */
  84170. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84171. /**
  84172. * Creates a rotation around an axis and stores it into the given quaternion
  84173. * @param axis defines the axis to use
  84174. * @param angle defines the angle to use
  84175. * @param result defines the target quaternion
  84176. * @returns the target quaternion
  84177. */
  84178. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84179. /**
  84180. * Creates a new quaternion from data stored into an array
  84181. * @param array defines the data source
  84182. * @param offset defines the offset in the source array where the data starts
  84183. * @returns a new quaternion
  84184. */
  84185. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84186. /**
  84187. * Updates the given quaternion "result" from the starting index of the given array.
  84188. * @param array the array to pull values from
  84189. * @param offset the offset into the array to start at
  84190. * @param result the quaternion to store the result in
  84191. */
  84192. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84193. /**
  84194. * Create a quaternion from Euler rotation angles
  84195. * @param x Pitch
  84196. * @param y Yaw
  84197. * @param z Roll
  84198. * @returns the new Quaternion
  84199. */
  84200. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84201. /**
  84202. * Updates a quaternion from Euler rotation angles
  84203. * @param x Pitch
  84204. * @param y Yaw
  84205. * @param z Roll
  84206. * @param result the quaternion to store the result
  84207. * @returns the updated quaternion
  84208. */
  84209. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84210. /**
  84211. * Create a quaternion from Euler rotation vector
  84212. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84213. * @returns the new Quaternion
  84214. */
  84215. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84216. /**
  84217. * Updates a quaternion from Euler rotation vector
  84218. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84219. * @param result the quaternion to store the result
  84220. * @returns the updated quaternion
  84221. */
  84222. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84223. /**
  84224. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84225. * @param yaw defines the rotation around Y axis
  84226. * @param pitch defines the rotation around X axis
  84227. * @param roll defines the rotation around Z axis
  84228. * @returns the new quaternion
  84229. */
  84230. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84231. /**
  84232. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84233. * @param yaw defines the rotation around Y axis
  84234. * @param pitch defines the rotation around X axis
  84235. * @param roll defines the rotation around Z axis
  84236. * @param result defines the target quaternion
  84237. */
  84238. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84239. /**
  84240. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84241. * @param alpha defines the rotation around first axis
  84242. * @param beta defines the rotation around second axis
  84243. * @param gamma defines the rotation around third axis
  84244. * @returns the new quaternion
  84245. */
  84246. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84247. /**
  84248. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84249. * @param alpha defines the rotation around first axis
  84250. * @param beta defines the rotation around second axis
  84251. * @param gamma defines the rotation around third axis
  84252. * @param result defines the target quaternion
  84253. */
  84254. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84255. /**
  84256. * 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)
  84257. * @param axis1 defines the first axis
  84258. * @param axis2 defines the second axis
  84259. * @param axis3 defines the third axis
  84260. * @returns the new quaternion
  84261. */
  84262. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84263. /**
  84264. * 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
  84265. * @param axis1 defines the first axis
  84266. * @param axis2 defines the second axis
  84267. * @param axis3 defines the third axis
  84268. * @param ref defines the target quaternion
  84269. */
  84270. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84271. /**
  84272. * Interpolates between two quaternions
  84273. * @param left defines first quaternion
  84274. * @param right defines second quaternion
  84275. * @param amount defines the gradient to use
  84276. * @returns the new interpolated quaternion
  84277. */
  84278. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84279. /**
  84280. * Interpolates between two quaternions and stores it into a target quaternion
  84281. * @param left defines first quaternion
  84282. * @param right defines second quaternion
  84283. * @param amount defines the gradient to use
  84284. * @param result defines the target quaternion
  84285. */
  84286. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84287. /**
  84288. * Interpolate between two quaternions using Hermite interpolation
  84289. * @param value1 defines first quaternion
  84290. * @param tangent1 defines the incoming tangent
  84291. * @param value2 defines second quaternion
  84292. * @param tangent2 defines the outgoing tangent
  84293. * @param amount defines the target quaternion
  84294. * @returns the new interpolated quaternion
  84295. */
  84296. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84297. }
  84298. /**
  84299. * Class used to store matrix data (4x4)
  84300. */
  84301. export class Matrix {
  84302. /**
  84303. * Gets the precision of matrix computations
  84304. */
  84305. static get Use64Bits(): boolean;
  84306. private static _updateFlagSeed;
  84307. private static _identityReadOnly;
  84308. private _isIdentity;
  84309. private _isIdentityDirty;
  84310. private _isIdentity3x2;
  84311. private _isIdentity3x2Dirty;
  84312. /**
  84313. * Gets the update flag of the matrix which is an unique number for the matrix.
  84314. * It will be incremented every time the matrix data change.
  84315. * You can use it to speed the comparison between two versions of the same matrix.
  84316. */
  84317. updateFlag: number;
  84318. private readonly _m;
  84319. /**
  84320. * Gets the internal data of the matrix
  84321. */
  84322. get m(): DeepImmutable<Float32Array | Array<number>>;
  84323. /** @hidden */
  84324. _markAsUpdated(): void;
  84325. /** @hidden */
  84326. private _updateIdentityStatus;
  84327. /**
  84328. * Creates an empty matrix (filled with zeros)
  84329. */
  84330. constructor();
  84331. /**
  84332. * Check if the current matrix is identity
  84333. * @returns true is the matrix is the identity matrix
  84334. */
  84335. isIdentity(): boolean;
  84336. /**
  84337. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84338. * @returns true is the matrix is the identity matrix
  84339. */
  84340. isIdentityAs3x2(): boolean;
  84341. /**
  84342. * Gets the determinant of the matrix
  84343. * @returns the matrix determinant
  84344. */
  84345. determinant(): number;
  84346. /**
  84347. * Returns the matrix as a Float32Array or Array<number>
  84348. * @returns the matrix underlying array
  84349. */
  84350. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84351. /**
  84352. * Returns the matrix as a Float32Array or Array<number>
  84353. * @returns the matrix underlying array.
  84354. */
  84355. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84356. /**
  84357. * Inverts the current matrix in place
  84358. * @returns the current inverted matrix
  84359. */
  84360. invert(): Matrix;
  84361. /**
  84362. * Sets all the matrix elements to zero
  84363. * @returns the current matrix
  84364. */
  84365. reset(): Matrix;
  84366. /**
  84367. * Adds the current matrix with a second one
  84368. * @param other defines the matrix to add
  84369. * @returns a new matrix as the addition of the current matrix and the given one
  84370. */
  84371. add(other: DeepImmutable<Matrix>): Matrix;
  84372. /**
  84373. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84374. * @param other defines the matrix to add
  84375. * @param result defines the target matrix
  84376. * @returns the current matrix
  84377. */
  84378. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84379. /**
  84380. * Adds in place the given matrix to the current matrix
  84381. * @param other defines the second operand
  84382. * @returns the current updated matrix
  84383. */
  84384. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84385. /**
  84386. * Sets the given matrix to the current inverted Matrix
  84387. * @param other defines the target matrix
  84388. * @returns the unmodified current matrix
  84389. */
  84390. invertToRef(other: Matrix): Matrix;
  84391. /**
  84392. * add a value at the specified position in the current Matrix
  84393. * @param index the index of the value within the matrix. between 0 and 15.
  84394. * @param value the value to be added
  84395. * @returns the current updated matrix
  84396. */
  84397. addAtIndex(index: number, value: number): Matrix;
  84398. /**
  84399. * mutiply the specified position in the current Matrix by a value
  84400. * @param index the index of the value within the matrix. between 0 and 15.
  84401. * @param value the value to be added
  84402. * @returns the current updated matrix
  84403. */
  84404. multiplyAtIndex(index: number, value: number): Matrix;
  84405. /**
  84406. * Inserts the translation vector (using 3 floats) in the current matrix
  84407. * @param x defines the 1st component of the translation
  84408. * @param y defines the 2nd component of the translation
  84409. * @param z defines the 3rd component of the translation
  84410. * @returns the current updated matrix
  84411. */
  84412. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84413. /**
  84414. * Adds the translation vector (using 3 floats) in the current matrix
  84415. * @param x defines the 1st component of the translation
  84416. * @param y defines the 2nd component of the translation
  84417. * @param z defines the 3rd component of the translation
  84418. * @returns the current updated matrix
  84419. */
  84420. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84421. /**
  84422. * Inserts the translation vector in the current matrix
  84423. * @param vector3 defines the translation to insert
  84424. * @returns the current updated matrix
  84425. */
  84426. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84427. /**
  84428. * Gets the translation value of the current matrix
  84429. * @returns a new Vector3 as the extracted translation from the matrix
  84430. */
  84431. getTranslation(): Vector3;
  84432. /**
  84433. * Fill a Vector3 with the extracted translation from the matrix
  84434. * @param result defines the Vector3 where to store the translation
  84435. * @returns the current matrix
  84436. */
  84437. getTranslationToRef(result: Vector3): Matrix;
  84438. /**
  84439. * Remove rotation and scaling part from the matrix
  84440. * @returns the updated matrix
  84441. */
  84442. removeRotationAndScaling(): Matrix;
  84443. /**
  84444. * Multiply two matrices
  84445. * @param other defines the second operand
  84446. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84447. */
  84448. multiply(other: DeepImmutable<Matrix>): Matrix;
  84449. /**
  84450. * Copy the current matrix from the given one
  84451. * @param other defines the source matrix
  84452. * @returns the current updated matrix
  84453. */
  84454. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84455. /**
  84456. * Populates the given array from the starting index with the current matrix values
  84457. * @param array defines the target array
  84458. * @param offset defines the offset in the target array where to start storing values
  84459. * @returns the current matrix
  84460. */
  84461. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84462. /**
  84463. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84464. * @param other defines the second operand
  84465. * @param result defines the matrix where to store the multiplication
  84466. * @returns the current matrix
  84467. */
  84468. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84469. /**
  84470. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84471. * @param other defines the second operand
  84472. * @param result defines the array where to store the multiplication
  84473. * @param offset defines the offset in the target array where to start storing values
  84474. * @returns the current matrix
  84475. */
  84476. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84477. /**
  84478. * Check equality between this matrix and a second one
  84479. * @param value defines the second matrix to compare
  84480. * @returns true is the current matrix and the given one values are strictly equal
  84481. */
  84482. equals(value: DeepImmutable<Matrix>): boolean;
  84483. /**
  84484. * Clone the current matrix
  84485. * @returns a new matrix from the current matrix
  84486. */
  84487. clone(): Matrix;
  84488. /**
  84489. * Returns the name of the current matrix class
  84490. * @returns the string "Matrix"
  84491. */
  84492. getClassName(): string;
  84493. /**
  84494. * Gets the hash code of the current matrix
  84495. * @returns the hash code
  84496. */
  84497. getHashCode(): number;
  84498. /**
  84499. * Decomposes the current Matrix into a translation, rotation and scaling components
  84500. * @param scale defines the scale vector3 given as a reference to update
  84501. * @param rotation defines the rotation quaternion given as a reference to update
  84502. * @param translation defines the translation vector3 given as a reference to update
  84503. * @returns true if operation was successful
  84504. */
  84505. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84506. /**
  84507. * Gets specific row of the matrix
  84508. * @param index defines the number of the row to get
  84509. * @returns the index-th row of the current matrix as a new Vector4
  84510. */
  84511. getRow(index: number): Nullable<Vector4>;
  84512. /**
  84513. * Sets the index-th row of the current matrix to the vector4 values
  84514. * @param index defines the number of the row to set
  84515. * @param row defines the target vector4
  84516. * @returns the updated current matrix
  84517. */
  84518. setRow(index: number, row: Vector4): Matrix;
  84519. /**
  84520. * Compute the transpose of the matrix
  84521. * @returns the new transposed matrix
  84522. */
  84523. transpose(): Matrix;
  84524. /**
  84525. * Compute the transpose of the matrix and store it in a given matrix
  84526. * @param result defines the target matrix
  84527. * @returns the current matrix
  84528. */
  84529. transposeToRef(result: Matrix): Matrix;
  84530. /**
  84531. * Sets the index-th row of the current matrix with the given 4 x float values
  84532. * @param index defines the row index
  84533. * @param x defines the x component to set
  84534. * @param y defines the y component to set
  84535. * @param z defines the z component to set
  84536. * @param w defines the w component to set
  84537. * @returns the updated current matrix
  84538. */
  84539. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84540. /**
  84541. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84542. * @param scale defines the scale factor
  84543. * @returns a new matrix
  84544. */
  84545. scale(scale: number): Matrix;
  84546. /**
  84547. * Scale the current matrix values by a factor to a given result matrix
  84548. * @param scale defines the scale factor
  84549. * @param result defines the matrix to store the result
  84550. * @returns the current matrix
  84551. */
  84552. scaleToRef(scale: number, result: Matrix): Matrix;
  84553. /**
  84554. * Scale the current matrix values by a factor and add the result to a given matrix
  84555. * @param scale defines the scale factor
  84556. * @param result defines the Matrix to store the result
  84557. * @returns the current matrix
  84558. */
  84559. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84560. /**
  84561. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84562. * @param ref matrix to store the result
  84563. */
  84564. toNormalMatrix(ref: Matrix): void;
  84565. /**
  84566. * Gets only rotation part of the current matrix
  84567. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84568. */
  84569. getRotationMatrix(): Matrix;
  84570. /**
  84571. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84572. * @param result defines the target matrix to store data to
  84573. * @returns the current matrix
  84574. */
  84575. getRotationMatrixToRef(result: Matrix): Matrix;
  84576. /**
  84577. * Toggles model matrix from being right handed to left handed in place and vice versa
  84578. */
  84579. toggleModelMatrixHandInPlace(): void;
  84580. /**
  84581. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84582. */
  84583. toggleProjectionMatrixHandInPlace(): void;
  84584. /**
  84585. * Creates a matrix from an array
  84586. * @param array defines the source array
  84587. * @param offset defines an offset in the source array
  84588. * @returns a new Matrix set from the starting index of the given array
  84589. */
  84590. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84591. /**
  84592. * Copy the content of an array into a given matrix
  84593. * @param array defines the source array
  84594. * @param offset defines an offset in the source array
  84595. * @param result defines the target matrix
  84596. */
  84597. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84598. /**
  84599. * Stores an array into a matrix after having multiplied each component by a given factor
  84600. * @param array defines the source array
  84601. * @param offset defines the offset in the source array
  84602. * @param scale defines the scaling factor
  84603. * @param result defines the target matrix
  84604. */
  84605. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84606. /**
  84607. * Gets an identity matrix that must not be updated
  84608. */
  84609. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84610. /**
  84611. * Stores a list of values (16) inside a given matrix
  84612. * @param initialM11 defines 1st value of 1st row
  84613. * @param initialM12 defines 2nd value of 1st row
  84614. * @param initialM13 defines 3rd value of 1st row
  84615. * @param initialM14 defines 4th value of 1st row
  84616. * @param initialM21 defines 1st value of 2nd row
  84617. * @param initialM22 defines 2nd value of 2nd row
  84618. * @param initialM23 defines 3rd value of 2nd row
  84619. * @param initialM24 defines 4th value of 2nd row
  84620. * @param initialM31 defines 1st value of 3rd row
  84621. * @param initialM32 defines 2nd value of 3rd row
  84622. * @param initialM33 defines 3rd value of 3rd row
  84623. * @param initialM34 defines 4th value of 3rd row
  84624. * @param initialM41 defines 1st value of 4th row
  84625. * @param initialM42 defines 2nd value of 4th row
  84626. * @param initialM43 defines 3rd value of 4th row
  84627. * @param initialM44 defines 4th value of 4th row
  84628. * @param result defines the target matrix
  84629. */
  84630. 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;
  84631. /**
  84632. * Creates new matrix from a list of values (16)
  84633. * @param initialM11 defines 1st value of 1st row
  84634. * @param initialM12 defines 2nd value of 1st row
  84635. * @param initialM13 defines 3rd value of 1st row
  84636. * @param initialM14 defines 4th value of 1st row
  84637. * @param initialM21 defines 1st value of 2nd row
  84638. * @param initialM22 defines 2nd value of 2nd row
  84639. * @param initialM23 defines 3rd value of 2nd row
  84640. * @param initialM24 defines 4th value of 2nd row
  84641. * @param initialM31 defines 1st value of 3rd row
  84642. * @param initialM32 defines 2nd value of 3rd row
  84643. * @param initialM33 defines 3rd value of 3rd row
  84644. * @param initialM34 defines 4th value of 3rd row
  84645. * @param initialM41 defines 1st value of 4th row
  84646. * @param initialM42 defines 2nd value of 4th row
  84647. * @param initialM43 defines 3rd value of 4th row
  84648. * @param initialM44 defines 4th value of 4th row
  84649. * @returns the new matrix
  84650. */
  84651. 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;
  84652. /**
  84653. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84654. * @param scale defines the scale vector3
  84655. * @param rotation defines the rotation quaternion
  84656. * @param translation defines the translation vector3
  84657. * @returns a new matrix
  84658. */
  84659. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84660. /**
  84661. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84662. * @param scale defines the scale vector3
  84663. * @param rotation defines the rotation quaternion
  84664. * @param translation defines the translation vector3
  84665. * @param result defines the target matrix
  84666. */
  84667. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84668. /**
  84669. * Creates a new identity matrix
  84670. * @returns a new identity matrix
  84671. */
  84672. static Identity(): Matrix;
  84673. /**
  84674. * Creates a new identity matrix and stores the result in a given matrix
  84675. * @param result defines the target matrix
  84676. */
  84677. static IdentityToRef(result: Matrix): void;
  84678. /**
  84679. * Creates a new zero matrix
  84680. * @returns a new zero matrix
  84681. */
  84682. static Zero(): Matrix;
  84683. /**
  84684. * Creates a new rotation matrix for "angle" radians around the X axis
  84685. * @param angle defines the angle (in radians) to use
  84686. * @return the new matrix
  84687. */
  84688. static RotationX(angle: number): Matrix;
  84689. /**
  84690. * Creates a new matrix as the invert of a given matrix
  84691. * @param source defines the source matrix
  84692. * @returns the new matrix
  84693. */
  84694. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84695. /**
  84696. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84697. * @param angle defines the angle (in radians) to use
  84698. * @param result defines the target matrix
  84699. */
  84700. static RotationXToRef(angle: number, result: Matrix): void;
  84701. /**
  84702. * Creates a new rotation matrix for "angle" radians around the Y axis
  84703. * @param angle defines the angle (in radians) to use
  84704. * @return the new matrix
  84705. */
  84706. static RotationY(angle: number): Matrix;
  84707. /**
  84708. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84709. * @param angle defines the angle (in radians) to use
  84710. * @param result defines the target matrix
  84711. */
  84712. static RotationYToRef(angle: number, result: Matrix): void;
  84713. /**
  84714. * Creates a new rotation matrix for "angle" radians around the Z axis
  84715. * @param angle defines the angle (in radians) to use
  84716. * @return the new matrix
  84717. */
  84718. static RotationZ(angle: number): Matrix;
  84719. /**
  84720. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84721. * @param angle defines the angle (in radians) to use
  84722. * @param result defines the target matrix
  84723. */
  84724. static RotationZToRef(angle: number, result: Matrix): void;
  84725. /**
  84726. * Creates a new rotation matrix for "angle" radians around the given axis
  84727. * @param axis defines the axis to use
  84728. * @param angle defines the angle (in radians) to use
  84729. * @return the new matrix
  84730. */
  84731. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84732. /**
  84733. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84734. * @param axis defines the axis to use
  84735. * @param angle defines the angle (in radians) to use
  84736. * @param result defines the target matrix
  84737. */
  84738. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84739. /**
  84740. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84741. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84742. * @param from defines the vector to align
  84743. * @param to defines the vector to align to
  84744. * @param result defines the target matrix
  84745. */
  84746. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84747. /**
  84748. * Creates a rotation matrix
  84749. * @param yaw defines the yaw angle in radians (Y axis)
  84750. * @param pitch defines the pitch angle in radians (X axis)
  84751. * @param roll defines the roll angle in radians (Z axis)
  84752. * @returns the new rotation matrix
  84753. */
  84754. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84755. /**
  84756. * Creates a rotation matrix and stores it in a given matrix
  84757. * @param yaw defines the yaw angle in radians (Y axis)
  84758. * @param pitch defines the pitch angle in radians (X axis)
  84759. * @param roll defines the roll angle in radians (Z axis)
  84760. * @param result defines the target matrix
  84761. */
  84762. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84763. /**
  84764. * Creates a scaling matrix
  84765. * @param x defines the scale factor on X axis
  84766. * @param y defines the scale factor on Y axis
  84767. * @param z defines the scale factor on Z axis
  84768. * @returns the new matrix
  84769. */
  84770. static Scaling(x: number, y: number, z: number): Matrix;
  84771. /**
  84772. * Creates a scaling matrix and stores it in a given matrix
  84773. * @param x defines the scale factor on X axis
  84774. * @param y defines the scale factor on Y axis
  84775. * @param z defines the scale factor on Z axis
  84776. * @param result defines the target matrix
  84777. */
  84778. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84779. /**
  84780. * Creates a translation matrix
  84781. * @param x defines the translation on X axis
  84782. * @param y defines the translation on Y axis
  84783. * @param z defines the translationon Z axis
  84784. * @returns the new matrix
  84785. */
  84786. static Translation(x: number, y: number, z: number): Matrix;
  84787. /**
  84788. * Creates a translation matrix and stores it in a given matrix
  84789. * @param x defines the translation on X axis
  84790. * @param y defines the translation on Y axis
  84791. * @param z defines the translationon Z axis
  84792. * @param result defines the target matrix
  84793. */
  84794. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84795. /**
  84796. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84797. * @param startValue defines the start value
  84798. * @param endValue defines the end value
  84799. * @param gradient defines the gradient factor
  84800. * @returns the new matrix
  84801. */
  84802. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84803. /**
  84804. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84805. * @param startValue defines the start value
  84806. * @param endValue defines the end value
  84807. * @param gradient defines the gradient factor
  84808. * @param result defines the Matrix object where to store data
  84809. */
  84810. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84811. /**
  84812. * Builds a new matrix whose values are computed by:
  84813. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84814. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84815. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84816. * @param startValue defines the first matrix
  84817. * @param endValue defines the second matrix
  84818. * @param gradient defines the gradient between the two matrices
  84819. * @returns the new matrix
  84820. */
  84821. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84822. /**
  84823. * Update a matrix to values which are computed by:
  84824. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84825. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84826. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84827. * @param startValue defines the first matrix
  84828. * @param endValue defines the second matrix
  84829. * @param gradient defines the gradient between the two matrices
  84830. * @param result defines the target matrix
  84831. */
  84832. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84833. /**
  84834. * 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"
  84835. * This function works in left handed mode
  84836. * @param eye defines the final position of the entity
  84837. * @param target defines where the entity should look at
  84838. * @param up defines the up vector for the entity
  84839. * @returns the new matrix
  84840. */
  84841. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84842. /**
  84843. * 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".
  84844. * This function works in left handed mode
  84845. * @param eye defines the final position of the entity
  84846. * @param target defines where the entity should look at
  84847. * @param up defines the up vector for the entity
  84848. * @param result defines the target matrix
  84849. */
  84850. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84851. /**
  84852. * 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"
  84853. * This function works in right handed mode
  84854. * @param eye defines the final position of the entity
  84855. * @param target defines where the entity should look at
  84856. * @param up defines the up vector for the entity
  84857. * @returns the new matrix
  84858. */
  84859. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84860. /**
  84861. * 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".
  84862. * This function works in right handed mode
  84863. * @param eye defines the final position of the entity
  84864. * @param target defines where the entity should look at
  84865. * @param up defines the up vector for the entity
  84866. * @param result defines the target matrix
  84867. */
  84868. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84869. /**
  84870. * Create a left-handed orthographic projection matrix
  84871. * @param width defines the viewport width
  84872. * @param height defines the viewport height
  84873. * @param znear defines the near clip plane
  84874. * @param zfar defines the far clip plane
  84875. * @returns a new matrix as a left-handed orthographic projection matrix
  84876. */
  84877. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84878. /**
  84879. * Store a left-handed orthographic projection to a given matrix
  84880. * @param width defines the viewport width
  84881. * @param height defines the viewport height
  84882. * @param znear defines the near clip plane
  84883. * @param zfar defines the far clip plane
  84884. * @param result defines the target matrix
  84885. */
  84886. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84887. /**
  84888. * Create a left-handed orthographic projection matrix
  84889. * @param left defines the viewport left coordinate
  84890. * @param right defines the viewport right coordinate
  84891. * @param bottom defines the viewport bottom coordinate
  84892. * @param top defines the viewport top coordinate
  84893. * @param znear defines the near clip plane
  84894. * @param zfar defines the far clip plane
  84895. * @returns a new matrix as a left-handed orthographic projection matrix
  84896. */
  84897. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84898. /**
  84899. * Stores a left-handed orthographic projection into a given matrix
  84900. * @param left defines the viewport left coordinate
  84901. * @param right defines the viewport right coordinate
  84902. * @param bottom defines the viewport bottom coordinate
  84903. * @param top defines the viewport top coordinate
  84904. * @param znear defines the near clip plane
  84905. * @param zfar defines the far clip plane
  84906. * @param result defines the target matrix
  84907. */
  84908. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84909. /**
  84910. * Creates a right-handed orthographic projection matrix
  84911. * @param left defines the viewport left coordinate
  84912. * @param right defines the viewport right coordinate
  84913. * @param bottom defines the viewport bottom coordinate
  84914. * @param top defines the viewport top coordinate
  84915. * @param znear defines the near clip plane
  84916. * @param zfar defines the far clip plane
  84917. * @returns a new matrix as a right-handed orthographic projection matrix
  84918. */
  84919. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84920. /**
  84921. * Stores a right-handed orthographic projection into a given matrix
  84922. * @param left defines the viewport left coordinate
  84923. * @param right defines the viewport right coordinate
  84924. * @param bottom defines the viewport bottom coordinate
  84925. * @param top defines the viewport top coordinate
  84926. * @param znear defines the near clip plane
  84927. * @param zfar defines the far clip plane
  84928. * @param result defines the target matrix
  84929. */
  84930. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84931. /**
  84932. * Creates a left-handed perspective projection matrix
  84933. * @param width defines the viewport width
  84934. * @param height defines the viewport height
  84935. * @param znear defines the near clip plane
  84936. * @param zfar defines the far clip plane
  84937. * @returns a new matrix as a left-handed perspective projection matrix
  84938. */
  84939. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84940. /**
  84941. * Creates a left-handed perspective projection matrix
  84942. * @param fov defines the horizontal field of view
  84943. * @param aspect defines the aspect ratio
  84944. * @param znear defines the near clip plane
  84945. * @param zfar defines the far clip plane
  84946. * @returns a new matrix as a left-handed perspective projection matrix
  84947. */
  84948. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84949. /**
  84950. * Stores a left-handed perspective projection into a given matrix
  84951. * @param fov defines the horizontal field of view
  84952. * @param aspect defines the aspect ratio
  84953. * @param znear defines the near clip plane
  84954. * @param zfar defines the far clip plane
  84955. * @param result defines the target matrix
  84956. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84957. */
  84958. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84959. /**
  84960. * Stores a left-handed perspective projection into a given matrix with depth reversed
  84961. * @param fov defines the horizontal field of view
  84962. * @param aspect defines the aspect ratio
  84963. * @param znear defines the near clip plane
  84964. * @param zfar not used as infinity is used as far clip
  84965. * @param result defines the target matrix
  84966. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84967. */
  84968. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84969. /**
  84970. * Creates a right-handed perspective projection matrix
  84971. * @param fov defines the horizontal field of view
  84972. * @param aspect defines the aspect ratio
  84973. * @param znear defines the near clip plane
  84974. * @param zfar defines the far clip plane
  84975. * @returns a new matrix as a right-handed perspective projection matrix
  84976. */
  84977. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84978. /**
  84979. * Stores a right-handed perspective projection into a given matrix
  84980. * @param fov defines the horizontal field of view
  84981. * @param aspect defines the aspect ratio
  84982. * @param znear defines the near clip plane
  84983. * @param zfar defines the far clip plane
  84984. * @param result defines the target matrix
  84985. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84986. */
  84987. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84988. /**
  84989. * Stores a right-handed perspective projection into a given matrix
  84990. * @param fov defines the horizontal field of view
  84991. * @param aspect defines the aspect ratio
  84992. * @param znear defines the near clip plane
  84993. * @param zfar not used as infinity is used as far clip
  84994. * @param result defines the target matrix
  84995. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84996. */
  84997. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84998. /**
  84999. * Stores a perspective projection for WebVR info a given matrix
  85000. * @param fov defines the field of view
  85001. * @param znear defines the near clip plane
  85002. * @param zfar defines the far clip plane
  85003. * @param result defines the target matrix
  85004. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85005. */
  85006. static PerspectiveFovWebVRToRef(fov: {
  85007. upDegrees: number;
  85008. downDegrees: number;
  85009. leftDegrees: number;
  85010. rightDegrees: number;
  85011. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85012. /**
  85013. * Computes a complete transformation matrix
  85014. * @param viewport defines the viewport to use
  85015. * @param world defines the world matrix
  85016. * @param view defines the view matrix
  85017. * @param projection defines the projection matrix
  85018. * @param zmin defines the near clip plane
  85019. * @param zmax defines the far clip plane
  85020. * @returns the transformation matrix
  85021. */
  85022. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85023. /**
  85024. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85025. * @param matrix defines the matrix to use
  85026. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85027. */
  85028. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85029. /**
  85030. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85031. * @param matrix defines the matrix to use
  85032. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85033. */
  85034. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85035. /**
  85036. * Compute the transpose of a given matrix
  85037. * @param matrix defines the matrix to transpose
  85038. * @returns the new matrix
  85039. */
  85040. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85041. /**
  85042. * Compute the transpose of a matrix and store it in a target matrix
  85043. * @param matrix defines the matrix to transpose
  85044. * @param result defines the target matrix
  85045. */
  85046. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85047. /**
  85048. * Computes a reflection matrix from a plane
  85049. * @param plane defines the reflection plane
  85050. * @returns a new matrix
  85051. */
  85052. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85053. /**
  85054. * Computes a reflection matrix from a plane
  85055. * @param plane defines the reflection plane
  85056. * @param result defines the target matrix
  85057. */
  85058. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85059. /**
  85060. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85061. * @param xaxis defines the value of the 1st axis
  85062. * @param yaxis defines the value of the 2nd axis
  85063. * @param zaxis defines the value of the 3rd axis
  85064. * @param result defines the target matrix
  85065. */
  85066. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85067. /**
  85068. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85069. * @param quat defines the quaternion to use
  85070. * @param result defines the target matrix
  85071. */
  85072. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85073. }
  85074. /**
  85075. * @hidden
  85076. */
  85077. export class TmpVectors {
  85078. static Vector2: Vector2[];
  85079. static Vector3: Vector3[];
  85080. static Vector4: Vector4[];
  85081. static Quaternion: Quaternion[];
  85082. static Matrix: Matrix[];
  85083. }
  85084. }
  85085. declare module BABYLON {
  85086. /**
  85087. * Defines potential orientation for back face culling
  85088. */
  85089. export enum Orientation {
  85090. /**
  85091. * Clockwise
  85092. */
  85093. CW = 0,
  85094. /** Counter clockwise */
  85095. CCW = 1
  85096. }
  85097. /** Class used to represent a Bezier curve */
  85098. export class BezierCurve {
  85099. /**
  85100. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85101. * @param t defines the time
  85102. * @param x1 defines the left coordinate on X axis
  85103. * @param y1 defines the left coordinate on Y axis
  85104. * @param x2 defines the right coordinate on X axis
  85105. * @param y2 defines the right coordinate on Y axis
  85106. * @returns the interpolated value
  85107. */
  85108. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85109. }
  85110. /**
  85111. * Defines angle representation
  85112. */
  85113. export class Angle {
  85114. private _radians;
  85115. /**
  85116. * Creates an Angle object of "radians" radians (float).
  85117. * @param radians the angle in radians
  85118. */
  85119. constructor(radians: number);
  85120. /**
  85121. * Get value in degrees
  85122. * @returns the Angle value in degrees (float)
  85123. */
  85124. degrees(): number;
  85125. /**
  85126. * Get value in radians
  85127. * @returns the Angle value in radians (float)
  85128. */
  85129. radians(): number;
  85130. /**
  85131. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85132. * @param a defines first point as the origin
  85133. * @param b defines point
  85134. * @returns a new Angle
  85135. */
  85136. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85137. /**
  85138. * Gets a new Angle object from the given float in radians
  85139. * @param radians defines the angle value in radians
  85140. * @returns a new Angle
  85141. */
  85142. static FromRadians(radians: number): Angle;
  85143. /**
  85144. * Gets a new Angle object from the given float in degrees
  85145. * @param degrees defines the angle value in degrees
  85146. * @returns a new Angle
  85147. */
  85148. static FromDegrees(degrees: number): Angle;
  85149. }
  85150. /**
  85151. * This represents an arc in a 2d space.
  85152. */
  85153. export class Arc2 {
  85154. /** Defines the start point of the arc */
  85155. startPoint: Vector2;
  85156. /** Defines the mid point of the arc */
  85157. midPoint: Vector2;
  85158. /** Defines the end point of the arc */
  85159. endPoint: Vector2;
  85160. /**
  85161. * Defines the center point of the arc.
  85162. */
  85163. centerPoint: Vector2;
  85164. /**
  85165. * Defines the radius of the arc.
  85166. */
  85167. radius: number;
  85168. /**
  85169. * Defines the angle of the arc (from mid point to end point).
  85170. */
  85171. angle: Angle;
  85172. /**
  85173. * Defines the start angle of the arc (from start point to middle point).
  85174. */
  85175. startAngle: Angle;
  85176. /**
  85177. * Defines the orientation of the arc (clock wise/counter clock wise).
  85178. */
  85179. orientation: Orientation;
  85180. /**
  85181. * Creates an Arc object from the three given points : start, middle and end.
  85182. * @param startPoint Defines the start point of the arc
  85183. * @param midPoint Defines the midlle point of the arc
  85184. * @param endPoint Defines the end point of the arc
  85185. */
  85186. constructor(
  85187. /** Defines the start point of the arc */
  85188. startPoint: Vector2,
  85189. /** Defines the mid point of the arc */
  85190. midPoint: Vector2,
  85191. /** Defines the end point of the arc */
  85192. endPoint: Vector2);
  85193. }
  85194. /**
  85195. * Represents a 2D path made up of multiple 2D points
  85196. */
  85197. export class Path2 {
  85198. private _points;
  85199. private _length;
  85200. /**
  85201. * If the path start and end point are the same
  85202. */
  85203. closed: boolean;
  85204. /**
  85205. * Creates a Path2 object from the starting 2D coordinates x and y.
  85206. * @param x the starting points x value
  85207. * @param y the starting points y value
  85208. */
  85209. constructor(x: number, y: number);
  85210. /**
  85211. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85212. * @param x the added points x value
  85213. * @param y the added points y value
  85214. * @returns the updated Path2.
  85215. */
  85216. addLineTo(x: number, y: number): Path2;
  85217. /**
  85218. * 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.
  85219. * @param midX middle point x value
  85220. * @param midY middle point y value
  85221. * @param endX end point x value
  85222. * @param endY end point y value
  85223. * @param numberOfSegments (default: 36)
  85224. * @returns the updated Path2.
  85225. */
  85226. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85227. /**
  85228. * Closes the Path2.
  85229. * @returns the Path2.
  85230. */
  85231. close(): Path2;
  85232. /**
  85233. * Gets the sum of the distance between each sequential point in the path
  85234. * @returns the Path2 total length (float).
  85235. */
  85236. length(): number;
  85237. /**
  85238. * Gets the points which construct the path
  85239. * @returns the Path2 internal array of points.
  85240. */
  85241. getPoints(): Vector2[];
  85242. /**
  85243. * Retreives the point at the distance aways from the starting point
  85244. * @param normalizedLengthPosition the length along the path to retreive the point from
  85245. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85246. */
  85247. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85248. /**
  85249. * Creates a new path starting from an x and y position
  85250. * @param x starting x value
  85251. * @param y starting y value
  85252. * @returns a new Path2 starting at the coordinates (x, y).
  85253. */
  85254. static StartingAt(x: number, y: number): Path2;
  85255. }
  85256. /**
  85257. * Represents a 3D path made up of multiple 3D points
  85258. */
  85259. export class Path3D {
  85260. /**
  85261. * an array of Vector3, the curve axis of the Path3D
  85262. */
  85263. path: Vector3[];
  85264. private _curve;
  85265. private _distances;
  85266. private _tangents;
  85267. private _normals;
  85268. private _binormals;
  85269. private _raw;
  85270. private _alignTangentsWithPath;
  85271. private readonly _pointAtData;
  85272. /**
  85273. * new Path3D(path, normal, raw)
  85274. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85275. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85276. * @param path an array of Vector3, the curve axis of the Path3D
  85277. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85278. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85279. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85280. */
  85281. constructor(
  85282. /**
  85283. * an array of Vector3, the curve axis of the Path3D
  85284. */
  85285. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85286. /**
  85287. * Returns the Path3D array of successive Vector3 designing its curve.
  85288. * @returns the Path3D array of successive Vector3 designing its curve.
  85289. */
  85290. getCurve(): Vector3[];
  85291. /**
  85292. * Returns the Path3D array of successive Vector3 designing its curve.
  85293. * @returns the Path3D array of successive Vector3 designing its curve.
  85294. */
  85295. getPoints(): Vector3[];
  85296. /**
  85297. * @returns the computed length (float) of the path.
  85298. */
  85299. length(): number;
  85300. /**
  85301. * Returns an array populated with tangent vectors on each Path3D curve point.
  85302. * @returns an array populated with tangent vectors on each Path3D curve point.
  85303. */
  85304. getTangents(): Vector3[];
  85305. /**
  85306. * Returns an array populated with normal vectors on each Path3D curve point.
  85307. * @returns an array populated with normal vectors on each Path3D curve point.
  85308. */
  85309. getNormals(): Vector3[];
  85310. /**
  85311. * Returns an array populated with binormal vectors on each Path3D curve point.
  85312. * @returns an array populated with binormal vectors on each Path3D curve point.
  85313. */
  85314. getBinormals(): Vector3[];
  85315. /**
  85316. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85317. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85318. */
  85319. getDistances(): number[];
  85320. /**
  85321. * Returns an interpolated point along this path
  85322. * @param position the position of the point along this path, from 0.0 to 1.0
  85323. * @returns a new Vector3 as the point
  85324. */
  85325. getPointAt(position: number): Vector3;
  85326. /**
  85327. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85328. * @param position the position of the point along this path, from 0.0 to 1.0
  85329. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85330. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85331. */
  85332. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85333. /**
  85334. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85335. * @param position the position of the point along this path, from 0.0 to 1.0
  85336. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85337. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85338. */
  85339. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85340. /**
  85341. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85342. * @param position the position of the point along this path, from 0.0 to 1.0
  85343. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85344. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85345. */
  85346. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85347. /**
  85348. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85349. * @param position the position of the point along this path, from 0.0 to 1.0
  85350. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85351. */
  85352. getDistanceAt(position: number): number;
  85353. /**
  85354. * Returns the array index of the previous point of an interpolated point along this path
  85355. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85356. * @returns the array index
  85357. */
  85358. getPreviousPointIndexAt(position: number): number;
  85359. /**
  85360. * 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)
  85361. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85362. * @returns the sub position
  85363. */
  85364. getSubPositionAt(position: number): number;
  85365. /**
  85366. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85367. * @param target the vector of which to get the closest position to
  85368. * @returns the position of the closest virtual point on this path to the target vector
  85369. */
  85370. getClosestPositionTo(target: Vector3): number;
  85371. /**
  85372. * Returns a sub path (slice) of this path
  85373. * @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
  85374. * @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
  85375. * @returns a sub path (slice) of this path
  85376. */
  85377. slice(start?: number, end?: number): Path3D;
  85378. /**
  85379. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85380. * @param path path which all values are copied into the curves points
  85381. * @param firstNormal which should be projected onto the curve
  85382. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85383. * @returns the same object updated.
  85384. */
  85385. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85386. private _compute;
  85387. private _getFirstNonNullVector;
  85388. private _getLastNonNullVector;
  85389. private _normalVector;
  85390. /**
  85391. * Updates the point at data for an interpolated point along this curve
  85392. * @param position the position of the point along this curve, from 0.0 to 1.0
  85393. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85394. * @returns the (updated) point at data
  85395. */
  85396. private _updatePointAtData;
  85397. /**
  85398. * Updates the point at data from the specified parameters
  85399. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85400. * @param point the interpolated point
  85401. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85402. */
  85403. private _setPointAtData;
  85404. /**
  85405. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85406. */
  85407. private _updateInterpolationMatrix;
  85408. }
  85409. /**
  85410. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85411. * A Curve3 is designed from a series of successive Vector3.
  85412. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85413. */
  85414. export class Curve3 {
  85415. private _points;
  85416. private _length;
  85417. /**
  85418. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85419. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85420. * @param v1 (Vector3) the control point
  85421. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85422. * @param nbPoints (integer) the wanted number of points in the curve
  85423. * @returns the created Curve3
  85424. */
  85425. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85426. /**
  85427. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85428. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85429. * @param v1 (Vector3) the first control point
  85430. * @param v2 (Vector3) the second control point
  85431. * @param v3 (Vector3) the end point of the Cubic Bezier
  85432. * @param nbPoints (integer) the wanted number of points in the curve
  85433. * @returns the created Curve3
  85434. */
  85435. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85436. /**
  85437. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85438. * @param p1 (Vector3) the origin point of the Hermite Spline
  85439. * @param t1 (Vector3) the tangent vector at the origin point
  85440. * @param p2 (Vector3) the end point of the Hermite Spline
  85441. * @param t2 (Vector3) the tangent vector at the end point
  85442. * @param nbPoints (integer) the wanted number of points in the curve
  85443. * @returns the created Curve3
  85444. */
  85445. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85446. /**
  85447. * Returns a Curve3 object along a CatmullRom Spline curve :
  85448. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85449. * @param nbPoints (integer) the wanted number of points between each curve control points
  85450. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85451. * @returns the created Curve3
  85452. */
  85453. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85454. /**
  85455. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85456. * A Curve3 is designed from a series of successive Vector3.
  85457. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85458. * @param points points which make up the curve
  85459. */
  85460. constructor(points: Vector3[]);
  85461. /**
  85462. * @returns the Curve3 stored array of successive Vector3
  85463. */
  85464. getPoints(): Vector3[];
  85465. /**
  85466. * @returns the computed length (float) of the curve.
  85467. */
  85468. length(): number;
  85469. /**
  85470. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85471. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85472. * curveA and curveB keep unchanged.
  85473. * @param curve the curve to continue from this curve
  85474. * @returns the newly constructed curve
  85475. */
  85476. continue(curve: DeepImmutable<Curve3>): Curve3;
  85477. private _computeLength;
  85478. }
  85479. }
  85480. declare module BABYLON {
  85481. /**
  85482. * This represents the main contract an easing function should follow.
  85483. * Easing functions are used throughout the animation system.
  85484. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85485. */
  85486. export interface IEasingFunction {
  85487. /**
  85488. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85489. * of the easing function.
  85490. * The link below provides some of the most common examples of easing functions.
  85491. * @see https://easings.net/
  85492. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85493. * @returns the corresponding value on the curve defined by the easing function
  85494. */
  85495. ease(gradient: number): number;
  85496. }
  85497. /**
  85498. * Base class used for every default easing function.
  85499. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85500. */
  85501. export class EasingFunction implements IEasingFunction {
  85502. /**
  85503. * Interpolation follows the mathematical formula associated with the easing function.
  85504. */
  85505. static readonly EASINGMODE_EASEIN: number;
  85506. /**
  85507. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85508. */
  85509. static readonly EASINGMODE_EASEOUT: number;
  85510. /**
  85511. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85512. */
  85513. static readonly EASINGMODE_EASEINOUT: number;
  85514. private _easingMode;
  85515. /**
  85516. * Sets the easing mode of the current function.
  85517. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85518. */
  85519. setEasingMode(easingMode: number): void;
  85520. /**
  85521. * Gets the current easing mode.
  85522. * @returns the easing mode
  85523. */
  85524. getEasingMode(): number;
  85525. /**
  85526. * @hidden
  85527. */
  85528. easeInCore(gradient: number): number;
  85529. /**
  85530. * Given an input gradient between 0 and 1, this returns the corresponding value
  85531. * of the easing function.
  85532. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85533. * @returns the corresponding value on the curve defined by the easing function
  85534. */
  85535. ease(gradient: number): number;
  85536. }
  85537. /**
  85538. * Easing function with a circle shape (see link below).
  85539. * @see https://easings.net/#easeInCirc
  85540. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85541. */
  85542. export class CircleEase extends EasingFunction implements IEasingFunction {
  85543. /** @hidden */
  85544. easeInCore(gradient: number): number;
  85545. }
  85546. /**
  85547. * Easing function with a ease back shape (see link below).
  85548. * @see https://easings.net/#easeInBack
  85549. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85550. */
  85551. export class BackEase extends EasingFunction implements IEasingFunction {
  85552. /** Defines the amplitude of the function */
  85553. amplitude: number;
  85554. /**
  85555. * Instantiates a back ease easing
  85556. * @see https://easings.net/#easeInBack
  85557. * @param amplitude Defines the amplitude of the function
  85558. */
  85559. constructor(
  85560. /** Defines the amplitude of the function */
  85561. amplitude?: number);
  85562. /** @hidden */
  85563. easeInCore(gradient: number): number;
  85564. }
  85565. /**
  85566. * Easing function with a bouncing shape (see link below).
  85567. * @see https://easings.net/#easeInBounce
  85568. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85569. */
  85570. export class BounceEase extends EasingFunction implements IEasingFunction {
  85571. /** Defines the number of bounces */
  85572. bounces: number;
  85573. /** Defines the amplitude of the bounce */
  85574. bounciness: number;
  85575. /**
  85576. * Instantiates a bounce easing
  85577. * @see https://easings.net/#easeInBounce
  85578. * @param bounces Defines the number of bounces
  85579. * @param bounciness Defines the amplitude of the bounce
  85580. */
  85581. constructor(
  85582. /** Defines the number of bounces */
  85583. bounces?: number,
  85584. /** Defines the amplitude of the bounce */
  85585. bounciness?: number);
  85586. /** @hidden */
  85587. easeInCore(gradient: number): number;
  85588. }
  85589. /**
  85590. * Easing function with a power of 3 shape (see link below).
  85591. * @see https://easings.net/#easeInCubic
  85592. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85593. */
  85594. export class CubicEase extends EasingFunction implements IEasingFunction {
  85595. /** @hidden */
  85596. easeInCore(gradient: number): number;
  85597. }
  85598. /**
  85599. * Easing function with an elastic shape (see link below).
  85600. * @see https://easings.net/#easeInElastic
  85601. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85602. */
  85603. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85604. /** Defines the number of oscillations*/
  85605. oscillations: number;
  85606. /** Defines the amplitude of the oscillations*/
  85607. springiness: number;
  85608. /**
  85609. * Instantiates an elastic easing function
  85610. * @see https://easings.net/#easeInElastic
  85611. * @param oscillations Defines the number of oscillations
  85612. * @param springiness Defines the amplitude of the oscillations
  85613. */
  85614. constructor(
  85615. /** Defines the number of oscillations*/
  85616. oscillations?: number,
  85617. /** Defines the amplitude of the oscillations*/
  85618. springiness?: number);
  85619. /** @hidden */
  85620. easeInCore(gradient: number): number;
  85621. }
  85622. /**
  85623. * Easing function with an exponential shape (see link below).
  85624. * @see https://easings.net/#easeInExpo
  85625. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85626. */
  85627. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85628. /** Defines the exponent of the function */
  85629. exponent: number;
  85630. /**
  85631. * Instantiates an exponential easing function
  85632. * @see https://easings.net/#easeInExpo
  85633. * @param exponent Defines the exponent of the function
  85634. */
  85635. constructor(
  85636. /** Defines the exponent of the function */
  85637. exponent?: number);
  85638. /** @hidden */
  85639. easeInCore(gradient: number): number;
  85640. }
  85641. /**
  85642. * Easing function with a power shape (see link below).
  85643. * @see https://easings.net/#easeInQuad
  85644. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85645. */
  85646. export class PowerEase extends EasingFunction implements IEasingFunction {
  85647. /** Defines the power of the function */
  85648. power: number;
  85649. /**
  85650. * Instantiates an power base easing function
  85651. * @see https://easings.net/#easeInQuad
  85652. * @param power Defines the power of the function
  85653. */
  85654. constructor(
  85655. /** Defines the power of the function */
  85656. power?: number);
  85657. /** @hidden */
  85658. easeInCore(gradient: number): number;
  85659. }
  85660. /**
  85661. * Easing function with a power of 2 shape (see link below).
  85662. * @see https://easings.net/#easeInQuad
  85663. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85664. */
  85665. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85666. /** @hidden */
  85667. easeInCore(gradient: number): number;
  85668. }
  85669. /**
  85670. * Easing function with a power of 4 shape (see link below).
  85671. * @see https://easings.net/#easeInQuart
  85672. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85673. */
  85674. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85675. /** @hidden */
  85676. easeInCore(gradient: number): number;
  85677. }
  85678. /**
  85679. * Easing function with a power of 5 shape (see link below).
  85680. * @see https://easings.net/#easeInQuint
  85681. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85682. */
  85683. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85684. /** @hidden */
  85685. easeInCore(gradient: number): number;
  85686. }
  85687. /**
  85688. * Easing function with a sin shape (see link below).
  85689. * @see https://easings.net/#easeInSine
  85690. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85691. */
  85692. export class SineEase extends EasingFunction implements IEasingFunction {
  85693. /** @hidden */
  85694. easeInCore(gradient: number): number;
  85695. }
  85696. /**
  85697. * Easing function with a bezier shape (see link below).
  85698. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85699. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85700. */
  85701. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85702. /** Defines the x component of the start tangent in the bezier curve */
  85703. x1: number;
  85704. /** Defines the y component of the start tangent in the bezier curve */
  85705. y1: number;
  85706. /** Defines the x component of the end tangent in the bezier curve */
  85707. x2: number;
  85708. /** Defines the y component of the end tangent in the bezier curve */
  85709. y2: number;
  85710. /**
  85711. * Instantiates a bezier function
  85712. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85713. * @param x1 Defines the x component of the start tangent in the bezier curve
  85714. * @param y1 Defines the y component of the start tangent in the bezier curve
  85715. * @param x2 Defines the x component of the end tangent in the bezier curve
  85716. * @param y2 Defines the y component of the end tangent in the bezier curve
  85717. */
  85718. constructor(
  85719. /** Defines the x component of the start tangent in the bezier curve */
  85720. x1?: number,
  85721. /** Defines the y component of the start tangent in the bezier curve */
  85722. y1?: number,
  85723. /** Defines the x component of the end tangent in the bezier curve */
  85724. x2?: number,
  85725. /** Defines the y component of the end tangent in the bezier curve */
  85726. y2?: number);
  85727. /** @hidden */
  85728. easeInCore(gradient: number): number;
  85729. }
  85730. }
  85731. declare module BABYLON {
  85732. /**
  85733. * Class used to hold a RBG color
  85734. */
  85735. export class Color3 {
  85736. /**
  85737. * Defines the red component (between 0 and 1, default is 0)
  85738. */
  85739. r: number;
  85740. /**
  85741. * Defines the green component (between 0 and 1, default is 0)
  85742. */
  85743. g: number;
  85744. /**
  85745. * Defines the blue component (between 0 and 1, default is 0)
  85746. */
  85747. b: number;
  85748. /**
  85749. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85750. * @param r defines the red component (between 0 and 1, default is 0)
  85751. * @param g defines the green component (between 0 and 1, default is 0)
  85752. * @param b defines the blue component (between 0 and 1, default is 0)
  85753. */
  85754. constructor(
  85755. /**
  85756. * Defines the red component (between 0 and 1, default is 0)
  85757. */
  85758. r?: number,
  85759. /**
  85760. * Defines the green component (between 0 and 1, default is 0)
  85761. */
  85762. g?: number,
  85763. /**
  85764. * Defines the blue component (between 0 and 1, default is 0)
  85765. */
  85766. b?: number);
  85767. /**
  85768. * Creates a string with the Color3 current values
  85769. * @returns the string representation of the Color3 object
  85770. */
  85771. toString(): string;
  85772. /**
  85773. * Returns the string "Color3"
  85774. * @returns "Color3"
  85775. */
  85776. getClassName(): string;
  85777. /**
  85778. * Compute the Color3 hash code
  85779. * @returns an unique number that can be used to hash Color3 objects
  85780. */
  85781. getHashCode(): number;
  85782. /**
  85783. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85784. * @param array defines the array where to store the r,g,b components
  85785. * @param index defines an optional index in the target array to define where to start storing values
  85786. * @returns the current Color3 object
  85787. */
  85788. toArray(array: FloatArray, index?: number): Color3;
  85789. /**
  85790. * Update the current color with values stored in an array from the starting index of the given array
  85791. * @param array defines the source array
  85792. * @param offset defines an offset in the source array
  85793. * @returns the current Color3 object
  85794. */
  85795. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85796. /**
  85797. * Returns a new Color4 object from the current Color3 and the given alpha
  85798. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85799. * @returns a new Color4 object
  85800. */
  85801. toColor4(alpha?: number): Color4;
  85802. /**
  85803. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85804. * @returns the new array
  85805. */
  85806. asArray(): number[];
  85807. /**
  85808. * Returns the luminance value
  85809. * @returns a float value
  85810. */
  85811. toLuminance(): number;
  85812. /**
  85813. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85814. * @param otherColor defines the second operand
  85815. * @returns the new Color3 object
  85816. */
  85817. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85818. /**
  85819. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85820. * @param otherColor defines the second operand
  85821. * @param result defines the Color3 object where to store the result
  85822. * @returns the current Color3
  85823. */
  85824. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85825. /**
  85826. * Determines equality between Color3 objects
  85827. * @param otherColor defines the second operand
  85828. * @returns true if the rgb values are equal to the given ones
  85829. */
  85830. equals(otherColor: DeepImmutable<Color3>): boolean;
  85831. /**
  85832. * Determines equality between the current Color3 object and a set of r,b,g values
  85833. * @param r defines the red component to check
  85834. * @param g defines the green component to check
  85835. * @param b defines the blue component to check
  85836. * @returns true if the rgb values are equal to the given ones
  85837. */
  85838. equalsFloats(r: number, g: number, b: number): boolean;
  85839. /**
  85840. * Multiplies in place each rgb value by scale
  85841. * @param scale defines the scaling factor
  85842. * @returns the updated Color3
  85843. */
  85844. scale(scale: number): Color3;
  85845. /**
  85846. * Multiplies the rgb values by scale and stores the result into "result"
  85847. * @param scale defines the scaling factor
  85848. * @param result defines the Color3 object where to store the result
  85849. * @returns the unmodified current Color3
  85850. */
  85851. scaleToRef(scale: number, result: Color3): Color3;
  85852. /**
  85853. * Scale the current Color3 values by a factor and add the result to a given Color3
  85854. * @param scale defines the scale factor
  85855. * @param result defines color to store the result into
  85856. * @returns the unmodified current Color3
  85857. */
  85858. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85859. /**
  85860. * Clamps the rgb values by the min and max values and stores the result into "result"
  85861. * @param min defines minimum clamping value (default is 0)
  85862. * @param max defines maximum clamping value (default is 1)
  85863. * @param result defines color to store the result into
  85864. * @returns the original Color3
  85865. */
  85866. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85867. /**
  85868. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85869. * @param otherColor defines the second operand
  85870. * @returns the new Color3
  85871. */
  85872. add(otherColor: DeepImmutable<Color3>): Color3;
  85873. /**
  85874. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85875. * @param otherColor defines the second operand
  85876. * @param result defines Color3 object to store the result into
  85877. * @returns the unmodified current Color3
  85878. */
  85879. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85880. /**
  85881. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85882. * @param otherColor defines the second operand
  85883. * @returns the new Color3
  85884. */
  85885. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85886. /**
  85887. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85888. * @param otherColor defines the second operand
  85889. * @param result defines Color3 object to store the result into
  85890. * @returns the unmodified current Color3
  85891. */
  85892. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85893. /**
  85894. * Copy the current object
  85895. * @returns a new Color3 copied the current one
  85896. */
  85897. clone(): Color3;
  85898. /**
  85899. * Copies the rgb values from the source in the current Color3
  85900. * @param source defines the source Color3 object
  85901. * @returns the updated Color3 object
  85902. */
  85903. copyFrom(source: DeepImmutable<Color3>): Color3;
  85904. /**
  85905. * Updates the Color3 rgb values from the given floats
  85906. * @param r defines the red component to read from
  85907. * @param g defines the green component to read from
  85908. * @param b defines the blue component to read from
  85909. * @returns the current Color3 object
  85910. */
  85911. copyFromFloats(r: number, g: number, b: number): Color3;
  85912. /**
  85913. * Updates the Color3 rgb values from the given floats
  85914. * @param r defines the red component to read from
  85915. * @param g defines the green component to read from
  85916. * @param b defines the blue component to read from
  85917. * @returns the current Color3 object
  85918. */
  85919. set(r: number, g: number, b: number): Color3;
  85920. /**
  85921. * Compute the Color3 hexadecimal code as a string
  85922. * @returns a string containing the hexadecimal representation of the Color3 object
  85923. */
  85924. toHexString(): string;
  85925. /**
  85926. * Computes a new Color3 converted from the current one to linear space
  85927. * @returns a new Color3 object
  85928. */
  85929. toLinearSpace(): Color3;
  85930. /**
  85931. * Converts current color in rgb space to HSV values
  85932. * @returns a new color3 representing the HSV values
  85933. */
  85934. toHSV(): Color3;
  85935. /**
  85936. * Converts current color in rgb space to HSV values
  85937. * @param result defines the Color3 where to store the HSV values
  85938. */
  85939. toHSVToRef(result: Color3): void;
  85940. /**
  85941. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  85942. * @param convertedColor defines the Color3 object where to store the linear space version
  85943. * @returns the unmodified Color3
  85944. */
  85945. toLinearSpaceToRef(convertedColor: Color3): Color3;
  85946. /**
  85947. * Computes a new Color3 converted from the current one to gamma space
  85948. * @returns a new Color3 object
  85949. */
  85950. toGammaSpace(): Color3;
  85951. /**
  85952. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  85953. * @param convertedColor defines the Color3 object where to store the gamma space version
  85954. * @returns the unmodified Color3
  85955. */
  85956. toGammaSpaceToRef(convertedColor: Color3): Color3;
  85957. private static _BlackReadOnly;
  85958. /**
  85959. * Convert Hue, saturation and value to a Color3 (RGB)
  85960. * @param hue defines the hue
  85961. * @param saturation defines the saturation
  85962. * @param value defines the value
  85963. * @param result defines the Color3 where to store the RGB values
  85964. */
  85965. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  85966. /**
  85967. * Creates a new Color3 from the string containing valid hexadecimal values
  85968. * @param hex defines a string containing valid hexadecimal values
  85969. * @returns a new Color3 object
  85970. */
  85971. static FromHexString(hex: string): Color3;
  85972. /**
  85973. * Creates a new Color3 from the starting index of the given array
  85974. * @param array defines the source array
  85975. * @param offset defines an offset in the source array
  85976. * @returns a new Color3 object
  85977. */
  85978. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85979. /**
  85980. * Creates a new Color3 from the starting index element of the given array
  85981. * @param array defines the source array to read from
  85982. * @param offset defines the offset in the source array
  85983. * @param result defines the target Color3 object
  85984. */
  85985. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  85986. /**
  85987. * Creates a new Color3 from integer values (< 256)
  85988. * @param r defines the red component to read from (value between 0 and 255)
  85989. * @param g defines the green component to read from (value between 0 and 255)
  85990. * @param b defines the blue component to read from (value between 0 and 255)
  85991. * @returns a new Color3 object
  85992. */
  85993. static FromInts(r: number, g: number, b: number): Color3;
  85994. /**
  85995. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85996. * @param start defines the start Color3 value
  85997. * @param end defines the end Color3 value
  85998. * @param amount defines the gradient value between start and end
  85999. * @returns a new Color3 object
  86000. */
  86001. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86002. /**
  86003. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86004. * @param left defines the start value
  86005. * @param right defines the end value
  86006. * @param amount defines the gradient factor
  86007. * @param result defines the Color3 object where to store the result
  86008. */
  86009. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86010. /**
  86011. * Returns a Color3 value containing a red color
  86012. * @returns a new Color3 object
  86013. */
  86014. static Red(): Color3;
  86015. /**
  86016. * Returns a Color3 value containing a green color
  86017. * @returns a new Color3 object
  86018. */
  86019. static Green(): Color3;
  86020. /**
  86021. * Returns a Color3 value containing a blue color
  86022. * @returns a new Color3 object
  86023. */
  86024. static Blue(): Color3;
  86025. /**
  86026. * Returns a Color3 value containing a black color
  86027. * @returns a new Color3 object
  86028. */
  86029. static Black(): Color3;
  86030. /**
  86031. * Gets a Color3 value containing a black color that must not be updated
  86032. */
  86033. static get BlackReadOnly(): DeepImmutable<Color3>;
  86034. /**
  86035. * Returns a Color3 value containing a white color
  86036. * @returns a new Color3 object
  86037. */
  86038. static White(): Color3;
  86039. /**
  86040. * Returns a Color3 value containing a purple color
  86041. * @returns a new Color3 object
  86042. */
  86043. static Purple(): Color3;
  86044. /**
  86045. * Returns a Color3 value containing a magenta color
  86046. * @returns a new Color3 object
  86047. */
  86048. static Magenta(): Color3;
  86049. /**
  86050. * Returns a Color3 value containing a yellow color
  86051. * @returns a new Color3 object
  86052. */
  86053. static Yellow(): Color3;
  86054. /**
  86055. * Returns a Color3 value containing a gray color
  86056. * @returns a new Color3 object
  86057. */
  86058. static Gray(): Color3;
  86059. /**
  86060. * Returns a Color3 value containing a teal color
  86061. * @returns a new Color3 object
  86062. */
  86063. static Teal(): Color3;
  86064. /**
  86065. * Returns a Color3 value containing a random color
  86066. * @returns a new Color3 object
  86067. */
  86068. static Random(): Color3;
  86069. }
  86070. /**
  86071. * Class used to hold a RBGA color
  86072. */
  86073. export class Color4 {
  86074. /**
  86075. * Defines the red component (between 0 and 1, default is 0)
  86076. */
  86077. r: number;
  86078. /**
  86079. * Defines the green component (between 0 and 1, default is 0)
  86080. */
  86081. g: number;
  86082. /**
  86083. * Defines the blue component (between 0 and 1, default is 0)
  86084. */
  86085. b: number;
  86086. /**
  86087. * Defines the alpha component (between 0 and 1, default is 1)
  86088. */
  86089. a: number;
  86090. /**
  86091. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86092. * @param r defines the red component (between 0 and 1, default is 0)
  86093. * @param g defines the green component (between 0 and 1, default is 0)
  86094. * @param b defines the blue component (between 0 and 1, default is 0)
  86095. * @param a defines the alpha component (between 0 and 1, default is 1)
  86096. */
  86097. constructor(
  86098. /**
  86099. * Defines the red component (between 0 and 1, default is 0)
  86100. */
  86101. r?: number,
  86102. /**
  86103. * Defines the green component (between 0 and 1, default is 0)
  86104. */
  86105. g?: number,
  86106. /**
  86107. * Defines the blue component (between 0 and 1, default is 0)
  86108. */
  86109. b?: number,
  86110. /**
  86111. * Defines the alpha component (between 0 and 1, default is 1)
  86112. */
  86113. a?: number);
  86114. /**
  86115. * Adds in place the given Color4 values to the current Color4 object
  86116. * @param right defines the second operand
  86117. * @returns the current updated Color4 object
  86118. */
  86119. addInPlace(right: DeepImmutable<Color4>): Color4;
  86120. /**
  86121. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86122. * @returns the new array
  86123. */
  86124. asArray(): number[];
  86125. /**
  86126. * Stores from the starting index in the given array the Color4 successive values
  86127. * @param array defines the array where to store the r,g,b components
  86128. * @param index defines an optional index in the target array to define where to start storing values
  86129. * @returns the current Color4 object
  86130. */
  86131. toArray(array: number[], index?: number): Color4;
  86132. /**
  86133. * Update the current color with values stored in an array from the starting index of the given array
  86134. * @param array defines the source array
  86135. * @param offset defines an offset in the source array
  86136. * @returns the current Color4 object
  86137. */
  86138. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86139. /**
  86140. * Determines equality between Color4 objects
  86141. * @param otherColor defines the second operand
  86142. * @returns true if the rgba values are equal to the given ones
  86143. */
  86144. equals(otherColor: DeepImmutable<Color4>): boolean;
  86145. /**
  86146. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86147. * @param right defines the second operand
  86148. * @returns a new Color4 object
  86149. */
  86150. add(right: DeepImmutable<Color4>): Color4;
  86151. /**
  86152. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86153. * @param right defines the second operand
  86154. * @returns a new Color4 object
  86155. */
  86156. subtract(right: DeepImmutable<Color4>): Color4;
  86157. /**
  86158. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86159. * @param right defines the second operand
  86160. * @param result defines the Color4 object where to store the result
  86161. * @returns the current Color4 object
  86162. */
  86163. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86164. /**
  86165. * Creates a new Color4 with the current Color4 values multiplied by scale
  86166. * @param scale defines the scaling factor to apply
  86167. * @returns a new Color4 object
  86168. */
  86169. scale(scale: number): Color4;
  86170. /**
  86171. * Multiplies the current Color4 values by scale and stores the result in "result"
  86172. * @param scale defines the scaling factor to apply
  86173. * @param result defines the Color4 object where to store the result
  86174. * @returns the current unmodified Color4
  86175. */
  86176. scaleToRef(scale: number, result: Color4): Color4;
  86177. /**
  86178. * Scale the current Color4 values by a factor and add the result to a given Color4
  86179. * @param scale defines the scale factor
  86180. * @param result defines the Color4 object where to store the result
  86181. * @returns the unmodified current Color4
  86182. */
  86183. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86184. /**
  86185. * Clamps the rgb values by the min and max values and stores the result into "result"
  86186. * @param min defines minimum clamping value (default is 0)
  86187. * @param max defines maximum clamping value (default is 1)
  86188. * @param result defines color to store the result into.
  86189. * @returns the cuurent Color4
  86190. */
  86191. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86192. /**
  86193. * Multipy an Color4 value by another and return a new Color4 object
  86194. * @param color defines the Color4 value to multiply by
  86195. * @returns a new Color4 object
  86196. */
  86197. multiply(color: Color4): Color4;
  86198. /**
  86199. * Multipy a Color4 value by another and push the result in a reference value
  86200. * @param color defines the Color4 value to multiply by
  86201. * @param result defines the Color4 to fill the result in
  86202. * @returns the result Color4
  86203. */
  86204. multiplyToRef(color: Color4, result: Color4): Color4;
  86205. /**
  86206. * Creates a string with the Color4 current values
  86207. * @returns the string representation of the Color4 object
  86208. */
  86209. toString(): string;
  86210. /**
  86211. * Returns the string "Color4"
  86212. * @returns "Color4"
  86213. */
  86214. getClassName(): string;
  86215. /**
  86216. * Compute the Color4 hash code
  86217. * @returns an unique number that can be used to hash Color4 objects
  86218. */
  86219. getHashCode(): number;
  86220. /**
  86221. * Creates a new Color4 copied from the current one
  86222. * @returns a new Color4 object
  86223. */
  86224. clone(): Color4;
  86225. /**
  86226. * Copies the given Color4 values into the current one
  86227. * @param source defines the source Color4 object
  86228. * @returns the current updated Color4 object
  86229. */
  86230. copyFrom(source: Color4): Color4;
  86231. /**
  86232. * Copies the given float values into the current one
  86233. * @param r defines the red component to read from
  86234. * @param g defines the green component to read from
  86235. * @param b defines the blue component to read from
  86236. * @param a defines the alpha component to read from
  86237. * @returns the current updated Color4 object
  86238. */
  86239. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86240. /**
  86241. * Copies the given float values into the current one
  86242. * @param r defines the red component to read from
  86243. * @param g defines the green component to read from
  86244. * @param b defines the blue component to read from
  86245. * @param a defines the alpha component to read from
  86246. * @returns the current updated Color4 object
  86247. */
  86248. set(r: number, g: number, b: number, a: number): Color4;
  86249. /**
  86250. * Compute the Color4 hexadecimal code as a string
  86251. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86252. * @returns a string containing the hexadecimal representation of the Color4 object
  86253. */
  86254. toHexString(returnAsColor3?: boolean): string;
  86255. /**
  86256. * Computes a new Color4 converted from the current one to linear space
  86257. * @returns a new Color4 object
  86258. */
  86259. toLinearSpace(): Color4;
  86260. /**
  86261. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86262. * @param convertedColor defines the Color4 object where to store the linear space version
  86263. * @returns the unmodified Color4
  86264. */
  86265. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86266. /**
  86267. * Computes a new Color4 converted from the current one to gamma space
  86268. * @returns a new Color4 object
  86269. */
  86270. toGammaSpace(): Color4;
  86271. /**
  86272. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86273. * @param convertedColor defines the Color4 object where to store the gamma space version
  86274. * @returns the unmodified Color4
  86275. */
  86276. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86277. /**
  86278. * Creates a new Color4 from the string containing valid hexadecimal values
  86279. * @param hex defines a string containing valid hexadecimal values
  86280. * @returns a new Color4 object
  86281. */
  86282. static FromHexString(hex: string): Color4;
  86283. /**
  86284. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86285. * @param left defines the start value
  86286. * @param right defines the end value
  86287. * @param amount defines the gradient factor
  86288. * @returns a new Color4 object
  86289. */
  86290. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86291. /**
  86292. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86293. * @param left defines the start value
  86294. * @param right defines the end value
  86295. * @param amount defines the gradient factor
  86296. * @param result defines the Color4 object where to store data
  86297. */
  86298. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86299. /**
  86300. * Creates a new Color4 from a Color3 and an alpha value
  86301. * @param color3 defines the source Color3 to read from
  86302. * @param alpha defines the alpha component (1.0 by default)
  86303. * @returns a new Color4 object
  86304. */
  86305. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86306. /**
  86307. * Creates a new Color4 from the starting index element of the given array
  86308. * @param array defines the source array to read from
  86309. * @param offset defines the offset in the source array
  86310. * @returns a new Color4 object
  86311. */
  86312. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86313. /**
  86314. * Creates a new Color4 from the starting index element of the given array
  86315. * @param array defines the source array to read from
  86316. * @param offset defines the offset in the source array
  86317. * @param result defines the target Color4 object
  86318. */
  86319. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86320. /**
  86321. * Creates a new Color3 from integer values (< 256)
  86322. * @param r defines the red component to read from (value between 0 and 255)
  86323. * @param g defines the green component to read from (value between 0 and 255)
  86324. * @param b defines the blue component to read from (value between 0 and 255)
  86325. * @param a defines the alpha component to read from (value between 0 and 255)
  86326. * @returns a new Color3 object
  86327. */
  86328. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86329. /**
  86330. * Check the content of a given array and convert it to an array containing RGBA data
  86331. * If the original array was already containing count * 4 values then it is returned directly
  86332. * @param colors defines the array to check
  86333. * @param count defines the number of RGBA data to expect
  86334. * @returns an array containing count * 4 values (RGBA)
  86335. */
  86336. static CheckColors4(colors: number[], count: number): number[];
  86337. }
  86338. /**
  86339. * @hidden
  86340. */
  86341. export class TmpColors {
  86342. static Color3: Color3[];
  86343. static Color4: Color4[];
  86344. }
  86345. }
  86346. declare module BABYLON {
  86347. /**
  86348. * Defines an interface which represents an animation key frame
  86349. */
  86350. export interface IAnimationKey {
  86351. /**
  86352. * Frame of the key frame
  86353. */
  86354. frame: number;
  86355. /**
  86356. * Value at the specifies key frame
  86357. */
  86358. value: any;
  86359. /**
  86360. * The input tangent for the cubic hermite spline
  86361. */
  86362. inTangent?: any;
  86363. /**
  86364. * The output tangent for the cubic hermite spline
  86365. */
  86366. outTangent?: any;
  86367. /**
  86368. * The animation interpolation type
  86369. */
  86370. interpolation?: AnimationKeyInterpolation;
  86371. }
  86372. /**
  86373. * Enum for the animation key frame interpolation type
  86374. */
  86375. export enum AnimationKeyInterpolation {
  86376. /**
  86377. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86378. */
  86379. STEP = 1
  86380. }
  86381. }
  86382. declare module BABYLON {
  86383. /**
  86384. * Represents the range of an animation
  86385. */
  86386. export class AnimationRange {
  86387. /**The name of the animation range**/
  86388. name: string;
  86389. /**The starting frame of the animation */
  86390. from: number;
  86391. /**The ending frame of the animation*/
  86392. to: number;
  86393. /**
  86394. * Initializes the range of an animation
  86395. * @param name The name of the animation range
  86396. * @param from The starting frame of the animation
  86397. * @param to The ending frame of the animation
  86398. */
  86399. constructor(
  86400. /**The name of the animation range**/
  86401. name: string,
  86402. /**The starting frame of the animation */
  86403. from: number,
  86404. /**The ending frame of the animation*/
  86405. to: number);
  86406. /**
  86407. * Makes a copy of the animation range
  86408. * @returns A copy of the animation range
  86409. */
  86410. clone(): AnimationRange;
  86411. }
  86412. }
  86413. declare module BABYLON {
  86414. /**
  86415. * Composed of a frame, and an action function
  86416. */
  86417. export class AnimationEvent {
  86418. /** The frame for which the event is triggered **/
  86419. frame: number;
  86420. /** The event to perform when triggered **/
  86421. action: (currentFrame: number) => void;
  86422. /** Specifies if the event should be triggered only once**/
  86423. onlyOnce?: boolean | undefined;
  86424. /**
  86425. * Specifies if the animation event is done
  86426. */
  86427. isDone: boolean;
  86428. /**
  86429. * Initializes the animation event
  86430. * @param frame The frame for which the event is triggered
  86431. * @param action The event to perform when triggered
  86432. * @param onlyOnce Specifies if the event should be triggered only once
  86433. */
  86434. constructor(
  86435. /** The frame for which the event is triggered **/
  86436. frame: number,
  86437. /** The event to perform when triggered **/
  86438. action: (currentFrame: number) => void,
  86439. /** Specifies if the event should be triggered only once**/
  86440. onlyOnce?: boolean | undefined);
  86441. /** @hidden */
  86442. _clone(): AnimationEvent;
  86443. }
  86444. }
  86445. declare module BABYLON {
  86446. /**
  86447. * Interface used to define a behavior
  86448. */
  86449. export interface Behavior<T> {
  86450. /** gets or sets behavior's name */
  86451. name: string;
  86452. /**
  86453. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86454. */
  86455. init(): void;
  86456. /**
  86457. * Called when the behavior is attached to a target
  86458. * @param target defines the target where the behavior is attached to
  86459. */
  86460. attach(target: T): void;
  86461. /**
  86462. * Called when the behavior is detached from its target
  86463. */
  86464. detach(): void;
  86465. }
  86466. /**
  86467. * Interface implemented by classes supporting behaviors
  86468. */
  86469. export interface IBehaviorAware<T> {
  86470. /**
  86471. * Attach a behavior
  86472. * @param behavior defines the behavior to attach
  86473. * @returns the current host
  86474. */
  86475. addBehavior(behavior: Behavior<T>): T;
  86476. /**
  86477. * Remove a behavior from the current object
  86478. * @param behavior defines the behavior to detach
  86479. * @returns the current host
  86480. */
  86481. removeBehavior(behavior: Behavior<T>): T;
  86482. /**
  86483. * Gets a behavior using its name to search
  86484. * @param name defines the name to search
  86485. * @returns the behavior or null if not found
  86486. */
  86487. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86488. }
  86489. }
  86490. declare module BABYLON {
  86491. /**
  86492. * Defines an array and its length.
  86493. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86494. */
  86495. export interface ISmartArrayLike<T> {
  86496. /**
  86497. * The data of the array.
  86498. */
  86499. data: Array<T>;
  86500. /**
  86501. * The active length of the array.
  86502. */
  86503. length: number;
  86504. }
  86505. /**
  86506. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86507. */
  86508. export class SmartArray<T> implements ISmartArrayLike<T> {
  86509. /**
  86510. * The full set of data from the array.
  86511. */
  86512. data: Array<T>;
  86513. /**
  86514. * The active length of the array.
  86515. */
  86516. length: number;
  86517. protected _id: number;
  86518. /**
  86519. * Instantiates a Smart Array.
  86520. * @param capacity defines the default capacity of the array.
  86521. */
  86522. constructor(capacity: number);
  86523. /**
  86524. * Pushes a value at the end of the active data.
  86525. * @param value defines the object to push in the array.
  86526. */
  86527. push(value: T): void;
  86528. /**
  86529. * Iterates over the active data and apply the lambda to them.
  86530. * @param func defines the action to apply on each value.
  86531. */
  86532. forEach(func: (content: T) => void): void;
  86533. /**
  86534. * Sorts the full sets of data.
  86535. * @param compareFn defines the comparison function to apply.
  86536. */
  86537. sort(compareFn: (a: T, b: T) => number): void;
  86538. /**
  86539. * Resets the active data to an empty array.
  86540. */
  86541. reset(): void;
  86542. /**
  86543. * Releases all the data from the array as well as the array.
  86544. */
  86545. dispose(): void;
  86546. /**
  86547. * Concats the active data with a given array.
  86548. * @param array defines the data to concatenate with.
  86549. */
  86550. concat(array: any): void;
  86551. /**
  86552. * Returns the position of a value in the active data.
  86553. * @param value defines the value to find the index for
  86554. * @returns the index if found in the active data otherwise -1
  86555. */
  86556. indexOf(value: T): number;
  86557. /**
  86558. * Returns whether an element is part of the active data.
  86559. * @param value defines the value to look for
  86560. * @returns true if found in the active data otherwise false
  86561. */
  86562. contains(value: T): boolean;
  86563. private static _GlobalId;
  86564. }
  86565. /**
  86566. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86567. * The data in this array can only be present once
  86568. */
  86569. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86570. private _duplicateId;
  86571. /**
  86572. * Pushes a value at the end of the active data.
  86573. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86574. * @param value defines the object to push in the array.
  86575. */
  86576. push(value: T): void;
  86577. /**
  86578. * Pushes a value at the end of the active data.
  86579. * If the data is already present, it won t be added again
  86580. * @param value defines the object to push in the array.
  86581. * @returns true if added false if it was already present
  86582. */
  86583. pushNoDuplicate(value: T): boolean;
  86584. /**
  86585. * Resets the active data to an empty array.
  86586. */
  86587. reset(): void;
  86588. /**
  86589. * Concats the active data with a given array.
  86590. * This ensures no dupplicate will be present in the result.
  86591. * @param array defines the data to concatenate with.
  86592. */
  86593. concatWithNoDuplicate(array: any): void;
  86594. }
  86595. }
  86596. declare module BABYLON {
  86597. /**
  86598. * @ignore
  86599. * This is a list of all the different input types that are available in the application.
  86600. * Fo instance: ArcRotateCameraGamepadInput...
  86601. */
  86602. export var CameraInputTypes: {};
  86603. /**
  86604. * This is the contract to implement in order to create a new input class.
  86605. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86606. */
  86607. export interface ICameraInput<TCamera extends Camera> {
  86608. /**
  86609. * Defines the camera the input is attached to.
  86610. */
  86611. camera: Nullable<TCamera>;
  86612. /**
  86613. * Gets the class name of the current intput.
  86614. * @returns the class name
  86615. */
  86616. getClassName(): string;
  86617. /**
  86618. * Get the friendly name associated with the input class.
  86619. * @returns the input friendly name
  86620. */
  86621. getSimpleName(): string;
  86622. /**
  86623. * Attach the input controls to a specific dom element to get the input from.
  86624. * @param element Defines the element the controls should be listened from
  86625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86626. */
  86627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86628. /**
  86629. * Detach the current controls from the specified dom element.
  86630. * @param element Defines the element to stop listening the inputs from
  86631. */
  86632. detachControl(element: Nullable<HTMLElement>): void;
  86633. /**
  86634. * Update the current camera state depending on the inputs that have been used this frame.
  86635. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86636. */
  86637. checkInputs?: () => void;
  86638. }
  86639. /**
  86640. * Represents a map of input types to input instance or input index to input instance.
  86641. */
  86642. export interface CameraInputsMap<TCamera extends Camera> {
  86643. /**
  86644. * Accessor to the input by input type.
  86645. */
  86646. [name: string]: ICameraInput<TCamera>;
  86647. /**
  86648. * Accessor to the input by input index.
  86649. */
  86650. [idx: number]: ICameraInput<TCamera>;
  86651. }
  86652. /**
  86653. * This represents the input manager used within a camera.
  86654. * It helps dealing with all the different kind of input attached to a camera.
  86655. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86656. */
  86657. export class CameraInputsManager<TCamera extends Camera> {
  86658. /**
  86659. * Defines the list of inputs attahed to the camera.
  86660. */
  86661. attached: CameraInputsMap<TCamera>;
  86662. /**
  86663. * Defines the dom element the camera is collecting inputs from.
  86664. * This is null if the controls have not been attached.
  86665. */
  86666. attachedElement: Nullable<HTMLElement>;
  86667. /**
  86668. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86669. */
  86670. noPreventDefault: boolean;
  86671. /**
  86672. * Defined the camera the input manager belongs to.
  86673. */
  86674. camera: TCamera;
  86675. /**
  86676. * Update the current camera state depending on the inputs that have been used this frame.
  86677. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86678. */
  86679. checkInputs: () => void;
  86680. /**
  86681. * Instantiate a new Camera Input Manager.
  86682. * @param camera Defines the camera the input manager blongs to
  86683. */
  86684. constructor(camera: TCamera);
  86685. /**
  86686. * Add an input method to a camera
  86687. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86688. * @param input camera input method
  86689. */
  86690. add(input: ICameraInput<TCamera>): void;
  86691. /**
  86692. * Remove a specific input method from a camera
  86693. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86694. * @param inputToRemove camera input method
  86695. */
  86696. remove(inputToRemove: ICameraInput<TCamera>): void;
  86697. /**
  86698. * Remove a specific input type from a camera
  86699. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86700. * @param inputType the type of the input to remove
  86701. */
  86702. removeByType(inputType: string): void;
  86703. private _addCheckInputs;
  86704. /**
  86705. * Attach the input controls to the currently attached dom element to listen the events from.
  86706. * @param input Defines the input to attach
  86707. */
  86708. attachInput(input: ICameraInput<TCamera>): void;
  86709. /**
  86710. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86711. * @param element Defines the dom element to collect the events from
  86712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86713. */
  86714. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86715. /**
  86716. * Detach the current manager inputs controls from a specific dom element.
  86717. * @param element Defines the dom element to collect the events from
  86718. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86719. */
  86720. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86721. /**
  86722. * Rebuild the dynamic inputCheck function from the current list of
  86723. * defined inputs in the manager.
  86724. */
  86725. rebuildInputCheck(): void;
  86726. /**
  86727. * Remove all attached input methods from a camera
  86728. */
  86729. clear(): void;
  86730. /**
  86731. * Serialize the current input manager attached to a camera.
  86732. * This ensures than once parsed,
  86733. * the input associated to the camera will be identical to the current ones
  86734. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86735. */
  86736. serialize(serializedCamera: any): void;
  86737. /**
  86738. * Parses an input manager serialized JSON to restore the previous list of inputs
  86739. * and states associated to a camera.
  86740. * @param parsedCamera Defines the JSON to parse
  86741. */
  86742. parse(parsedCamera: any): void;
  86743. }
  86744. }
  86745. declare module BABYLON {
  86746. /**
  86747. * Class used to store data that will be store in GPU memory
  86748. */
  86749. export class Buffer {
  86750. private _engine;
  86751. private _buffer;
  86752. /** @hidden */
  86753. _data: Nullable<DataArray>;
  86754. private _updatable;
  86755. private _instanced;
  86756. private _divisor;
  86757. /**
  86758. * Gets the byte stride.
  86759. */
  86760. readonly byteStride: number;
  86761. /**
  86762. * Constructor
  86763. * @param engine the engine
  86764. * @param data the data to use for this buffer
  86765. * @param updatable whether the data is updatable
  86766. * @param stride the stride (optional)
  86767. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86768. * @param instanced whether the buffer is instanced (optional)
  86769. * @param useBytes set to true if the stride in in bytes (optional)
  86770. * @param divisor sets an optional divisor for instances (1 by default)
  86771. */
  86772. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86773. /**
  86774. * Create a new VertexBuffer based on the current buffer
  86775. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86776. * @param offset defines offset in the buffer (0 by default)
  86777. * @param size defines the size in floats of attributes (position is 3 for instance)
  86778. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86779. * @param instanced defines if the vertex buffer contains indexed data
  86780. * @param useBytes defines if the offset and stride are in bytes *
  86781. * @param divisor sets an optional divisor for instances (1 by default)
  86782. * @returns the new vertex buffer
  86783. */
  86784. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86785. /**
  86786. * Gets a boolean indicating if the Buffer is updatable?
  86787. * @returns true if the buffer is updatable
  86788. */
  86789. isUpdatable(): boolean;
  86790. /**
  86791. * Gets current buffer's data
  86792. * @returns a DataArray or null
  86793. */
  86794. getData(): Nullable<DataArray>;
  86795. /**
  86796. * Gets underlying native buffer
  86797. * @returns underlying native buffer
  86798. */
  86799. getBuffer(): Nullable<DataBuffer>;
  86800. /**
  86801. * Gets the stride in float32 units (i.e. byte stride / 4).
  86802. * May not be an integer if the byte stride is not divisible by 4.
  86803. * @returns the stride in float32 units
  86804. * @deprecated Please use byteStride instead.
  86805. */
  86806. getStrideSize(): number;
  86807. /**
  86808. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86809. * @param data defines the data to store
  86810. */
  86811. create(data?: Nullable<DataArray>): void;
  86812. /** @hidden */
  86813. _rebuild(): void;
  86814. /**
  86815. * Update current buffer data
  86816. * @param data defines the data to store
  86817. */
  86818. update(data: DataArray): void;
  86819. /**
  86820. * Updates the data directly.
  86821. * @param data the new data
  86822. * @param offset the new offset
  86823. * @param vertexCount the vertex count (optional)
  86824. * @param useBytes set to true if the offset is in bytes
  86825. */
  86826. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86827. /**
  86828. * Release all resources
  86829. */
  86830. dispose(): void;
  86831. }
  86832. /**
  86833. * Specialized buffer used to store vertex data
  86834. */
  86835. export class VertexBuffer {
  86836. /** @hidden */
  86837. _buffer: Buffer;
  86838. private _kind;
  86839. private _size;
  86840. private _ownsBuffer;
  86841. private _instanced;
  86842. private _instanceDivisor;
  86843. /**
  86844. * The byte type.
  86845. */
  86846. static readonly BYTE: number;
  86847. /**
  86848. * The unsigned byte type.
  86849. */
  86850. static readonly UNSIGNED_BYTE: number;
  86851. /**
  86852. * The short type.
  86853. */
  86854. static readonly SHORT: number;
  86855. /**
  86856. * The unsigned short type.
  86857. */
  86858. static readonly UNSIGNED_SHORT: number;
  86859. /**
  86860. * The integer type.
  86861. */
  86862. static readonly INT: number;
  86863. /**
  86864. * The unsigned integer type.
  86865. */
  86866. static readonly UNSIGNED_INT: number;
  86867. /**
  86868. * The float type.
  86869. */
  86870. static readonly FLOAT: number;
  86871. /**
  86872. * Gets or sets the instance divisor when in instanced mode
  86873. */
  86874. get instanceDivisor(): number;
  86875. set instanceDivisor(value: number);
  86876. /**
  86877. * Gets the byte stride.
  86878. */
  86879. readonly byteStride: number;
  86880. /**
  86881. * Gets the byte offset.
  86882. */
  86883. readonly byteOffset: number;
  86884. /**
  86885. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86886. */
  86887. readonly normalized: boolean;
  86888. /**
  86889. * Gets the data type of each component in the array.
  86890. */
  86891. readonly type: number;
  86892. /**
  86893. * Constructor
  86894. * @param engine the engine
  86895. * @param data the data to use for this vertex buffer
  86896. * @param kind the vertex buffer kind
  86897. * @param updatable whether the data is updatable
  86898. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86899. * @param stride the stride (optional)
  86900. * @param instanced whether the buffer is instanced (optional)
  86901. * @param offset the offset of the data (optional)
  86902. * @param size the number of components (optional)
  86903. * @param type the type of the component (optional)
  86904. * @param normalized whether the data contains normalized data (optional)
  86905. * @param useBytes set to true if stride and offset are in bytes (optional)
  86906. * @param divisor defines the instance divisor to use (1 by default)
  86907. */
  86908. 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);
  86909. /** @hidden */
  86910. _rebuild(): void;
  86911. /**
  86912. * Returns the kind of the VertexBuffer (string)
  86913. * @returns a string
  86914. */
  86915. getKind(): string;
  86916. /**
  86917. * Gets a boolean indicating if the VertexBuffer is updatable?
  86918. * @returns true if the buffer is updatable
  86919. */
  86920. isUpdatable(): boolean;
  86921. /**
  86922. * Gets current buffer's data
  86923. * @returns a DataArray or null
  86924. */
  86925. getData(): Nullable<DataArray>;
  86926. /**
  86927. * Gets underlying native buffer
  86928. * @returns underlying native buffer
  86929. */
  86930. getBuffer(): Nullable<DataBuffer>;
  86931. /**
  86932. * Gets the stride in float32 units (i.e. byte stride / 4).
  86933. * May not be an integer if the byte stride is not divisible by 4.
  86934. * @returns the stride in float32 units
  86935. * @deprecated Please use byteStride instead.
  86936. */
  86937. getStrideSize(): number;
  86938. /**
  86939. * Returns the offset as a multiple of the type byte length.
  86940. * @returns the offset in bytes
  86941. * @deprecated Please use byteOffset instead.
  86942. */
  86943. getOffset(): number;
  86944. /**
  86945. * Returns the number of components per vertex attribute (integer)
  86946. * @returns the size in float
  86947. */
  86948. getSize(): number;
  86949. /**
  86950. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  86951. * @returns true if this buffer is instanced
  86952. */
  86953. getIsInstanced(): boolean;
  86954. /**
  86955. * Returns the instancing divisor, zero for non-instanced (integer).
  86956. * @returns a number
  86957. */
  86958. getInstanceDivisor(): number;
  86959. /**
  86960. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86961. * @param data defines the data to store
  86962. */
  86963. create(data?: DataArray): void;
  86964. /**
  86965. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  86966. * This function will create a new buffer if the current one is not updatable
  86967. * @param data defines the data to store
  86968. */
  86969. update(data: DataArray): void;
  86970. /**
  86971. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  86972. * Returns the directly updated WebGLBuffer.
  86973. * @param data the new data
  86974. * @param offset the new offset
  86975. * @param useBytes set to true if the offset is in bytes
  86976. */
  86977. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  86978. /**
  86979. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  86980. */
  86981. dispose(): void;
  86982. /**
  86983. * Enumerates each value of this vertex buffer as numbers.
  86984. * @param count the number of values to enumerate
  86985. * @param callback the callback function called for each value
  86986. */
  86987. forEach(count: number, callback: (value: number, index: number) => void): void;
  86988. /**
  86989. * Positions
  86990. */
  86991. static readonly PositionKind: string;
  86992. /**
  86993. * Normals
  86994. */
  86995. static readonly NormalKind: string;
  86996. /**
  86997. * Tangents
  86998. */
  86999. static readonly TangentKind: string;
  87000. /**
  87001. * Texture coordinates
  87002. */
  87003. static readonly UVKind: string;
  87004. /**
  87005. * Texture coordinates 2
  87006. */
  87007. static readonly UV2Kind: string;
  87008. /**
  87009. * Texture coordinates 3
  87010. */
  87011. static readonly UV3Kind: string;
  87012. /**
  87013. * Texture coordinates 4
  87014. */
  87015. static readonly UV4Kind: string;
  87016. /**
  87017. * Texture coordinates 5
  87018. */
  87019. static readonly UV5Kind: string;
  87020. /**
  87021. * Texture coordinates 6
  87022. */
  87023. static readonly UV6Kind: string;
  87024. /**
  87025. * Colors
  87026. */
  87027. static readonly ColorKind: string;
  87028. /**
  87029. * Matrix indices (for bones)
  87030. */
  87031. static readonly MatricesIndicesKind: string;
  87032. /**
  87033. * Matrix weights (for bones)
  87034. */
  87035. static readonly MatricesWeightsKind: string;
  87036. /**
  87037. * Additional matrix indices (for bones)
  87038. */
  87039. static readonly MatricesIndicesExtraKind: string;
  87040. /**
  87041. * Additional matrix weights (for bones)
  87042. */
  87043. static readonly MatricesWeightsExtraKind: string;
  87044. /**
  87045. * Deduces the stride given a kind.
  87046. * @param kind The kind string to deduce
  87047. * @returns The deduced stride
  87048. */
  87049. static DeduceStride(kind: string): number;
  87050. /**
  87051. * Gets the byte length of the given type.
  87052. * @param type the type
  87053. * @returns the number of bytes
  87054. */
  87055. static GetTypeByteLength(type: number): number;
  87056. /**
  87057. * Enumerates each value of the given parameters as numbers.
  87058. * @param data the data to enumerate
  87059. * @param byteOffset the byte offset of the data
  87060. * @param byteStride the byte stride of the data
  87061. * @param componentCount the number of components per element
  87062. * @param componentType the type of the component
  87063. * @param count the number of values to enumerate
  87064. * @param normalized whether the data is normalized
  87065. * @param callback the callback function called for each value
  87066. */
  87067. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87068. private static _GetFloatValue;
  87069. }
  87070. }
  87071. declare module BABYLON {
  87072. /**
  87073. * The options Interface for creating a Capsule Mesh
  87074. */
  87075. export interface ICreateCapsuleOptions {
  87076. /** The Orientation of the capsule. Default : Vector3.Up() */
  87077. orientation?: Vector3;
  87078. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87079. subdivisions: number;
  87080. /** Number of cylindrical segments on the capsule. */
  87081. tessellation: number;
  87082. /** Height or Length of the capsule. */
  87083. height: number;
  87084. /** Radius of the capsule. */
  87085. radius: number;
  87086. /** Height or Length of the capsule. */
  87087. capSubdivisions: number;
  87088. /** Overwrite for the top radius. */
  87089. radiusTop?: number;
  87090. /** Overwrite for the bottom radius. */
  87091. radiusBottom?: number;
  87092. /** Overwrite for the top capSubdivisions. */
  87093. topCapSubdivisions?: number;
  87094. /** Overwrite for the bottom capSubdivisions. */
  87095. bottomCapSubdivisions?: number;
  87096. }
  87097. /**
  87098. * Class containing static functions to help procedurally build meshes
  87099. */
  87100. export class CapsuleBuilder {
  87101. /**
  87102. * Creates a capsule or a pill mesh
  87103. * @param name defines the name of the mesh
  87104. * @param options The constructors options.
  87105. * @param scene The scene the mesh is scoped to.
  87106. * @returns Capsule Mesh
  87107. */
  87108. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87109. }
  87110. }
  87111. declare module BABYLON {
  87112. /**
  87113. * @hidden
  87114. */
  87115. export class IntersectionInfo {
  87116. bu: Nullable<number>;
  87117. bv: Nullable<number>;
  87118. distance: number;
  87119. faceId: number;
  87120. subMeshId: number;
  87121. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87122. }
  87123. }
  87124. declare module BABYLON {
  87125. /**
  87126. * Class used to store bounding sphere information
  87127. */
  87128. export class BoundingSphere {
  87129. /**
  87130. * Gets the center of the bounding sphere in local space
  87131. */
  87132. readonly center: Vector3;
  87133. /**
  87134. * Radius of the bounding sphere in local space
  87135. */
  87136. radius: number;
  87137. /**
  87138. * Gets the center of the bounding sphere in world space
  87139. */
  87140. readonly centerWorld: Vector3;
  87141. /**
  87142. * Radius of the bounding sphere in world space
  87143. */
  87144. radiusWorld: number;
  87145. /**
  87146. * Gets the minimum vector in local space
  87147. */
  87148. readonly minimum: Vector3;
  87149. /**
  87150. * Gets the maximum vector in local space
  87151. */
  87152. readonly maximum: Vector3;
  87153. private _worldMatrix;
  87154. private static readonly TmpVector3;
  87155. /**
  87156. * Creates a new bounding sphere
  87157. * @param min defines the minimum vector (in local space)
  87158. * @param max defines the maximum vector (in local space)
  87159. * @param worldMatrix defines the new world matrix
  87160. */
  87161. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87162. /**
  87163. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87164. * @param min defines the new minimum vector (in local space)
  87165. * @param max defines the new maximum vector (in local space)
  87166. * @param worldMatrix defines the new world matrix
  87167. */
  87168. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87169. /**
  87170. * Scale the current bounding sphere by applying a scale factor
  87171. * @param factor defines the scale factor to apply
  87172. * @returns the current bounding box
  87173. */
  87174. scale(factor: number): BoundingSphere;
  87175. /**
  87176. * Gets the world matrix of the bounding box
  87177. * @returns a matrix
  87178. */
  87179. getWorldMatrix(): DeepImmutable<Matrix>;
  87180. /** @hidden */
  87181. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87182. /**
  87183. * Tests if the bounding sphere is intersecting the frustum planes
  87184. * @param frustumPlanes defines the frustum planes to test
  87185. * @returns true if there is an intersection
  87186. */
  87187. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87188. /**
  87189. * Tests if the bounding sphere center is in between the frustum planes.
  87190. * Used for optimistic fast inclusion.
  87191. * @param frustumPlanes defines the frustum planes to test
  87192. * @returns true if the sphere center is in between the frustum planes
  87193. */
  87194. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87195. /**
  87196. * Tests if a point is inside the bounding sphere
  87197. * @param point defines the point to test
  87198. * @returns true if the point is inside the bounding sphere
  87199. */
  87200. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87201. /**
  87202. * Checks if two sphere intersct
  87203. * @param sphere0 sphere 0
  87204. * @param sphere1 sphere 1
  87205. * @returns true if the speres intersect
  87206. */
  87207. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87208. }
  87209. }
  87210. declare module BABYLON {
  87211. /**
  87212. * Class used to store bounding box information
  87213. */
  87214. export class BoundingBox implements ICullable {
  87215. /**
  87216. * Gets the 8 vectors representing the bounding box in local space
  87217. */
  87218. readonly vectors: Vector3[];
  87219. /**
  87220. * Gets the center of the bounding box in local space
  87221. */
  87222. readonly center: Vector3;
  87223. /**
  87224. * Gets the center of the bounding box in world space
  87225. */
  87226. readonly centerWorld: Vector3;
  87227. /**
  87228. * Gets the extend size in local space
  87229. */
  87230. readonly extendSize: Vector3;
  87231. /**
  87232. * Gets the extend size in world space
  87233. */
  87234. readonly extendSizeWorld: Vector3;
  87235. /**
  87236. * Gets the OBB (object bounding box) directions
  87237. */
  87238. readonly directions: Vector3[];
  87239. /**
  87240. * Gets the 8 vectors representing the bounding box in world space
  87241. */
  87242. readonly vectorsWorld: Vector3[];
  87243. /**
  87244. * Gets the minimum vector in world space
  87245. */
  87246. readonly minimumWorld: Vector3;
  87247. /**
  87248. * Gets the maximum vector in world space
  87249. */
  87250. readonly maximumWorld: Vector3;
  87251. /**
  87252. * Gets the minimum vector in local space
  87253. */
  87254. readonly minimum: Vector3;
  87255. /**
  87256. * Gets the maximum vector in local space
  87257. */
  87258. readonly maximum: Vector3;
  87259. private _worldMatrix;
  87260. private static readonly TmpVector3;
  87261. /**
  87262. * @hidden
  87263. */
  87264. _tag: number;
  87265. /**
  87266. * Creates a new bounding box
  87267. * @param min defines the minimum vector (in local space)
  87268. * @param max defines the maximum vector (in local space)
  87269. * @param worldMatrix defines the new world matrix
  87270. */
  87271. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87272. /**
  87273. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87274. * @param min defines the new minimum vector (in local space)
  87275. * @param max defines the new maximum vector (in local space)
  87276. * @param worldMatrix defines the new world matrix
  87277. */
  87278. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87279. /**
  87280. * Scale the current bounding box by applying a scale factor
  87281. * @param factor defines the scale factor to apply
  87282. * @returns the current bounding box
  87283. */
  87284. scale(factor: number): BoundingBox;
  87285. /**
  87286. * Gets the world matrix of the bounding box
  87287. * @returns a matrix
  87288. */
  87289. getWorldMatrix(): DeepImmutable<Matrix>;
  87290. /** @hidden */
  87291. _update(world: DeepImmutable<Matrix>): void;
  87292. /**
  87293. * Tests if the bounding box is intersecting the frustum planes
  87294. * @param frustumPlanes defines the frustum planes to test
  87295. * @returns true if there is an intersection
  87296. */
  87297. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87298. /**
  87299. * Tests if the bounding box is entirely inside the frustum planes
  87300. * @param frustumPlanes defines the frustum planes to test
  87301. * @returns true if there is an inclusion
  87302. */
  87303. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87304. /**
  87305. * Tests if a point is inside the bounding box
  87306. * @param point defines the point to test
  87307. * @returns true if the point is inside the bounding box
  87308. */
  87309. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87310. /**
  87311. * Tests if the bounding box intersects with a bounding sphere
  87312. * @param sphere defines the sphere to test
  87313. * @returns true if there is an intersection
  87314. */
  87315. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87316. /**
  87317. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87318. * @param min defines the min vector to use
  87319. * @param max defines the max vector to use
  87320. * @returns true if there is an intersection
  87321. */
  87322. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87323. /**
  87324. * Tests if two bounding boxes are intersections
  87325. * @param box0 defines the first box to test
  87326. * @param box1 defines the second box to test
  87327. * @returns true if there is an intersection
  87328. */
  87329. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87330. /**
  87331. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87332. * @param minPoint defines the minimum vector of the bounding box
  87333. * @param maxPoint defines the maximum vector of the bounding box
  87334. * @param sphereCenter defines the sphere center
  87335. * @param sphereRadius defines the sphere radius
  87336. * @returns true if there is an intersection
  87337. */
  87338. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87339. /**
  87340. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87341. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87342. * @param frustumPlanes defines the frustum planes to test
  87343. * @return true if there is an inclusion
  87344. */
  87345. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87346. /**
  87347. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87348. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87349. * @param frustumPlanes defines the frustum planes to test
  87350. * @return true if there is an intersection
  87351. */
  87352. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87353. }
  87354. }
  87355. declare module BABYLON {
  87356. /** @hidden */
  87357. export class Collider {
  87358. /** Define if a collision was found */
  87359. collisionFound: boolean;
  87360. /**
  87361. * Define last intersection point in local space
  87362. */
  87363. intersectionPoint: Vector3;
  87364. /**
  87365. * Define last collided mesh
  87366. */
  87367. collidedMesh: Nullable<AbstractMesh>;
  87368. private _collisionPoint;
  87369. private _planeIntersectionPoint;
  87370. private _tempVector;
  87371. private _tempVector2;
  87372. private _tempVector3;
  87373. private _tempVector4;
  87374. private _edge;
  87375. private _baseToVertex;
  87376. private _destinationPoint;
  87377. private _slidePlaneNormal;
  87378. private _displacementVector;
  87379. /** @hidden */
  87380. _radius: Vector3;
  87381. /** @hidden */
  87382. _retry: number;
  87383. private _velocity;
  87384. private _basePoint;
  87385. private _epsilon;
  87386. /** @hidden */
  87387. _velocityWorldLength: number;
  87388. /** @hidden */
  87389. _basePointWorld: Vector3;
  87390. private _velocityWorld;
  87391. private _normalizedVelocity;
  87392. /** @hidden */
  87393. _initialVelocity: Vector3;
  87394. /** @hidden */
  87395. _initialPosition: Vector3;
  87396. private _nearestDistance;
  87397. private _collisionMask;
  87398. get collisionMask(): number;
  87399. set collisionMask(mask: number);
  87400. /**
  87401. * Gets the plane normal used to compute the sliding response (in local space)
  87402. */
  87403. get slidePlaneNormal(): Vector3;
  87404. /** @hidden */
  87405. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87406. /** @hidden */
  87407. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87408. /** @hidden */
  87409. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87410. /** @hidden */
  87411. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87412. /** @hidden */
  87413. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87414. /** @hidden */
  87415. _getResponse(pos: Vector3, vel: Vector3): void;
  87416. }
  87417. }
  87418. declare module BABYLON {
  87419. /**
  87420. * Interface for cullable objects
  87421. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87422. */
  87423. export interface ICullable {
  87424. /**
  87425. * Checks if the object or part of the object is in the frustum
  87426. * @param frustumPlanes Camera near/planes
  87427. * @returns true if the object is in frustum otherwise false
  87428. */
  87429. isInFrustum(frustumPlanes: Plane[]): boolean;
  87430. /**
  87431. * Checks if a cullable object (mesh...) is in the camera frustum
  87432. * Unlike isInFrustum this cheks the full bounding box
  87433. * @param frustumPlanes Camera near/planes
  87434. * @returns true if the object is in frustum otherwise false
  87435. */
  87436. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87437. }
  87438. /**
  87439. * Info for a bounding data of a mesh
  87440. */
  87441. export class BoundingInfo implements ICullable {
  87442. /**
  87443. * Bounding box for the mesh
  87444. */
  87445. readonly boundingBox: BoundingBox;
  87446. /**
  87447. * Bounding sphere for the mesh
  87448. */
  87449. readonly boundingSphere: BoundingSphere;
  87450. private _isLocked;
  87451. private static readonly TmpVector3;
  87452. /**
  87453. * Constructs bounding info
  87454. * @param minimum min vector of the bounding box/sphere
  87455. * @param maximum max vector of the bounding box/sphere
  87456. * @param worldMatrix defines the new world matrix
  87457. */
  87458. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87459. /**
  87460. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87461. * @param min defines the new minimum vector (in local space)
  87462. * @param max defines the new maximum vector (in local space)
  87463. * @param worldMatrix defines the new world matrix
  87464. */
  87465. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87466. /**
  87467. * min vector of the bounding box/sphere
  87468. */
  87469. get minimum(): Vector3;
  87470. /**
  87471. * max vector of the bounding box/sphere
  87472. */
  87473. get maximum(): Vector3;
  87474. /**
  87475. * If the info is locked and won't be updated to avoid perf overhead
  87476. */
  87477. get isLocked(): boolean;
  87478. set isLocked(value: boolean);
  87479. /**
  87480. * Updates the bounding sphere and box
  87481. * @param world world matrix to be used to update
  87482. */
  87483. update(world: DeepImmutable<Matrix>): void;
  87484. /**
  87485. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87486. * @param center New center of the bounding info
  87487. * @param extend New extend of the bounding info
  87488. * @returns the current bounding info
  87489. */
  87490. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87491. /**
  87492. * Scale the current bounding info by applying a scale factor
  87493. * @param factor defines the scale factor to apply
  87494. * @returns the current bounding info
  87495. */
  87496. scale(factor: number): BoundingInfo;
  87497. /**
  87498. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87499. * @param frustumPlanes defines the frustum to test
  87500. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87501. * @returns true if the bounding info is in the frustum planes
  87502. */
  87503. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87504. /**
  87505. * Gets the world distance between the min and max points of the bounding box
  87506. */
  87507. get diagonalLength(): number;
  87508. /**
  87509. * Checks if a cullable object (mesh...) is in the camera frustum
  87510. * Unlike isInFrustum this cheks the full bounding box
  87511. * @param frustumPlanes Camera near/planes
  87512. * @returns true if the object is in frustum otherwise false
  87513. */
  87514. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87515. /** @hidden */
  87516. _checkCollision(collider: Collider): boolean;
  87517. /**
  87518. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87519. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87520. * @param point the point to check intersection with
  87521. * @returns if the point intersects
  87522. */
  87523. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87524. /**
  87525. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87526. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87527. * @param boundingInfo the bounding info to check intersection with
  87528. * @param precise if the intersection should be done using OBB
  87529. * @returns if the bounding info intersects
  87530. */
  87531. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87532. }
  87533. }
  87534. declare module BABYLON {
  87535. /**
  87536. * Extracts minimum and maximum values from a list of indexed positions
  87537. * @param positions defines the positions to use
  87538. * @param indices defines the indices to the positions
  87539. * @param indexStart defines the start index
  87540. * @param indexCount defines the end index
  87541. * @param bias defines bias value to add to the result
  87542. * @return minimum and maximum values
  87543. */
  87544. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87545. minimum: Vector3;
  87546. maximum: Vector3;
  87547. };
  87548. /**
  87549. * Extracts minimum and maximum values from a list of positions
  87550. * @param positions defines the positions to use
  87551. * @param start defines the start index in the positions array
  87552. * @param count defines the number of positions to handle
  87553. * @param bias defines bias value to add to the result
  87554. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87555. * @return minimum and maximum values
  87556. */
  87557. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87558. minimum: Vector3;
  87559. maximum: Vector3;
  87560. };
  87561. }
  87562. declare module BABYLON {
  87563. /** @hidden */
  87564. export class WebGLDataBuffer extends DataBuffer {
  87565. private _buffer;
  87566. constructor(resource: WebGLBuffer);
  87567. get underlyingResource(): any;
  87568. }
  87569. }
  87570. declare module BABYLON {
  87571. /** @hidden */
  87572. export class WebGLPipelineContext implements IPipelineContext {
  87573. engine: ThinEngine;
  87574. program: Nullable<WebGLProgram>;
  87575. context?: WebGLRenderingContext;
  87576. vertexShader?: WebGLShader;
  87577. fragmentShader?: WebGLShader;
  87578. isParallelCompiled: boolean;
  87579. onCompiled?: () => void;
  87580. transformFeedback?: WebGLTransformFeedback | null;
  87581. vertexCompilationError: Nullable<string>;
  87582. fragmentCompilationError: Nullable<string>;
  87583. programLinkError: Nullable<string>;
  87584. programValidationError: Nullable<string>;
  87585. get isAsync(): boolean;
  87586. get isReady(): boolean;
  87587. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87588. _getVertexShaderCode(): string | null;
  87589. _getFragmentShaderCode(): string | null;
  87590. }
  87591. }
  87592. declare module BABYLON {
  87593. interface ThinEngine {
  87594. /**
  87595. * Create an uniform buffer
  87596. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87597. * @param elements defines the content of the uniform buffer
  87598. * @returns the webGL uniform buffer
  87599. */
  87600. createUniformBuffer(elements: FloatArray): DataBuffer;
  87601. /**
  87602. * Create a dynamic uniform buffer
  87603. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87604. * @param elements defines the content of the uniform buffer
  87605. * @returns the webGL uniform buffer
  87606. */
  87607. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87608. /**
  87609. * Update an existing uniform buffer
  87610. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87611. * @param uniformBuffer defines the target uniform buffer
  87612. * @param elements defines the content to update
  87613. * @param offset defines the offset in the uniform buffer where update should start
  87614. * @param count defines the size of the data to update
  87615. */
  87616. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87617. /**
  87618. * Bind an uniform buffer to the current webGL context
  87619. * @param buffer defines the buffer to bind
  87620. */
  87621. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87622. /**
  87623. * Bind a buffer to the current webGL context at a given location
  87624. * @param buffer defines the buffer to bind
  87625. * @param location defines the index where to bind the buffer
  87626. */
  87627. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87628. /**
  87629. * Bind a specific block at a given index in a specific shader program
  87630. * @param pipelineContext defines the pipeline context to use
  87631. * @param blockName defines the block name
  87632. * @param index defines the index where to bind the block
  87633. */
  87634. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87635. }
  87636. }
  87637. declare module BABYLON {
  87638. /**
  87639. * Uniform buffer objects.
  87640. *
  87641. * Handles blocks of uniform on the GPU.
  87642. *
  87643. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87644. *
  87645. * For more information, please refer to :
  87646. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87647. */
  87648. export class UniformBuffer {
  87649. private _engine;
  87650. private _buffer;
  87651. private _data;
  87652. private _bufferData;
  87653. private _dynamic?;
  87654. private _uniformLocations;
  87655. private _uniformSizes;
  87656. private _uniformLocationPointer;
  87657. private _needSync;
  87658. private _noUBO;
  87659. private _currentEffect;
  87660. /** @hidden */
  87661. _alreadyBound: boolean;
  87662. private static _MAX_UNIFORM_SIZE;
  87663. private static _tempBuffer;
  87664. /**
  87665. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87666. * This is dynamic to allow compat with webgl 1 and 2.
  87667. * You will need to pass the name of the uniform as well as the value.
  87668. */
  87669. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87670. /**
  87671. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87672. * This is dynamic to allow compat with webgl 1 and 2.
  87673. * You will need to pass the name of the uniform as well as the value.
  87674. */
  87675. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87676. /**
  87677. * Lambda to Update a single float in a uniform buffer.
  87678. * This is dynamic to allow compat with webgl 1 and 2.
  87679. * You will need to pass the name of the uniform as well as the value.
  87680. */
  87681. updateFloat: (name: string, x: number) => void;
  87682. /**
  87683. * Lambda to Update a vec2 of float in a uniform buffer.
  87684. * This is dynamic to allow compat with webgl 1 and 2.
  87685. * You will need to pass the name of the uniform as well as the value.
  87686. */
  87687. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87688. /**
  87689. * Lambda to Update a vec3 of float in a uniform buffer.
  87690. * This is dynamic to allow compat with webgl 1 and 2.
  87691. * You will need to pass the name of the uniform as well as the value.
  87692. */
  87693. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87694. /**
  87695. * Lambda to Update a vec4 of float in a uniform buffer.
  87696. * This is dynamic to allow compat with webgl 1 and 2.
  87697. * You will need to pass the name of the uniform as well as the value.
  87698. */
  87699. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87700. /**
  87701. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87702. * This is dynamic to allow compat with webgl 1 and 2.
  87703. * You will need to pass the name of the uniform as well as the value.
  87704. */
  87705. updateMatrix: (name: string, mat: Matrix) => void;
  87706. /**
  87707. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87708. * This is dynamic to allow compat with webgl 1 and 2.
  87709. * You will need to pass the name of the uniform as well as the value.
  87710. */
  87711. updateVector3: (name: string, vector: Vector3) => void;
  87712. /**
  87713. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87714. * This is dynamic to allow compat with webgl 1 and 2.
  87715. * You will need to pass the name of the uniform as well as the value.
  87716. */
  87717. updateVector4: (name: string, vector: Vector4) => void;
  87718. /**
  87719. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87720. * This is dynamic to allow compat with webgl 1 and 2.
  87721. * You will need to pass the name of the uniform as well as the value.
  87722. */
  87723. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87724. /**
  87725. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87726. * This is dynamic to allow compat with webgl 1 and 2.
  87727. * You will need to pass the name of the uniform as well as the value.
  87728. */
  87729. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87730. /**
  87731. * Instantiates a new Uniform buffer objects.
  87732. *
  87733. * Handles blocks of uniform on the GPU.
  87734. *
  87735. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87736. *
  87737. * For more information, please refer to :
  87738. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87739. * @param engine Define the engine the buffer is associated with
  87740. * @param data Define the data contained in the buffer
  87741. * @param dynamic Define if the buffer is updatable
  87742. */
  87743. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87744. /**
  87745. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87746. * or just falling back on setUniformXXX calls.
  87747. */
  87748. get useUbo(): boolean;
  87749. /**
  87750. * Indicates if the WebGL underlying uniform buffer is in sync
  87751. * with the javascript cache data.
  87752. */
  87753. get isSync(): boolean;
  87754. /**
  87755. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87756. * Also, a dynamic UniformBuffer will disable cache verification and always
  87757. * update the underlying WebGL uniform buffer to the GPU.
  87758. * @returns if Dynamic, otherwise false
  87759. */
  87760. isDynamic(): boolean;
  87761. /**
  87762. * The data cache on JS side.
  87763. * @returns the underlying data as a float array
  87764. */
  87765. getData(): Float32Array;
  87766. /**
  87767. * The underlying WebGL Uniform buffer.
  87768. * @returns the webgl buffer
  87769. */
  87770. getBuffer(): Nullable<DataBuffer>;
  87771. /**
  87772. * std140 layout specifies how to align data within an UBO structure.
  87773. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87774. * for specs.
  87775. */
  87776. private _fillAlignment;
  87777. /**
  87778. * Adds an uniform in the buffer.
  87779. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87780. * for the layout to be correct !
  87781. * @param name Name of the uniform, as used in the uniform block in the shader.
  87782. * @param size Data size, or data directly.
  87783. */
  87784. addUniform(name: string, size: number | number[]): void;
  87785. /**
  87786. * Adds a Matrix 4x4 to the uniform buffer.
  87787. * @param name Name of the uniform, as used in the uniform block in the shader.
  87788. * @param mat A 4x4 matrix.
  87789. */
  87790. addMatrix(name: string, mat: Matrix): void;
  87791. /**
  87792. * Adds a vec2 to the uniform buffer.
  87793. * @param name Name of the uniform, as used in the uniform block in the shader.
  87794. * @param x Define the x component value of the vec2
  87795. * @param y Define the y component value of the vec2
  87796. */
  87797. addFloat2(name: string, x: number, y: number): void;
  87798. /**
  87799. * Adds a vec3 to the uniform buffer.
  87800. * @param name Name of the uniform, as used in the uniform block in the shader.
  87801. * @param x Define the x component value of the vec3
  87802. * @param y Define the y component value of the vec3
  87803. * @param z Define the z component value of the vec3
  87804. */
  87805. addFloat3(name: string, x: number, y: number, z: number): void;
  87806. /**
  87807. * Adds a vec3 to the uniform buffer.
  87808. * @param name Name of the uniform, as used in the uniform block in the shader.
  87809. * @param color Define the vec3 from a Color
  87810. */
  87811. addColor3(name: string, color: Color3): void;
  87812. /**
  87813. * Adds a vec4 to the uniform buffer.
  87814. * @param name Name of the uniform, as used in the uniform block in the shader.
  87815. * @param color Define the rgb components from a Color
  87816. * @param alpha Define the a component of the vec4
  87817. */
  87818. addColor4(name: string, color: Color3, alpha: number): void;
  87819. /**
  87820. * Adds a vec3 to the uniform buffer.
  87821. * @param name Name of the uniform, as used in the uniform block in the shader.
  87822. * @param vector Define the vec3 components from a Vector
  87823. */
  87824. addVector3(name: string, vector: Vector3): void;
  87825. /**
  87826. * Adds a Matrix 3x3 to the uniform buffer.
  87827. * @param name Name of the uniform, as used in the uniform block in the shader.
  87828. */
  87829. addMatrix3x3(name: string): void;
  87830. /**
  87831. * Adds a Matrix 2x2 to the uniform buffer.
  87832. * @param name Name of the uniform, as used in the uniform block in the shader.
  87833. */
  87834. addMatrix2x2(name: string): void;
  87835. /**
  87836. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87837. */
  87838. create(): void;
  87839. /** @hidden */
  87840. _rebuild(): void;
  87841. /**
  87842. * Updates the WebGL Uniform Buffer on the GPU.
  87843. * If the `dynamic` flag is set to true, no cache comparison is done.
  87844. * Otherwise, the buffer will be updated only if the cache differs.
  87845. */
  87846. update(): void;
  87847. /**
  87848. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87849. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87850. * @param data Define the flattened data
  87851. * @param size Define the size of the data.
  87852. */
  87853. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87854. private _valueCache;
  87855. private _cacheMatrix;
  87856. private _updateMatrix3x3ForUniform;
  87857. private _updateMatrix3x3ForEffect;
  87858. private _updateMatrix2x2ForEffect;
  87859. private _updateMatrix2x2ForUniform;
  87860. private _updateFloatForEffect;
  87861. private _updateFloatForUniform;
  87862. private _updateFloat2ForEffect;
  87863. private _updateFloat2ForUniform;
  87864. private _updateFloat3ForEffect;
  87865. private _updateFloat3ForUniform;
  87866. private _updateFloat4ForEffect;
  87867. private _updateFloat4ForUniform;
  87868. private _updateMatrixForEffect;
  87869. private _updateMatrixForUniform;
  87870. private _updateVector3ForEffect;
  87871. private _updateVector3ForUniform;
  87872. private _updateVector4ForEffect;
  87873. private _updateVector4ForUniform;
  87874. private _updateColor3ForEffect;
  87875. private _updateColor3ForUniform;
  87876. private _updateColor4ForEffect;
  87877. private _updateColor4ForUniform;
  87878. /**
  87879. * Sets a sampler uniform on the effect.
  87880. * @param name Define the name of the sampler.
  87881. * @param texture Define the texture to set in the sampler
  87882. */
  87883. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87884. /**
  87885. * Directly updates the value of the uniform in the cache AND on the GPU.
  87886. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87887. * @param data Define the flattened data
  87888. */
  87889. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87890. /**
  87891. * Binds this uniform buffer to an effect.
  87892. * @param effect Define the effect to bind the buffer to
  87893. * @param name Name of the uniform block in the shader.
  87894. */
  87895. bindToEffect(effect: Effect, name: string): void;
  87896. /**
  87897. * Disposes the uniform buffer.
  87898. */
  87899. dispose(): void;
  87900. }
  87901. }
  87902. declare module BABYLON {
  87903. /**
  87904. * Enum that determines the text-wrapping mode to use.
  87905. */
  87906. export enum InspectableType {
  87907. /**
  87908. * Checkbox for booleans
  87909. */
  87910. Checkbox = 0,
  87911. /**
  87912. * Sliders for numbers
  87913. */
  87914. Slider = 1,
  87915. /**
  87916. * Vector3
  87917. */
  87918. Vector3 = 2,
  87919. /**
  87920. * Quaternions
  87921. */
  87922. Quaternion = 3,
  87923. /**
  87924. * Color3
  87925. */
  87926. Color3 = 4,
  87927. /**
  87928. * String
  87929. */
  87930. String = 5
  87931. }
  87932. /**
  87933. * Interface used to define custom inspectable properties.
  87934. * This interface is used by the inspector to display custom property grids
  87935. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87936. */
  87937. export interface IInspectable {
  87938. /**
  87939. * Gets the label to display
  87940. */
  87941. label: string;
  87942. /**
  87943. * Gets the name of the property to edit
  87944. */
  87945. propertyName: string;
  87946. /**
  87947. * Gets the type of the editor to use
  87948. */
  87949. type: InspectableType;
  87950. /**
  87951. * Gets the minimum value of the property when using in "slider" mode
  87952. */
  87953. min?: number;
  87954. /**
  87955. * Gets the maximum value of the property when using in "slider" mode
  87956. */
  87957. max?: number;
  87958. /**
  87959. * Gets the setp to use when using in "slider" mode
  87960. */
  87961. step?: number;
  87962. }
  87963. }
  87964. declare module BABYLON {
  87965. /**
  87966. * Class used to provide helper for timing
  87967. */
  87968. export class TimingTools {
  87969. /**
  87970. * Polyfill for setImmediate
  87971. * @param action defines the action to execute after the current execution block
  87972. */
  87973. static SetImmediate(action: () => void): void;
  87974. }
  87975. }
  87976. declare module BABYLON {
  87977. /**
  87978. * Class used to enable instatition of objects by class name
  87979. */
  87980. export class InstantiationTools {
  87981. /**
  87982. * Use this object to register external classes like custom textures or material
  87983. * to allow the laoders to instantiate them
  87984. */
  87985. static RegisteredExternalClasses: {
  87986. [key: string]: Object;
  87987. };
  87988. /**
  87989. * Tries to instantiate a new object from a given class name
  87990. * @param className defines the class name to instantiate
  87991. * @returns the new object or null if the system was not able to do the instantiation
  87992. */
  87993. static Instantiate(className: string): any;
  87994. }
  87995. }
  87996. declare module BABYLON {
  87997. /**
  87998. * Define options used to create a depth texture
  87999. */
  88000. export class DepthTextureCreationOptions {
  88001. /** Specifies whether or not a stencil should be allocated in the texture */
  88002. generateStencil?: boolean;
  88003. /** Specifies whether or not bilinear filtering is enable on the texture */
  88004. bilinearFiltering?: boolean;
  88005. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88006. comparisonFunction?: number;
  88007. /** Specifies if the created texture is a cube texture */
  88008. isCube?: boolean;
  88009. }
  88010. }
  88011. declare module BABYLON {
  88012. interface ThinEngine {
  88013. /**
  88014. * Creates a depth stencil cube texture.
  88015. * This is only available in WebGL 2.
  88016. * @param size The size of face edge in the cube texture.
  88017. * @param options The options defining the cube texture.
  88018. * @returns The cube texture
  88019. */
  88020. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88021. /**
  88022. * Creates a cube texture
  88023. * @param rootUrl defines the url where the files to load is located
  88024. * @param scene defines the current scene
  88025. * @param files defines the list of files to load (1 per face)
  88026. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88027. * @param onLoad defines an optional callback raised when the texture is loaded
  88028. * @param onError defines an optional callback raised if there is an issue to load the texture
  88029. * @param format defines the format of the data
  88030. * @param forcedExtension defines the extension to use to pick the right loader
  88031. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88032. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88033. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88034. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88035. * @returns the cube texture as an InternalTexture
  88036. */
  88037. 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;
  88038. /**
  88039. * Creates a cube texture
  88040. * @param rootUrl defines the url where the files to load is located
  88041. * @param scene defines the current scene
  88042. * @param files defines the list of files to load (1 per face)
  88043. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88044. * @param onLoad defines an optional callback raised when the texture is loaded
  88045. * @param onError defines an optional callback raised if there is an issue to load the texture
  88046. * @param format defines the format of the data
  88047. * @param forcedExtension defines the extension to use to pick the right loader
  88048. * @returns the cube texture as an InternalTexture
  88049. */
  88050. 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;
  88051. /**
  88052. * Creates a cube texture
  88053. * @param rootUrl defines the url where the files to load is located
  88054. * @param scene defines the current scene
  88055. * @param files defines the list of files to load (1 per face)
  88056. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88057. * @param onLoad defines an optional callback raised when the texture is loaded
  88058. * @param onError defines an optional callback raised if there is an issue to load the texture
  88059. * @param format defines the format of the data
  88060. * @param forcedExtension defines the extension to use to pick the right loader
  88061. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88062. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88063. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88064. * @returns the cube texture as an InternalTexture
  88065. */
  88066. 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;
  88067. /** @hidden */
  88068. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88069. /** @hidden */
  88070. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88071. /** @hidden */
  88072. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88073. /** @hidden */
  88074. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88075. /**
  88076. * @hidden
  88077. */
  88078. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88079. }
  88080. }
  88081. declare module BABYLON {
  88082. /**
  88083. * Class for creating a cube texture
  88084. */
  88085. export class CubeTexture extends BaseTexture {
  88086. private _delayedOnLoad;
  88087. /**
  88088. * Observable triggered once the texture has been loaded.
  88089. */
  88090. onLoadObservable: Observable<CubeTexture>;
  88091. /**
  88092. * The url of the texture
  88093. */
  88094. url: string;
  88095. /**
  88096. * Gets or sets the center of the bounding box associated with the cube texture.
  88097. * It must define where the camera used to render the texture was set
  88098. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88099. */
  88100. boundingBoxPosition: Vector3;
  88101. private _boundingBoxSize;
  88102. /**
  88103. * Gets or sets the size of the bounding box associated with the cube texture
  88104. * When defined, the cubemap will switch to local mode
  88105. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88106. * @example https://www.babylonjs-playground.com/#RNASML
  88107. */
  88108. set boundingBoxSize(value: Vector3);
  88109. /**
  88110. * Returns the bounding box size
  88111. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88112. */
  88113. get boundingBoxSize(): Vector3;
  88114. protected _rotationY: number;
  88115. /**
  88116. * Sets texture matrix rotation angle around Y axis in radians.
  88117. */
  88118. set rotationY(value: number);
  88119. /**
  88120. * Gets texture matrix rotation angle around Y axis radians.
  88121. */
  88122. get rotationY(): number;
  88123. /**
  88124. * Are mip maps generated for this texture or not.
  88125. */
  88126. get noMipmap(): boolean;
  88127. private _noMipmap;
  88128. private _files;
  88129. protected _forcedExtension: Nullable<string>;
  88130. private _extensions;
  88131. private _textureMatrix;
  88132. private _format;
  88133. private _createPolynomials;
  88134. /**
  88135. * Creates a cube texture from an array of image urls
  88136. * @param files defines an array of image urls
  88137. * @param scene defines the hosting scene
  88138. * @param noMipmap specifies if mip maps are not used
  88139. * @returns a cube texture
  88140. */
  88141. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88142. /**
  88143. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88144. * @param url defines the url of the prefiltered texture
  88145. * @param scene defines the scene the texture is attached to
  88146. * @param forcedExtension defines the extension of the file if different from the url
  88147. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88148. * @return the prefiltered texture
  88149. */
  88150. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88151. /**
  88152. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88153. * as prefiltered data.
  88154. * @param rootUrl defines the url of the texture or the root name of the six images
  88155. * @param null defines the scene or engine the texture is attached to
  88156. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88157. * @param noMipmap defines if mipmaps should be created or not
  88158. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88159. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88160. * @param onError defines a callback triggered in case of error during load
  88161. * @param format defines the internal format to use for the texture once loaded
  88162. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88163. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88164. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88165. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88166. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88167. * @return the cube texture
  88168. */
  88169. 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);
  88170. /**
  88171. * Get the current class name of the texture useful for serialization or dynamic coding.
  88172. * @returns "CubeTexture"
  88173. */
  88174. getClassName(): string;
  88175. /**
  88176. * Update the url (and optional buffer) of this texture if url was null during construction.
  88177. * @param url the url of the texture
  88178. * @param forcedExtension defines the extension to use
  88179. * @param onLoad callback called when the texture is loaded (defaults to null)
  88180. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88181. */
  88182. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88183. /**
  88184. * Delays loading of the cube texture
  88185. * @param forcedExtension defines the extension to use
  88186. */
  88187. delayLoad(forcedExtension?: string): void;
  88188. /**
  88189. * Returns the reflection texture matrix
  88190. * @returns the reflection texture matrix
  88191. */
  88192. getReflectionTextureMatrix(): Matrix;
  88193. /**
  88194. * Sets the reflection texture matrix
  88195. * @param value Reflection texture matrix
  88196. */
  88197. setReflectionTextureMatrix(value: Matrix): void;
  88198. /**
  88199. * Parses text to create a cube texture
  88200. * @param parsedTexture define the serialized text to read from
  88201. * @param scene defines the hosting scene
  88202. * @param rootUrl defines the root url of the cube texture
  88203. * @returns a cube texture
  88204. */
  88205. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88206. /**
  88207. * Makes a clone, or deep copy, of the cube texture
  88208. * @returns a new cube texture
  88209. */
  88210. clone(): CubeTexture;
  88211. }
  88212. }
  88213. declare module BABYLON {
  88214. /**
  88215. * Manages the defines for the Material
  88216. */
  88217. export class MaterialDefines {
  88218. /** @hidden */
  88219. protected _keys: string[];
  88220. private _isDirty;
  88221. /** @hidden */
  88222. _renderId: number;
  88223. /** @hidden */
  88224. _areLightsDirty: boolean;
  88225. /** @hidden */
  88226. _areLightsDisposed: boolean;
  88227. /** @hidden */
  88228. _areAttributesDirty: boolean;
  88229. /** @hidden */
  88230. _areTexturesDirty: boolean;
  88231. /** @hidden */
  88232. _areFresnelDirty: boolean;
  88233. /** @hidden */
  88234. _areMiscDirty: boolean;
  88235. /** @hidden */
  88236. _areImageProcessingDirty: boolean;
  88237. /** @hidden */
  88238. _normals: boolean;
  88239. /** @hidden */
  88240. _uvs: boolean;
  88241. /** @hidden */
  88242. _needNormals: boolean;
  88243. /** @hidden */
  88244. _needUVs: boolean;
  88245. [id: string]: any;
  88246. /**
  88247. * Specifies if the material needs to be re-calculated
  88248. */
  88249. get isDirty(): boolean;
  88250. /**
  88251. * Marks the material to indicate that it has been re-calculated
  88252. */
  88253. markAsProcessed(): void;
  88254. /**
  88255. * Marks the material to indicate that it needs to be re-calculated
  88256. */
  88257. markAsUnprocessed(): void;
  88258. /**
  88259. * Marks the material to indicate all of its defines need to be re-calculated
  88260. */
  88261. markAllAsDirty(): void;
  88262. /**
  88263. * Marks the material to indicate that image processing needs to be re-calculated
  88264. */
  88265. markAsImageProcessingDirty(): void;
  88266. /**
  88267. * Marks the material to indicate the lights need to be re-calculated
  88268. * @param disposed Defines whether the light is dirty due to dispose or not
  88269. */
  88270. markAsLightDirty(disposed?: boolean): void;
  88271. /**
  88272. * Marks the attribute state as changed
  88273. */
  88274. markAsAttributesDirty(): void;
  88275. /**
  88276. * Marks the texture state as changed
  88277. */
  88278. markAsTexturesDirty(): void;
  88279. /**
  88280. * Marks the fresnel state as changed
  88281. */
  88282. markAsFresnelDirty(): void;
  88283. /**
  88284. * Marks the misc state as changed
  88285. */
  88286. markAsMiscDirty(): void;
  88287. /**
  88288. * Rebuilds the material defines
  88289. */
  88290. rebuild(): void;
  88291. /**
  88292. * Specifies if two material defines are equal
  88293. * @param other - A material define instance to compare to
  88294. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88295. */
  88296. isEqual(other: MaterialDefines): boolean;
  88297. /**
  88298. * Clones this instance's defines to another instance
  88299. * @param other - material defines to clone values to
  88300. */
  88301. cloneTo(other: MaterialDefines): void;
  88302. /**
  88303. * Resets the material define values
  88304. */
  88305. reset(): void;
  88306. /**
  88307. * Converts the material define values to a string
  88308. * @returns - String of material define information
  88309. */
  88310. toString(): string;
  88311. }
  88312. }
  88313. declare module BABYLON {
  88314. /**
  88315. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88316. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88317. * 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;
  88318. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88319. */
  88320. export class ColorCurves {
  88321. private _dirty;
  88322. private _tempColor;
  88323. private _globalCurve;
  88324. private _highlightsCurve;
  88325. private _midtonesCurve;
  88326. private _shadowsCurve;
  88327. private _positiveCurve;
  88328. private _negativeCurve;
  88329. private _globalHue;
  88330. private _globalDensity;
  88331. private _globalSaturation;
  88332. private _globalExposure;
  88333. /**
  88334. * Gets the global Hue value.
  88335. * 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).
  88336. */
  88337. get globalHue(): number;
  88338. /**
  88339. * Sets the global Hue value.
  88340. * 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).
  88341. */
  88342. set globalHue(value: number);
  88343. /**
  88344. * Gets the global Density value.
  88345. * 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.
  88346. * Values less than zero provide a filter of opposite hue.
  88347. */
  88348. get globalDensity(): number;
  88349. /**
  88350. * Sets the global Density value.
  88351. * 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.
  88352. * Values less than zero provide a filter of opposite hue.
  88353. */
  88354. set globalDensity(value: number);
  88355. /**
  88356. * Gets the global Saturation value.
  88357. * 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.
  88358. */
  88359. get globalSaturation(): number;
  88360. /**
  88361. * Sets the global Saturation value.
  88362. * 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.
  88363. */
  88364. set globalSaturation(value: number);
  88365. /**
  88366. * Gets the global Exposure value.
  88367. * 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.
  88368. */
  88369. get globalExposure(): number;
  88370. /**
  88371. * Sets the global Exposure value.
  88372. * 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.
  88373. */
  88374. set globalExposure(value: number);
  88375. private _highlightsHue;
  88376. private _highlightsDensity;
  88377. private _highlightsSaturation;
  88378. private _highlightsExposure;
  88379. /**
  88380. * Gets the highlights Hue value.
  88381. * 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).
  88382. */
  88383. get highlightsHue(): number;
  88384. /**
  88385. * Sets the highlights Hue value.
  88386. * 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).
  88387. */
  88388. set highlightsHue(value: number);
  88389. /**
  88390. * Gets the highlights Density value.
  88391. * 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.
  88392. * Values less than zero provide a filter of opposite hue.
  88393. */
  88394. get highlightsDensity(): number;
  88395. /**
  88396. * Sets the highlights Density value.
  88397. * 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.
  88398. * Values less than zero provide a filter of opposite hue.
  88399. */
  88400. set highlightsDensity(value: number);
  88401. /**
  88402. * Gets the highlights Saturation value.
  88403. * 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.
  88404. */
  88405. get highlightsSaturation(): number;
  88406. /**
  88407. * Sets the highlights Saturation value.
  88408. * 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.
  88409. */
  88410. set highlightsSaturation(value: number);
  88411. /**
  88412. * Gets the highlights Exposure value.
  88413. * 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.
  88414. */
  88415. get highlightsExposure(): number;
  88416. /**
  88417. * Sets the highlights Exposure value.
  88418. * 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.
  88419. */
  88420. set highlightsExposure(value: number);
  88421. private _midtonesHue;
  88422. private _midtonesDensity;
  88423. private _midtonesSaturation;
  88424. private _midtonesExposure;
  88425. /**
  88426. * Gets the midtones Hue value.
  88427. * 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).
  88428. */
  88429. get midtonesHue(): number;
  88430. /**
  88431. * Sets the midtones Hue value.
  88432. * 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).
  88433. */
  88434. set midtonesHue(value: number);
  88435. /**
  88436. * Gets the midtones Density value.
  88437. * 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.
  88438. * Values less than zero provide a filter of opposite hue.
  88439. */
  88440. get midtonesDensity(): number;
  88441. /**
  88442. * Sets the midtones Density value.
  88443. * 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.
  88444. * Values less than zero provide a filter of opposite hue.
  88445. */
  88446. set midtonesDensity(value: number);
  88447. /**
  88448. * Gets the midtones Saturation value.
  88449. * 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.
  88450. */
  88451. get midtonesSaturation(): number;
  88452. /**
  88453. * Sets the midtones Saturation value.
  88454. * 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.
  88455. */
  88456. set midtonesSaturation(value: number);
  88457. /**
  88458. * Gets the midtones Exposure value.
  88459. * 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.
  88460. */
  88461. get midtonesExposure(): number;
  88462. /**
  88463. * Sets the midtones Exposure value.
  88464. * 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.
  88465. */
  88466. set midtonesExposure(value: number);
  88467. private _shadowsHue;
  88468. private _shadowsDensity;
  88469. private _shadowsSaturation;
  88470. private _shadowsExposure;
  88471. /**
  88472. * Gets the shadows Hue value.
  88473. * 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).
  88474. */
  88475. get shadowsHue(): number;
  88476. /**
  88477. * Sets the shadows Hue value.
  88478. * 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).
  88479. */
  88480. set shadowsHue(value: number);
  88481. /**
  88482. * Gets the shadows Density value.
  88483. * 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.
  88484. * Values less than zero provide a filter of opposite hue.
  88485. */
  88486. get shadowsDensity(): number;
  88487. /**
  88488. * Sets the shadows Density value.
  88489. * 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.
  88490. * Values less than zero provide a filter of opposite hue.
  88491. */
  88492. set shadowsDensity(value: number);
  88493. /**
  88494. * Gets the shadows Saturation value.
  88495. * 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.
  88496. */
  88497. get shadowsSaturation(): number;
  88498. /**
  88499. * Sets the shadows Saturation value.
  88500. * 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.
  88501. */
  88502. set shadowsSaturation(value: number);
  88503. /**
  88504. * Gets the shadows Exposure value.
  88505. * 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.
  88506. */
  88507. get shadowsExposure(): number;
  88508. /**
  88509. * Sets the shadows Exposure value.
  88510. * 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.
  88511. */
  88512. set shadowsExposure(value: number);
  88513. /**
  88514. * Returns the class name
  88515. * @returns The class name
  88516. */
  88517. getClassName(): string;
  88518. /**
  88519. * Binds the color curves to the shader.
  88520. * @param colorCurves The color curve to bind
  88521. * @param effect The effect to bind to
  88522. * @param positiveUniform The positive uniform shader parameter
  88523. * @param neutralUniform The neutral uniform shader parameter
  88524. * @param negativeUniform The negative uniform shader parameter
  88525. */
  88526. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88527. /**
  88528. * Prepare the list of uniforms associated with the ColorCurves effects.
  88529. * @param uniformsList The list of uniforms used in the effect
  88530. */
  88531. static PrepareUniforms(uniformsList: string[]): void;
  88532. /**
  88533. * Returns color grading data based on a hue, density, saturation and exposure value.
  88534. * @param filterHue The hue of the color filter.
  88535. * @param filterDensity The density of the color filter.
  88536. * @param saturation The saturation.
  88537. * @param exposure The exposure.
  88538. * @param result The result data container.
  88539. */
  88540. private getColorGradingDataToRef;
  88541. /**
  88542. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88543. * @param value The input slider value in range [-100,100].
  88544. * @returns Adjusted value.
  88545. */
  88546. private static applyColorGradingSliderNonlinear;
  88547. /**
  88548. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88549. * @param hue The hue (H) input.
  88550. * @param saturation The saturation (S) input.
  88551. * @param brightness The brightness (B) input.
  88552. * @result An RGBA color represented as Vector4.
  88553. */
  88554. private static fromHSBToRef;
  88555. /**
  88556. * Returns a value clamped between min and max
  88557. * @param value The value to clamp
  88558. * @param min The minimum of value
  88559. * @param max The maximum of value
  88560. * @returns The clamped value.
  88561. */
  88562. private static clamp;
  88563. /**
  88564. * Clones the current color curve instance.
  88565. * @return The cloned curves
  88566. */
  88567. clone(): ColorCurves;
  88568. /**
  88569. * Serializes the current color curve instance to a json representation.
  88570. * @return a JSON representation
  88571. */
  88572. serialize(): any;
  88573. /**
  88574. * Parses the color curve from a json representation.
  88575. * @param source the JSON source to parse
  88576. * @return The parsed curves
  88577. */
  88578. static Parse(source: any): ColorCurves;
  88579. }
  88580. }
  88581. declare module BABYLON {
  88582. /**
  88583. * Interface to follow in your material defines to integrate easily the
  88584. * Image proccessing functions.
  88585. * @hidden
  88586. */
  88587. export interface IImageProcessingConfigurationDefines {
  88588. IMAGEPROCESSING: boolean;
  88589. VIGNETTE: boolean;
  88590. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88591. VIGNETTEBLENDMODEOPAQUE: boolean;
  88592. TONEMAPPING: boolean;
  88593. TONEMAPPING_ACES: boolean;
  88594. CONTRAST: boolean;
  88595. EXPOSURE: boolean;
  88596. COLORCURVES: boolean;
  88597. COLORGRADING: boolean;
  88598. COLORGRADING3D: boolean;
  88599. SAMPLER3DGREENDEPTH: boolean;
  88600. SAMPLER3DBGRMAP: boolean;
  88601. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88602. }
  88603. /**
  88604. * @hidden
  88605. */
  88606. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88607. IMAGEPROCESSING: boolean;
  88608. VIGNETTE: boolean;
  88609. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88610. VIGNETTEBLENDMODEOPAQUE: boolean;
  88611. TONEMAPPING: boolean;
  88612. TONEMAPPING_ACES: boolean;
  88613. CONTRAST: boolean;
  88614. COLORCURVES: boolean;
  88615. COLORGRADING: boolean;
  88616. COLORGRADING3D: boolean;
  88617. SAMPLER3DGREENDEPTH: boolean;
  88618. SAMPLER3DBGRMAP: boolean;
  88619. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88620. EXPOSURE: boolean;
  88621. constructor();
  88622. }
  88623. /**
  88624. * This groups together the common properties used for image processing either in direct forward pass
  88625. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88626. * or not.
  88627. */
  88628. export class ImageProcessingConfiguration {
  88629. /**
  88630. * Default tone mapping applied in BabylonJS.
  88631. */
  88632. static readonly TONEMAPPING_STANDARD: number;
  88633. /**
  88634. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88635. * to other engines rendering to increase portability.
  88636. */
  88637. static readonly TONEMAPPING_ACES: number;
  88638. /**
  88639. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88640. */
  88641. colorCurves: Nullable<ColorCurves>;
  88642. private _colorCurvesEnabled;
  88643. /**
  88644. * Gets wether the color curves effect is enabled.
  88645. */
  88646. get colorCurvesEnabled(): boolean;
  88647. /**
  88648. * Sets wether the color curves effect is enabled.
  88649. */
  88650. set colorCurvesEnabled(value: boolean);
  88651. private _colorGradingTexture;
  88652. /**
  88653. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88654. */
  88655. get colorGradingTexture(): Nullable<BaseTexture>;
  88656. /**
  88657. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88658. */
  88659. set colorGradingTexture(value: Nullable<BaseTexture>);
  88660. private _colorGradingEnabled;
  88661. /**
  88662. * Gets wether the color grading effect is enabled.
  88663. */
  88664. get colorGradingEnabled(): boolean;
  88665. /**
  88666. * Sets wether the color grading effect is enabled.
  88667. */
  88668. set colorGradingEnabled(value: boolean);
  88669. private _colorGradingWithGreenDepth;
  88670. /**
  88671. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88672. */
  88673. get colorGradingWithGreenDepth(): boolean;
  88674. /**
  88675. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88676. */
  88677. set colorGradingWithGreenDepth(value: boolean);
  88678. private _colorGradingBGR;
  88679. /**
  88680. * Gets wether the color grading texture contains BGR values.
  88681. */
  88682. get colorGradingBGR(): boolean;
  88683. /**
  88684. * Sets wether the color grading texture contains BGR values.
  88685. */
  88686. set colorGradingBGR(value: boolean);
  88687. /** @hidden */
  88688. _exposure: number;
  88689. /**
  88690. * Gets the Exposure used in the effect.
  88691. */
  88692. get exposure(): number;
  88693. /**
  88694. * Sets the Exposure used in the effect.
  88695. */
  88696. set exposure(value: number);
  88697. private _toneMappingEnabled;
  88698. /**
  88699. * Gets wether the tone mapping effect is enabled.
  88700. */
  88701. get toneMappingEnabled(): boolean;
  88702. /**
  88703. * Sets wether the tone mapping effect is enabled.
  88704. */
  88705. set toneMappingEnabled(value: boolean);
  88706. private _toneMappingType;
  88707. /**
  88708. * Gets the type of tone mapping effect.
  88709. */
  88710. get toneMappingType(): number;
  88711. /**
  88712. * Sets the type of tone mapping effect used in BabylonJS.
  88713. */
  88714. set toneMappingType(value: number);
  88715. protected _contrast: number;
  88716. /**
  88717. * Gets the contrast used in the effect.
  88718. */
  88719. get contrast(): number;
  88720. /**
  88721. * Sets the contrast used in the effect.
  88722. */
  88723. set contrast(value: number);
  88724. /**
  88725. * Vignette stretch size.
  88726. */
  88727. vignetteStretch: number;
  88728. /**
  88729. * Vignette centre X Offset.
  88730. */
  88731. vignetteCentreX: number;
  88732. /**
  88733. * Vignette centre Y Offset.
  88734. */
  88735. vignetteCentreY: number;
  88736. /**
  88737. * Vignette weight or intensity of the vignette effect.
  88738. */
  88739. vignetteWeight: number;
  88740. /**
  88741. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88742. * if vignetteEnabled is set to true.
  88743. */
  88744. vignetteColor: Color4;
  88745. /**
  88746. * Camera field of view used by the Vignette effect.
  88747. */
  88748. vignetteCameraFov: number;
  88749. private _vignetteBlendMode;
  88750. /**
  88751. * Gets the vignette blend mode allowing different kind of effect.
  88752. */
  88753. get vignetteBlendMode(): number;
  88754. /**
  88755. * Sets the vignette blend mode allowing different kind of effect.
  88756. */
  88757. set vignetteBlendMode(value: number);
  88758. private _vignetteEnabled;
  88759. /**
  88760. * Gets wether the vignette effect is enabled.
  88761. */
  88762. get vignetteEnabled(): boolean;
  88763. /**
  88764. * Sets wether the vignette effect is enabled.
  88765. */
  88766. set vignetteEnabled(value: boolean);
  88767. private _applyByPostProcess;
  88768. /**
  88769. * Gets wether the image processing is applied through a post process or not.
  88770. */
  88771. get applyByPostProcess(): boolean;
  88772. /**
  88773. * Sets wether the image processing is applied through a post process or not.
  88774. */
  88775. set applyByPostProcess(value: boolean);
  88776. private _isEnabled;
  88777. /**
  88778. * Gets wether the image processing is enabled or not.
  88779. */
  88780. get isEnabled(): boolean;
  88781. /**
  88782. * Sets wether the image processing is enabled or not.
  88783. */
  88784. set isEnabled(value: boolean);
  88785. /**
  88786. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88787. */
  88788. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88789. /**
  88790. * Method called each time the image processing information changes requires to recompile the effect.
  88791. */
  88792. protected _updateParameters(): void;
  88793. /**
  88794. * Gets the current class name.
  88795. * @return "ImageProcessingConfiguration"
  88796. */
  88797. getClassName(): string;
  88798. /**
  88799. * Prepare the list of uniforms associated with the Image Processing effects.
  88800. * @param uniforms The list of uniforms used in the effect
  88801. * @param defines the list of defines currently in use
  88802. */
  88803. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88804. /**
  88805. * Prepare the list of samplers associated with the Image Processing effects.
  88806. * @param samplersList The list of uniforms used in the effect
  88807. * @param defines the list of defines currently in use
  88808. */
  88809. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88810. /**
  88811. * Prepare the list of defines associated to the shader.
  88812. * @param defines the list of defines to complete
  88813. * @param forPostProcess Define if we are currently in post process mode or not
  88814. */
  88815. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88816. /**
  88817. * Returns true if all the image processing information are ready.
  88818. * @returns True if ready, otherwise, false
  88819. */
  88820. isReady(): boolean;
  88821. /**
  88822. * Binds the image processing to the shader.
  88823. * @param effect The effect to bind to
  88824. * @param overrideAspectRatio Override the aspect ratio of the effect
  88825. */
  88826. bind(effect: Effect, overrideAspectRatio?: number): void;
  88827. /**
  88828. * Clones the current image processing instance.
  88829. * @return The cloned image processing
  88830. */
  88831. clone(): ImageProcessingConfiguration;
  88832. /**
  88833. * Serializes the current image processing instance to a json representation.
  88834. * @return a JSON representation
  88835. */
  88836. serialize(): any;
  88837. /**
  88838. * Parses the image processing from a json representation.
  88839. * @param source the JSON source to parse
  88840. * @return The parsed image processing
  88841. */
  88842. static Parse(source: any): ImageProcessingConfiguration;
  88843. private static _VIGNETTEMODE_MULTIPLY;
  88844. private static _VIGNETTEMODE_OPAQUE;
  88845. /**
  88846. * Used to apply the vignette as a mix with the pixel color.
  88847. */
  88848. static get VIGNETTEMODE_MULTIPLY(): number;
  88849. /**
  88850. * Used to apply the vignette as a replacement of the pixel color.
  88851. */
  88852. static get VIGNETTEMODE_OPAQUE(): number;
  88853. }
  88854. }
  88855. declare module BABYLON {
  88856. /** @hidden */
  88857. export var postprocessVertexShader: {
  88858. name: string;
  88859. shader: string;
  88860. };
  88861. }
  88862. declare module BABYLON {
  88863. /**
  88864. * Type used to define a render target texture size (either with a number or with a rect width and height)
  88865. */
  88866. export type RenderTargetTextureSize = number | {
  88867. width: number;
  88868. height: number;
  88869. layers?: number;
  88870. };
  88871. interface ThinEngine {
  88872. /**
  88873. * Creates a new render target texture
  88874. * @param size defines the size of the texture
  88875. * @param options defines the options used to create the texture
  88876. * @returns a new render target texture stored in an InternalTexture
  88877. */
  88878. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88879. /**
  88880. * Creates a depth stencil texture.
  88881. * This is only available in WebGL 2 or with the depth texture extension available.
  88882. * @param size The size of face edge in the texture.
  88883. * @param options The options defining the texture.
  88884. * @returns The texture
  88885. */
  88886. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88887. /** @hidden */
  88888. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88889. }
  88890. }
  88891. declare module BABYLON {
  88892. /**
  88893. * Defines the kind of connection point for node based material
  88894. */
  88895. export enum NodeMaterialBlockConnectionPointTypes {
  88896. /** Float */
  88897. Float = 1,
  88898. /** Int */
  88899. Int = 2,
  88900. /** Vector2 */
  88901. Vector2 = 4,
  88902. /** Vector3 */
  88903. Vector3 = 8,
  88904. /** Vector4 */
  88905. Vector4 = 16,
  88906. /** Color3 */
  88907. Color3 = 32,
  88908. /** Color4 */
  88909. Color4 = 64,
  88910. /** Matrix */
  88911. Matrix = 128,
  88912. /** Custom object */
  88913. Object = 256,
  88914. /** Detect type based on connection */
  88915. AutoDetect = 1024,
  88916. /** Output type that will be defined by input type */
  88917. BasedOnInput = 2048
  88918. }
  88919. }
  88920. declare module BABYLON {
  88921. /**
  88922. * Enum used to define the target of a block
  88923. */
  88924. export enum NodeMaterialBlockTargets {
  88925. /** Vertex shader */
  88926. Vertex = 1,
  88927. /** Fragment shader */
  88928. Fragment = 2,
  88929. /** Neutral */
  88930. Neutral = 4,
  88931. /** Vertex and Fragment */
  88932. VertexAndFragment = 3
  88933. }
  88934. }
  88935. declare module BABYLON {
  88936. /**
  88937. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  88938. */
  88939. export enum NodeMaterialBlockConnectionPointMode {
  88940. /** Value is an uniform */
  88941. Uniform = 0,
  88942. /** Value is a mesh attribute */
  88943. Attribute = 1,
  88944. /** Value is a varying between vertex and fragment shaders */
  88945. Varying = 2,
  88946. /** Mode is undefined */
  88947. Undefined = 3
  88948. }
  88949. }
  88950. declare module BABYLON {
  88951. /**
  88952. * Enum used to define system values e.g. values automatically provided by the system
  88953. */
  88954. export enum NodeMaterialSystemValues {
  88955. /** World */
  88956. World = 1,
  88957. /** View */
  88958. View = 2,
  88959. /** Projection */
  88960. Projection = 3,
  88961. /** ViewProjection */
  88962. ViewProjection = 4,
  88963. /** WorldView */
  88964. WorldView = 5,
  88965. /** WorldViewProjection */
  88966. WorldViewProjection = 6,
  88967. /** CameraPosition */
  88968. CameraPosition = 7,
  88969. /** Fog Color */
  88970. FogColor = 8,
  88971. /** Delta time */
  88972. DeltaTime = 9
  88973. }
  88974. }
  88975. declare module BABYLON {
  88976. /** Defines supported spaces */
  88977. export enum Space {
  88978. /** Local (object) space */
  88979. LOCAL = 0,
  88980. /** World space */
  88981. WORLD = 1,
  88982. /** Bone space */
  88983. BONE = 2
  88984. }
  88985. /** Defines the 3 main axes */
  88986. export class Axis {
  88987. /** X axis */
  88988. static X: Vector3;
  88989. /** Y axis */
  88990. static Y: Vector3;
  88991. /** Z axis */
  88992. static Z: Vector3;
  88993. }
  88994. }
  88995. declare module BABYLON {
  88996. /**
  88997. * Represents a camera frustum
  88998. */
  88999. export class Frustum {
  89000. /**
  89001. * Gets the planes representing the frustum
  89002. * @param transform matrix to be applied to the returned planes
  89003. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89004. */
  89005. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89006. /**
  89007. * Gets the near frustum plane transformed by the transform matrix
  89008. * @param transform transformation matrix to be applied to the resulting frustum plane
  89009. * @param frustumPlane the resuling frustum plane
  89010. */
  89011. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89012. /**
  89013. * Gets the far frustum plane transformed by the transform matrix
  89014. * @param transform transformation matrix to be applied to the resulting frustum plane
  89015. * @param frustumPlane the resuling frustum plane
  89016. */
  89017. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89018. /**
  89019. * Gets the left frustum plane transformed by the transform matrix
  89020. * @param transform transformation matrix to be applied to the resulting frustum plane
  89021. * @param frustumPlane the resuling frustum plane
  89022. */
  89023. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89024. /**
  89025. * Gets the right frustum plane transformed by the transform matrix
  89026. * @param transform transformation matrix to be applied to the resulting frustum plane
  89027. * @param frustumPlane the resuling frustum plane
  89028. */
  89029. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89030. /**
  89031. * Gets the top frustum plane transformed by the transform matrix
  89032. * @param transform transformation matrix to be applied to the resulting frustum plane
  89033. * @param frustumPlane the resuling frustum plane
  89034. */
  89035. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89036. /**
  89037. * Gets the bottom frustum plane transformed by the transform matrix
  89038. * @param transform transformation matrix to be applied to the resulting frustum plane
  89039. * @param frustumPlane the resuling frustum plane
  89040. */
  89041. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89042. /**
  89043. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89044. * @param transform transformation matrix to be applied to the resulting frustum planes
  89045. * @param frustumPlanes the resuling frustum planes
  89046. */
  89047. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89048. }
  89049. }
  89050. declare module BABYLON {
  89051. /**
  89052. * Interface for the size containing width and height
  89053. */
  89054. export interface ISize {
  89055. /**
  89056. * Width
  89057. */
  89058. width: number;
  89059. /**
  89060. * Heighht
  89061. */
  89062. height: number;
  89063. }
  89064. /**
  89065. * Size containing widht and height
  89066. */
  89067. export class Size implements ISize {
  89068. /**
  89069. * Width
  89070. */
  89071. width: number;
  89072. /**
  89073. * Height
  89074. */
  89075. height: number;
  89076. /**
  89077. * Creates a Size object from the given width and height (floats).
  89078. * @param width width of the new size
  89079. * @param height height of the new size
  89080. */
  89081. constructor(width: number, height: number);
  89082. /**
  89083. * Returns a string with the Size width and height
  89084. * @returns a string with the Size width and height
  89085. */
  89086. toString(): string;
  89087. /**
  89088. * "Size"
  89089. * @returns the string "Size"
  89090. */
  89091. getClassName(): string;
  89092. /**
  89093. * Returns the Size hash code.
  89094. * @returns a hash code for a unique width and height
  89095. */
  89096. getHashCode(): number;
  89097. /**
  89098. * Updates the current size from the given one.
  89099. * @param src the given size
  89100. */
  89101. copyFrom(src: Size): void;
  89102. /**
  89103. * Updates in place the current Size from the given floats.
  89104. * @param width width of the new size
  89105. * @param height height of the new size
  89106. * @returns the updated Size.
  89107. */
  89108. copyFromFloats(width: number, height: number): Size;
  89109. /**
  89110. * Updates in place the current Size from the given floats.
  89111. * @param width width to set
  89112. * @param height height to set
  89113. * @returns the updated Size.
  89114. */
  89115. set(width: number, height: number): Size;
  89116. /**
  89117. * Multiplies the width and height by numbers
  89118. * @param w factor to multiple the width by
  89119. * @param h factor to multiple the height by
  89120. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89121. */
  89122. multiplyByFloats(w: number, h: number): Size;
  89123. /**
  89124. * Clones the size
  89125. * @returns a new Size copied from the given one.
  89126. */
  89127. clone(): Size;
  89128. /**
  89129. * True if the current Size and the given one width and height are strictly equal.
  89130. * @param other the other size to compare against
  89131. * @returns True if the current Size and the given one width and height are strictly equal.
  89132. */
  89133. equals(other: Size): boolean;
  89134. /**
  89135. * The surface of the Size : width * height (float).
  89136. */
  89137. get surface(): number;
  89138. /**
  89139. * Create a new size of zero
  89140. * @returns a new Size set to (0.0, 0.0)
  89141. */
  89142. static Zero(): Size;
  89143. /**
  89144. * Sums the width and height of two sizes
  89145. * @param otherSize size to add to this size
  89146. * @returns a new Size set as the addition result of the current Size and the given one.
  89147. */
  89148. add(otherSize: Size): Size;
  89149. /**
  89150. * Subtracts the width and height of two
  89151. * @param otherSize size to subtract to this size
  89152. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89153. */
  89154. subtract(otherSize: Size): Size;
  89155. /**
  89156. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89157. * @param start starting size to lerp between
  89158. * @param end end size to lerp between
  89159. * @param amount amount to lerp between the start and end values
  89160. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89161. */
  89162. static Lerp(start: Size, end: Size, amount: number): Size;
  89163. }
  89164. }
  89165. declare module BABYLON {
  89166. /**
  89167. * Contains position and normal vectors for a vertex
  89168. */
  89169. export class PositionNormalVertex {
  89170. /** the position of the vertex (defaut: 0,0,0) */
  89171. position: Vector3;
  89172. /** the normal of the vertex (defaut: 0,1,0) */
  89173. normal: Vector3;
  89174. /**
  89175. * Creates a PositionNormalVertex
  89176. * @param position the position of the vertex (defaut: 0,0,0)
  89177. * @param normal the normal of the vertex (defaut: 0,1,0)
  89178. */
  89179. constructor(
  89180. /** the position of the vertex (defaut: 0,0,0) */
  89181. position?: Vector3,
  89182. /** the normal of the vertex (defaut: 0,1,0) */
  89183. normal?: Vector3);
  89184. /**
  89185. * Clones the PositionNormalVertex
  89186. * @returns the cloned PositionNormalVertex
  89187. */
  89188. clone(): PositionNormalVertex;
  89189. }
  89190. /**
  89191. * Contains position, normal and uv vectors for a vertex
  89192. */
  89193. export class PositionNormalTextureVertex {
  89194. /** the position of the vertex (defaut: 0,0,0) */
  89195. position: Vector3;
  89196. /** the normal of the vertex (defaut: 0,1,0) */
  89197. normal: Vector3;
  89198. /** the uv of the vertex (default: 0,0) */
  89199. uv: Vector2;
  89200. /**
  89201. * Creates a PositionNormalTextureVertex
  89202. * @param position the position of the vertex (defaut: 0,0,0)
  89203. * @param normal the normal of the vertex (defaut: 0,1,0)
  89204. * @param uv the uv of the vertex (default: 0,0)
  89205. */
  89206. constructor(
  89207. /** the position of the vertex (defaut: 0,0,0) */
  89208. position?: Vector3,
  89209. /** the normal of the vertex (defaut: 0,1,0) */
  89210. normal?: Vector3,
  89211. /** the uv of the vertex (default: 0,0) */
  89212. uv?: Vector2);
  89213. /**
  89214. * Clones the PositionNormalTextureVertex
  89215. * @returns the cloned PositionNormalTextureVertex
  89216. */
  89217. clone(): PositionNormalTextureVertex;
  89218. }
  89219. }
  89220. declare module BABYLON {
  89221. /**
  89222. * Enum defining the type of animations supported by InputBlock
  89223. */
  89224. export enum AnimatedInputBlockTypes {
  89225. /** No animation */
  89226. None = 0,
  89227. /** Time based animation. Will only work for floats */
  89228. Time = 1
  89229. }
  89230. }
  89231. declare module BABYLON {
  89232. /**
  89233. * Interface describing all the common properties and methods a shadow light needs to implement.
  89234. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89235. * as well as binding the different shadow properties to the effects.
  89236. */
  89237. export interface IShadowLight extends Light {
  89238. /**
  89239. * The light id in the scene (used in scene.findLighById for instance)
  89240. */
  89241. id: string;
  89242. /**
  89243. * The position the shdow will be casted from.
  89244. */
  89245. position: Vector3;
  89246. /**
  89247. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89248. */
  89249. direction: Vector3;
  89250. /**
  89251. * The transformed position. Position of the light in world space taking parenting in account.
  89252. */
  89253. transformedPosition: Vector3;
  89254. /**
  89255. * The transformed direction. Direction of the light in world space taking parenting in account.
  89256. */
  89257. transformedDirection: Vector3;
  89258. /**
  89259. * The friendly name of the light in the scene.
  89260. */
  89261. name: string;
  89262. /**
  89263. * Defines the shadow projection clipping minimum z value.
  89264. */
  89265. shadowMinZ: number;
  89266. /**
  89267. * Defines the shadow projection clipping maximum z value.
  89268. */
  89269. shadowMaxZ: number;
  89270. /**
  89271. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89272. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89273. */
  89274. computeTransformedInformation(): boolean;
  89275. /**
  89276. * Gets the scene the light belongs to.
  89277. * @returns The scene
  89278. */
  89279. getScene(): Scene;
  89280. /**
  89281. * Callback defining a custom Projection Matrix Builder.
  89282. * This can be used to override the default projection matrix computation.
  89283. */
  89284. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89285. /**
  89286. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89287. * @param matrix The materix to updated with the projection information
  89288. * @param viewMatrix The transform matrix of the light
  89289. * @param renderList The list of mesh to render in the map
  89290. * @returns The current light
  89291. */
  89292. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89293. /**
  89294. * Gets the current depth scale used in ESM.
  89295. * @returns The scale
  89296. */
  89297. getDepthScale(): number;
  89298. /**
  89299. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89300. * @returns true if a cube texture needs to be use
  89301. */
  89302. needCube(): boolean;
  89303. /**
  89304. * Detects if the projection matrix requires to be recomputed this frame.
  89305. * @returns true if it requires to be recomputed otherwise, false.
  89306. */
  89307. needProjectionMatrixCompute(): boolean;
  89308. /**
  89309. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89310. */
  89311. forceProjectionMatrixCompute(): void;
  89312. /**
  89313. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89314. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89315. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89316. */
  89317. getShadowDirection(faceIndex?: number): Vector3;
  89318. /**
  89319. * Gets the minZ used for shadow according to both the scene and the light.
  89320. * @param activeCamera The camera we are returning the min for
  89321. * @returns the depth min z
  89322. */
  89323. getDepthMinZ(activeCamera: Camera): number;
  89324. /**
  89325. * Gets the maxZ used for shadow according to both the scene and the light.
  89326. * @param activeCamera The camera we are returning the max for
  89327. * @returns the depth max z
  89328. */
  89329. getDepthMaxZ(activeCamera: Camera): number;
  89330. }
  89331. /**
  89332. * Base implementation IShadowLight
  89333. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89334. */
  89335. export abstract class ShadowLight extends Light implements IShadowLight {
  89336. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89337. protected _position: Vector3;
  89338. protected _setPosition(value: Vector3): void;
  89339. /**
  89340. * Sets the position the shadow will be casted from. Also use as the light position for both
  89341. * point and spot lights.
  89342. */
  89343. get position(): Vector3;
  89344. /**
  89345. * Sets the position the shadow will be casted from. Also use as the light position for both
  89346. * point and spot lights.
  89347. */
  89348. set position(value: Vector3);
  89349. protected _direction: Vector3;
  89350. protected _setDirection(value: Vector3): void;
  89351. /**
  89352. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89353. * Also use as the light direction on spot and directional lights.
  89354. */
  89355. get direction(): Vector3;
  89356. /**
  89357. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89358. * Also use as the light direction on spot and directional lights.
  89359. */
  89360. set direction(value: Vector3);
  89361. protected _shadowMinZ: number;
  89362. /**
  89363. * Gets the shadow projection clipping minimum z value.
  89364. */
  89365. get shadowMinZ(): number;
  89366. /**
  89367. * Sets the shadow projection clipping minimum z value.
  89368. */
  89369. set shadowMinZ(value: number);
  89370. protected _shadowMaxZ: number;
  89371. /**
  89372. * Sets the shadow projection clipping maximum z value.
  89373. */
  89374. get shadowMaxZ(): number;
  89375. /**
  89376. * Gets the shadow projection clipping maximum z value.
  89377. */
  89378. set shadowMaxZ(value: number);
  89379. /**
  89380. * Callback defining a custom Projection Matrix Builder.
  89381. * This can be used to override the default projection matrix computation.
  89382. */
  89383. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89384. /**
  89385. * The transformed position. Position of the light in world space taking parenting in account.
  89386. */
  89387. transformedPosition: Vector3;
  89388. /**
  89389. * The transformed direction. Direction of the light in world space taking parenting in account.
  89390. */
  89391. transformedDirection: Vector3;
  89392. private _needProjectionMatrixCompute;
  89393. /**
  89394. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89395. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89396. */
  89397. computeTransformedInformation(): boolean;
  89398. /**
  89399. * Return the depth scale used for the shadow map.
  89400. * @returns the depth scale.
  89401. */
  89402. getDepthScale(): number;
  89403. /**
  89404. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89405. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89406. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89407. */
  89408. getShadowDirection(faceIndex?: number): Vector3;
  89409. /**
  89410. * Returns the ShadowLight absolute position in the World.
  89411. * @returns the position vector in world space
  89412. */
  89413. getAbsolutePosition(): Vector3;
  89414. /**
  89415. * Sets the ShadowLight direction toward the passed target.
  89416. * @param target The point to target in local space
  89417. * @returns the updated ShadowLight direction
  89418. */
  89419. setDirectionToTarget(target: Vector3): Vector3;
  89420. /**
  89421. * Returns the light rotation in euler definition.
  89422. * @returns the x y z rotation in local space.
  89423. */
  89424. getRotation(): Vector3;
  89425. /**
  89426. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89427. * @returns true if a cube texture needs to be use
  89428. */
  89429. needCube(): boolean;
  89430. /**
  89431. * Detects if the projection matrix requires to be recomputed this frame.
  89432. * @returns true if it requires to be recomputed otherwise, false.
  89433. */
  89434. needProjectionMatrixCompute(): boolean;
  89435. /**
  89436. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89437. */
  89438. forceProjectionMatrixCompute(): void;
  89439. /** @hidden */
  89440. _initCache(): void;
  89441. /** @hidden */
  89442. _isSynchronized(): boolean;
  89443. /**
  89444. * Computes the world matrix of the node
  89445. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89446. * @returns the world matrix
  89447. */
  89448. computeWorldMatrix(force?: boolean): Matrix;
  89449. /**
  89450. * Gets the minZ used for shadow according to both the scene and the light.
  89451. * @param activeCamera The camera we are returning the min for
  89452. * @returns the depth min z
  89453. */
  89454. getDepthMinZ(activeCamera: Camera): number;
  89455. /**
  89456. * Gets the maxZ used for shadow according to both the scene and the light.
  89457. * @param activeCamera The camera we are returning the max for
  89458. * @returns the depth max z
  89459. */
  89460. getDepthMaxZ(activeCamera: Camera): number;
  89461. /**
  89462. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89463. * @param matrix The materix to updated with the projection information
  89464. * @param viewMatrix The transform matrix of the light
  89465. * @param renderList The list of mesh to render in the map
  89466. * @returns The current light
  89467. */
  89468. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89469. }
  89470. }
  89471. declare module BABYLON {
  89472. /** @hidden */
  89473. export var packingFunctions: {
  89474. name: string;
  89475. shader: string;
  89476. };
  89477. }
  89478. declare module BABYLON {
  89479. /** @hidden */
  89480. export var bayerDitherFunctions: {
  89481. name: string;
  89482. shader: string;
  89483. };
  89484. }
  89485. declare module BABYLON {
  89486. /** @hidden */
  89487. export var shadowMapFragmentDeclaration: {
  89488. name: string;
  89489. shader: string;
  89490. };
  89491. }
  89492. declare module BABYLON {
  89493. /** @hidden */
  89494. export var clipPlaneFragmentDeclaration: {
  89495. name: string;
  89496. shader: string;
  89497. };
  89498. }
  89499. declare module BABYLON {
  89500. /** @hidden */
  89501. export var clipPlaneFragment: {
  89502. name: string;
  89503. shader: string;
  89504. };
  89505. }
  89506. declare module BABYLON {
  89507. /** @hidden */
  89508. export var shadowMapFragment: {
  89509. name: string;
  89510. shader: string;
  89511. };
  89512. }
  89513. declare module BABYLON {
  89514. /** @hidden */
  89515. export var shadowMapPixelShader: {
  89516. name: string;
  89517. shader: string;
  89518. };
  89519. }
  89520. declare module BABYLON {
  89521. /** @hidden */
  89522. export var bonesDeclaration: {
  89523. name: string;
  89524. shader: string;
  89525. };
  89526. }
  89527. declare module BABYLON {
  89528. /** @hidden */
  89529. export var morphTargetsVertexGlobalDeclaration: {
  89530. name: string;
  89531. shader: string;
  89532. };
  89533. }
  89534. declare module BABYLON {
  89535. /** @hidden */
  89536. export var morphTargetsVertexDeclaration: {
  89537. name: string;
  89538. shader: string;
  89539. };
  89540. }
  89541. declare module BABYLON {
  89542. /** @hidden */
  89543. export var instancesDeclaration: {
  89544. name: string;
  89545. shader: string;
  89546. };
  89547. }
  89548. declare module BABYLON {
  89549. /** @hidden */
  89550. export var helperFunctions: {
  89551. name: string;
  89552. shader: string;
  89553. };
  89554. }
  89555. declare module BABYLON {
  89556. /** @hidden */
  89557. export var shadowMapVertexDeclaration: {
  89558. name: string;
  89559. shader: string;
  89560. };
  89561. }
  89562. declare module BABYLON {
  89563. /** @hidden */
  89564. export var clipPlaneVertexDeclaration: {
  89565. name: string;
  89566. shader: string;
  89567. };
  89568. }
  89569. declare module BABYLON {
  89570. /** @hidden */
  89571. export var morphTargetsVertex: {
  89572. name: string;
  89573. shader: string;
  89574. };
  89575. }
  89576. declare module BABYLON {
  89577. /** @hidden */
  89578. export var instancesVertex: {
  89579. name: string;
  89580. shader: string;
  89581. };
  89582. }
  89583. declare module BABYLON {
  89584. /** @hidden */
  89585. export var bonesVertex: {
  89586. name: string;
  89587. shader: string;
  89588. };
  89589. }
  89590. declare module BABYLON {
  89591. /** @hidden */
  89592. export var shadowMapVertexNormalBias: {
  89593. name: string;
  89594. shader: string;
  89595. };
  89596. }
  89597. declare module BABYLON {
  89598. /** @hidden */
  89599. export var shadowMapVertexMetric: {
  89600. name: string;
  89601. shader: string;
  89602. };
  89603. }
  89604. declare module BABYLON {
  89605. /** @hidden */
  89606. export var clipPlaneVertex: {
  89607. name: string;
  89608. shader: string;
  89609. };
  89610. }
  89611. declare module BABYLON {
  89612. /** @hidden */
  89613. export var shadowMapVertexShader: {
  89614. name: string;
  89615. shader: string;
  89616. };
  89617. }
  89618. declare module BABYLON {
  89619. /** @hidden */
  89620. export var depthBoxBlurPixelShader: {
  89621. name: string;
  89622. shader: string;
  89623. };
  89624. }
  89625. declare module BABYLON {
  89626. /** @hidden */
  89627. export var shadowMapFragmentSoftTransparentShadow: {
  89628. name: string;
  89629. shader: string;
  89630. };
  89631. }
  89632. declare module BABYLON {
  89633. /**
  89634. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89635. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89636. */
  89637. export class EffectFallbacks implements IEffectFallbacks {
  89638. private _defines;
  89639. private _currentRank;
  89640. private _maxRank;
  89641. private _mesh;
  89642. /**
  89643. * Removes the fallback from the bound mesh.
  89644. */
  89645. unBindMesh(): void;
  89646. /**
  89647. * Adds a fallback on the specified property.
  89648. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89649. * @param define The name of the define in the shader
  89650. */
  89651. addFallback(rank: number, define: string): void;
  89652. /**
  89653. * Sets the mesh to use CPU skinning when needing to fallback.
  89654. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89655. * @param mesh The mesh to use the fallbacks.
  89656. */
  89657. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89658. /**
  89659. * Checks to see if more fallbacks are still availible.
  89660. */
  89661. get hasMoreFallbacks(): boolean;
  89662. /**
  89663. * Removes the defines that should be removed when falling back.
  89664. * @param currentDefines defines the current define statements for the shader.
  89665. * @param effect defines the current effect we try to compile
  89666. * @returns The resulting defines with defines of the current rank removed.
  89667. */
  89668. reduce(currentDefines: string, effect: Effect): string;
  89669. }
  89670. }
  89671. declare module BABYLON {
  89672. /**
  89673. * Interface used to define Action
  89674. */
  89675. export interface IAction {
  89676. /**
  89677. * Trigger for the action
  89678. */
  89679. trigger: number;
  89680. /** Options of the trigger */
  89681. triggerOptions: any;
  89682. /**
  89683. * Gets the trigger parameters
  89684. * @returns the trigger parameters
  89685. */
  89686. getTriggerParameter(): any;
  89687. /**
  89688. * Internal only - executes current action event
  89689. * @hidden
  89690. */
  89691. _executeCurrent(evt?: ActionEvent): void;
  89692. /**
  89693. * Serialize placeholder for child classes
  89694. * @param parent of child
  89695. * @returns the serialized object
  89696. */
  89697. serialize(parent: any): any;
  89698. /**
  89699. * Internal only
  89700. * @hidden
  89701. */
  89702. _prepare(): void;
  89703. /**
  89704. * Internal only - manager for action
  89705. * @hidden
  89706. */
  89707. _actionManager: Nullable<AbstractActionManager>;
  89708. /**
  89709. * Adds action to chain of actions, may be a DoNothingAction
  89710. * @param action defines the next action to execute
  89711. * @returns The action passed in
  89712. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89713. */
  89714. then(action: IAction): IAction;
  89715. }
  89716. /**
  89717. * The action to be carried out following a trigger
  89718. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89719. */
  89720. export class Action implements IAction {
  89721. /** the trigger, with or without parameters, for the action */
  89722. triggerOptions: any;
  89723. /**
  89724. * Trigger for the action
  89725. */
  89726. trigger: number;
  89727. /**
  89728. * Internal only - manager for action
  89729. * @hidden
  89730. */
  89731. _actionManager: ActionManager;
  89732. private _nextActiveAction;
  89733. private _child;
  89734. private _condition?;
  89735. private _triggerParameter;
  89736. /**
  89737. * An event triggered prior to action being executed.
  89738. */
  89739. onBeforeExecuteObservable: Observable<Action>;
  89740. /**
  89741. * Creates a new Action
  89742. * @param triggerOptions the trigger, with or without parameters, for the action
  89743. * @param condition an optional determinant of action
  89744. */
  89745. constructor(
  89746. /** the trigger, with or without parameters, for the action */
  89747. triggerOptions: any, condition?: Condition);
  89748. /**
  89749. * Internal only
  89750. * @hidden
  89751. */
  89752. _prepare(): void;
  89753. /**
  89754. * Gets the trigger parameters
  89755. * @returns the trigger parameters
  89756. */
  89757. getTriggerParameter(): any;
  89758. /**
  89759. * Internal only - executes current action event
  89760. * @hidden
  89761. */
  89762. _executeCurrent(evt?: ActionEvent): void;
  89763. /**
  89764. * Execute placeholder for child classes
  89765. * @param evt optional action event
  89766. */
  89767. execute(evt?: ActionEvent): void;
  89768. /**
  89769. * Skips to next active action
  89770. */
  89771. skipToNextActiveAction(): void;
  89772. /**
  89773. * Adds action to chain of actions, may be a DoNothingAction
  89774. * @param action defines the next action to execute
  89775. * @returns The action passed in
  89776. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89777. */
  89778. then(action: Action): Action;
  89779. /**
  89780. * Internal only
  89781. * @hidden
  89782. */
  89783. _getProperty(propertyPath: string): string;
  89784. /**
  89785. * Internal only
  89786. * @hidden
  89787. */
  89788. _getEffectiveTarget(target: any, propertyPath: string): any;
  89789. /**
  89790. * Serialize placeholder for child classes
  89791. * @param parent of child
  89792. * @returns the serialized object
  89793. */
  89794. serialize(parent: any): any;
  89795. /**
  89796. * Internal only called by serialize
  89797. * @hidden
  89798. */
  89799. protected _serialize(serializedAction: any, parent?: any): any;
  89800. /**
  89801. * Internal only
  89802. * @hidden
  89803. */
  89804. static _SerializeValueAsString: (value: any) => string;
  89805. /**
  89806. * Internal only
  89807. * @hidden
  89808. */
  89809. static _GetTargetProperty: (target: Scene | Node) => {
  89810. name: string;
  89811. targetType: string;
  89812. value: string;
  89813. };
  89814. }
  89815. }
  89816. declare module BABYLON {
  89817. /**
  89818. * A Condition applied to an Action
  89819. */
  89820. export class Condition {
  89821. /**
  89822. * Internal only - manager for action
  89823. * @hidden
  89824. */
  89825. _actionManager: ActionManager;
  89826. /**
  89827. * Internal only
  89828. * @hidden
  89829. */
  89830. _evaluationId: number;
  89831. /**
  89832. * Internal only
  89833. * @hidden
  89834. */
  89835. _currentResult: boolean;
  89836. /**
  89837. * Creates a new Condition
  89838. * @param actionManager the manager of the action the condition is applied to
  89839. */
  89840. constructor(actionManager: ActionManager);
  89841. /**
  89842. * Check if the current condition is valid
  89843. * @returns a boolean
  89844. */
  89845. isValid(): boolean;
  89846. /**
  89847. * Internal only
  89848. * @hidden
  89849. */
  89850. _getProperty(propertyPath: string): string;
  89851. /**
  89852. * Internal only
  89853. * @hidden
  89854. */
  89855. _getEffectiveTarget(target: any, propertyPath: string): any;
  89856. /**
  89857. * Serialize placeholder for child classes
  89858. * @returns the serialized object
  89859. */
  89860. serialize(): any;
  89861. /**
  89862. * Internal only
  89863. * @hidden
  89864. */
  89865. protected _serialize(serializedCondition: any): any;
  89866. }
  89867. /**
  89868. * Defines specific conditional operators as extensions of Condition
  89869. */
  89870. export class ValueCondition extends Condition {
  89871. /** path to specify the property of the target the conditional operator uses */
  89872. propertyPath: string;
  89873. /** the value compared by the conditional operator against the current value of the property */
  89874. value: any;
  89875. /** the conditional operator, default ValueCondition.IsEqual */
  89876. operator: number;
  89877. /**
  89878. * Internal only
  89879. * @hidden
  89880. */
  89881. private static _IsEqual;
  89882. /**
  89883. * Internal only
  89884. * @hidden
  89885. */
  89886. private static _IsDifferent;
  89887. /**
  89888. * Internal only
  89889. * @hidden
  89890. */
  89891. private static _IsGreater;
  89892. /**
  89893. * Internal only
  89894. * @hidden
  89895. */
  89896. private static _IsLesser;
  89897. /**
  89898. * returns the number for IsEqual
  89899. */
  89900. static get IsEqual(): number;
  89901. /**
  89902. * Returns the number for IsDifferent
  89903. */
  89904. static get IsDifferent(): number;
  89905. /**
  89906. * Returns the number for IsGreater
  89907. */
  89908. static get IsGreater(): number;
  89909. /**
  89910. * Returns the number for IsLesser
  89911. */
  89912. static get IsLesser(): number;
  89913. /**
  89914. * Internal only The action manager for the condition
  89915. * @hidden
  89916. */
  89917. _actionManager: ActionManager;
  89918. /**
  89919. * Internal only
  89920. * @hidden
  89921. */
  89922. private _target;
  89923. /**
  89924. * Internal only
  89925. * @hidden
  89926. */
  89927. private _effectiveTarget;
  89928. /**
  89929. * Internal only
  89930. * @hidden
  89931. */
  89932. private _property;
  89933. /**
  89934. * Creates a new ValueCondition
  89935. * @param actionManager manager for the action the condition applies to
  89936. * @param target for the action
  89937. * @param propertyPath path to specify the property of the target the conditional operator uses
  89938. * @param value the value compared by the conditional operator against the current value of the property
  89939. * @param operator the conditional operator, default ValueCondition.IsEqual
  89940. */
  89941. constructor(actionManager: ActionManager, target: any,
  89942. /** path to specify the property of the target the conditional operator uses */
  89943. propertyPath: string,
  89944. /** the value compared by the conditional operator against the current value of the property */
  89945. value: any,
  89946. /** the conditional operator, default ValueCondition.IsEqual */
  89947. operator?: number);
  89948. /**
  89949. * Compares the given value with the property value for the specified conditional operator
  89950. * @returns the result of the comparison
  89951. */
  89952. isValid(): boolean;
  89953. /**
  89954. * Serialize the ValueCondition into a JSON compatible object
  89955. * @returns serialization object
  89956. */
  89957. serialize(): any;
  89958. /**
  89959. * Gets the name of the conditional operator for the ValueCondition
  89960. * @param operator the conditional operator
  89961. * @returns the name
  89962. */
  89963. static GetOperatorName(operator: number): string;
  89964. }
  89965. /**
  89966. * Defines a predicate condition as an extension of Condition
  89967. */
  89968. export class PredicateCondition extends Condition {
  89969. /** defines the predicate function used to validate the condition */
  89970. predicate: () => boolean;
  89971. /**
  89972. * Internal only - manager for action
  89973. * @hidden
  89974. */
  89975. _actionManager: ActionManager;
  89976. /**
  89977. * Creates a new PredicateCondition
  89978. * @param actionManager manager for the action the condition applies to
  89979. * @param predicate defines the predicate function used to validate the condition
  89980. */
  89981. constructor(actionManager: ActionManager,
  89982. /** defines the predicate function used to validate the condition */
  89983. predicate: () => boolean);
  89984. /**
  89985. * @returns the validity of the predicate condition
  89986. */
  89987. isValid(): boolean;
  89988. }
  89989. /**
  89990. * Defines a state condition as an extension of Condition
  89991. */
  89992. export class StateCondition extends Condition {
  89993. /** Value to compare with target state */
  89994. value: string;
  89995. /**
  89996. * Internal only - manager for action
  89997. * @hidden
  89998. */
  89999. _actionManager: ActionManager;
  90000. /**
  90001. * Internal only
  90002. * @hidden
  90003. */
  90004. private _target;
  90005. /**
  90006. * Creates a new StateCondition
  90007. * @param actionManager manager for the action the condition applies to
  90008. * @param target of the condition
  90009. * @param value to compare with target state
  90010. */
  90011. constructor(actionManager: ActionManager, target: any,
  90012. /** Value to compare with target state */
  90013. value: string);
  90014. /**
  90015. * Gets a boolean indicating if the current condition is met
  90016. * @returns the validity of the state
  90017. */
  90018. isValid(): boolean;
  90019. /**
  90020. * Serialize the StateCondition into a JSON compatible object
  90021. * @returns serialization object
  90022. */
  90023. serialize(): any;
  90024. }
  90025. }
  90026. declare module BABYLON {
  90027. /**
  90028. * This defines an action responsible to toggle a boolean once triggered.
  90029. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90030. */
  90031. export class SwitchBooleanAction extends Action {
  90032. /**
  90033. * The path to the boolean property in the target object
  90034. */
  90035. propertyPath: string;
  90036. private _target;
  90037. private _effectiveTarget;
  90038. private _property;
  90039. /**
  90040. * Instantiate the action
  90041. * @param triggerOptions defines the trigger options
  90042. * @param target defines the object containing the boolean
  90043. * @param propertyPath defines the path to the boolean property in the target object
  90044. * @param condition defines the trigger related conditions
  90045. */
  90046. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90047. /** @hidden */
  90048. _prepare(): void;
  90049. /**
  90050. * Execute the action toggle the boolean value.
  90051. */
  90052. execute(): void;
  90053. /**
  90054. * Serializes the actions and its related information.
  90055. * @param parent defines the object to serialize in
  90056. * @returns the serialized object
  90057. */
  90058. serialize(parent: any): any;
  90059. }
  90060. /**
  90061. * This defines an action responsible to set a the state field of the target
  90062. * to a desired value once triggered.
  90063. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90064. */
  90065. export class SetStateAction extends Action {
  90066. /**
  90067. * The value to store in the state field.
  90068. */
  90069. value: string;
  90070. private _target;
  90071. /**
  90072. * Instantiate the action
  90073. * @param triggerOptions defines the trigger options
  90074. * @param target defines the object containing the state property
  90075. * @param value defines the value to store in the state field
  90076. * @param condition defines the trigger related conditions
  90077. */
  90078. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90079. /**
  90080. * Execute the action and store the value on the target state property.
  90081. */
  90082. execute(): void;
  90083. /**
  90084. * Serializes the actions and its related information.
  90085. * @param parent defines the object to serialize in
  90086. * @returns the serialized object
  90087. */
  90088. serialize(parent: any): any;
  90089. }
  90090. /**
  90091. * This defines an action responsible to set a property of the target
  90092. * to a desired value once triggered.
  90093. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90094. */
  90095. export class SetValueAction extends Action {
  90096. /**
  90097. * The path of the property to set in the target.
  90098. */
  90099. propertyPath: string;
  90100. /**
  90101. * The value to set in the property
  90102. */
  90103. value: any;
  90104. private _target;
  90105. private _effectiveTarget;
  90106. private _property;
  90107. /**
  90108. * Instantiate the action
  90109. * @param triggerOptions defines the trigger options
  90110. * @param target defines the object containing the property
  90111. * @param propertyPath defines the path of the property to set in the target
  90112. * @param value defines the value to set in the property
  90113. * @param condition defines the trigger related conditions
  90114. */
  90115. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90116. /** @hidden */
  90117. _prepare(): void;
  90118. /**
  90119. * Execute the action and set the targetted property to the desired value.
  90120. */
  90121. execute(): void;
  90122. /**
  90123. * Serializes the actions and its related information.
  90124. * @param parent defines the object to serialize in
  90125. * @returns the serialized object
  90126. */
  90127. serialize(parent: any): any;
  90128. }
  90129. /**
  90130. * This defines an action responsible to increment the target value
  90131. * to a desired value once triggered.
  90132. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90133. */
  90134. export class IncrementValueAction extends Action {
  90135. /**
  90136. * The path of the property to increment in the target.
  90137. */
  90138. propertyPath: string;
  90139. /**
  90140. * The value we should increment the property by.
  90141. */
  90142. value: any;
  90143. private _target;
  90144. private _effectiveTarget;
  90145. private _property;
  90146. /**
  90147. * Instantiate the action
  90148. * @param triggerOptions defines the trigger options
  90149. * @param target defines the object containing the property
  90150. * @param propertyPath defines the path of the property to increment in the target
  90151. * @param value defines the value value we should increment the property by
  90152. * @param condition defines the trigger related conditions
  90153. */
  90154. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90155. /** @hidden */
  90156. _prepare(): void;
  90157. /**
  90158. * Execute the action and increment the target of the value amount.
  90159. */
  90160. execute(): void;
  90161. /**
  90162. * Serializes the actions and its related information.
  90163. * @param parent defines the object to serialize in
  90164. * @returns the serialized object
  90165. */
  90166. serialize(parent: any): any;
  90167. }
  90168. /**
  90169. * This defines an action responsible to start an animation once triggered.
  90170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90171. */
  90172. export class PlayAnimationAction extends Action {
  90173. /**
  90174. * Where the animation should start (animation frame)
  90175. */
  90176. from: number;
  90177. /**
  90178. * Where the animation should stop (animation frame)
  90179. */
  90180. to: number;
  90181. /**
  90182. * Define if the animation should loop or stop after the first play.
  90183. */
  90184. loop?: boolean;
  90185. private _target;
  90186. /**
  90187. * Instantiate the action
  90188. * @param triggerOptions defines the trigger options
  90189. * @param target defines the target animation or animation name
  90190. * @param from defines from where the animation should start (animation frame)
  90191. * @param end defines where the animation should stop (animation frame)
  90192. * @param loop defines if the animation should loop or stop after the first play
  90193. * @param condition defines the trigger related conditions
  90194. */
  90195. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90196. /** @hidden */
  90197. _prepare(): void;
  90198. /**
  90199. * Execute the action and play the animation.
  90200. */
  90201. execute(): void;
  90202. /**
  90203. * Serializes the actions and its related information.
  90204. * @param parent defines the object to serialize in
  90205. * @returns the serialized object
  90206. */
  90207. serialize(parent: any): any;
  90208. }
  90209. /**
  90210. * This defines an action responsible to stop an animation once triggered.
  90211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90212. */
  90213. export class StopAnimationAction extends Action {
  90214. private _target;
  90215. /**
  90216. * Instantiate the action
  90217. * @param triggerOptions defines the trigger options
  90218. * @param target defines the target animation or animation name
  90219. * @param condition defines the trigger related conditions
  90220. */
  90221. constructor(triggerOptions: any, target: any, condition?: Condition);
  90222. /** @hidden */
  90223. _prepare(): void;
  90224. /**
  90225. * Execute the action and stop the animation.
  90226. */
  90227. execute(): void;
  90228. /**
  90229. * Serializes the actions and its related information.
  90230. * @param parent defines the object to serialize in
  90231. * @returns the serialized object
  90232. */
  90233. serialize(parent: any): any;
  90234. }
  90235. /**
  90236. * This defines an action responsible that does nothing once triggered.
  90237. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90238. */
  90239. export class DoNothingAction extends Action {
  90240. /**
  90241. * Instantiate the action
  90242. * @param triggerOptions defines the trigger options
  90243. * @param condition defines the trigger related conditions
  90244. */
  90245. constructor(triggerOptions?: any, condition?: Condition);
  90246. /**
  90247. * Execute the action and do nothing.
  90248. */
  90249. execute(): void;
  90250. /**
  90251. * Serializes the actions and its related information.
  90252. * @param parent defines the object to serialize in
  90253. * @returns the serialized object
  90254. */
  90255. serialize(parent: any): any;
  90256. }
  90257. /**
  90258. * This defines an action responsible to trigger several actions once triggered.
  90259. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90260. */
  90261. export class CombineAction extends Action {
  90262. /**
  90263. * The list of aggregated animations to run.
  90264. */
  90265. children: Action[];
  90266. /**
  90267. * Instantiate the action
  90268. * @param triggerOptions defines the trigger options
  90269. * @param children defines the list of aggregated animations to run
  90270. * @param condition defines the trigger related conditions
  90271. */
  90272. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90273. /** @hidden */
  90274. _prepare(): void;
  90275. /**
  90276. * Execute the action and executes all the aggregated actions.
  90277. */
  90278. execute(evt: ActionEvent): void;
  90279. /**
  90280. * Serializes the actions and its related information.
  90281. * @param parent defines the object to serialize in
  90282. * @returns the serialized object
  90283. */
  90284. serialize(parent: any): any;
  90285. }
  90286. /**
  90287. * This defines an action responsible to run code (external event) once triggered.
  90288. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90289. */
  90290. export class ExecuteCodeAction extends Action {
  90291. /**
  90292. * The callback function to run.
  90293. */
  90294. func: (evt: ActionEvent) => void;
  90295. /**
  90296. * Instantiate the action
  90297. * @param triggerOptions defines the trigger options
  90298. * @param func defines the callback function to run
  90299. * @param condition defines the trigger related conditions
  90300. */
  90301. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90302. /**
  90303. * Execute the action and run the attached code.
  90304. */
  90305. execute(evt: ActionEvent): void;
  90306. }
  90307. /**
  90308. * This defines an action responsible to set the parent property of the target once triggered.
  90309. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90310. */
  90311. export class SetParentAction extends Action {
  90312. private _parent;
  90313. private _target;
  90314. /**
  90315. * Instantiate the action
  90316. * @param triggerOptions defines the trigger options
  90317. * @param target defines the target containing the parent property
  90318. * @param parent defines from where the animation should start (animation frame)
  90319. * @param condition defines the trigger related conditions
  90320. */
  90321. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90322. /** @hidden */
  90323. _prepare(): void;
  90324. /**
  90325. * Execute the action and set the parent property.
  90326. */
  90327. execute(): void;
  90328. /**
  90329. * Serializes the actions and its related information.
  90330. * @param parent defines the object to serialize in
  90331. * @returns the serialized object
  90332. */
  90333. serialize(parent: any): any;
  90334. }
  90335. }
  90336. declare module BABYLON {
  90337. /**
  90338. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90339. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90340. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90341. */
  90342. export class ActionManager extends AbstractActionManager {
  90343. /**
  90344. * Nothing
  90345. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90346. */
  90347. static readonly NothingTrigger: number;
  90348. /**
  90349. * On pick
  90350. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90351. */
  90352. static readonly OnPickTrigger: number;
  90353. /**
  90354. * On left pick
  90355. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90356. */
  90357. static readonly OnLeftPickTrigger: number;
  90358. /**
  90359. * On right pick
  90360. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90361. */
  90362. static readonly OnRightPickTrigger: number;
  90363. /**
  90364. * On center pick
  90365. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90366. */
  90367. static readonly OnCenterPickTrigger: number;
  90368. /**
  90369. * On pick down
  90370. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90371. */
  90372. static readonly OnPickDownTrigger: number;
  90373. /**
  90374. * On double pick
  90375. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90376. */
  90377. static readonly OnDoublePickTrigger: number;
  90378. /**
  90379. * On pick up
  90380. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90381. */
  90382. static readonly OnPickUpTrigger: number;
  90383. /**
  90384. * On pick out.
  90385. * This trigger will only be raised if you also declared a OnPickDown
  90386. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90387. */
  90388. static readonly OnPickOutTrigger: number;
  90389. /**
  90390. * On long press
  90391. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90392. */
  90393. static readonly OnLongPressTrigger: number;
  90394. /**
  90395. * On pointer over
  90396. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90397. */
  90398. static readonly OnPointerOverTrigger: number;
  90399. /**
  90400. * On pointer out
  90401. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90402. */
  90403. static readonly OnPointerOutTrigger: number;
  90404. /**
  90405. * On every frame
  90406. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90407. */
  90408. static readonly OnEveryFrameTrigger: number;
  90409. /**
  90410. * On intersection enter
  90411. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90412. */
  90413. static readonly OnIntersectionEnterTrigger: number;
  90414. /**
  90415. * On intersection exit
  90416. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90417. */
  90418. static readonly OnIntersectionExitTrigger: number;
  90419. /**
  90420. * On key down
  90421. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90422. */
  90423. static readonly OnKeyDownTrigger: number;
  90424. /**
  90425. * On key up
  90426. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90427. */
  90428. static readonly OnKeyUpTrigger: number;
  90429. private _scene;
  90430. /**
  90431. * Creates a new action manager
  90432. * @param scene defines the hosting scene
  90433. */
  90434. constructor(scene: Scene);
  90435. /**
  90436. * Releases all associated resources
  90437. */
  90438. dispose(): void;
  90439. /**
  90440. * Gets hosting scene
  90441. * @returns the hosting scene
  90442. */
  90443. getScene(): Scene;
  90444. /**
  90445. * Does this action manager handles actions of any of the given triggers
  90446. * @param triggers defines the triggers to be tested
  90447. * @return a boolean indicating whether one (or more) of the triggers is handled
  90448. */
  90449. hasSpecificTriggers(triggers: number[]): boolean;
  90450. /**
  90451. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90452. * speed.
  90453. * @param triggerA defines the trigger to be tested
  90454. * @param triggerB defines the trigger to be tested
  90455. * @return a boolean indicating whether one (or more) of the triggers is handled
  90456. */
  90457. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90458. /**
  90459. * Does this action manager handles actions of a given trigger
  90460. * @param trigger defines the trigger to be tested
  90461. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90462. * @return whether the trigger is handled
  90463. */
  90464. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90465. /**
  90466. * Does this action manager has pointer triggers
  90467. */
  90468. get hasPointerTriggers(): boolean;
  90469. /**
  90470. * Does this action manager has pick triggers
  90471. */
  90472. get hasPickTriggers(): boolean;
  90473. /**
  90474. * Registers an action to this action manager
  90475. * @param action defines the action to be registered
  90476. * @return the action amended (prepared) after registration
  90477. */
  90478. registerAction(action: IAction): Nullable<IAction>;
  90479. /**
  90480. * Unregisters an action to this action manager
  90481. * @param action defines the action to be unregistered
  90482. * @return a boolean indicating whether the action has been unregistered
  90483. */
  90484. unregisterAction(action: IAction): Boolean;
  90485. /**
  90486. * Process a specific trigger
  90487. * @param trigger defines the trigger to process
  90488. * @param evt defines the event details to be processed
  90489. */
  90490. processTrigger(trigger: number, evt?: IActionEvent): void;
  90491. /** @hidden */
  90492. _getEffectiveTarget(target: any, propertyPath: string): any;
  90493. /** @hidden */
  90494. _getProperty(propertyPath: string): string;
  90495. /**
  90496. * Serialize this manager to a JSON object
  90497. * @param name defines the property name to store this manager
  90498. * @returns a JSON representation of this manager
  90499. */
  90500. serialize(name: string): any;
  90501. /**
  90502. * Creates a new ActionManager from a JSON data
  90503. * @param parsedActions defines the JSON data to read from
  90504. * @param object defines the hosting mesh
  90505. * @param scene defines the hosting scene
  90506. */
  90507. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90508. /**
  90509. * Get a trigger name by index
  90510. * @param trigger defines the trigger index
  90511. * @returns a trigger name
  90512. */
  90513. static GetTriggerName(trigger: number): string;
  90514. }
  90515. }
  90516. declare module BABYLON {
  90517. /**
  90518. * Class used to represent a sprite
  90519. * @see https://doc.babylonjs.com/babylon101/sprites
  90520. */
  90521. export class Sprite implements IAnimatable {
  90522. /** defines the name */
  90523. name: string;
  90524. /** Gets or sets the current world position */
  90525. position: Vector3;
  90526. /** Gets or sets the main color */
  90527. color: Color4;
  90528. /** Gets or sets the width */
  90529. width: number;
  90530. /** Gets or sets the height */
  90531. height: number;
  90532. /** Gets or sets rotation angle */
  90533. angle: number;
  90534. /** Gets or sets the cell index in the sprite sheet */
  90535. cellIndex: number;
  90536. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90537. cellRef: string;
  90538. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90539. invertU: boolean;
  90540. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90541. invertV: boolean;
  90542. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90543. disposeWhenFinishedAnimating: boolean;
  90544. /** Gets the list of attached animations */
  90545. animations: Nullable<Array<Animation>>;
  90546. /** Gets or sets a boolean indicating if the sprite can be picked */
  90547. isPickable: boolean;
  90548. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90549. useAlphaForPicking: boolean;
  90550. /** @hidden */
  90551. _xOffset: number;
  90552. /** @hidden */
  90553. _yOffset: number;
  90554. /** @hidden */
  90555. _xSize: number;
  90556. /** @hidden */
  90557. _ySize: number;
  90558. /**
  90559. * Gets or sets the associated action manager
  90560. */
  90561. actionManager: Nullable<ActionManager>;
  90562. /**
  90563. * An event triggered when the control has been disposed
  90564. */
  90565. onDisposeObservable: Observable<Sprite>;
  90566. private _animationStarted;
  90567. private _loopAnimation;
  90568. private _fromIndex;
  90569. private _toIndex;
  90570. private _delay;
  90571. private _direction;
  90572. private _manager;
  90573. private _time;
  90574. private _onAnimationEnd;
  90575. /**
  90576. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90577. */
  90578. isVisible: boolean;
  90579. /**
  90580. * Gets or sets the sprite size
  90581. */
  90582. get size(): number;
  90583. set size(value: number);
  90584. /**
  90585. * Returns a boolean indicating if the animation is started
  90586. */
  90587. get animationStarted(): boolean;
  90588. /**
  90589. * Gets or sets the unique id of the sprite
  90590. */
  90591. uniqueId: number;
  90592. /**
  90593. * Gets the manager of this sprite
  90594. */
  90595. get manager(): ISpriteManager;
  90596. /**
  90597. * Creates a new Sprite
  90598. * @param name defines the name
  90599. * @param manager defines the manager
  90600. */
  90601. constructor(
  90602. /** defines the name */
  90603. name: string, manager: ISpriteManager);
  90604. /**
  90605. * Returns the string "Sprite"
  90606. * @returns "Sprite"
  90607. */
  90608. getClassName(): string;
  90609. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90610. get fromIndex(): number;
  90611. set fromIndex(value: number);
  90612. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90613. get toIndex(): number;
  90614. set toIndex(value: number);
  90615. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90616. get loopAnimation(): boolean;
  90617. set loopAnimation(value: boolean);
  90618. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90619. get delay(): number;
  90620. set delay(value: number);
  90621. /**
  90622. * Starts an animation
  90623. * @param from defines the initial key
  90624. * @param to defines the end key
  90625. * @param loop defines if the animation must loop
  90626. * @param delay defines the start delay (in ms)
  90627. * @param onAnimationEnd defines a callback to call when animation ends
  90628. */
  90629. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90630. /** Stops current animation (if any) */
  90631. stopAnimation(): void;
  90632. /** @hidden */
  90633. _animate(deltaTime: number): void;
  90634. /** Release associated resources */
  90635. dispose(): void;
  90636. /**
  90637. * Serializes the sprite to a JSON object
  90638. * @returns the JSON object
  90639. */
  90640. serialize(): any;
  90641. /**
  90642. * Parses a JSON object to create a new sprite
  90643. * @param parsedSprite The JSON object to parse
  90644. * @param manager defines the hosting manager
  90645. * @returns the new sprite
  90646. */
  90647. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90648. }
  90649. }
  90650. declare module BABYLON {
  90651. /**
  90652. * Information about the result of picking within a scene
  90653. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90654. */
  90655. export class PickingInfo {
  90656. /** @hidden */
  90657. _pickingUnavailable: boolean;
  90658. /**
  90659. * If the pick collided with an object
  90660. */
  90661. hit: boolean;
  90662. /**
  90663. * Distance away where the pick collided
  90664. */
  90665. distance: number;
  90666. /**
  90667. * The location of pick collision
  90668. */
  90669. pickedPoint: Nullable<Vector3>;
  90670. /**
  90671. * The mesh corresponding the the pick collision
  90672. */
  90673. pickedMesh: Nullable<AbstractMesh>;
  90674. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90675. bu: number;
  90676. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90677. bv: number;
  90678. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90679. faceId: number;
  90680. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90681. subMeshFaceId: number;
  90682. /** Id of the the submesh that was picked */
  90683. subMeshId: number;
  90684. /** If a sprite was picked, this will be the sprite the pick collided with */
  90685. pickedSprite: Nullable<Sprite>;
  90686. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90687. thinInstanceIndex: number;
  90688. /**
  90689. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90690. */
  90691. originMesh: Nullable<AbstractMesh>;
  90692. /**
  90693. * The ray that was used to perform the picking.
  90694. */
  90695. ray: Nullable<Ray>;
  90696. /**
  90697. * Gets the normal correspodning to the face the pick collided with
  90698. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90699. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90700. * @returns The normal correspodning to the face the pick collided with
  90701. */
  90702. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90703. /**
  90704. * Gets the texture coordinates of where the pick occured
  90705. * @returns the vector containing the coordnates of the texture
  90706. */
  90707. getTextureCoordinates(): Nullable<Vector2>;
  90708. }
  90709. }
  90710. declare module BABYLON {
  90711. /**
  90712. * Class representing a ray with position and direction
  90713. */
  90714. export class Ray {
  90715. /** origin point */
  90716. origin: Vector3;
  90717. /** direction */
  90718. direction: Vector3;
  90719. /** length of the ray */
  90720. length: number;
  90721. private static readonly _TmpVector3;
  90722. private _tmpRay;
  90723. /**
  90724. * Creates a new ray
  90725. * @param origin origin point
  90726. * @param direction direction
  90727. * @param length length of the ray
  90728. */
  90729. constructor(
  90730. /** origin point */
  90731. origin: Vector3,
  90732. /** direction */
  90733. direction: Vector3,
  90734. /** length of the ray */
  90735. length?: number);
  90736. /**
  90737. * Checks if the ray intersects a box
  90738. * This does not account for the ray lenght by design to improve perfs.
  90739. * @param minimum bound of the box
  90740. * @param maximum bound of the box
  90741. * @param intersectionTreshold extra extend to be added to the box in all direction
  90742. * @returns if the box was hit
  90743. */
  90744. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90745. /**
  90746. * Checks if the ray intersects a box
  90747. * This does not account for the ray lenght by design to improve perfs.
  90748. * @param box the bounding box to check
  90749. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90750. * @returns if the box was hit
  90751. */
  90752. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90753. /**
  90754. * If the ray hits a sphere
  90755. * @param sphere the bounding sphere to check
  90756. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90757. * @returns true if it hits the sphere
  90758. */
  90759. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90760. /**
  90761. * If the ray hits a triange
  90762. * @param vertex0 triangle vertex
  90763. * @param vertex1 triangle vertex
  90764. * @param vertex2 triangle vertex
  90765. * @returns intersection information if hit
  90766. */
  90767. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90768. /**
  90769. * Checks if ray intersects a plane
  90770. * @param plane the plane to check
  90771. * @returns the distance away it was hit
  90772. */
  90773. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90774. /**
  90775. * Calculate the intercept of a ray on a given axis
  90776. * @param axis to check 'x' | 'y' | 'z'
  90777. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90778. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90779. */
  90780. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90781. /**
  90782. * Checks if ray intersects a mesh
  90783. * @param mesh the mesh to check
  90784. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90785. * @returns picking info of the intersecton
  90786. */
  90787. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90788. /**
  90789. * Checks if ray intersects a mesh
  90790. * @param meshes the meshes to check
  90791. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90792. * @param results array to store result in
  90793. * @returns Array of picking infos
  90794. */
  90795. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90796. private _comparePickingInfo;
  90797. private static smallnum;
  90798. private static rayl;
  90799. /**
  90800. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90801. * @param sega the first point of the segment to test the intersection against
  90802. * @param segb the second point of the segment to test the intersection against
  90803. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90804. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90805. */
  90806. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90807. /**
  90808. * Update the ray from viewport position
  90809. * @param x position
  90810. * @param y y position
  90811. * @param viewportWidth viewport width
  90812. * @param viewportHeight viewport height
  90813. * @param world world matrix
  90814. * @param view view matrix
  90815. * @param projection projection matrix
  90816. * @returns this ray updated
  90817. */
  90818. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90819. /**
  90820. * Creates a ray with origin and direction of 0,0,0
  90821. * @returns the new ray
  90822. */
  90823. static Zero(): Ray;
  90824. /**
  90825. * Creates a new ray from screen space and viewport
  90826. * @param x position
  90827. * @param y y position
  90828. * @param viewportWidth viewport width
  90829. * @param viewportHeight viewport height
  90830. * @param world world matrix
  90831. * @param view view matrix
  90832. * @param projection projection matrix
  90833. * @returns new ray
  90834. */
  90835. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90836. /**
  90837. * 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
  90838. * transformed to the given world matrix.
  90839. * @param origin The origin point
  90840. * @param end The end point
  90841. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90842. * @returns the new ray
  90843. */
  90844. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90845. /**
  90846. * Transforms a ray by a matrix
  90847. * @param ray ray to transform
  90848. * @param matrix matrix to apply
  90849. * @returns the resulting new ray
  90850. */
  90851. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90852. /**
  90853. * Transforms a ray by a matrix
  90854. * @param ray ray to transform
  90855. * @param matrix matrix to apply
  90856. * @param result ray to store result in
  90857. */
  90858. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90859. /**
  90860. * Unproject a ray from screen space to object space
  90861. * @param sourceX defines the screen space x coordinate to use
  90862. * @param sourceY defines the screen space y coordinate to use
  90863. * @param viewportWidth defines the current width of the viewport
  90864. * @param viewportHeight defines the current height of the viewport
  90865. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90866. * @param view defines the view matrix to use
  90867. * @param projection defines the projection matrix to use
  90868. */
  90869. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90870. }
  90871. /**
  90872. * Type used to define predicate used to select faces when a mesh intersection is detected
  90873. */
  90874. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90875. interface Scene {
  90876. /** @hidden */
  90877. _tempPickingRay: Nullable<Ray>;
  90878. /** @hidden */
  90879. _cachedRayForTransform: Ray;
  90880. /** @hidden */
  90881. _pickWithRayInverseMatrix: Matrix;
  90882. /** @hidden */
  90883. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90884. /** @hidden */
  90885. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90886. /** @hidden */
  90887. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90888. }
  90889. }
  90890. declare module BABYLON {
  90891. /**
  90892. * Groups all the scene component constants in one place to ease maintenance.
  90893. * @hidden
  90894. */
  90895. export class SceneComponentConstants {
  90896. static readonly NAME_EFFECTLAYER: string;
  90897. static readonly NAME_LAYER: string;
  90898. static readonly NAME_LENSFLARESYSTEM: string;
  90899. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90900. static readonly NAME_PARTICLESYSTEM: string;
  90901. static readonly NAME_GAMEPAD: string;
  90902. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90903. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90904. static readonly NAME_PREPASSRENDERER: string;
  90905. static readonly NAME_DEPTHRENDERER: string;
  90906. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90907. static readonly NAME_SPRITE: string;
  90908. static readonly NAME_SUBSURFACE: string;
  90909. static readonly NAME_OUTLINERENDERER: string;
  90910. static readonly NAME_PROCEDURALTEXTURE: string;
  90911. static readonly NAME_SHADOWGENERATOR: string;
  90912. static readonly NAME_OCTREE: string;
  90913. static readonly NAME_PHYSICSENGINE: string;
  90914. static readonly NAME_AUDIO: string;
  90915. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  90916. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90917. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  90918. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90919. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  90920. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  90921. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  90922. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  90923. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  90924. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  90925. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  90926. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  90927. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  90928. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  90929. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  90930. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  90931. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  90932. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  90933. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  90934. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  90935. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  90936. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  90937. static readonly STEP_AFTERRENDER_AUDIO: number;
  90938. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  90939. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  90940. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  90941. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  90942. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  90943. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  90944. static readonly STEP_POINTERMOVE_SPRITE: number;
  90945. static readonly STEP_POINTERDOWN_SPRITE: number;
  90946. static readonly STEP_POINTERUP_SPRITE: number;
  90947. }
  90948. /**
  90949. * This represents a scene component.
  90950. *
  90951. * This is used to decouple the dependency the scene is having on the different workloads like
  90952. * layers, post processes...
  90953. */
  90954. export interface ISceneComponent {
  90955. /**
  90956. * The name of the component. Each component must have a unique name.
  90957. */
  90958. name: string;
  90959. /**
  90960. * The scene the component belongs to.
  90961. */
  90962. scene: Scene;
  90963. /**
  90964. * Register the component to one instance of a scene.
  90965. */
  90966. register(): void;
  90967. /**
  90968. * Rebuilds the elements related to this component in case of
  90969. * context lost for instance.
  90970. */
  90971. rebuild(): void;
  90972. /**
  90973. * Disposes the component and the associated ressources.
  90974. */
  90975. dispose(): void;
  90976. }
  90977. /**
  90978. * This represents a SERIALIZABLE scene component.
  90979. *
  90980. * This extends Scene Component to add Serialization methods on top.
  90981. */
  90982. export interface ISceneSerializableComponent extends ISceneComponent {
  90983. /**
  90984. * Adds all the elements from the container to the scene
  90985. * @param container the container holding the elements
  90986. */
  90987. addFromContainer(container: AbstractScene): void;
  90988. /**
  90989. * Removes all the elements in the container from the scene
  90990. * @param container contains the elements to remove
  90991. * @param dispose if the removed element should be disposed (default: false)
  90992. */
  90993. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  90994. /**
  90995. * Serializes the component data to the specified json object
  90996. * @param serializationObject The object to serialize to
  90997. */
  90998. serialize(serializationObject: any): void;
  90999. }
  91000. /**
  91001. * Strong typing of a Mesh related stage step action
  91002. */
  91003. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91004. /**
  91005. * Strong typing of a Evaluate Sub Mesh related stage step action
  91006. */
  91007. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91008. /**
  91009. * Strong typing of a Active Mesh related stage step action
  91010. */
  91011. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91012. /**
  91013. * Strong typing of a Camera related stage step action
  91014. */
  91015. export type CameraStageAction = (camera: Camera) => void;
  91016. /**
  91017. * Strong typing of a Camera Frame buffer related stage step action
  91018. */
  91019. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91020. /**
  91021. * Strong typing of a Render Target related stage step action
  91022. */
  91023. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91024. /**
  91025. * Strong typing of a RenderingGroup related stage step action
  91026. */
  91027. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91028. /**
  91029. * Strong typing of a Mesh Render related stage step action
  91030. */
  91031. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91032. /**
  91033. * Strong typing of a simple stage step action
  91034. */
  91035. export type SimpleStageAction = () => void;
  91036. /**
  91037. * Strong typing of a render target action.
  91038. */
  91039. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91040. /**
  91041. * Strong typing of a pointer move action.
  91042. */
  91043. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91044. /**
  91045. * Strong typing of a pointer up/down action.
  91046. */
  91047. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91048. /**
  91049. * Representation of a stage in the scene (Basically a list of ordered steps)
  91050. * @hidden
  91051. */
  91052. export class Stage<T extends Function> extends Array<{
  91053. index: number;
  91054. component: ISceneComponent;
  91055. action: T;
  91056. }> {
  91057. /**
  91058. * Hide ctor from the rest of the world.
  91059. * @param items The items to add.
  91060. */
  91061. private constructor();
  91062. /**
  91063. * Creates a new Stage.
  91064. * @returns A new instance of a Stage
  91065. */
  91066. static Create<T extends Function>(): Stage<T>;
  91067. /**
  91068. * Registers a step in an ordered way in the targeted stage.
  91069. * @param index Defines the position to register the step in
  91070. * @param component Defines the component attached to the step
  91071. * @param action Defines the action to launch during the step
  91072. */
  91073. registerStep(index: number, component: ISceneComponent, action: T): void;
  91074. /**
  91075. * Clears all the steps from the stage.
  91076. */
  91077. clear(): void;
  91078. }
  91079. }
  91080. declare module BABYLON {
  91081. interface Scene {
  91082. /** @hidden */
  91083. _pointerOverSprite: Nullable<Sprite>;
  91084. /** @hidden */
  91085. _pickedDownSprite: Nullable<Sprite>;
  91086. /** @hidden */
  91087. _tempSpritePickingRay: Nullable<Ray>;
  91088. /**
  91089. * All of the sprite managers added to this scene
  91090. * @see https://doc.babylonjs.com/babylon101/sprites
  91091. */
  91092. spriteManagers: Array<ISpriteManager>;
  91093. /**
  91094. * An event triggered when sprites rendering is about to start
  91095. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91096. */
  91097. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91098. /**
  91099. * An event triggered when sprites rendering is done
  91100. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91101. */
  91102. onAfterSpritesRenderingObservable: Observable<Scene>;
  91103. /** @hidden */
  91104. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91105. /** Launch a ray to try to pick a sprite in the scene
  91106. * @param x position on screen
  91107. * @param y position on screen
  91108. * @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
  91109. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91110. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91111. * @returns a PickingInfo
  91112. */
  91113. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91114. /** Use the given ray to pick a sprite in the scene
  91115. * @param ray The ray (in world space) to use to pick meshes
  91116. * @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
  91117. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91118. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91119. * @returns a PickingInfo
  91120. */
  91121. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91122. /** @hidden */
  91123. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91124. /** Launch a ray to try to pick sprites in the scene
  91125. * @param x position on screen
  91126. * @param y position on screen
  91127. * @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
  91128. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91129. * @returns a PickingInfo array
  91130. */
  91131. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91132. /** Use the given ray to pick sprites in the scene
  91133. * @param ray The ray (in world space) to use to pick meshes
  91134. * @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
  91135. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91136. * @returns a PickingInfo array
  91137. */
  91138. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91139. /**
  91140. * Force the sprite under the pointer
  91141. * @param sprite defines the sprite to use
  91142. */
  91143. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91144. /**
  91145. * Gets the sprite under the pointer
  91146. * @returns a Sprite or null if no sprite is under the pointer
  91147. */
  91148. getPointerOverSprite(): Nullable<Sprite>;
  91149. }
  91150. /**
  91151. * Defines the sprite scene component responsible to manage sprites
  91152. * in a given scene.
  91153. */
  91154. export class SpriteSceneComponent implements ISceneComponent {
  91155. /**
  91156. * The component name helpfull to identify the component in the list of scene components.
  91157. */
  91158. readonly name: string;
  91159. /**
  91160. * The scene the component belongs to.
  91161. */
  91162. scene: Scene;
  91163. /** @hidden */
  91164. private _spritePredicate;
  91165. /**
  91166. * Creates a new instance of the component for the given scene
  91167. * @param scene Defines the scene to register the component in
  91168. */
  91169. constructor(scene: Scene);
  91170. /**
  91171. * Registers the component in a given scene
  91172. */
  91173. register(): void;
  91174. /**
  91175. * Rebuilds the elements related to this component in case of
  91176. * context lost for instance.
  91177. */
  91178. rebuild(): void;
  91179. /**
  91180. * Disposes the component and the associated ressources.
  91181. */
  91182. dispose(): void;
  91183. private _pickSpriteButKeepRay;
  91184. private _pointerMove;
  91185. private _pointerDown;
  91186. private _pointerUp;
  91187. }
  91188. }
  91189. declare module BABYLON {
  91190. /** @hidden */
  91191. export var fogFragmentDeclaration: {
  91192. name: string;
  91193. shader: string;
  91194. };
  91195. }
  91196. declare module BABYLON {
  91197. /** @hidden */
  91198. export var fogFragment: {
  91199. name: string;
  91200. shader: string;
  91201. };
  91202. }
  91203. declare module BABYLON {
  91204. /** @hidden */
  91205. export var spritesPixelShader: {
  91206. name: string;
  91207. shader: string;
  91208. };
  91209. }
  91210. declare module BABYLON {
  91211. /** @hidden */
  91212. export var fogVertexDeclaration: {
  91213. name: string;
  91214. shader: string;
  91215. };
  91216. }
  91217. declare module BABYLON {
  91218. /** @hidden */
  91219. export var spritesVertexShader: {
  91220. name: string;
  91221. shader: string;
  91222. };
  91223. }
  91224. declare module BABYLON {
  91225. /**
  91226. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91227. */
  91228. export interface ISpriteManager extends IDisposable {
  91229. /**
  91230. * Gets manager's name
  91231. */
  91232. name: string;
  91233. /**
  91234. * Restricts the camera to viewing objects with the same layerMask.
  91235. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91236. */
  91237. layerMask: number;
  91238. /**
  91239. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91240. */
  91241. isPickable: boolean;
  91242. /**
  91243. * Gets the hosting scene
  91244. */
  91245. scene: Scene;
  91246. /**
  91247. * Specifies the rendering group id for this mesh (0 by default)
  91248. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91249. */
  91250. renderingGroupId: number;
  91251. /**
  91252. * Defines the list of sprites managed by the manager.
  91253. */
  91254. sprites: Array<Sprite>;
  91255. /**
  91256. * Gets or sets the spritesheet texture
  91257. */
  91258. texture: Texture;
  91259. /** Defines the default width of a cell in the spritesheet */
  91260. cellWidth: number;
  91261. /** Defines the default height of a cell in the spritesheet */
  91262. cellHeight: number;
  91263. /**
  91264. * Tests the intersection of a sprite with a specific ray.
  91265. * @param ray The ray we are sending to test the collision
  91266. * @param camera The camera space we are sending rays in
  91267. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91268. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91269. * @returns picking info or null.
  91270. */
  91271. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91272. /**
  91273. * Intersects the sprites with a ray
  91274. * @param ray defines the ray to intersect with
  91275. * @param camera defines the current active camera
  91276. * @param predicate defines a predicate used to select candidate sprites
  91277. * @returns null if no hit or a PickingInfo array
  91278. */
  91279. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91280. /**
  91281. * Renders the list of sprites on screen.
  91282. */
  91283. render(): void;
  91284. }
  91285. /**
  91286. * Class used to manage multiple sprites on the same spritesheet
  91287. * @see https://doc.babylonjs.com/babylon101/sprites
  91288. */
  91289. export class SpriteManager implements ISpriteManager {
  91290. /** defines the manager's name */
  91291. name: string;
  91292. /** Define the Url to load snippets */
  91293. static SnippetUrl: string;
  91294. /** Snippet ID if the manager was created from the snippet server */
  91295. snippetId: string;
  91296. /** Gets the list of sprites */
  91297. sprites: Sprite[];
  91298. /** Gets or sets the rendering group id (0 by default) */
  91299. renderingGroupId: number;
  91300. /** Gets or sets camera layer mask */
  91301. layerMask: number;
  91302. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91303. fogEnabled: boolean;
  91304. /** Gets or sets a boolean indicating if the sprites are pickable */
  91305. isPickable: boolean;
  91306. /** Defines the default width of a cell in the spritesheet */
  91307. cellWidth: number;
  91308. /** Defines the default height of a cell in the spritesheet */
  91309. cellHeight: number;
  91310. /** Associative array from JSON sprite data file */
  91311. private _cellData;
  91312. /** Array of sprite names from JSON sprite data file */
  91313. private _spriteMap;
  91314. /** True when packed cell data from JSON file is ready*/
  91315. private _packedAndReady;
  91316. private _textureContent;
  91317. private _useInstancing;
  91318. /**
  91319. * An event triggered when the manager is disposed.
  91320. */
  91321. onDisposeObservable: Observable<SpriteManager>;
  91322. private _onDisposeObserver;
  91323. /**
  91324. * Callback called when the manager is disposed
  91325. */
  91326. set onDispose(callback: () => void);
  91327. private _capacity;
  91328. private _fromPacked;
  91329. private _spriteTexture;
  91330. private _epsilon;
  91331. private _scene;
  91332. private _vertexData;
  91333. private _buffer;
  91334. private _vertexBuffers;
  91335. private _spriteBuffer;
  91336. private _indexBuffer;
  91337. private _effectBase;
  91338. private _effectFog;
  91339. private _vertexBufferSize;
  91340. /**
  91341. * Gets or sets the unique id of the sprite
  91342. */
  91343. uniqueId: number;
  91344. /**
  91345. * Gets the array of sprites
  91346. */
  91347. get children(): Sprite[];
  91348. /**
  91349. * Gets the hosting scene
  91350. */
  91351. get scene(): Scene;
  91352. /**
  91353. * Gets the capacity of the manager
  91354. */
  91355. get capacity(): number;
  91356. /**
  91357. * Gets or sets the spritesheet texture
  91358. */
  91359. get texture(): Texture;
  91360. set texture(value: Texture);
  91361. private _blendMode;
  91362. /**
  91363. * Blend mode use to render the particle, it can be any of
  91364. * the static Constants.ALPHA_x properties provided in this class.
  91365. * Default value is Constants.ALPHA_COMBINE
  91366. */
  91367. get blendMode(): number;
  91368. set blendMode(blendMode: number);
  91369. /** Disables writing to the depth buffer when rendering the sprites.
  91370. * It can be handy to disable depth writing when using textures without alpha channel
  91371. * and setting some specific blend modes.
  91372. */
  91373. disableDepthWrite: boolean;
  91374. /**
  91375. * Creates a new sprite manager
  91376. * @param name defines the manager's name
  91377. * @param imgUrl defines the sprite sheet url
  91378. * @param capacity defines the maximum allowed number of sprites
  91379. * @param cellSize defines the size of a sprite cell
  91380. * @param scene defines the hosting scene
  91381. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91382. * @param samplingMode defines the smapling mode to use with spritesheet
  91383. * @param fromPacked set to false; do not alter
  91384. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91385. */
  91386. constructor(
  91387. /** defines the manager's name */
  91388. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91389. /**
  91390. * Returns the string "SpriteManager"
  91391. * @returns "SpriteManager"
  91392. */
  91393. getClassName(): string;
  91394. private _makePacked;
  91395. private _appendSpriteVertex;
  91396. private _checkTextureAlpha;
  91397. /**
  91398. * Intersects the sprites with a ray
  91399. * @param ray defines the ray to intersect with
  91400. * @param camera defines the current active camera
  91401. * @param predicate defines a predicate used to select candidate sprites
  91402. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91403. * @returns null if no hit or a PickingInfo
  91404. */
  91405. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91406. /**
  91407. * Intersects the sprites with a ray
  91408. * @param ray defines the ray to intersect with
  91409. * @param camera defines the current active camera
  91410. * @param predicate defines a predicate used to select candidate sprites
  91411. * @returns null if no hit or a PickingInfo array
  91412. */
  91413. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91414. /**
  91415. * Render all child sprites
  91416. */
  91417. render(): void;
  91418. /**
  91419. * Release associated resources
  91420. */
  91421. dispose(): void;
  91422. /**
  91423. * Serializes the sprite manager to a JSON object
  91424. * @param serializeTexture defines if the texture must be serialized as well
  91425. * @returns the JSON object
  91426. */
  91427. serialize(serializeTexture?: boolean): any;
  91428. /**
  91429. * Parses a JSON object to create a new sprite manager.
  91430. * @param parsedManager The JSON object to parse
  91431. * @param scene The scene to create the sprite managerin
  91432. * @param rootUrl The root url to use to load external dependencies like texture
  91433. * @returns the new sprite manager
  91434. */
  91435. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91436. /**
  91437. * Creates a sprite manager from a snippet saved in a remote file
  91438. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91439. * @param url defines the url to load from
  91440. * @param scene defines the hosting scene
  91441. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91442. * @returns a promise that will resolve to the new sprite manager
  91443. */
  91444. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91445. /**
  91446. * Creates a sprite manager from a snippet saved by the sprite editor
  91447. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91448. * @param scene defines the hosting scene
  91449. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91450. * @returns a promise that will resolve to the new sprite manager
  91451. */
  91452. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91453. }
  91454. }
  91455. declare module BABYLON {
  91456. /** Interface used by value gradients (color, factor, ...) */
  91457. export interface IValueGradient {
  91458. /**
  91459. * Gets or sets the gradient value (between 0 and 1)
  91460. */
  91461. gradient: number;
  91462. }
  91463. /** Class used to store color4 gradient */
  91464. export class ColorGradient implements IValueGradient {
  91465. /**
  91466. * Gets or sets the gradient value (between 0 and 1)
  91467. */
  91468. gradient: number;
  91469. /**
  91470. * Gets or sets first associated color
  91471. */
  91472. color1: Color4;
  91473. /**
  91474. * Gets or sets second associated color
  91475. */
  91476. color2?: Color4 | undefined;
  91477. /**
  91478. * Creates a new color4 gradient
  91479. * @param gradient gets or sets the gradient value (between 0 and 1)
  91480. * @param color1 gets or sets first associated color
  91481. * @param color2 gets or sets first second color
  91482. */
  91483. constructor(
  91484. /**
  91485. * Gets or sets the gradient value (between 0 and 1)
  91486. */
  91487. gradient: number,
  91488. /**
  91489. * Gets or sets first associated color
  91490. */
  91491. color1: Color4,
  91492. /**
  91493. * Gets or sets second associated color
  91494. */
  91495. color2?: Color4 | undefined);
  91496. /**
  91497. * Will get a color picked randomly between color1 and color2.
  91498. * If color2 is undefined then color1 will be used
  91499. * @param result defines the target Color4 to store the result in
  91500. */
  91501. getColorToRef(result: Color4): void;
  91502. }
  91503. /** Class used to store color 3 gradient */
  91504. export class Color3Gradient implements IValueGradient {
  91505. /**
  91506. * Gets or sets the gradient value (between 0 and 1)
  91507. */
  91508. gradient: number;
  91509. /**
  91510. * Gets or sets the associated color
  91511. */
  91512. color: Color3;
  91513. /**
  91514. * Creates a new color3 gradient
  91515. * @param gradient gets or sets the gradient value (between 0 and 1)
  91516. * @param color gets or sets associated color
  91517. */
  91518. constructor(
  91519. /**
  91520. * Gets or sets the gradient value (between 0 and 1)
  91521. */
  91522. gradient: number,
  91523. /**
  91524. * Gets or sets the associated color
  91525. */
  91526. color: Color3);
  91527. }
  91528. /** Class used to store factor gradient */
  91529. export class FactorGradient implements IValueGradient {
  91530. /**
  91531. * Gets or sets the gradient value (between 0 and 1)
  91532. */
  91533. gradient: number;
  91534. /**
  91535. * Gets or sets first associated factor
  91536. */
  91537. factor1: number;
  91538. /**
  91539. * Gets or sets second associated factor
  91540. */
  91541. factor2?: number | undefined;
  91542. /**
  91543. * Creates a new factor gradient
  91544. * @param gradient gets or sets the gradient value (between 0 and 1)
  91545. * @param factor1 gets or sets first associated factor
  91546. * @param factor2 gets or sets second associated factor
  91547. */
  91548. constructor(
  91549. /**
  91550. * Gets or sets the gradient value (between 0 and 1)
  91551. */
  91552. gradient: number,
  91553. /**
  91554. * Gets or sets first associated factor
  91555. */
  91556. factor1: number,
  91557. /**
  91558. * Gets or sets second associated factor
  91559. */
  91560. factor2?: number | undefined);
  91561. /**
  91562. * Will get a number picked randomly between factor1 and factor2.
  91563. * If factor2 is undefined then factor1 will be used
  91564. * @returns the picked number
  91565. */
  91566. getFactor(): number;
  91567. }
  91568. /**
  91569. * Helper used to simplify some generic gradient tasks
  91570. */
  91571. export class GradientHelper {
  91572. /**
  91573. * Gets the current gradient from an array of IValueGradient
  91574. * @param ratio defines the current ratio to get
  91575. * @param gradients defines the array of IValueGradient
  91576. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91577. */
  91578. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91579. }
  91580. }
  91581. declare module BABYLON {
  91582. interface ThinEngine {
  91583. /**
  91584. * Creates a raw texture
  91585. * @param data defines the data to store in the texture
  91586. * @param width defines the width of the texture
  91587. * @param height defines the height of the texture
  91588. * @param format defines the format of the data
  91589. * @param generateMipMaps defines if the engine should generate the mip levels
  91590. * @param invertY defines if data must be stored with Y axis inverted
  91591. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91592. * @param compression defines the compression used (null by default)
  91593. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91594. * @returns the raw texture inside an InternalTexture
  91595. */
  91596. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91597. /**
  91598. * Update a raw texture
  91599. * @param texture defines the texture to update
  91600. * @param data defines the data to store in the texture
  91601. * @param format defines the format of the data
  91602. * @param invertY defines if data must be stored with Y axis inverted
  91603. */
  91604. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91605. /**
  91606. * Update a raw texture
  91607. * @param texture defines the texture to update
  91608. * @param data defines the data to store in the texture
  91609. * @param format defines the format of the data
  91610. * @param invertY defines if data must be stored with Y axis inverted
  91611. * @param compression defines the compression used (null by default)
  91612. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91613. */
  91614. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91615. /**
  91616. * Creates a new raw cube texture
  91617. * @param data defines the array of data to use to create each face
  91618. * @param size defines the size of the textures
  91619. * @param format defines the format of the data
  91620. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91621. * @param generateMipMaps defines if the engine should generate the mip levels
  91622. * @param invertY defines if data must be stored with Y axis inverted
  91623. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91624. * @param compression defines the compression used (null by default)
  91625. * @returns the cube texture as an InternalTexture
  91626. */
  91627. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91628. /**
  91629. * Update a raw cube texture
  91630. * @param texture defines the texture to udpdate
  91631. * @param data defines the data to store
  91632. * @param format defines the data format
  91633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91634. * @param invertY defines if data must be stored with Y axis inverted
  91635. */
  91636. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91637. /**
  91638. * Update a raw cube texture
  91639. * @param texture defines the texture to udpdate
  91640. * @param data defines the data to store
  91641. * @param format defines the data format
  91642. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91643. * @param invertY defines if data must be stored with Y axis inverted
  91644. * @param compression defines the compression used (null by default)
  91645. */
  91646. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91647. /**
  91648. * Update a raw cube texture
  91649. * @param texture defines the texture to udpdate
  91650. * @param data defines the data to store
  91651. * @param format defines the data format
  91652. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91653. * @param invertY defines if data must be stored with Y axis inverted
  91654. * @param compression defines the compression used (null by default)
  91655. * @param level defines which level of the texture to update
  91656. */
  91657. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91658. /**
  91659. * Creates a new raw cube texture from a specified url
  91660. * @param url defines the url where the data is located
  91661. * @param scene defines the current scene
  91662. * @param size defines the size of the textures
  91663. * @param format defines the format of the data
  91664. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91665. * @param noMipmap defines if the engine should avoid generating the mip levels
  91666. * @param callback defines a callback used to extract texture data from loaded data
  91667. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91668. * @param onLoad defines a callback called when texture is loaded
  91669. * @param onError defines a callback called if there is an error
  91670. * @returns the cube texture as an InternalTexture
  91671. */
  91672. 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;
  91673. /**
  91674. * Creates a new raw cube texture from a specified url
  91675. * @param url defines the url where the data is located
  91676. * @param scene defines the current scene
  91677. * @param size defines the size of the textures
  91678. * @param format defines the format of the data
  91679. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91680. * @param noMipmap defines if the engine should avoid generating the mip levels
  91681. * @param callback defines a callback used to extract texture data from loaded data
  91682. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91683. * @param onLoad defines a callback called when texture is loaded
  91684. * @param onError defines a callback called if there is an error
  91685. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91686. * @param invertY defines if data must be stored with Y axis inverted
  91687. * @returns the cube texture as an InternalTexture
  91688. */
  91689. 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;
  91690. /**
  91691. * Creates a new raw 3D texture
  91692. * @param data defines the data used to create the texture
  91693. * @param width defines the width of the texture
  91694. * @param height defines the height of the texture
  91695. * @param depth defines the depth of the texture
  91696. * @param format defines the format of the texture
  91697. * @param generateMipMaps defines if the engine must generate mip levels
  91698. * @param invertY defines if data must be stored with Y axis inverted
  91699. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91700. * @param compression defines the compressed used (can be null)
  91701. * @param textureType defines the compressed used (can be null)
  91702. * @returns a new raw 3D texture (stored in an InternalTexture)
  91703. */
  91704. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91705. /**
  91706. * Update a raw 3D texture
  91707. * @param texture defines the texture to update
  91708. * @param data defines the data to store
  91709. * @param format defines the data format
  91710. * @param invertY defines if data must be stored with Y axis inverted
  91711. */
  91712. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91713. /**
  91714. * Update a raw 3D texture
  91715. * @param texture defines the texture to update
  91716. * @param data defines the data to store
  91717. * @param format defines the data format
  91718. * @param invertY defines if data must be stored with Y axis inverted
  91719. * @param compression defines the used compression (can be null)
  91720. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91721. */
  91722. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91723. /**
  91724. * Creates a new raw 2D array texture
  91725. * @param data defines the data used to create the texture
  91726. * @param width defines the width of the texture
  91727. * @param height defines the height of the texture
  91728. * @param depth defines the number of layers of the texture
  91729. * @param format defines the format of the texture
  91730. * @param generateMipMaps defines if the engine must generate mip levels
  91731. * @param invertY defines if data must be stored with Y axis inverted
  91732. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91733. * @param compression defines the compressed used (can be null)
  91734. * @param textureType defines the compressed used (can be null)
  91735. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91736. */
  91737. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91738. /**
  91739. * Update a raw 2D array texture
  91740. * @param texture defines the texture to update
  91741. * @param data defines the data to store
  91742. * @param format defines the data format
  91743. * @param invertY defines if data must be stored with Y axis inverted
  91744. */
  91745. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91746. /**
  91747. * Update a raw 2D array texture
  91748. * @param texture defines the texture to update
  91749. * @param data defines the data to store
  91750. * @param format defines the data format
  91751. * @param invertY defines if data must be stored with Y axis inverted
  91752. * @param compression defines the used compression (can be null)
  91753. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91754. */
  91755. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91756. }
  91757. }
  91758. declare module BABYLON {
  91759. /**
  91760. * Raw texture can help creating a texture directly from an array of data.
  91761. * This can be super useful if you either get the data from an uncompressed source or
  91762. * if you wish to create your texture pixel by pixel.
  91763. */
  91764. export class RawTexture extends Texture {
  91765. /**
  91766. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91767. */
  91768. format: number;
  91769. /**
  91770. * Instantiates a new RawTexture.
  91771. * Raw texture can help creating a texture directly from an array of data.
  91772. * This can be super useful if you either get the data from an uncompressed source or
  91773. * if you wish to create your texture pixel by pixel.
  91774. * @param data define the array of data to use to create the texture
  91775. * @param width define the width of the texture
  91776. * @param height define the height of the texture
  91777. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91778. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91779. * @param generateMipMaps define whether mip maps should be generated or not
  91780. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91781. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91782. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91783. */
  91784. constructor(data: ArrayBufferView, width: number, height: number,
  91785. /**
  91786. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91787. */
  91788. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91789. /**
  91790. * Updates the texture underlying data.
  91791. * @param data Define the new data of the texture
  91792. */
  91793. update(data: ArrayBufferView): void;
  91794. /**
  91795. * Creates a luminance texture from some data.
  91796. * @param data Define the texture data
  91797. * @param width Define the width of the texture
  91798. * @param height Define the height of the texture
  91799. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91800. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91801. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91802. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91803. * @returns the luminance texture
  91804. */
  91805. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91806. /**
  91807. * Creates a luminance alpha texture from some data.
  91808. * @param data Define the texture data
  91809. * @param width Define the width of the texture
  91810. * @param height Define the height of the texture
  91811. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91812. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91813. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91814. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91815. * @returns the luminance alpha texture
  91816. */
  91817. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91818. /**
  91819. * Creates an alpha texture from some data.
  91820. * @param data Define the texture data
  91821. * @param width Define the width of the texture
  91822. * @param height Define the height of the texture
  91823. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91824. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91825. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91826. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91827. * @returns the alpha texture
  91828. */
  91829. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91830. /**
  91831. * Creates a RGB texture from some data.
  91832. * @param data Define the texture data
  91833. * @param width Define the width of the texture
  91834. * @param height Define the height of the texture
  91835. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91836. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91837. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91838. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91839. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91840. * @returns the RGB alpha texture
  91841. */
  91842. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91843. /**
  91844. * Creates a RGBA texture from some data.
  91845. * @param data Define the texture data
  91846. * @param width Define the width of the texture
  91847. * @param height Define the height of the texture
  91848. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91849. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91850. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91851. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91852. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91853. * @returns the RGBA texture
  91854. */
  91855. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91856. /**
  91857. * Creates a R texture from some data.
  91858. * @param data Define the texture data
  91859. * @param width Define the width of the texture
  91860. * @param height Define the height of the texture
  91861. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91862. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91863. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91864. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91865. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91866. * @returns the R texture
  91867. */
  91868. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91869. }
  91870. }
  91871. declare module BABYLON {
  91872. interface ThinEngine {
  91873. /**
  91874. * Update a dynamic index buffer
  91875. * @param indexBuffer defines the target index buffer
  91876. * @param indices defines the data to update
  91877. * @param offset defines the offset in the target index buffer where update should start
  91878. */
  91879. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91880. /**
  91881. * Updates a dynamic vertex buffer.
  91882. * @param vertexBuffer the vertex buffer to update
  91883. * @param data the data used to update the vertex buffer
  91884. * @param byteOffset the byte offset of the data
  91885. * @param byteLength the byte length of the data
  91886. */
  91887. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91888. }
  91889. }
  91890. declare module BABYLON {
  91891. interface AbstractScene {
  91892. /**
  91893. * The list of procedural textures added to the scene
  91894. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91895. */
  91896. proceduralTextures: Array<ProceduralTexture>;
  91897. }
  91898. /**
  91899. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91900. * in a given scene.
  91901. */
  91902. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91903. /**
  91904. * The component name helpfull to identify the component in the list of scene components.
  91905. */
  91906. readonly name: string;
  91907. /**
  91908. * The scene the component belongs to.
  91909. */
  91910. scene: Scene;
  91911. /**
  91912. * Creates a new instance of the component for the given scene
  91913. * @param scene Defines the scene to register the component in
  91914. */
  91915. constructor(scene: Scene);
  91916. /**
  91917. * Registers the component in a given scene
  91918. */
  91919. register(): void;
  91920. /**
  91921. * Rebuilds the elements related to this component in case of
  91922. * context lost for instance.
  91923. */
  91924. rebuild(): void;
  91925. /**
  91926. * Disposes the component and the associated ressources.
  91927. */
  91928. dispose(): void;
  91929. private _beforeClear;
  91930. }
  91931. }
  91932. declare module BABYLON {
  91933. interface ThinEngine {
  91934. /**
  91935. * Creates a new render target cube texture
  91936. * @param size defines the size of the texture
  91937. * @param options defines the options used to create the texture
  91938. * @returns a new render target cube texture stored in an InternalTexture
  91939. */
  91940. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  91941. }
  91942. }
  91943. declare module BABYLON {
  91944. /** @hidden */
  91945. export var proceduralVertexShader: {
  91946. name: string;
  91947. shader: string;
  91948. };
  91949. }
  91950. declare module BABYLON {
  91951. /**
  91952. * 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.
  91953. * This is the base class of any Procedural texture and contains most of the shareable code.
  91954. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91955. */
  91956. export class ProceduralTexture extends Texture {
  91957. /**
  91958. * Define if the texture is enabled or not (disabled texture will not render)
  91959. */
  91960. isEnabled: boolean;
  91961. /**
  91962. * Define if the texture must be cleared before rendering (default is true)
  91963. */
  91964. autoClear: boolean;
  91965. /**
  91966. * Callback called when the texture is generated
  91967. */
  91968. onGenerated: () => void;
  91969. /**
  91970. * Event raised when the texture is generated
  91971. */
  91972. onGeneratedObservable: Observable<ProceduralTexture>;
  91973. /**
  91974. * Event raised before the texture is generated
  91975. */
  91976. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  91977. /**
  91978. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  91979. */
  91980. nodeMaterialSource: Nullable<NodeMaterial>;
  91981. /** @hidden */
  91982. _generateMipMaps: boolean;
  91983. /** @hidden **/
  91984. _effect: Effect;
  91985. /** @hidden */
  91986. _textures: {
  91987. [key: string]: Texture;
  91988. };
  91989. /** @hidden */
  91990. protected _fallbackTexture: Nullable<Texture>;
  91991. private _size;
  91992. private _currentRefreshId;
  91993. private _frameId;
  91994. private _refreshRate;
  91995. private _vertexBuffers;
  91996. private _indexBuffer;
  91997. private _uniforms;
  91998. private _samplers;
  91999. private _fragment;
  92000. private _floats;
  92001. private _ints;
  92002. private _floatsArrays;
  92003. private _colors3;
  92004. private _colors4;
  92005. private _vectors2;
  92006. private _vectors3;
  92007. private _matrices;
  92008. private _fallbackTextureUsed;
  92009. private _fullEngine;
  92010. private _cachedDefines;
  92011. private _contentUpdateId;
  92012. private _contentData;
  92013. /**
  92014. * Instantiates a new procedural texture.
  92015. * 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.
  92016. * This is the base class of any Procedural texture and contains most of the shareable code.
  92017. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92018. * @param name Define the name of the texture
  92019. * @param size Define the size of the texture to create
  92020. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92021. * @param scene Define the scene the texture belongs to
  92022. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92023. * @param generateMipMaps Define if the texture should creates mip maps or not
  92024. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92025. */
  92026. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  92027. /**
  92028. * The effect that is created when initializing the post process.
  92029. * @returns The created effect corresponding the the postprocess.
  92030. */
  92031. getEffect(): Effect;
  92032. /**
  92033. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92034. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92035. */
  92036. getContent(): Nullable<ArrayBufferView>;
  92037. private _createIndexBuffer;
  92038. /** @hidden */
  92039. _rebuild(): void;
  92040. /**
  92041. * Resets the texture in order to recreate its associated resources.
  92042. * This can be called in case of context loss
  92043. */
  92044. reset(): void;
  92045. protected _getDefines(): string;
  92046. /**
  92047. * Is the texture ready to be used ? (rendered at least once)
  92048. * @returns true if ready, otherwise, false.
  92049. */
  92050. isReady(): boolean;
  92051. /**
  92052. * Resets the refresh counter of the texture and start bak from scratch.
  92053. * Could be useful to regenerate the texture if it is setup to render only once.
  92054. */
  92055. resetRefreshCounter(): void;
  92056. /**
  92057. * Set the fragment shader to use in order to render the texture.
  92058. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92059. */
  92060. setFragment(fragment: any): void;
  92061. /**
  92062. * Define the refresh rate of the texture or the rendering frequency.
  92063. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92064. */
  92065. get refreshRate(): number;
  92066. set refreshRate(value: number);
  92067. /** @hidden */
  92068. _shouldRender(): boolean;
  92069. /**
  92070. * Get the size the texture is rendering at.
  92071. * @returns the size (on cube texture it is always squared)
  92072. */
  92073. getRenderSize(): RenderTargetTextureSize;
  92074. /**
  92075. * Resize the texture to new value.
  92076. * @param size Define the new size the texture should have
  92077. * @param generateMipMaps Define whether the new texture should create mip maps
  92078. */
  92079. resize(size: number, generateMipMaps: boolean): void;
  92080. private _checkUniform;
  92081. /**
  92082. * Set a texture in the shader program used to render.
  92083. * @param name Define the name of the uniform samplers as defined in the shader
  92084. * @param texture Define the texture to bind to this sampler
  92085. * @return the texture itself allowing "fluent" like uniform updates
  92086. */
  92087. setTexture(name: string, texture: Texture): ProceduralTexture;
  92088. /**
  92089. * Set a float in the shader.
  92090. * @param name Define the name of the uniform as defined in the shader
  92091. * @param value Define the value to give to the uniform
  92092. * @return the texture itself allowing "fluent" like uniform updates
  92093. */
  92094. setFloat(name: string, value: number): ProceduralTexture;
  92095. /**
  92096. * Set a int in the shader.
  92097. * @param name Define the name of the uniform as defined in the shader
  92098. * @param value Define the value to give to the uniform
  92099. * @return the texture itself allowing "fluent" like uniform updates
  92100. */
  92101. setInt(name: string, value: number): ProceduralTexture;
  92102. /**
  92103. * Set an array of floats in the shader.
  92104. * @param name Define the name of the uniform as defined in the shader
  92105. * @param value Define the value to give to the uniform
  92106. * @return the texture itself allowing "fluent" like uniform updates
  92107. */
  92108. setFloats(name: string, value: number[]): ProceduralTexture;
  92109. /**
  92110. * Set a vec3 in the shader from a Color3.
  92111. * @param name Define the name of the uniform as defined in the shader
  92112. * @param value Define the value to give to the uniform
  92113. * @return the texture itself allowing "fluent" like uniform updates
  92114. */
  92115. setColor3(name: string, value: Color3): ProceduralTexture;
  92116. /**
  92117. * Set a vec4 in the shader from a Color4.
  92118. * @param name Define the name of the uniform as defined in the shader
  92119. * @param value Define the value to give to the uniform
  92120. * @return the texture itself allowing "fluent" like uniform updates
  92121. */
  92122. setColor4(name: string, value: Color4): ProceduralTexture;
  92123. /**
  92124. * Set a vec2 in the shader from a Vector2.
  92125. * @param name Define the name of the uniform as defined in the shader
  92126. * @param value Define the value to give to the uniform
  92127. * @return the texture itself allowing "fluent" like uniform updates
  92128. */
  92129. setVector2(name: string, value: Vector2): ProceduralTexture;
  92130. /**
  92131. * Set a vec3 in the shader from a Vector3.
  92132. * @param name Define the name of the uniform as defined in the shader
  92133. * @param value Define the value to give to the uniform
  92134. * @return the texture itself allowing "fluent" like uniform updates
  92135. */
  92136. setVector3(name: string, value: Vector3): ProceduralTexture;
  92137. /**
  92138. * Set a mat4 in the shader from a MAtrix.
  92139. * @param name Define the name of the uniform as defined in the shader
  92140. * @param value Define the value to give to the uniform
  92141. * @return the texture itself allowing "fluent" like uniform updates
  92142. */
  92143. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92144. /**
  92145. * Render the texture to its associated render target.
  92146. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92147. */
  92148. render(useCameraPostProcess?: boolean): void;
  92149. /**
  92150. * Clone the texture.
  92151. * @returns the cloned texture
  92152. */
  92153. clone(): ProceduralTexture;
  92154. /**
  92155. * Dispose the texture and release its asoociated resources.
  92156. */
  92157. dispose(): void;
  92158. }
  92159. }
  92160. declare module BABYLON {
  92161. /**
  92162. * This represents the base class for particle system in Babylon.
  92163. * 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.
  92164. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92165. * @example https://doc.babylonjs.com/babylon101/particles
  92166. */
  92167. export class BaseParticleSystem {
  92168. /**
  92169. * Source color is added to the destination color without alpha affecting the result
  92170. */
  92171. static BLENDMODE_ONEONE: number;
  92172. /**
  92173. * Blend current color and particle color using particle’s alpha
  92174. */
  92175. static BLENDMODE_STANDARD: number;
  92176. /**
  92177. * Add current color and particle color multiplied by particle’s alpha
  92178. */
  92179. static BLENDMODE_ADD: number;
  92180. /**
  92181. * Multiply current color with particle color
  92182. */
  92183. static BLENDMODE_MULTIPLY: number;
  92184. /**
  92185. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92186. */
  92187. static BLENDMODE_MULTIPLYADD: number;
  92188. /**
  92189. * List of animations used by the particle system.
  92190. */
  92191. animations: Animation[];
  92192. /**
  92193. * Gets or sets the unique id of the particle system
  92194. */
  92195. uniqueId: number;
  92196. /**
  92197. * The id of the Particle system.
  92198. */
  92199. id: string;
  92200. /**
  92201. * The friendly name of the Particle system.
  92202. */
  92203. name: string;
  92204. /**
  92205. * Snippet ID if the particle system was created from the snippet server
  92206. */
  92207. snippetId: string;
  92208. /**
  92209. * The rendering group used by the Particle system to chose when to render.
  92210. */
  92211. renderingGroupId: number;
  92212. /**
  92213. * The emitter represents the Mesh or position we are attaching the particle system to.
  92214. */
  92215. emitter: Nullable<AbstractMesh | Vector3>;
  92216. /**
  92217. * The maximum number of particles to emit per frame
  92218. */
  92219. emitRate: number;
  92220. /**
  92221. * If you want to launch only a few particles at once, that can be done, as well.
  92222. */
  92223. manualEmitCount: number;
  92224. /**
  92225. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92226. */
  92227. updateSpeed: number;
  92228. /**
  92229. * The amount of time the particle system is running (depends of the overall update speed).
  92230. */
  92231. targetStopDuration: number;
  92232. /**
  92233. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92234. */
  92235. disposeOnStop: boolean;
  92236. /**
  92237. * Minimum power of emitting particles.
  92238. */
  92239. minEmitPower: number;
  92240. /**
  92241. * Maximum power of emitting particles.
  92242. */
  92243. maxEmitPower: number;
  92244. /**
  92245. * Minimum life time of emitting particles.
  92246. */
  92247. minLifeTime: number;
  92248. /**
  92249. * Maximum life time of emitting particles.
  92250. */
  92251. maxLifeTime: number;
  92252. /**
  92253. * Minimum Size of emitting particles.
  92254. */
  92255. minSize: number;
  92256. /**
  92257. * Maximum Size of emitting particles.
  92258. */
  92259. maxSize: number;
  92260. /**
  92261. * Minimum scale of emitting particles on X axis.
  92262. */
  92263. minScaleX: number;
  92264. /**
  92265. * Maximum scale of emitting particles on X axis.
  92266. */
  92267. maxScaleX: number;
  92268. /**
  92269. * Minimum scale of emitting particles on Y axis.
  92270. */
  92271. minScaleY: number;
  92272. /**
  92273. * Maximum scale of emitting particles on Y axis.
  92274. */
  92275. maxScaleY: number;
  92276. /**
  92277. * Gets or sets the minimal initial rotation in radians.
  92278. */
  92279. minInitialRotation: number;
  92280. /**
  92281. * Gets or sets the maximal initial rotation in radians.
  92282. */
  92283. maxInitialRotation: number;
  92284. /**
  92285. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92286. */
  92287. minAngularSpeed: number;
  92288. /**
  92289. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92290. */
  92291. maxAngularSpeed: number;
  92292. /**
  92293. * The texture used to render each particle. (this can be a spritesheet)
  92294. */
  92295. particleTexture: Nullable<BaseTexture>;
  92296. /**
  92297. * The layer mask we are rendering the particles through.
  92298. */
  92299. layerMask: number;
  92300. /**
  92301. * This can help using your own shader to render the particle system.
  92302. * The according effect will be created
  92303. */
  92304. customShader: any;
  92305. /**
  92306. * By default particle system starts as soon as they are created. This prevents the
  92307. * automatic start to happen and let you decide when to start emitting particles.
  92308. */
  92309. preventAutoStart: boolean;
  92310. private _noiseTexture;
  92311. /**
  92312. * Gets or sets a texture used to add random noise to particle positions
  92313. */
  92314. get noiseTexture(): Nullable<ProceduralTexture>;
  92315. set noiseTexture(value: Nullable<ProceduralTexture>);
  92316. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92317. noiseStrength: Vector3;
  92318. /**
  92319. * Callback triggered when the particle animation is ending.
  92320. */
  92321. onAnimationEnd: Nullable<() => void>;
  92322. /**
  92323. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92324. */
  92325. blendMode: number;
  92326. /**
  92327. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92328. * to override the particles.
  92329. */
  92330. forceDepthWrite: boolean;
  92331. /** 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 */
  92332. preWarmCycles: number;
  92333. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92334. preWarmStepOffset: number;
  92335. /**
  92336. * 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)
  92337. */
  92338. spriteCellChangeSpeed: number;
  92339. /**
  92340. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92341. */
  92342. startSpriteCellID: number;
  92343. /**
  92344. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92345. */
  92346. endSpriteCellID: number;
  92347. /**
  92348. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92349. */
  92350. spriteCellWidth: number;
  92351. /**
  92352. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92353. */
  92354. spriteCellHeight: number;
  92355. /**
  92356. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92357. */
  92358. spriteRandomStartCell: boolean;
  92359. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92360. translationPivot: Vector2;
  92361. /** @hidden */
  92362. protected _isAnimationSheetEnabled: boolean;
  92363. /**
  92364. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92365. */
  92366. beginAnimationOnStart: boolean;
  92367. /**
  92368. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92369. */
  92370. beginAnimationFrom: number;
  92371. /**
  92372. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92373. */
  92374. beginAnimationTo: number;
  92375. /**
  92376. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92377. */
  92378. beginAnimationLoop: boolean;
  92379. /**
  92380. * Gets or sets a world offset applied to all particles
  92381. */
  92382. worldOffset: Vector3;
  92383. /**
  92384. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92385. */
  92386. get isAnimationSheetEnabled(): boolean;
  92387. set isAnimationSheetEnabled(value: boolean);
  92388. /**
  92389. * Get hosting scene
  92390. * @returns the scene
  92391. */
  92392. getScene(): Nullable<Scene>;
  92393. /**
  92394. * You can use gravity if you want to give an orientation to your particles.
  92395. */
  92396. gravity: Vector3;
  92397. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92398. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92399. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92400. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92401. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92402. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92403. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92404. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92405. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92406. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92407. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92408. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92409. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92410. /**
  92411. * Defines the delay in milliseconds before starting the system (0 by default)
  92412. */
  92413. startDelay: number;
  92414. /**
  92415. * Gets the current list of drag gradients.
  92416. * You must use addDragGradient and removeDragGradient to udpate this list
  92417. * @returns the list of drag gradients
  92418. */
  92419. getDragGradients(): Nullable<Array<FactorGradient>>;
  92420. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92421. limitVelocityDamping: number;
  92422. /**
  92423. * Gets the current list of limit velocity gradients.
  92424. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92425. * @returns the list of limit velocity gradients
  92426. */
  92427. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92428. /**
  92429. * Gets the current list of color gradients.
  92430. * You must use addColorGradient and removeColorGradient to udpate this list
  92431. * @returns the list of color gradients
  92432. */
  92433. getColorGradients(): Nullable<Array<ColorGradient>>;
  92434. /**
  92435. * Gets the current list of size gradients.
  92436. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92437. * @returns the list of size gradients
  92438. */
  92439. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92440. /**
  92441. * Gets the current list of color remap gradients.
  92442. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92443. * @returns the list of color remap gradients
  92444. */
  92445. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92446. /**
  92447. * Gets the current list of alpha remap gradients.
  92448. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92449. * @returns the list of alpha remap gradients
  92450. */
  92451. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92452. /**
  92453. * Gets the current list of life time gradients.
  92454. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92455. * @returns the list of life time gradients
  92456. */
  92457. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92458. /**
  92459. * Gets the current list of angular speed gradients.
  92460. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92461. * @returns the list of angular speed gradients
  92462. */
  92463. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92464. /**
  92465. * Gets the current list of velocity gradients.
  92466. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92467. * @returns the list of velocity gradients
  92468. */
  92469. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92470. /**
  92471. * Gets the current list of start size gradients.
  92472. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92473. * @returns the list of start size gradients
  92474. */
  92475. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92476. /**
  92477. * Gets the current list of emit rate gradients.
  92478. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92479. * @returns the list of emit rate gradients
  92480. */
  92481. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92482. /**
  92483. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92484. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92485. */
  92486. get direction1(): Vector3;
  92487. set direction1(value: Vector3);
  92488. /**
  92489. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92490. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92491. */
  92492. get direction2(): Vector3;
  92493. set direction2(value: Vector3);
  92494. /**
  92495. * 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.
  92496. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92497. */
  92498. get minEmitBox(): Vector3;
  92499. set minEmitBox(value: Vector3);
  92500. /**
  92501. * 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.
  92502. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92503. */
  92504. get maxEmitBox(): Vector3;
  92505. set maxEmitBox(value: Vector3);
  92506. /**
  92507. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92508. */
  92509. color1: Color4;
  92510. /**
  92511. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92512. */
  92513. color2: Color4;
  92514. /**
  92515. * Color the particle will have at the end of its lifetime
  92516. */
  92517. colorDead: Color4;
  92518. /**
  92519. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92520. */
  92521. textureMask: Color4;
  92522. /**
  92523. * The particle emitter type defines the emitter used by the particle system.
  92524. * It can be for example box, sphere, or cone...
  92525. */
  92526. particleEmitterType: IParticleEmitterType;
  92527. /** @hidden */
  92528. _isSubEmitter: boolean;
  92529. /**
  92530. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92531. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92532. */
  92533. billboardMode: number;
  92534. protected _isBillboardBased: boolean;
  92535. /**
  92536. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92537. */
  92538. get isBillboardBased(): boolean;
  92539. set isBillboardBased(value: boolean);
  92540. /**
  92541. * The scene the particle system belongs to.
  92542. */
  92543. protected _scene: Nullable<Scene>;
  92544. /**
  92545. * The engine the particle system belongs to.
  92546. */
  92547. protected _engine: ThinEngine;
  92548. /**
  92549. * Local cache of defines for image processing.
  92550. */
  92551. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92552. /**
  92553. * Default configuration related to image processing available in the standard Material.
  92554. */
  92555. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92556. /**
  92557. * Gets the image processing configuration used either in this material.
  92558. */
  92559. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92560. /**
  92561. * Sets the Default image processing configuration used either in the this material.
  92562. *
  92563. * If sets to null, the scene one is in use.
  92564. */
  92565. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92566. /**
  92567. * Attaches a new image processing configuration to the Standard Material.
  92568. * @param configuration
  92569. */
  92570. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92571. /** @hidden */
  92572. protected _reset(): void;
  92573. /** @hidden */
  92574. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92575. /**
  92576. * Instantiates a particle system.
  92577. * 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.
  92578. * @param name The name of the particle system
  92579. */
  92580. constructor(name: string);
  92581. /**
  92582. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92583. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92584. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92585. * @returns the emitter
  92586. */
  92587. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92588. /**
  92589. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92590. * @param radius The radius of the hemisphere to emit from
  92591. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92592. * @returns the emitter
  92593. */
  92594. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92595. /**
  92596. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92597. * @param radius The radius of the sphere to emit from
  92598. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92599. * @returns the emitter
  92600. */
  92601. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92602. /**
  92603. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92604. * @param radius The radius of the sphere to emit from
  92605. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92606. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92607. * @returns the emitter
  92608. */
  92609. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92610. /**
  92611. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92612. * @param radius The radius of the emission cylinder
  92613. * @param height The height of the emission cylinder
  92614. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92615. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92616. * @returns the emitter
  92617. */
  92618. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92619. /**
  92620. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92621. * @param radius The radius of the cylinder to emit from
  92622. * @param height The height of the emission cylinder
  92623. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92624. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92625. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92626. * @returns the emitter
  92627. */
  92628. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92629. /**
  92630. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92631. * @param radius The radius of the cone to emit from
  92632. * @param angle The base angle of the cone
  92633. * @returns the emitter
  92634. */
  92635. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92636. /**
  92637. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92640. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92641. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92642. * @returns the emitter
  92643. */
  92644. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92645. }
  92646. }
  92647. declare module BABYLON {
  92648. /**
  92649. * Type of sub emitter
  92650. */
  92651. export enum SubEmitterType {
  92652. /**
  92653. * Attached to the particle over it's lifetime
  92654. */
  92655. ATTACHED = 0,
  92656. /**
  92657. * Created when the particle dies
  92658. */
  92659. END = 1
  92660. }
  92661. /**
  92662. * Sub emitter class used to emit particles from an existing particle
  92663. */
  92664. export class SubEmitter {
  92665. /**
  92666. * the particle system to be used by the sub emitter
  92667. */
  92668. particleSystem: ParticleSystem;
  92669. /**
  92670. * Type of the submitter (Default: END)
  92671. */
  92672. type: SubEmitterType;
  92673. /**
  92674. * 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)
  92675. * Note: This only is supported when using an emitter of type Mesh
  92676. */
  92677. inheritDirection: boolean;
  92678. /**
  92679. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92680. */
  92681. inheritedVelocityAmount: number;
  92682. /**
  92683. * Creates a sub emitter
  92684. * @param particleSystem the particle system to be used by the sub emitter
  92685. */
  92686. constructor(
  92687. /**
  92688. * the particle system to be used by the sub emitter
  92689. */
  92690. particleSystem: ParticleSystem);
  92691. /**
  92692. * Clones the sub emitter
  92693. * @returns the cloned sub emitter
  92694. */
  92695. clone(): SubEmitter;
  92696. /**
  92697. * Serialize current object to a JSON object
  92698. * @returns the serialized object
  92699. */
  92700. serialize(): any;
  92701. /** @hidden */
  92702. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92703. /**
  92704. * Creates a new SubEmitter from a serialized JSON version
  92705. * @param serializationObject defines the JSON object to read from
  92706. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92707. * @param rootUrl defines the rootUrl for data loading
  92708. * @returns a new SubEmitter
  92709. */
  92710. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92711. /** Release associated resources */
  92712. dispose(): void;
  92713. }
  92714. }
  92715. declare module BABYLON {
  92716. /** @hidden */
  92717. export var imageProcessingDeclaration: {
  92718. name: string;
  92719. shader: string;
  92720. };
  92721. }
  92722. declare module BABYLON {
  92723. /** @hidden */
  92724. export var imageProcessingFunctions: {
  92725. name: string;
  92726. shader: string;
  92727. };
  92728. }
  92729. declare module BABYLON {
  92730. /** @hidden */
  92731. export var particlesPixelShader: {
  92732. name: string;
  92733. shader: string;
  92734. };
  92735. }
  92736. declare module BABYLON {
  92737. /** @hidden */
  92738. export var particlesVertexShader: {
  92739. name: string;
  92740. shader: string;
  92741. };
  92742. }
  92743. declare module BABYLON {
  92744. /**
  92745. * Interface used to define entities containing multiple clip planes
  92746. */
  92747. export interface IClipPlanesHolder {
  92748. /**
  92749. * Gets or sets the active clipplane 1
  92750. */
  92751. clipPlane: Nullable<Plane>;
  92752. /**
  92753. * Gets or sets the active clipplane 2
  92754. */
  92755. clipPlane2: Nullable<Plane>;
  92756. /**
  92757. * Gets or sets the active clipplane 3
  92758. */
  92759. clipPlane3: Nullable<Plane>;
  92760. /**
  92761. * Gets or sets the active clipplane 4
  92762. */
  92763. clipPlane4: Nullable<Plane>;
  92764. /**
  92765. * Gets or sets the active clipplane 5
  92766. */
  92767. clipPlane5: Nullable<Plane>;
  92768. /**
  92769. * Gets or sets the active clipplane 6
  92770. */
  92771. clipPlane6: Nullable<Plane>;
  92772. }
  92773. }
  92774. declare module BABYLON {
  92775. /**
  92776. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92777. *
  92778. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92779. *
  92780. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92781. */
  92782. export class ThinMaterialHelper {
  92783. /**
  92784. * Binds the clip plane information from the holder to the effect.
  92785. * @param effect The effect we are binding the data to
  92786. * @param holder The entity containing the clip plane information
  92787. */
  92788. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92789. }
  92790. }
  92791. declare module BABYLON {
  92792. interface ThinEngine {
  92793. /**
  92794. * Sets alpha constants used by some alpha blending modes
  92795. * @param r defines the red component
  92796. * @param g defines the green component
  92797. * @param b defines the blue component
  92798. * @param a defines the alpha component
  92799. */
  92800. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92801. /**
  92802. * Sets the current alpha mode
  92803. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92804. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92805. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92806. */
  92807. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92808. /**
  92809. * Gets the current alpha mode
  92810. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92811. * @returns the current alpha mode
  92812. */
  92813. getAlphaMode(): number;
  92814. /**
  92815. * Sets the current alpha equation
  92816. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92817. */
  92818. setAlphaEquation(equation: number): void;
  92819. /**
  92820. * Gets the current alpha equation.
  92821. * @returns the current alpha equation
  92822. */
  92823. getAlphaEquation(): number;
  92824. }
  92825. }
  92826. declare module BABYLON {
  92827. /**
  92828. * This represents a particle system in Babylon.
  92829. * 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.
  92830. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92831. * @example https://doc.babylonjs.com/babylon101/particles
  92832. */
  92833. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92834. /**
  92835. * Billboard mode will only apply to Y axis
  92836. */
  92837. static readonly BILLBOARDMODE_Y: number;
  92838. /**
  92839. * Billboard mode will apply to all axes
  92840. */
  92841. static readonly BILLBOARDMODE_ALL: number;
  92842. /**
  92843. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92844. */
  92845. static readonly BILLBOARDMODE_STRETCHED: number;
  92846. /**
  92847. * This function can be defined to provide custom update for active particles.
  92848. * This function will be called instead of regular update (age, position, color, etc.).
  92849. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92850. */
  92851. updateFunction: (particles: Particle[]) => void;
  92852. private _emitterWorldMatrix;
  92853. /**
  92854. * This function can be defined to specify initial direction for every new particle.
  92855. * It by default use the emitterType defined function
  92856. */
  92857. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92858. /**
  92859. * This function can be defined to specify initial position for every new particle.
  92860. * It by default use the emitterType defined function
  92861. */
  92862. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92863. /**
  92864. * @hidden
  92865. */
  92866. _inheritedVelocityOffset: Vector3;
  92867. /**
  92868. * An event triggered when the system is disposed
  92869. */
  92870. onDisposeObservable: Observable<IParticleSystem>;
  92871. private _onDisposeObserver;
  92872. /**
  92873. * Sets a callback that will be triggered when the system is disposed
  92874. */
  92875. set onDispose(callback: () => void);
  92876. private _particles;
  92877. private _epsilon;
  92878. private _capacity;
  92879. private _stockParticles;
  92880. private _newPartsExcess;
  92881. private _vertexData;
  92882. private _vertexBuffer;
  92883. private _vertexBuffers;
  92884. private _spriteBuffer;
  92885. private _indexBuffer;
  92886. private _effect;
  92887. private _customEffect;
  92888. private _cachedDefines;
  92889. private _scaledColorStep;
  92890. private _colorDiff;
  92891. private _scaledDirection;
  92892. private _scaledGravity;
  92893. private _currentRenderId;
  92894. private _alive;
  92895. private _useInstancing;
  92896. private _started;
  92897. private _stopped;
  92898. private _actualFrame;
  92899. private _scaledUpdateSpeed;
  92900. private _vertexBufferSize;
  92901. /** @hidden */
  92902. _currentEmitRateGradient: Nullable<FactorGradient>;
  92903. /** @hidden */
  92904. _currentEmitRate1: number;
  92905. /** @hidden */
  92906. _currentEmitRate2: number;
  92907. /** @hidden */
  92908. _currentStartSizeGradient: Nullable<FactorGradient>;
  92909. /** @hidden */
  92910. _currentStartSize1: number;
  92911. /** @hidden */
  92912. _currentStartSize2: number;
  92913. private readonly _rawTextureWidth;
  92914. private _rampGradientsTexture;
  92915. private _useRampGradients;
  92916. /** Gets or sets a matrix to use to compute projection */
  92917. defaultProjectionMatrix: Matrix;
  92918. /** Gets or sets a matrix to use to compute view */
  92919. defaultViewMatrix: Matrix;
  92920. /** Gets or sets a boolean indicating that ramp gradients must be used
  92921. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92922. */
  92923. get useRampGradients(): boolean;
  92924. set useRampGradients(value: boolean);
  92925. /**
  92926. * 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.
  92927. * 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: [])
  92928. */
  92929. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  92930. private _subEmitters;
  92931. /**
  92932. * @hidden
  92933. * If the particle systems emitter should be disposed when the particle system is disposed
  92934. */
  92935. _disposeEmitterOnDispose: boolean;
  92936. /**
  92937. * The current active Sub-systems, this property is used by the root particle system only.
  92938. */
  92939. activeSubSystems: Array<ParticleSystem>;
  92940. /**
  92941. * Specifies if the particles are updated in emitter local space or world space
  92942. */
  92943. isLocal: boolean;
  92944. private _rootParticleSystem;
  92945. /**
  92946. * Gets the current list of active particles
  92947. */
  92948. get particles(): Particle[];
  92949. /**
  92950. * Gets the number of particles active at the same time.
  92951. * @returns The number of active particles.
  92952. */
  92953. getActiveCount(): number;
  92954. /**
  92955. * Returns the string "ParticleSystem"
  92956. * @returns a string containing the class name
  92957. */
  92958. getClassName(): string;
  92959. /**
  92960. * Gets a boolean indicating that the system is stopping
  92961. * @returns true if the system is currently stopping
  92962. */
  92963. isStopping(): boolean;
  92964. /**
  92965. * Gets the custom effect used to render the particles
  92966. * @param blendMode Blend mode for which the effect should be retrieved
  92967. * @returns The effect
  92968. */
  92969. getCustomEffect(blendMode?: number): Nullable<Effect>;
  92970. /**
  92971. * Sets the custom effect used to render the particles
  92972. * @param effect The effect to set
  92973. * @param blendMode Blend mode for which the effect should be set
  92974. */
  92975. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  92976. /** @hidden */
  92977. private _onBeforeDrawParticlesObservable;
  92978. /**
  92979. * Observable that will be called just before the particles are drawn
  92980. */
  92981. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  92982. /**
  92983. * Gets the name of the particle vertex shader
  92984. */
  92985. get vertexShaderName(): string;
  92986. /**
  92987. * Instantiates a particle system.
  92988. * 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.
  92989. * @param name The name of the particle system
  92990. * @param capacity The max number of particles alive at the same time
  92991. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  92992. * @param customEffect a custom effect used to change the way particles are rendered by default
  92993. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  92994. * @param epsilon Offset used to render the particles
  92995. */
  92996. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  92997. private _addFactorGradient;
  92998. private _removeFactorGradient;
  92999. /**
  93000. * Adds a new life time gradient
  93001. * @param gradient defines the gradient to use (between 0 and 1)
  93002. * @param factor defines the life time factor to affect to the specified gradient
  93003. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93004. * @returns the current particle system
  93005. */
  93006. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93007. /**
  93008. * Remove a specific life time gradient
  93009. * @param gradient defines the gradient to remove
  93010. * @returns the current particle system
  93011. */
  93012. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93013. /**
  93014. * Adds a new size gradient
  93015. * @param gradient defines the gradient to use (between 0 and 1)
  93016. * @param factor defines the size factor to affect to the specified gradient
  93017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93018. * @returns the current particle system
  93019. */
  93020. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93021. /**
  93022. * Remove a specific size gradient
  93023. * @param gradient defines the gradient to remove
  93024. * @returns the current particle system
  93025. */
  93026. removeSizeGradient(gradient: number): IParticleSystem;
  93027. /**
  93028. * Adds a new color remap gradient
  93029. * @param gradient defines the gradient to use (between 0 and 1)
  93030. * @param min defines the color remap minimal range
  93031. * @param max defines the color remap maximal range
  93032. * @returns the current particle system
  93033. */
  93034. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93035. /**
  93036. * Remove a specific color remap gradient
  93037. * @param gradient defines the gradient to remove
  93038. * @returns the current particle system
  93039. */
  93040. removeColorRemapGradient(gradient: number): IParticleSystem;
  93041. /**
  93042. * Adds a new alpha remap gradient
  93043. * @param gradient defines the gradient to use (between 0 and 1)
  93044. * @param min defines the alpha remap minimal range
  93045. * @param max defines the alpha remap maximal range
  93046. * @returns the current particle system
  93047. */
  93048. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93049. /**
  93050. * Remove a specific alpha remap gradient
  93051. * @param gradient defines the gradient to remove
  93052. * @returns the current particle system
  93053. */
  93054. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93055. /**
  93056. * Adds a new angular speed gradient
  93057. * @param gradient defines the gradient to use (between 0 and 1)
  93058. * @param factor defines the angular speed to affect to the specified gradient
  93059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93060. * @returns the current particle system
  93061. */
  93062. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93063. /**
  93064. * Remove a specific angular speed gradient
  93065. * @param gradient defines the gradient to remove
  93066. * @returns the current particle system
  93067. */
  93068. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93069. /**
  93070. * Adds a new velocity gradient
  93071. * @param gradient defines the gradient to use (between 0 and 1)
  93072. * @param factor defines the velocity to affect to the specified gradient
  93073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93074. * @returns the current particle system
  93075. */
  93076. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93077. /**
  93078. * Remove a specific velocity gradient
  93079. * @param gradient defines the gradient to remove
  93080. * @returns the current particle system
  93081. */
  93082. removeVelocityGradient(gradient: number): IParticleSystem;
  93083. /**
  93084. * Adds a new limit velocity gradient
  93085. * @param gradient defines the gradient to use (between 0 and 1)
  93086. * @param factor defines the limit velocity value to affect to the specified gradient
  93087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93088. * @returns the current particle system
  93089. */
  93090. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93091. /**
  93092. * Remove a specific limit velocity gradient
  93093. * @param gradient defines the gradient to remove
  93094. * @returns the current particle system
  93095. */
  93096. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93097. /**
  93098. * Adds a new drag gradient
  93099. * @param gradient defines the gradient to use (between 0 and 1)
  93100. * @param factor defines the drag value to affect to the specified gradient
  93101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93102. * @returns the current particle system
  93103. */
  93104. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93105. /**
  93106. * Remove a specific drag gradient
  93107. * @param gradient defines the gradient to remove
  93108. * @returns the current particle system
  93109. */
  93110. removeDragGradient(gradient: number): IParticleSystem;
  93111. /**
  93112. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93113. * @param gradient defines the gradient to use (between 0 and 1)
  93114. * @param factor defines the emit rate value to affect to the specified gradient
  93115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93116. * @returns the current particle system
  93117. */
  93118. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93119. /**
  93120. * Remove a specific emit rate gradient
  93121. * @param gradient defines the gradient to remove
  93122. * @returns the current particle system
  93123. */
  93124. removeEmitRateGradient(gradient: number): IParticleSystem;
  93125. /**
  93126. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93127. * @param gradient defines the gradient to use (between 0 and 1)
  93128. * @param factor defines the start size value to affect to the specified gradient
  93129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93130. * @returns the current particle system
  93131. */
  93132. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93133. /**
  93134. * Remove a specific start size gradient
  93135. * @param gradient defines the gradient to remove
  93136. * @returns the current particle system
  93137. */
  93138. removeStartSizeGradient(gradient: number): IParticleSystem;
  93139. private _createRampGradientTexture;
  93140. /**
  93141. * Gets the current list of ramp gradients.
  93142. * You must use addRampGradient and removeRampGradient to udpate this list
  93143. * @returns the list of ramp gradients
  93144. */
  93145. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93146. /** Force the system to rebuild all gradients that need to be resync */
  93147. forceRefreshGradients(): void;
  93148. private _syncRampGradientTexture;
  93149. /**
  93150. * Adds a new ramp gradient used to remap particle colors
  93151. * @param gradient defines the gradient to use (between 0 and 1)
  93152. * @param color defines the color to affect to the specified gradient
  93153. * @returns the current particle system
  93154. */
  93155. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93156. /**
  93157. * Remove a specific ramp gradient
  93158. * @param gradient defines the gradient to remove
  93159. * @returns the current particle system
  93160. */
  93161. removeRampGradient(gradient: number): ParticleSystem;
  93162. /**
  93163. * Adds a new color gradient
  93164. * @param gradient defines the gradient to use (between 0 and 1)
  93165. * @param color1 defines the color to affect to the specified gradient
  93166. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93167. * @returns this particle system
  93168. */
  93169. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93170. /**
  93171. * Remove a specific color gradient
  93172. * @param gradient defines the gradient to remove
  93173. * @returns this particle system
  93174. */
  93175. removeColorGradient(gradient: number): IParticleSystem;
  93176. private _fetchR;
  93177. protected _reset(): void;
  93178. private _resetEffect;
  93179. private _createVertexBuffers;
  93180. private _createIndexBuffer;
  93181. /**
  93182. * Gets the maximum number of particles active at the same time.
  93183. * @returns The max number of active particles.
  93184. */
  93185. getCapacity(): number;
  93186. /**
  93187. * Gets whether there are still active particles in the system.
  93188. * @returns True if it is alive, otherwise false.
  93189. */
  93190. isAlive(): boolean;
  93191. /**
  93192. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93193. * @returns True if it has been started, otherwise false.
  93194. */
  93195. isStarted(): boolean;
  93196. private _prepareSubEmitterInternalArray;
  93197. /**
  93198. * Starts the particle system and begins to emit
  93199. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93200. */
  93201. start(delay?: number): void;
  93202. /**
  93203. * Stops the particle system.
  93204. * @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.
  93205. */
  93206. stop(stopSubEmitters?: boolean): void;
  93207. /**
  93208. * Remove all active particles
  93209. */
  93210. reset(): void;
  93211. /**
  93212. * @hidden (for internal use only)
  93213. */
  93214. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93215. /**
  93216. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93217. * Its lifetime will start back at 0.
  93218. */
  93219. recycleParticle: (particle: Particle) => void;
  93220. private _stopSubEmitters;
  93221. private _createParticle;
  93222. private _removeFromRoot;
  93223. private _emitFromParticle;
  93224. private _update;
  93225. /** @hidden */
  93226. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93227. /** @hidden */
  93228. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93229. /**
  93230. * Fill the defines array according to the current settings of the particle system
  93231. * @param defines Array to be updated
  93232. * @param blendMode blend mode to take into account when updating the array
  93233. */
  93234. fillDefines(defines: Array<string>, blendMode: number): void;
  93235. /**
  93236. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93237. * @param uniforms Uniforms array to fill
  93238. * @param attributes Attributes array to fill
  93239. * @param samplers Samplers array to fill
  93240. */
  93241. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93242. /** @hidden */
  93243. private _getEffect;
  93244. /**
  93245. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93246. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93247. */
  93248. animate(preWarmOnly?: boolean): void;
  93249. private _appendParticleVertices;
  93250. /**
  93251. * Rebuilds the particle system.
  93252. */
  93253. rebuild(): void;
  93254. /**
  93255. * Is this system ready to be used/rendered
  93256. * @return true if the system is ready
  93257. */
  93258. isReady(): boolean;
  93259. private _render;
  93260. /**
  93261. * Renders the particle system in its current state.
  93262. * @returns the current number of particles
  93263. */
  93264. render(): number;
  93265. /**
  93266. * Disposes the particle system and free the associated resources
  93267. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93268. */
  93269. dispose(disposeTexture?: boolean): void;
  93270. /**
  93271. * Clones the particle system.
  93272. * @param name The name of the cloned object
  93273. * @param newEmitter The new emitter to use
  93274. * @returns the cloned particle system
  93275. */
  93276. clone(name: string, newEmitter: any): ParticleSystem;
  93277. /**
  93278. * Serializes the particle system to a JSON object
  93279. * @param serializeTexture defines if the texture must be serialized as well
  93280. * @returns the JSON object
  93281. */
  93282. serialize(serializeTexture?: boolean): any;
  93283. /** @hidden */
  93284. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93285. /** @hidden */
  93286. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93287. /**
  93288. * Parses a JSON object to create a particle system.
  93289. * @param parsedParticleSystem The JSON object to parse
  93290. * @param sceneOrEngine The scene or the engine to create the particle system in
  93291. * @param rootUrl The root url to use to load external dependencies like texture
  93292. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93293. * @returns the Parsed particle system
  93294. */
  93295. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93296. }
  93297. }
  93298. declare module BABYLON {
  93299. /**
  93300. * A particle represents one of the element emitted by a particle system.
  93301. * This is mainly define by its coordinates, direction, velocity and age.
  93302. */
  93303. export class Particle {
  93304. /**
  93305. * The particle system the particle belongs to.
  93306. */
  93307. particleSystem: ParticleSystem;
  93308. private static _Count;
  93309. /**
  93310. * Unique ID of the particle
  93311. */
  93312. id: number;
  93313. /**
  93314. * The world position of the particle in the scene.
  93315. */
  93316. position: Vector3;
  93317. /**
  93318. * The world direction of the particle in the scene.
  93319. */
  93320. direction: Vector3;
  93321. /**
  93322. * The color of the particle.
  93323. */
  93324. color: Color4;
  93325. /**
  93326. * The color change of the particle per step.
  93327. */
  93328. colorStep: Color4;
  93329. /**
  93330. * Defines how long will the life of the particle be.
  93331. */
  93332. lifeTime: number;
  93333. /**
  93334. * The current age of the particle.
  93335. */
  93336. age: number;
  93337. /**
  93338. * The current size of the particle.
  93339. */
  93340. size: number;
  93341. /**
  93342. * The current scale of the particle.
  93343. */
  93344. scale: Vector2;
  93345. /**
  93346. * The current angle of the particle.
  93347. */
  93348. angle: number;
  93349. /**
  93350. * Defines how fast is the angle changing.
  93351. */
  93352. angularSpeed: number;
  93353. /**
  93354. * Defines the cell index used by the particle to be rendered from a sprite.
  93355. */
  93356. cellIndex: number;
  93357. /**
  93358. * The information required to support color remapping
  93359. */
  93360. remapData: Vector4;
  93361. /** @hidden */
  93362. _randomCellOffset?: number;
  93363. /** @hidden */
  93364. _initialDirection: Nullable<Vector3>;
  93365. /** @hidden */
  93366. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93367. /** @hidden */
  93368. _initialStartSpriteCellID: number;
  93369. /** @hidden */
  93370. _initialEndSpriteCellID: number;
  93371. /** @hidden */
  93372. _currentColorGradient: Nullable<ColorGradient>;
  93373. /** @hidden */
  93374. _currentColor1: Color4;
  93375. /** @hidden */
  93376. _currentColor2: Color4;
  93377. /** @hidden */
  93378. _currentSizeGradient: Nullable<FactorGradient>;
  93379. /** @hidden */
  93380. _currentSize1: number;
  93381. /** @hidden */
  93382. _currentSize2: number;
  93383. /** @hidden */
  93384. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93385. /** @hidden */
  93386. _currentAngularSpeed1: number;
  93387. /** @hidden */
  93388. _currentAngularSpeed2: number;
  93389. /** @hidden */
  93390. _currentVelocityGradient: Nullable<FactorGradient>;
  93391. /** @hidden */
  93392. _currentVelocity1: number;
  93393. /** @hidden */
  93394. _currentVelocity2: number;
  93395. /** @hidden */
  93396. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93397. /** @hidden */
  93398. _currentLimitVelocity1: number;
  93399. /** @hidden */
  93400. _currentLimitVelocity2: number;
  93401. /** @hidden */
  93402. _currentDragGradient: Nullable<FactorGradient>;
  93403. /** @hidden */
  93404. _currentDrag1: number;
  93405. /** @hidden */
  93406. _currentDrag2: number;
  93407. /** @hidden */
  93408. _randomNoiseCoordinates1: Vector3;
  93409. /** @hidden */
  93410. _randomNoiseCoordinates2: Vector3;
  93411. /** @hidden */
  93412. _localPosition?: Vector3;
  93413. /**
  93414. * Creates a new instance Particle
  93415. * @param particleSystem the particle system the particle belongs to
  93416. */
  93417. constructor(
  93418. /**
  93419. * The particle system the particle belongs to.
  93420. */
  93421. particleSystem: ParticleSystem);
  93422. private updateCellInfoFromSystem;
  93423. /**
  93424. * Defines how the sprite cell index is updated for the particle
  93425. */
  93426. updateCellIndex(): void;
  93427. /** @hidden */
  93428. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93429. /** @hidden */
  93430. _inheritParticleInfoToSubEmitters(): void;
  93431. /** @hidden */
  93432. _reset(): void;
  93433. /**
  93434. * Copy the properties of particle to another one.
  93435. * @param other the particle to copy the information to.
  93436. */
  93437. copyTo(other: Particle): void;
  93438. }
  93439. }
  93440. declare module BABYLON {
  93441. /**
  93442. * Particle emitter represents a volume emitting particles.
  93443. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93444. */
  93445. export interface IParticleEmitterType {
  93446. /**
  93447. * Called by the particle System when the direction is computed for the created particle.
  93448. * @param worldMatrix is the world matrix of the particle system
  93449. * @param directionToUpdate is the direction vector to update with the result
  93450. * @param particle is the particle we are computed the direction for
  93451. * @param isLocal defines if the direction should be set in local space
  93452. */
  93453. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93454. /**
  93455. * Called by the particle System when the position is computed for the created particle.
  93456. * @param worldMatrix is the world matrix of the particle system
  93457. * @param positionToUpdate is the position vector to update with the result
  93458. * @param particle is the particle we are computed the position for
  93459. * @param isLocal defines if the position should be set in local space
  93460. */
  93461. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93462. /**
  93463. * Clones the current emitter and returns a copy of it
  93464. * @returns the new emitter
  93465. */
  93466. clone(): IParticleEmitterType;
  93467. /**
  93468. * Called by the GPUParticleSystem to setup the update shader
  93469. * @param effect defines the update shader
  93470. */
  93471. applyToShader(effect: Effect): void;
  93472. /**
  93473. * Returns a string to use to update the GPU particles update shader
  93474. * @returns the effect defines string
  93475. */
  93476. getEffectDefines(): string;
  93477. /**
  93478. * Returns a string representing the class name
  93479. * @returns a string containing the class name
  93480. */
  93481. getClassName(): string;
  93482. /**
  93483. * Serializes the particle system to a JSON object.
  93484. * @returns the JSON object
  93485. */
  93486. serialize(): any;
  93487. /**
  93488. * Parse properties from a JSON object
  93489. * @param serializationObject defines the JSON object
  93490. * @param scene defines the hosting scene
  93491. */
  93492. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93493. }
  93494. }
  93495. declare module BABYLON {
  93496. /**
  93497. * Particle emitter emitting particles from the inside of a box.
  93498. * It emits the particles randomly between 2 given directions.
  93499. */
  93500. export class BoxParticleEmitter implements IParticleEmitterType {
  93501. /**
  93502. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93503. */
  93504. direction1: Vector3;
  93505. /**
  93506. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93507. */
  93508. direction2: Vector3;
  93509. /**
  93510. * 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.
  93511. */
  93512. minEmitBox: Vector3;
  93513. /**
  93514. * 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.
  93515. */
  93516. maxEmitBox: Vector3;
  93517. /**
  93518. * Creates a new instance BoxParticleEmitter
  93519. */
  93520. constructor();
  93521. /**
  93522. * Called by the particle System when the direction is computed for the created particle.
  93523. * @param worldMatrix is the world matrix of the particle system
  93524. * @param directionToUpdate is the direction vector to update with the result
  93525. * @param particle is the particle we are computed the direction for
  93526. * @param isLocal defines if the direction should be set in local space
  93527. */
  93528. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93529. /**
  93530. * Called by the particle System when the position is computed for the created particle.
  93531. * @param worldMatrix is the world matrix of the particle system
  93532. * @param positionToUpdate is the position vector to update with the result
  93533. * @param particle is the particle we are computed the position for
  93534. * @param isLocal defines if the position should be set in local space
  93535. */
  93536. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93537. /**
  93538. * Clones the current emitter and returns a copy of it
  93539. * @returns the new emitter
  93540. */
  93541. clone(): BoxParticleEmitter;
  93542. /**
  93543. * Called by the GPUParticleSystem to setup the update shader
  93544. * @param effect defines the update shader
  93545. */
  93546. applyToShader(effect: Effect): void;
  93547. /**
  93548. * Returns a string to use to update the GPU particles update shader
  93549. * @returns a string containng the defines string
  93550. */
  93551. getEffectDefines(): string;
  93552. /**
  93553. * Returns the string "BoxParticleEmitter"
  93554. * @returns a string containing the class name
  93555. */
  93556. getClassName(): string;
  93557. /**
  93558. * Serializes the particle system to a JSON object.
  93559. * @returns the JSON object
  93560. */
  93561. serialize(): any;
  93562. /**
  93563. * Parse properties from a JSON object
  93564. * @param serializationObject defines the JSON object
  93565. */
  93566. parse(serializationObject: any): void;
  93567. }
  93568. }
  93569. declare module BABYLON {
  93570. /**
  93571. * Particle emitter emitting particles from the inside of a cone.
  93572. * It emits the particles alongside the cone volume from the base to the particle.
  93573. * The emission direction might be randomized.
  93574. */
  93575. export class ConeParticleEmitter implements IParticleEmitterType {
  93576. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93577. directionRandomizer: number;
  93578. private _radius;
  93579. private _angle;
  93580. private _height;
  93581. /**
  93582. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93583. */
  93584. radiusRange: number;
  93585. /**
  93586. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93587. */
  93588. heightRange: number;
  93589. /**
  93590. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93591. */
  93592. emitFromSpawnPointOnly: boolean;
  93593. /**
  93594. * Gets or sets the radius of the emission cone
  93595. */
  93596. get radius(): number;
  93597. set radius(value: number);
  93598. /**
  93599. * Gets or sets the angle of the emission cone
  93600. */
  93601. get angle(): number;
  93602. set angle(value: number);
  93603. private _buildHeight;
  93604. /**
  93605. * Creates a new instance ConeParticleEmitter
  93606. * @param radius the radius of the emission cone (1 by default)
  93607. * @param angle the cone base angle (PI by default)
  93608. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93609. */
  93610. constructor(radius?: number, angle?: number,
  93611. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93612. directionRandomizer?: number);
  93613. /**
  93614. * Called by the particle System when the direction is computed for the created particle.
  93615. * @param worldMatrix is the world matrix of the particle system
  93616. * @param directionToUpdate is the direction vector to update with the result
  93617. * @param particle is the particle we are computed the direction for
  93618. * @param isLocal defines if the direction should be set in local space
  93619. */
  93620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93621. /**
  93622. * Called by the particle System when the position is computed for the created particle.
  93623. * @param worldMatrix is the world matrix of the particle system
  93624. * @param positionToUpdate is the position vector to update with the result
  93625. * @param particle is the particle we are computed the position for
  93626. * @param isLocal defines if the position should be set in local space
  93627. */
  93628. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93629. /**
  93630. * Clones the current emitter and returns a copy of it
  93631. * @returns the new emitter
  93632. */
  93633. clone(): ConeParticleEmitter;
  93634. /**
  93635. * Called by the GPUParticleSystem to setup the update shader
  93636. * @param effect defines the update shader
  93637. */
  93638. applyToShader(effect: Effect): void;
  93639. /**
  93640. * Returns a string to use to update the GPU particles update shader
  93641. * @returns a string containng the defines string
  93642. */
  93643. getEffectDefines(): string;
  93644. /**
  93645. * Returns the string "ConeParticleEmitter"
  93646. * @returns a string containing the class name
  93647. */
  93648. getClassName(): string;
  93649. /**
  93650. * Serializes the particle system to a JSON object.
  93651. * @returns the JSON object
  93652. */
  93653. serialize(): any;
  93654. /**
  93655. * Parse properties from a JSON object
  93656. * @param serializationObject defines the JSON object
  93657. */
  93658. parse(serializationObject: any): void;
  93659. }
  93660. }
  93661. declare module BABYLON {
  93662. /**
  93663. * Particle emitter emitting particles from the inside of a cylinder.
  93664. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93665. */
  93666. export class CylinderParticleEmitter implements IParticleEmitterType {
  93667. /**
  93668. * The radius of the emission cylinder.
  93669. */
  93670. radius: number;
  93671. /**
  93672. * The height of the emission cylinder.
  93673. */
  93674. height: number;
  93675. /**
  93676. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93677. */
  93678. radiusRange: number;
  93679. /**
  93680. * How much to randomize the particle direction [0-1].
  93681. */
  93682. directionRandomizer: number;
  93683. /**
  93684. * Creates a new instance CylinderParticleEmitter
  93685. * @param radius the radius of the emission cylinder (1 by default)
  93686. * @param height the height of the emission cylinder (1 by default)
  93687. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93688. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93689. */
  93690. constructor(
  93691. /**
  93692. * The radius of the emission cylinder.
  93693. */
  93694. radius?: number,
  93695. /**
  93696. * The height of the emission cylinder.
  93697. */
  93698. height?: number,
  93699. /**
  93700. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93701. */
  93702. radiusRange?: number,
  93703. /**
  93704. * How much to randomize the particle direction [0-1].
  93705. */
  93706. directionRandomizer?: number);
  93707. /**
  93708. * Called by the particle System when the direction is computed for the created particle.
  93709. * @param worldMatrix is the world matrix of the particle system
  93710. * @param directionToUpdate is the direction vector to update with the result
  93711. * @param particle is the particle we are computed the direction for
  93712. * @param isLocal defines if the direction should be set in local space
  93713. */
  93714. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93715. /**
  93716. * Called by the particle System when the position is computed for the created particle.
  93717. * @param worldMatrix is the world matrix of the particle system
  93718. * @param positionToUpdate is the position vector to update with the result
  93719. * @param particle is the particle we are computed the position for
  93720. * @param isLocal defines if the position should be set in local space
  93721. */
  93722. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93723. /**
  93724. * Clones the current emitter and returns a copy of it
  93725. * @returns the new emitter
  93726. */
  93727. clone(): CylinderParticleEmitter;
  93728. /**
  93729. * Called by the GPUParticleSystem to setup the update shader
  93730. * @param effect defines the update shader
  93731. */
  93732. applyToShader(effect: Effect): void;
  93733. /**
  93734. * Returns a string to use to update the GPU particles update shader
  93735. * @returns a string containng the defines string
  93736. */
  93737. getEffectDefines(): string;
  93738. /**
  93739. * Returns the string "CylinderParticleEmitter"
  93740. * @returns a string containing the class name
  93741. */
  93742. getClassName(): string;
  93743. /**
  93744. * Serializes the particle system to a JSON object.
  93745. * @returns the JSON object
  93746. */
  93747. serialize(): any;
  93748. /**
  93749. * Parse properties from a JSON object
  93750. * @param serializationObject defines the JSON object
  93751. */
  93752. parse(serializationObject: any): void;
  93753. }
  93754. /**
  93755. * Particle emitter emitting particles from the inside of a cylinder.
  93756. * It emits the particles randomly between two vectors.
  93757. */
  93758. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93759. /**
  93760. * The min limit of the emission direction.
  93761. */
  93762. direction1: Vector3;
  93763. /**
  93764. * The max limit of the emission direction.
  93765. */
  93766. direction2: Vector3;
  93767. /**
  93768. * Creates a new instance CylinderDirectedParticleEmitter
  93769. * @param radius the radius of the emission cylinder (1 by default)
  93770. * @param height the height of the emission cylinder (1 by default)
  93771. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93772. * @param direction1 the min limit of the emission direction (up vector by default)
  93773. * @param direction2 the max limit of the emission direction (up vector by default)
  93774. */
  93775. constructor(radius?: number, height?: number, radiusRange?: number,
  93776. /**
  93777. * The min limit of the emission direction.
  93778. */
  93779. direction1?: Vector3,
  93780. /**
  93781. * The max limit of the emission direction.
  93782. */
  93783. direction2?: Vector3);
  93784. /**
  93785. * Called by the particle System when the direction is computed for the created particle.
  93786. * @param worldMatrix is the world matrix of the particle system
  93787. * @param directionToUpdate is the direction vector to update with the result
  93788. * @param particle is the particle we are computed the direction for
  93789. */
  93790. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93791. /**
  93792. * Clones the current emitter and returns a copy of it
  93793. * @returns the new emitter
  93794. */
  93795. clone(): CylinderDirectedParticleEmitter;
  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 "CylinderDirectedParticleEmitter"
  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 hemisphere.
  93826. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93827. */
  93828. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93829. /**
  93830. * The radius of the emission hemisphere.
  93831. */
  93832. radius: number;
  93833. /**
  93834. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93835. */
  93836. radiusRange: number;
  93837. /**
  93838. * How much to randomize the particle direction [0-1].
  93839. */
  93840. directionRandomizer: number;
  93841. /**
  93842. * Creates a new instance HemisphericParticleEmitter
  93843. * @param radius the radius of the emission hemisphere (1 by default)
  93844. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93845. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93846. */
  93847. constructor(
  93848. /**
  93849. * The radius of the emission hemisphere.
  93850. */
  93851. radius?: number,
  93852. /**
  93853. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93854. */
  93855. radiusRange?: number,
  93856. /**
  93857. * How much to randomize the particle direction [0-1].
  93858. */
  93859. directionRandomizer?: number);
  93860. /**
  93861. * Called by the particle System when the direction is computed for the created particle.
  93862. * @param worldMatrix is the world matrix of the particle system
  93863. * @param directionToUpdate is the direction vector to update with the result
  93864. * @param particle is the particle we are computed the direction for
  93865. * @param isLocal defines if the direction should be set in local space
  93866. */
  93867. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93868. /**
  93869. * Called by the particle System when the position is computed for the created particle.
  93870. * @param worldMatrix is the world matrix of the particle system
  93871. * @param positionToUpdate is the position vector to update with the result
  93872. * @param particle is the particle we are computed the position for
  93873. * @param isLocal defines if the position should be set in local space
  93874. */
  93875. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93876. /**
  93877. * Clones the current emitter and returns a copy of it
  93878. * @returns the new emitter
  93879. */
  93880. clone(): HemisphericParticleEmitter;
  93881. /**
  93882. * Called by the GPUParticleSystem to setup the update shader
  93883. * @param effect defines the update shader
  93884. */
  93885. applyToShader(effect: Effect): void;
  93886. /**
  93887. * Returns a string to use to update the GPU particles update shader
  93888. * @returns a string containng the defines string
  93889. */
  93890. getEffectDefines(): string;
  93891. /**
  93892. * Returns the string "HemisphericParticleEmitter"
  93893. * @returns a string containing the class name
  93894. */
  93895. getClassName(): string;
  93896. /**
  93897. * Serializes the particle system to a JSON object.
  93898. * @returns the JSON object
  93899. */
  93900. serialize(): any;
  93901. /**
  93902. * Parse properties from a JSON object
  93903. * @param serializationObject defines the JSON object
  93904. */
  93905. parse(serializationObject: any): void;
  93906. }
  93907. }
  93908. declare module BABYLON {
  93909. /**
  93910. * Particle emitter emitting particles from a point.
  93911. * It emits the particles randomly between 2 given directions.
  93912. */
  93913. export class PointParticleEmitter implements IParticleEmitterType {
  93914. /**
  93915. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93916. */
  93917. direction1: Vector3;
  93918. /**
  93919. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93920. */
  93921. direction2: Vector3;
  93922. /**
  93923. * Creates a new instance PointParticleEmitter
  93924. */
  93925. constructor();
  93926. /**
  93927. * Called by the particle System when the direction is computed for the created particle.
  93928. * @param worldMatrix is the world matrix of the particle system
  93929. * @param directionToUpdate is the direction vector to update with the result
  93930. * @param particle is the particle we are computed the direction for
  93931. * @param isLocal defines if the direction should be set in local space
  93932. */
  93933. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93934. /**
  93935. * Called by the particle System when the position is computed for the created particle.
  93936. * @param worldMatrix is the world matrix of the particle system
  93937. * @param positionToUpdate is the position vector to update with the result
  93938. * @param particle is the particle we are computed the position for
  93939. * @param isLocal defines if the position should be set in local space
  93940. */
  93941. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93942. /**
  93943. * Clones the current emitter and returns a copy of it
  93944. * @returns the new emitter
  93945. */
  93946. clone(): PointParticleEmitter;
  93947. /**
  93948. * Called by the GPUParticleSystem to setup the update shader
  93949. * @param effect defines the update shader
  93950. */
  93951. applyToShader(effect: Effect): void;
  93952. /**
  93953. * Returns a string to use to update the GPU particles update shader
  93954. * @returns a string containng the defines string
  93955. */
  93956. getEffectDefines(): string;
  93957. /**
  93958. * Returns the string "PointParticleEmitter"
  93959. * @returns a string containing the class name
  93960. */
  93961. getClassName(): string;
  93962. /**
  93963. * Serializes the particle system to a JSON object.
  93964. * @returns the JSON object
  93965. */
  93966. serialize(): any;
  93967. /**
  93968. * Parse properties from a JSON object
  93969. * @param serializationObject defines the JSON object
  93970. */
  93971. parse(serializationObject: any): void;
  93972. }
  93973. }
  93974. declare module BABYLON {
  93975. /**
  93976. * Particle emitter emitting particles from the inside of a sphere.
  93977. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  93978. */
  93979. export class SphereParticleEmitter implements IParticleEmitterType {
  93980. /**
  93981. * The radius of the emission sphere.
  93982. */
  93983. radius: number;
  93984. /**
  93985. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93986. */
  93987. radiusRange: number;
  93988. /**
  93989. * How much to randomize the particle direction [0-1].
  93990. */
  93991. directionRandomizer: number;
  93992. /**
  93993. * Creates a new instance SphereParticleEmitter
  93994. * @param radius the radius of the emission sphere (1 by default)
  93995. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93996. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93997. */
  93998. constructor(
  93999. /**
  94000. * The radius of the emission sphere.
  94001. */
  94002. radius?: number,
  94003. /**
  94004. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94005. */
  94006. radiusRange?: number,
  94007. /**
  94008. * How much to randomize the particle direction [0-1].
  94009. */
  94010. directionRandomizer?: number);
  94011. /**
  94012. * Called by the particle System when the direction is computed for the created particle.
  94013. * @param worldMatrix is the world matrix of the particle system
  94014. * @param directionToUpdate is the direction vector to update with the result
  94015. * @param particle is the particle we are computed the direction for
  94016. * @param isLocal defines if the direction should be set in local space
  94017. */
  94018. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94019. /**
  94020. * Called by the particle System when the position is computed for the created particle.
  94021. * @param worldMatrix is the world matrix of the particle system
  94022. * @param positionToUpdate is the position vector to update with the result
  94023. * @param particle is the particle we are computed the position for
  94024. * @param isLocal defines if the position should be set in local space
  94025. */
  94026. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94027. /**
  94028. * Clones the current emitter and returns a copy of it
  94029. * @returns the new emitter
  94030. */
  94031. clone(): SphereParticleEmitter;
  94032. /**
  94033. * Called by the GPUParticleSystem to setup the update shader
  94034. * @param effect defines the update shader
  94035. */
  94036. applyToShader(effect: Effect): void;
  94037. /**
  94038. * Returns a string to use to update the GPU particles update shader
  94039. * @returns a string containng the defines string
  94040. */
  94041. getEffectDefines(): string;
  94042. /**
  94043. * Returns the string "SphereParticleEmitter"
  94044. * @returns a string containing the class name
  94045. */
  94046. getClassName(): string;
  94047. /**
  94048. * Serializes the particle system to a JSON object.
  94049. * @returns the JSON object
  94050. */
  94051. serialize(): any;
  94052. /**
  94053. * Parse properties from a JSON object
  94054. * @param serializationObject defines the JSON object
  94055. */
  94056. parse(serializationObject: any): void;
  94057. }
  94058. /**
  94059. * Particle emitter emitting particles from the inside of a sphere.
  94060. * It emits the particles randomly between two vectors.
  94061. */
  94062. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94063. /**
  94064. * The min limit of the emission direction.
  94065. */
  94066. direction1: Vector3;
  94067. /**
  94068. * The max limit of the emission direction.
  94069. */
  94070. direction2: Vector3;
  94071. /**
  94072. * Creates a new instance SphereDirectedParticleEmitter
  94073. * @param radius the radius of the emission sphere (1 by default)
  94074. * @param direction1 the min limit of the emission direction (up vector by default)
  94075. * @param direction2 the max limit of the emission direction (up vector by default)
  94076. */
  94077. constructor(radius?: number,
  94078. /**
  94079. * The min limit of the emission direction.
  94080. */
  94081. direction1?: Vector3,
  94082. /**
  94083. * The max limit of the emission direction.
  94084. */
  94085. direction2?: Vector3);
  94086. /**
  94087. * Called by the particle System when the direction is computed for the created particle.
  94088. * @param worldMatrix is the world matrix of the particle system
  94089. * @param directionToUpdate is the direction vector to update with the result
  94090. * @param particle is the particle we are computed the direction for
  94091. */
  94092. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94093. /**
  94094. * Clones the current emitter and returns a copy of it
  94095. * @returns the new emitter
  94096. */
  94097. clone(): SphereDirectedParticleEmitter;
  94098. /**
  94099. * Called by the GPUParticleSystem to setup the update shader
  94100. * @param effect defines the update shader
  94101. */
  94102. applyToShader(effect: Effect): void;
  94103. /**
  94104. * Returns a string to use to update the GPU particles update shader
  94105. * @returns a string containng the defines string
  94106. */
  94107. getEffectDefines(): string;
  94108. /**
  94109. * Returns the string "SphereDirectedParticleEmitter"
  94110. * @returns a string containing the class name
  94111. */
  94112. getClassName(): string;
  94113. /**
  94114. * Serializes the particle system to a JSON object.
  94115. * @returns the JSON object
  94116. */
  94117. serialize(): any;
  94118. /**
  94119. * Parse properties from a JSON object
  94120. * @param serializationObject defines the JSON object
  94121. */
  94122. parse(serializationObject: any): void;
  94123. }
  94124. }
  94125. declare module BABYLON {
  94126. /**
  94127. * Particle emitter emitting particles from a custom list of positions.
  94128. */
  94129. export class CustomParticleEmitter implements IParticleEmitterType {
  94130. /**
  94131. * Gets or sets the position generator that will create the inital position of each particle.
  94132. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94133. */
  94134. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94135. /**
  94136. * Gets or sets the destination generator that will create the final destination of each particle.
  94137. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94138. */
  94139. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94140. /**
  94141. * Creates a new instance CustomParticleEmitter
  94142. */
  94143. constructor();
  94144. /**
  94145. * Called by the particle System when the direction is computed for the created particle.
  94146. * @param worldMatrix is the world matrix of the particle system
  94147. * @param directionToUpdate is the direction vector to update with the result
  94148. * @param particle is the particle we are computed the direction for
  94149. * @param isLocal defines if the direction should be set in local space
  94150. */
  94151. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94152. /**
  94153. * Called by the particle System when the position is computed for the created particle.
  94154. * @param worldMatrix is the world matrix of the particle system
  94155. * @param positionToUpdate is the position vector to update with the result
  94156. * @param particle is the particle we are computed the position for
  94157. * @param isLocal defines if the position should be set in local space
  94158. */
  94159. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94160. /**
  94161. * Clones the current emitter and returns a copy of it
  94162. * @returns the new emitter
  94163. */
  94164. clone(): CustomParticleEmitter;
  94165. /**
  94166. * Called by the GPUParticleSystem to setup the update shader
  94167. * @param effect defines the update shader
  94168. */
  94169. applyToShader(effect: Effect): void;
  94170. /**
  94171. * Returns a string to use to update the GPU particles update shader
  94172. * @returns a string containng the defines string
  94173. */
  94174. getEffectDefines(): string;
  94175. /**
  94176. * Returns the string "PointParticleEmitter"
  94177. * @returns a string containing the class name
  94178. */
  94179. getClassName(): string;
  94180. /**
  94181. * Serializes the particle system to a JSON object.
  94182. * @returns the JSON object
  94183. */
  94184. serialize(): any;
  94185. /**
  94186. * Parse properties from a JSON object
  94187. * @param serializationObject defines the JSON object
  94188. */
  94189. parse(serializationObject: any): void;
  94190. }
  94191. }
  94192. declare module BABYLON {
  94193. /**
  94194. * Particle emitter emitting particles from the inside of a box.
  94195. * It emits the particles randomly between 2 given directions.
  94196. */
  94197. export class MeshParticleEmitter implements IParticleEmitterType {
  94198. private _indices;
  94199. private _positions;
  94200. private _normals;
  94201. private _storedNormal;
  94202. private _mesh;
  94203. /**
  94204. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94205. */
  94206. direction1: Vector3;
  94207. /**
  94208. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94209. */
  94210. direction2: Vector3;
  94211. /**
  94212. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94213. */
  94214. useMeshNormalsForDirection: boolean;
  94215. /** Defines the mesh to use as source */
  94216. get mesh(): Nullable<AbstractMesh>;
  94217. set mesh(value: Nullable<AbstractMesh>);
  94218. /**
  94219. * Creates a new instance MeshParticleEmitter
  94220. * @param mesh defines the mesh to use as source
  94221. */
  94222. constructor(mesh?: Nullable<AbstractMesh>);
  94223. /**
  94224. * Called by the particle System when the direction is computed for the created particle.
  94225. * @param worldMatrix is the world matrix of the particle system
  94226. * @param directionToUpdate is the direction vector to update with the result
  94227. * @param particle is the particle we are computed the direction for
  94228. * @param isLocal defines if the direction should be set in local space
  94229. */
  94230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94231. /**
  94232. * Called by the particle System when the position is computed for the created particle.
  94233. * @param worldMatrix is the world matrix of the particle system
  94234. * @param positionToUpdate is the position vector to update with the result
  94235. * @param particle is the particle we are computed the position for
  94236. * @param isLocal defines if the position should be set in local space
  94237. */
  94238. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94239. /**
  94240. * Clones the current emitter and returns a copy of it
  94241. * @returns the new emitter
  94242. */
  94243. clone(): MeshParticleEmitter;
  94244. /**
  94245. * Called by the GPUParticleSystem to setup the update shader
  94246. * @param effect defines the update shader
  94247. */
  94248. applyToShader(effect: Effect): void;
  94249. /**
  94250. * Returns a string to use to update the GPU particles update shader
  94251. * @returns a string containng the defines string
  94252. */
  94253. getEffectDefines(): string;
  94254. /**
  94255. * Returns the string "BoxParticleEmitter"
  94256. * @returns a string containing the class name
  94257. */
  94258. getClassName(): string;
  94259. /**
  94260. * Serializes the particle system to a JSON object.
  94261. * @returns the JSON object
  94262. */
  94263. serialize(): any;
  94264. /**
  94265. * Parse properties from a JSON object
  94266. * @param serializationObject defines the JSON object
  94267. * @param scene defines the hosting scene
  94268. */
  94269. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94270. }
  94271. }
  94272. declare module BABYLON {
  94273. /**
  94274. * Interface representing a particle system in Babylon.js.
  94275. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94276. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94277. */
  94278. export interface IParticleSystem {
  94279. /**
  94280. * List of animations used by the particle system.
  94281. */
  94282. animations: Animation[];
  94283. /**
  94284. * The id of the Particle system.
  94285. */
  94286. id: string;
  94287. /**
  94288. * The name of the Particle system.
  94289. */
  94290. name: string;
  94291. /**
  94292. * The emitter represents the Mesh or position we are attaching the particle system to.
  94293. */
  94294. emitter: Nullable<AbstractMesh | Vector3>;
  94295. /**
  94296. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94297. */
  94298. isBillboardBased: boolean;
  94299. /**
  94300. * The rendering group used by the Particle system to chose when to render.
  94301. */
  94302. renderingGroupId: number;
  94303. /**
  94304. * The layer mask we are rendering the particles through.
  94305. */
  94306. layerMask: number;
  94307. /**
  94308. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94309. */
  94310. updateSpeed: number;
  94311. /**
  94312. * The amount of time the particle system is running (depends of the overall update speed).
  94313. */
  94314. targetStopDuration: number;
  94315. /**
  94316. * The texture used to render each particle. (this can be a spritesheet)
  94317. */
  94318. particleTexture: Nullable<BaseTexture>;
  94319. /**
  94320. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94321. */
  94322. blendMode: number;
  94323. /**
  94324. * Minimum life time of emitting particles.
  94325. */
  94326. minLifeTime: number;
  94327. /**
  94328. * Maximum life time of emitting particles.
  94329. */
  94330. maxLifeTime: number;
  94331. /**
  94332. * Minimum Size of emitting particles.
  94333. */
  94334. minSize: number;
  94335. /**
  94336. * Maximum Size of emitting particles.
  94337. */
  94338. maxSize: number;
  94339. /**
  94340. * Minimum scale of emitting particles on X axis.
  94341. */
  94342. minScaleX: number;
  94343. /**
  94344. * Maximum scale of emitting particles on X axis.
  94345. */
  94346. maxScaleX: number;
  94347. /**
  94348. * Minimum scale of emitting particles on Y axis.
  94349. */
  94350. minScaleY: number;
  94351. /**
  94352. * Maximum scale of emitting particles on Y axis.
  94353. */
  94354. maxScaleY: number;
  94355. /**
  94356. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94357. */
  94358. color1: Color4;
  94359. /**
  94360. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94361. */
  94362. color2: Color4;
  94363. /**
  94364. * Color the particle will have at the end of its lifetime.
  94365. */
  94366. colorDead: Color4;
  94367. /**
  94368. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94369. */
  94370. emitRate: number;
  94371. /**
  94372. * You can use gravity if you want to give an orientation to your particles.
  94373. */
  94374. gravity: Vector3;
  94375. /**
  94376. * Minimum power of emitting particles.
  94377. */
  94378. minEmitPower: number;
  94379. /**
  94380. * Maximum power of emitting particles.
  94381. */
  94382. maxEmitPower: number;
  94383. /**
  94384. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94385. */
  94386. minAngularSpeed: number;
  94387. /**
  94388. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94389. */
  94390. maxAngularSpeed: number;
  94391. /**
  94392. * Gets or sets the minimal initial rotation in radians.
  94393. */
  94394. minInitialRotation: number;
  94395. /**
  94396. * Gets or sets the maximal initial rotation in radians.
  94397. */
  94398. maxInitialRotation: number;
  94399. /**
  94400. * The particle emitter type defines the emitter used by the particle system.
  94401. * It can be for example box, sphere, or cone...
  94402. */
  94403. particleEmitterType: Nullable<IParticleEmitterType>;
  94404. /**
  94405. * Defines the delay in milliseconds before starting the system (0 by default)
  94406. */
  94407. startDelay: number;
  94408. /**
  94409. * 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
  94410. */
  94411. preWarmCycles: number;
  94412. /**
  94413. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94414. */
  94415. preWarmStepOffset: number;
  94416. /**
  94417. * 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)
  94418. */
  94419. spriteCellChangeSpeed: number;
  94420. /**
  94421. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94422. */
  94423. startSpriteCellID: number;
  94424. /**
  94425. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94426. */
  94427. endSpriteCellID: number;
  94428. /**
  94429. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94430. */
  94431. spriteCellWidth: number;
  94432. /**
  94433. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94434. */
  94435. spriteCellHeight: number;
  94436. /**
  94437. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94438. */
  94439. spriteRandomStartCell: boolean;
  94440. /**
  94441. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94442. */
  94443. isAnimationSheetEnabled: boolean;
  94444. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94445. translationPivot: Vector2;
  94446. /**
  94447. * Gets or sets a texture used to add random noise to particle positions
  94448. */
  94449. noiseTexture: Nullable<BaseTexture>;
  94450. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94451. noiseStrength: Vector3;
  94452. /**
  94453. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94454. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94455. */
  94456. billboardMode: number;
  94457. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94458. limitVelocityDamping: number;
  94459. /**
  94460. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94461. */
  94462. beginAnimationOnStart: boolean;
  94463. /**
  94464. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94465. */
  94466. beginAnimationFrom: number;
  94467. /**
  94468. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94469. */
  94470. beginAnimationTo: number;
  94471. /**
  94472. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94473. */
  94474. beginAnimationLoop: boolean;
  94475. /**
  94476. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94477. */
  94478. disposeOnStop: boolean;
  94479. /**
  94480. * Specifies if the particles are updated in emitter local space or world space
  94481. */
  94482. isLocal: boolean;
  94483. /** Snippet ID if the particle system was created from the snippet server */
  94484. snippetId: string;
  94485. /** Gets or sets a matrix to use to compute projection */
  94486. defaultProjectionMatrix: Matrix;
  94487. /**
  94488. * Gets the maximum number of particles active at the same time.
  94489. * @returns The max number of active particles.
  94490. */
  94491. getCapacity(): number;
  94492. /**
  94493. * Gets the number of particles active at the same time.
  94494. * @returns The number of active particles.
  94495. */
  94496. getActiveCount(): number;
  94497. /**
  94498. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94499. * @returns True if it has been started, otherwise false.
  94500. */
  94501. isStarted(): boolean;
  94502. /**
  94503. * Animates the particle system for this frame.
  94504. */
  94505. animate(): void;
  94506. /**
  94507. * Renders the particle system in its current state.
  94508. * @returns the current number of particles
  94509. */
  94510. render(): number;
  94511. /**
  94512. * Dispose the particle system and frees its associated resources.
  94513. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94514. */
  94515. dispose(disposeTexture?: boolean): void;
  94516. /**
  94517. * An event triggered when the system is disposed
  94518. */
  94519. onDisposeObservable: Observable<IParticleSystem>;
  94520. /**
  94521. * Clones the particle system.
  94522. * @param name The name of the cloned object
  94523. * @param newEmitter The new emitter to use
  94524. * @returns the cloned particle system
  94525. */
  94526. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94527. /**
  94528. * Serializes the particle system to a JSON object
  94529. * @param serializeTexture defines if the texture must be serialized as well
  94530. * @returns the JSON object
  94531. */
  94532. serialize(serializeTexture: boolean): any;
  94533. /**
  94534. * Rebuild the particle system
  94535. */
  94536. rebuild(): void;
  94537. /** Force the system to rebuild all gradients that need to be resync */
  94538. forceRefreshGradients(): void;
  94539. /**
  94540. * Starts the particle system and begins to emit
  94541. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94542. */
  94543. start(delay?: number): void;
  94544. /**
  94545. * Stops the particle system.
  94546. */
  94547. stop(): void;
  94548. /**
  94549. * Remove all active particles
  94550. */
  94551. reset(): void;
  94552. /**
  94553. * Gets a boolean indicating that the system is stopping
  94554. * @returns true if the system is currently stopping
  94555. */
  94556. isStopping(): boolean;
  94557. /**
  94558. * Is this system ready to be used/rendered
  94559. * @return true if the system is ready
  94560. */
  94561. isReady(): boolean;
  94562. /**
  94563. * Returns the string "ParticleSystem"
  94564. * @returns a string containing the class name
  94565. */
  94566. getClassName(): string;
  94567. /**
  94568. * Gets the custom effect used to render the particles
  94569. * @param blendMode Blend mode for which the effect should be retrieved
  94570. * @returns The effect
  94571. */
  94572. getCustomEffect(blendMode: number): Nullable<Effect>;
  94573. /**
  94574. * Sets the custom effect used to render the particles
  94575. * @param effect The effect to set
  94576. * @param blendMode Blend mode for which the effect should be set
  94577. */
  94578. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94579. /**
  94580. * Fill the defines array according to the current settings of the particle system
  94581. * @param defines Array to be updated
  94582. * @param blendMode blend mode to take into account when updating the array
  94583. */
  94584. fillDefines(defines: Array<string>, blendMode: number): void;
  94585. /**
  94586. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94587. * @param uniforms Uniforms array to fill
  94588. * @param attributes Attributes array to fill
  94589. * @param samplers Samplers array to fill
  94590. */
  94591. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94592. /**
  94593. * Observable that will be called just before the particles are drawn
  94594. */
  94595. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94596. /**
  94597. * Gets the name of the particle vertex shader
  94598. */
  94599. vertexShaderName: string;
  94600. /**
  94601. * Adds a new color gradient
  94602. * @param gradient defines the gradient to use (between 0 and 1)
  94603. * @param color1 defines the color to affect to the specified gradient
  94604. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94605. * @returns the current particle system
  94606. */
  94607. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94608. /**
  94609. * Remove a specific color gradient
  94610. * @param gradient defines the gradient to remove
  94611. * @returns the current particle system
  94612. */
  94613. removeColorGradient(gradient: number): IParticleSystem;
  94614. /**
  94615. * Adds a new size gradient
  94616. * @param gradient defines the gradient to use (between 0 and 1)
  94617. * @param factor defines the size factor to affect to the specified gradient
  94618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94619. * @returns the current particle system
  94620. */
  94621. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94622. /**
  94623. * Remove a specific size gradient
  94624. * @param gradient defines the gradient to remove
  94625. * @returns the current particle system
  94626. */
  94627. removeSizeGradient(gradient: number): IParticleSystem;
  94628. /**
  94629. * Gets the current list of color gradients.
  94630. * You must use addColorGradient and removeColorGradient to udpate this list
  94631. * @returns the list of color gradients
  94632. */
  94633. getColorGradients(): Nullable<Array<ColorGradient>>;
  94634. /**
  94635. * Gets the current list of size gradients.
  94636. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94637. * @returns the list of size gradients
  94638. */
  94639. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94640. /**
  94641. * Gets the current list of angular speed gradients.
  94642. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94643. * @returns the list of angular speed gradients
  94644. */
  94645. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94646. /**
  94647. * Adds a new angular speed gradient
  94648. * @param gradient defines the gradient to use (between 0 and 1)
  94649. * @param factor defines the angular speed to affect to the specified gradient
  94650. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94651. * @returns the current particle system
  94652. */
  94653. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94654. /**
  94655. * Remove a specific angular speed gradient
  94656. * @param gradient defines the gradient to remove
  94657. * @returns the current particle system
  94658. */
  94659. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94660. /**
  94661. * Gets the current list of velocity gradients.
  94662. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94663. * @returns the list of velocity gradients
  94664. */
  94665. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94666. /**
  94667. * Adds a new velocity gradient
  94668. * @param gradient defines the gradient to use (between 0 and 1)
  94669. * @param factor defines the velocity to affect to the specified gradient
  94670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94671. * @returns the current particle system
  94672. */
  94673. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94674. /**
  94675. * Remove a specific velocity gradient
  94676. * @param gradient defines the gradient to remove
  94677. * @returns the current particle system
  94678. */
  94679. removeVelocityGradient(gradient: number): IParticleSystem;
  94680. /**
  94681. * Gets the current list of limit velocity gradients.
  94682. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94683. * @returns the list of limit velocity gradients
  94684. */
  94685. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94686. /**
  94687. * Adds a new limit velocity gradient
  94688. * @param gradient defines the gradient to use (between 0 and 1)
  94689. * @param factor defines the limit velocity to affect to the specified gradient
  94690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94691. * @returns the current particle system
  94692. */
  94693. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94694. /**
  94695. * Remove a specific limit velocity gradient
  94696. * @param gradient defines the gradient to remove
  94697. * @returns the current particle system
  94698. */
  94699. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94700. /**
  94701. * Adds a new drag gradient
  94702. * @param gradient defines the gradient to use (between 0 and 1)
  94703. * @param factor defines the drag to affect to the specified gradient
  94704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94705. * @returns the current particle system
  94706. */
  94707. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94708. /**
  94709. * Remove a specific drag gradient
  94710. * @param gradient defines the gradient to remove
  94711. * @returns the current particle system
  94712. */
  94713. removeDragGradient(gradient: number): IParticleSystem;
  94714. /**
  94715. * Gets the current list of drag gradients.
  94716. * You must use addDragGradient and removeDragGradient to udpate this list
  94717. * @returns the list of drag gradients
  94718. */
  94719. getDragGradients(): Nullable<Array<FactorGradient>>;
  94720. /**
  94721. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94722. * @param gradient defines the gradient to use (between 0 and 1)
  94723. * @param factor defines the emit rate to affect to the specified gradient
  94724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94725. * @returns the current particle system
  94726. */
  94727. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94728. /**
  94729. * Remove a specific emit rate gradient
  94730. * @param gradient defines the gradient to remove
  94731. * @returns the current particle system
  94732. */
  94733. removeEmitRateGradient(gradient: number): IParticleSystem;
  94734. /**
  94735. * Gets the current list of emit rate gradients.
  94736. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94737. * @returns the list of emit rate gradients
  94738. */
  94739. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94740. /**
  94741. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94742. * @param gradient defines the gradient to use (between 0 and 1)
  94743. * @param factor defines the start size to affect to the specified gradient
  94744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94745. * @returns the current particle system
  94746. */
  94747. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94748. /**
  94749. * Remove a specific start size gradient
  94750. * @param gradient defines the gradient to remove
  94751. * @returns the current particle system
  94752. */
  94753. removeStartSizeGradient(gradient: number): IParticleSystem;
  94754. /**
  94755. * Gets the current list of start size gradients.
  94756. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94757. * @returns the list of start size gradients
  94758. */
  94759. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94760. /**
  94761. * Adds a new life time gradient
  94762. * @param gradient defines the gradient to use (between 0 and 1)
  94763. * @param factor defines the life time factor to affect to the specified gradient
  94764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94765. * @returns the current particle system
  94766. */
  94767. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94768. /**
  94769. * Remove a specific life time gradient
  94770. * @param gradient defines the gradient to remove
  94771. * @returns the current particle system
  94772. */
  94773. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94774. /**
  94775. * Gets the current list of life time gradients.
  94776. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94777. * @returns the list of life time gradients
  94778. */
  94779. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94780. /**
  94781. * Gets the current list of color gradients.
  94782. * You must use addColorGradient and removeColorGradient to udpate this list
  94783. * @returns the list of color gradients
  94784. */
  94785. getColorGradients(): Nullable<Array<ColorGradient>>;
  94786. /**
  94787. * Adds a new ramp gradient used to remap particle colors
  94788. * @param gradient defines the gradient to use (between 0 and 1)
  94789. * @param color defines the color to affect to the specified gradient
  94790. * @returns the current particle system
  94791. */
  94792. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94793. /**
  94794. * Gets the current list of ramp gradients.
  94795. * You must use addRampGradient and removeRampGradient to udpate this list
  94796. * @returns the list of ramp gradients
  94797. */
  94798. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94799. /** Gets or sets a boolean indicating that ramp gradients must be used
  94800. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94801. */
  94802. useRampGradients: boolean;
  94803. /**
  94804. * Adds a new color remap gradient
  94805. * @param gradient defines the gradient to use (between 0 and 1)
  94806. * @param min defines the color remap minimal range
  94807. * @param max defines the color remap maximal range
  94808. * @returns the current particle system
  94809. */
  94810. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94811. /**
  94812. * Gets the current list of color remap gradients.
  94813. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94814. * @returns the list of color remap gradients
  94815. */
  94816. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94817. /**
  94818. * Adds a new alpha remap gradient
  94819. * @param gradient defines the gradient to use (between 0 and 1)
  94820. * @param min defines the alpha remap minimal range
  94821. * @param max defines the alpha remap maximal range
  94822. * @returns the current particle system
  94823. */
  94824. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94825. /**
  94826. * Gets the current list of alpha remap gradients.
  94827. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94828. * @returns the list of alpha remap gradients
  94829. */
  94830. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94831. /**
  94832. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94833. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94834. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94835. * @returns the emitter
  94836. */
  94837. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94838. /**
  94839. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94840. * @param radius The radius of the hemisphere to emit from
  94841. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94842. * @returns the emitter
  94843. */
  94844. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94845. /**
  94846. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94847. * @param radius The radius of the sphere to emit from
  94848. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94849. * @returns the emitter
  94850. */
  94851. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94852. /**
  94853. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94854. * @param radius The radius of the sphere to emit from
  94855. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94856. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94857. * @returns the emitter
  94858. */
  94859. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94860. /**
  94861. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94862. * @param radius The radius of the emission cylinder
  94863. * @param height The height of the emission cylinder
  94864. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94865. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94866. * @returns the emitter
  94867. */
  94868. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94869. /**
  94870. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94871. * @param radius The radius of the cylinder to emit from
  94872. * @param height The height of the emission cylinder
  94873. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94874. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94875. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94876. * @returns the emitter
  94877. */
  94878. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94879. /**
  94880. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94881. * @param radius The radius of the cone to emit from
  94882. * @param angle The base angle of the cone
  94883. * @returns the emitter
  94884. */
  94885. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94886. /**
  94887. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94888. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94889. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94890. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94891. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94892. * @returns the emitter
  94893. */
  94894. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94895. /**
  94896. * Get hosting scene
  94897. * @returns the scene
  94898. */
  94899. getScene(): Nullable<Scene>;
  94900. }
  94901. }
  94902. declare module BABYLON {
  94903. /**
  94904. * 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.
  94905. * @see https://doc.babylonjs.com/how_to/transformnode
  94906. */
  94907. export class TransformNode extends Node {
  94908. /**
  94909. * Object will not rotate to face the camera
  94910. */
  94911. static BILLBOARDMODE_NONE: number;
  94912. /**
  94913. * Object will rotate to face the camera but only on the x axis
  94914. */
  94915. static BILLBOARDMODE_X: number;
  94916. /**
  94917. * Object will rotate to face the camera but only on the y axis
  94918. */
  94919. static BILLBOARDMODE_Y: number;
  94920. /**
  94921. * Object will rotate to face the camera but only on the z axis
  94922. */
  94923. static BILLBOARDMODE_Z: number;
  94924. /**
  94925. * Object will rotate to face the camera
  94926. */
  94927. static BILLBOARDMODE_ALL: number;
  94928. /**
  94929. * Object will rotate to face the camera's position instead of orientation
  94930. */
  94931. static BILLBOARDMODE_USE_POSITION: number;
  94932. private static _TmpRotation;
  94933. private static _TmpScaling;
  94934. private static _TmpTranslation;
  94935. private _forward;
  94936. private _forwardInverted;
  94937. private _up;
  94938. private _right;
  94939. private _rightInverted;
  94940. private _position;
  94941. private _rotation;
  94942. private _rotationQuaternion;
  94943. protected _scaling: Vector3;
  94944. protected _isDirty: boolean;
  94945. private _transformToBoneReferal;
  94946. private _isAbsoluteSynced;
  94947. private _billboardMode;
  94948. /**
  94949. * Gets or sets the billboard mode. Default is 0.
  94950. *
  94951. * | Value | Type | Description |
  94952. * | --- | --- | --- |
  94953. * | 0 | BILLBOARDMODE_NONE | |
  94954. * | 1 | BILLBOARDMODE_X | |
  94955. * | 2 | BILLBOARDMODE_Y | |
  94956. * | 4 | BILLBOARDMODE_Z | |
  94957. * | 7 | BILLBOARDMODE_ALL | |
  94958. *
  94959. */
  94960. get billboardMode(): number;
  94961. set billboardMode(value: number);
  94962. private _preserveParentRotationForBillboard;
  94963. /**
  94964. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  94965. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  94966. */
  94967. get preserveParentRotationForBillboard(): boolean;
  94968. set preserveParentRotationForBillboard(value: boolean);
  94969. /**
  94970. * 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
  94971. */
  94972. scalingDeterminant: number;
  94973. private _infiniteDistance;
  94974. /**
  94975. * Gets or sets the distance of the object to max, often used by skybox
  94976. */
  94977. get infiniteDistance(): boolean;
  94978. set infiniteDistance(value: boolean);
  94979. /**
  94980. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  94981. * By default the system will update normals to compensate
  94982. */
  94983. ignoreNonUniformScaling: boolean;
  94984. /**
  94985. * 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
  94986. */
  94987. reIntegrateRotationIntoRotationQuaternion: boolean;
  94988. /** @hidden */
  94989. _poseMatrix: Nullable<Matrix>;
  94990. /** @hidden */
  94991. _localMatrix: Matrix;
  94992. private _usePivotMatrix;
  94993. private _absolutePosition;
  94994. private _absoluteScaling;
  94995. private _absoluteRotationQuaternion;
  94996. private _pivotMatrix;
  94997. private _pivotMatrixInverse;
  94998. /** @hidden */
  94999. _postMultiplyPivotMatrix: boolean;
  95000. protected _isWorldMatrixFrozen: boolean;
  95001. /** @hidden */
  95002. _indexInSceneTransformNodesArray: number;
  95003. /**
  95004. * An event triggered after the world matrix is updated
  95005. */
  95006. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95007. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95008. /**
  95009. * Gets a string identifying the name of the class
  95010. * @returns "TransformNode" string
  95011. */
  95012. getClassName(): string;
  95013. /**
  95014. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95015. */
  95016. get position(): Vector3;
  95017. set position(newPosition: Vector3);
  95018. /**
  95019. * 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)).
  95020. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95021. */
  95022. get rotation(): Vector3;
  95023. set rotation(newRotation: Vector3);
  95024. /**
  95025. * 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)).
  95026. */
  95027. get scaling(): Vector3;
  95028. set scaling(newScaling: Vector3);
  95029. /**
  95030. * 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).
  95031. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95032. */
  95033. get rotationQuaternion(): Nullable<Quaternion>;
  95034. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95035. /**
  95036. * The forward direction of that transform in world space.
  95037. */
  95038. get forward(): Vector3;
  95039. /**
  95040. * The up direction of that transform in world space.
  95041. */
  95042. get up(): Vector3;
  95043. /**
  95044. * The right direction of that transform in world space.
  95045. */
  95046. get right(): Vector3;
  95047. /**
  95048. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95049. * @param matrix the matrix to copy the pose from
  95050. * @returns this TransformNode.
  95051. */
  95052. updatePoseMatrix(matrix: Matrix): TransformNode;
  95053. /**
  95054. * Returns the mesh Pose matrix.
  95055. * @returns the pose matrix
  95056. */
  95057. getPoseMatrix(): Matrix;
  95058. /** @hidden */
  95059. _isSynchronized(): boolean;
  95060. /** @hidden */
  95061. _initCache(): void;
  95062. /**
  95063. * Flag the transform node as dirty (Forcing it to update everything)
  95064. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95065. * @returns this transform node
  95066. */
  95067. markAsDirty(property: string): TransformNode;
  95068. /**
  95069. * Returns the current mesh absolute position.
  95070. * Returns a Vector3.
  95071. */
  95072. get absolutePosition(): Vector3;
  95073. /**
  95074. * Returns the current mesh absolute scaling.
  95075. * Returns a Vector3.
  95076. */
  95077. get absoluteScaling(): Vector3;
  95078. /**
  95079. * Returns the current mesh absolute rotation.
  95080. * Returns a Quaternion.
  95081. */
  95082. get absoluteRotationQuaternion(): Quaternion;
  95083. /**
  95084. * Sets a new matrix to apply before all other transformation
  95085. * @param matrix defines the transform matrix
  95086. * @returns the current TransformNode
  95087. */
  95088. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95089. /**
  95090. * Sets a new pivot matrix to the current node
  95091. * @param matrix defines the new pivot matrix to use
  95092. * @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
  95093. * @returns the current TransformNode
  95094. */
  95095. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95096. /**
  95097. * Returns the mesh pivot matrix.
  95098. * Default : Identity.
  95099. * @returns the matrix
  95100. */
  95101. getPivotMatrix(): Matrix;
  95102. /**
  95103. * Instantiate (when possible) or clone that node with its hierarchy
  95104. * @param newParent defines the new parent to use for the instance (or clone)
  95105. * @param options defines options to configure how copy is done
  95106. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95107. * @returns an instance (or a clone) of the current node with its hiearchy
  95108. */
  95109. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95110. doNotInstantiate: boolean;
  95111. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95112. /**
  95113. * Prevents the World matrix to be computed any longer
  95114. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95115. * @returns the TransformNode.
  95116. */
  95117. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95118. /**
  95119. * Allows back the World matrix computation.
  95120. * @returns the TransformNode.
  95121. */
  95122. unfreezeWorldMatrix(): this;
  95123. /**
  95124. * True if the World matrix has been frozen.
  95125. */
  95126. get isWorldMatrixFrozen(): boolean;
  95127. /**
  95128. * Retuns the mesh absolute position in the World.
  95129. * @returns a Vector3.
  95130. */
  95131. getAbsolutePosition(): Vector3;
  95132. /**
  95133. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95134. * @param absolutePosition the absolute position to set
  95135. * @returns the TransformNode.
  95136. */
  95137. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95138. /**
  95139. * Sets the mesh position in its local space.
  95140. * @param vector3 the position to set in localspace
  95141. * @returns the TransformNode.
  95142. */
  95143. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95144. /**
  95145. * Returns the mesh position in the local space from the current World matrix values.
  95146. * @returns a new Vector3.
  95147. */
  95148. getPositionExpressedInLocalSpace(): Vector3;
  95149. /**
  95150. * Translates the mesh along the passed Vector3 in its local space.
  95151. * @param vector3 the distance to translate in localspace
  95152. * @returns the TransformNode.
  95153. */
  95154. locallyTranslate(vector3: Vector3): TransformNode;
  95155. private static _lookAtVectorCache;
  95156. /**
  95157. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95158. * @param targetPoint the position (must be in same space as current mesh) to look at
  95159. * @param yawCor optional yaw (y-axis) correction in radians
  95160. * @param pitchCor optional pitch (x-axis) correction in radians
  95161. * @param rollCor optional roll (z-axis) correction in radians
  95162. * @param space the choosen space of the target
  95163. * @returns the TransformNode.
  95164. */
  95165. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95166. /**
  95167. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95168. * This Vector3 is expressed in the World space.
  95169. * @param localAxis axis to rotate
  95170. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95171. */
  95172. getDirection(localAxis: Vector3): Vector3;
  95173. /**
  95174. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95175. * localAxis is expressed in the mesh local space.
  95176. * result is computed in the Wordl space from the mesh World matrix.
  95177. * @param localAxis axis to rotate
  95178. * @param result the resulting transformnode
  95179. * @returns this TransformNode.
  95180. */
  95181. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95182. /**
  95183. * Sets this transform node rotation to the given local axis.
  95184. * @param localAxis the axis in local space
  95185. * @param yawCor optional yaw (y-axis) correction in radians
  95186. * @param pitchCor optional pitch (x-axis) correction in radians
  95187. * @param rollCor optional roll (z-axis) correction in radians
  95188. * @returns this TransformNode
  95189. */
  95190. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95191. /**
  95192. * Sets a new pivot point to the current node
  95193. * @param point defines the new pivot point to use
  95194. * @param space defines if the point is in world or local space (local by default)
  95195. * @returns the current TransformNode
  95196. */
  95197. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95198. /**
  95199. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95200. * @returns the pivot point
  95201. */
  95202. getPivotPoint(): Vector3;
  95203. /**
  95204. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95205. * @param result the vector3 to store the result
  95206. * @returns this TransformNode.
  95207. */
  95208. getPivotPointToRef(result: Vector3): TransformNode;
  95209. /**
  95210. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95211. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95212. */
  95213. getAbsolutePivotPoint(): Vector3;
  95214. /**
  95215. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95216. * @param result vector3 to store the result
  95217. * @returns this TransformNode.
  95218. */
  95219. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95220. /**
  95221. * Defines the passed node as the parent of the current node.
  95222. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95223. * @see https://doc.babylonjs.com/how_to/parenting
  95224. * @param node the node ot set as the parent
  95225. * @returns this TransformNode.
  95226. */
  95227. setParent(node: Nullable<Node>): TransformNode;
  95228. private _nonUniformScaling;
  95229. /**
  95230. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95231. */
  95232. get nonUniformScaling(): boolean;
  95233. /** @hidden */
  95234. _updateNonUniformScalingState(value: boolean): boolean;
  95235. /**
  95236. * Attach the current TransformNode to another TransformNode associated with a bone
  95237. * @param bone Bone affecting the TransformNode
  95238. * @param affectedTransformNode TransformNode associated with the bone
  95239. * @returns this object
  95240. */
  95241. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95242. /**
  95243. * Detach the transform node if its associated with a bone
  95244. * @returns this object
  95245. */
  95246. detachFromBone(): TransformNode;
  95247. private static _rotationAxisCache;
  95248. /**
  95249. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95250. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95251. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95252. * The passed axis is also normalized.
  95253. * @param axis the axis to rotate around
  95254. * @param amount the amount to rotate in radians
  95255. * @param space Space to rotate in (Default: local)
  95256. * @returns the TransformNode.
  95257. */
  95258. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95259. /**
  95260. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95261. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95262. * The passed axis is also normalized. .
  95263. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95264. * @param point the point to rotate around
  95265. * @param axis the axis to rotate around
  95266. * @param amount the amount to rotate in radians
  95267. * @returns the TransformNode
  95268. */
  95269. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95270. /**
  95271. * Translates the mesh along the axis vector for the passed distance in the given space.
  95272. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95273. * @param axis the axis to translate in
  95274. * @param distance the distance to translate
  95275. * @param space Space to rotate in (Default: local)
  95276. * @returns the TransformNode.
  95277. */
  95278. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95279. /**
  95280. * Adds a rotation step to the mesh current rotation.
  95281. * x, y, z are Euler angles expressed in radians.
  95282. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95283. * This means this rotation is made in the mesh local space only.
  95284. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95285. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95286. * ```javascript
  95287. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95288. * ```
  95289. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95290. * 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.
  95291. * @param x Rotation to add
  95292. * @param y Rotation to add
  95293. * @param z Rotation to add
  95294. * @returns the TransformNode.
  95295. */
  95296. addRotation(x: number, y: number, z: number): TransformNode;
  95297. /**
  95298. * @hidden
  95299. */
  95300. protected _getEffectiveParent(): Nullable<Node>;
  95301. /**
  95302. * Computes the world matrix of the node
  95303. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95304. * @returns the world matrix
  95305. */
  95306. computeWorldMatrix(force?: boolean): Matrix;
  95307. /**
  95308. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95309. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95310. */
  95311. resetLocalMatrix(independentOfChildren?: boolean): void;
  95312. protected _afterComputeWorldMatrix(): void;
  95313. /**
  95314. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95315. * @param func callback function to add
  95316. *
  95317. * @returns the TransformNode.
  95318. */
  95319. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95320. /**
  95321. * Removes a registered callback function.
  95322. * @param func callback function to remove
  95323. * @returns the TransformNode.
  95324. */
  95325. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95326. /**
  95327. * Gets the position of the current mesh in camera space
  95328. * @param camera defines the camera to use
  95329. * @returns a position
  95330. */
  95331. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95332. /**
  95333. * Returns the distance from the mesh to the active camera
  95334. * @param camera defines the camera to use
  95335. * @returns the distance
  95336. */
  95337. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95338. /**
  95339. * Clone the current transform node
  95340. * @param name Name of the new clone
  95341. * @param newParent New parent for the clone
  95342. * @param doNotCloneChildren Do not clone children hierarchy
  95343. * @returns the new transform node
  95344. */
  95345. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95346. /**
  95347. * Serializes the objects information.
  95348. * @param currentSerializationObject defines the object to serialize in
  95349. * @returns the serialized object
  95350. */
  95351. serialize(currentSerializationObject?: any): any;
  95352. /**
  95353. * Returns a new TransformNode object parsed from the source provided.
  95354. * @param parsedTransformNode is the source.
  95355. * @param scene the scne the object belongs to
  95356. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95357. * @returns a new TransformNode object parsed from the source provided.
  95358. */
  95359. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95360. /**
  95361. * Get all child-transformNodes of this node
  95362. * @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
  95363. * @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
  95364. * @returns an array of TransformNode
  95365. */
  95366. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95367. /**
  95368. * Releases resources associated with this transform node.
  95369. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95370. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95371. */
  95372. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95373. /**
  95374. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95375. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95376. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95377. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95378. * @returns the current mesh
  95379. */
  95380. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95381. private _syncAbsoluteScalingAndRotation;
  95382. }
  95383. }
  95384. declare module BABYLON {
  95385. /**
  95386. * Class used to override all child animations of a given target
  95387. */
  95388. export class AnimationPropertiesOverride {
  95389. /**
  95390. * Gets or sets a value indicating if animation blending must be used
  95391. */
  95392. enableBlending: boolean;
  95393. /**
  95394. * Gets or sets the blending speed to use when enableBlending is true
  95395. */
  95396. blendingSpeed: number;
  95397. /**
  95398. * Gets or sets the default loop mode to use
  95399. */
  95400. loopMode: number;
  95401. }
  95402. }
  95403. declare module BABYLON {
  95404. /**
  95405. * Class used to store bone information
  95406. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95407. */
  95408. export class Bone extends Node {
  95409. /**
  95410. * defines the bone name
  95411. */
  95412. name: string;
  95413. private static _tmpVecs;
  95414. private static _tmpQuat;
  95415. private static _tmpMats;
  95416. /**
  95417. * Gets the list of child bones
  95418. */
  95419. children: Bone[];
  95420. /** Gets the animations associated with this bone */
  95421. animations: Animation[];
  95422. /**
  95423. * Gets or sets bone length
  95424. */
  95425. length: number;
  95426. /**
  95427. * @hidden Internal only
  95428. * Set this value to map this bone to a different index in the transform matrices
  95429. * Set this value to -1 to exclude the bone from the transform matrices
  95430. */
  95431. _index: Nullable<number>;
  95432. private _skeleton;
  95433. private _localMatrix;
  95434. private _restPose;
  95435. private _bindPose;
  95436. private _baseMatrix;
  95437. private _absoluteTransform;
  95438. private _invertedAbsoluteTransform;
  95439. private _parent;
  95440. private _scalingDeterminant;
  95441. private _worldTransform;
  95442. private _localScaling;
  95443. private _localRotation;
  95444. private _localPosition;
  95445. private _needToDecompose;
  95446. private _needToCompose;
  95447. /** @hidden */
  95448. _linkedTransformNode: Nullable<TransformNode>;
  95449. /** @hidden */
  95450. _waitingTransformNodeId: Nullable<string>;
  95451. /** @hidden */
  95452. get _matrix(): Matrix;
  95453. /** @hidden */
  95454. set _matrix(value: Matrix);
  95455. /**
  95456. * Create a new bone
  95457. * @param name defines the bone name
  95458. * @param skeleton defines the parent skeleton
  95459. * @param parentBone defines the parent (can be null if the bone is the root)
  95460. * @param localMatrix defines the local matrix
  95461. * @param restPose defines the rest pose matrix
  95462. * @param baseMatrix defines the base matrix
  95463. * @param index defines index of the bone in the hiearchy
  95464. */
  95465. constructor(
  95466. /**
  95467. * defines the bone name
  95468. */
  95469. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95470. /**
  95471. * Gets the current object class name.
  95472. * @return the class name
  95473. */
  95474. getClassName(): string;
  95475. /**
  95476. * Gets the parent skeleton
  95477. * @returns a skeleton
  95478. */
  95479. getSkeleton(): Skeleton;
  95480. /**
  95481. * Gets parent bone
  95482. * @returns a bone or null if the bone is the root of the bone hierarchy
  95483. */
  95484. getParent(): Nullable<Bone>;
  95485. /**
  95486. * Returns an array containing the root bones
  95487. * @returns an array containing the root bones
  95488. */
  95489. getChildren(): Array<Bone>;
  95490. /**
  95491. * Gets the node index in matrix array generated for rendering
  95492. * @returns the node index
  95493. */
  95494. getIndex(): number;
  95495. /**
  95496. * Sets the parent bone
  95497. * @param parent defines the parent (can be null if the bone is the root)
  95498. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95499. */
  95500. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95501. /**
  95502. * Gets the local matrix
  95503. * @returns a matrix
  95504. */
  95505. getLocalMatrix(): Matrix;
  95506. /**
  95507. * Gets the base matrix (initial matrix which remains unchanged)
  95508. * @returns a matrix
  95509. */
  95510. getBaseMatrix(): Matrix;
  95511. /**
  95512. * Gets the rest pose matrix
  95513. * @returns a matrix
  95514. */
  95515. getRestPose(): Matrix;
  95516. /**
  95517. * Sets the rest pose matrix
  95518. * @param matrix the local-space rest pose to set for this bone
  95519. */
  95520. setRestPose(matrix: Matrix): void;
  95521. /**
  95522. * Gets the bind pose matrix
  95523. * @returns the bind pose matrix
  95524. */
  95525. getBindPose(): Matrix;
  95526. /**
  95527. * Sets the bind pose matrix
  95528. * @param matrix the local-space bind pose to set for this bone
  95529. */
  95530. setBindPose(matrix: Matrix): void;
  95531. /**
  95532. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95533. */
  95534. getWorldMatrix(): Matrix;
  95535. /**
  95536. * Sets the local matrix to rest pose matrix
  95537. */
  95538. returnToRest(): void;
  95539. /**
  95540. * Gets the inverse of the absolute transform matrix.
  95541. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95542. * @returns a matrix
  95543. */
  95544. getInvertedAbsoluteTransform(): Matrix;
  95545. /**
  95546. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95547. * @returns a matrix
  95548. */
  95549. getAbsoluteTransform(): Matrix;
  95550. /**
  95551. * Links with the given transform node.
  95552. * The local matrix of this bone is copied from the transform node every frame.
  95553. * @param transformNode defines the transform node to link to
  95554. */
  95555. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95556. /**
  95557. * Gets the node used to drive the bone's transformation
  95558. * @returns a transform node or null
  95559. */
  95560. getTransformNode(): Nullable<TransformNode>;
  95561. /** Gets or sets current position (in local space) */
  95562. get position(): Vector3;
  95563. set position(newPosition: Vector3);
  95564. /** Gets or sets current rotation (in local space) */
  95565. get rotation(): Vector3;
  95566. set rotation(newRotation: Vector3);
  95567. /** Gets or sets current rotation quaternion (in local space) */
  95568. get rotationQuaternion(): Quaternion;
  95569. set rotationQuaternion(newRotation: Quaternion);
  95570. /** Gets or sets current scaling (in local space) */
  95571. get scaling(): Vector3;
  95572. set scaling(newScaling: Vector3);
  95573. /**
  95574. * Gets the animation properties override
  95575. */
  95576. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95577. private _decompose;
  95578. private _compose;
  95579. /**
  95580. * Update the base and local matrices
  95581. * @param matrix defines the new base or local matrix
  95582. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95583. * @param updateLocalMatrix defines if the local matrix should be updated
  95584. */
  95585. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95586. /** @hidden */
  95587. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95588. /**
  95589. * Flag the bone as dirty (Forcing it to update everything)
  95590. */
  95591. markAsDirty(): void;
  95592. /** @hidden */
  95593. _markAsDirtyAndCompose(): void;
  95594. private _markAsDirtyAndDecompose;
  95595. /**
  95596. * Translate the bone in local or world space
  95597. * @param vec The amount to translate the bone
  95598. * @param space The space that the translation is in
  95599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95600. */
  95601. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95602. /**
  95603. * Set the postion of the bone in local or world space
  95604. * @param position The position to set the bone
  95605. * @param space The space that the position is in
  95606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95607. */
  95608. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95609. /**
  95610. * Set the absolute position of the bone (world space)
  95611. * @param position The position to set the bone
  95612. * @param mesh The mesh that this bone is attached to
  95613. */
  95614. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95615. /**
  95616. * Scale the bone on the x, y and z axes (in local space)
  95617. * @param x The amount to scale the bone on the x axis
  95618. * @param y The amount to scale the bone on the y axis
  95619. * @param z The amount to scale the bone on the z axis
  95620. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95621. */
  95622. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95623. /**
  95624. * Set the bone scaling in local space
  95625. * @param scale defines the scaling vector
  95626. */
  95627. setScale(scale: Vector3): void;
  95628. /**
  95629. * Gets the current scaling in local space
  95630. * @returns the current scaling vector
  95631. */
  95632. getScale(): Vector3;
  95633. /**
  95634. * Gets the current scaling in local space and stores it in a target vector
  95635. * @param result defines the target vector
  95636. */
  95637. getScaleToRef(result: Vector3): void;
  95638. /**
  95639. * Set the yaw, pitch, and roll of the bone in local or world space
  95640. * @param yaw The rotation of the bone on the y axis
  95641. * @param pitch The rotation of the bone on the x axis
  95642. * @param roll The rotation of the bone on the z axis
  95643. * @param space The space that the axes of rotation are in
  95644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95645. */
  95646. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95647. /**
  95648. * Add a rotation to the bone on an axis in local or world space
  95649. * @param axis The axis to rotate the bone on
  95650. * @param amount The amount to rotate the bone
  95651. * @param space The space that the axis is in
  95652. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95653. */
  95654. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95655. /**
  95656. * Set the rotation of the bone to a particular axis angle in local or world space
  95657. * @param axis The axis to rotate the bone on
  95658. * @param angle The angle that the bone should be rotated to
  95659. * @param space The space that the axis is in
  95660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95661. */
  95662. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95663. /**
  95664. * Set the euler rotation of the bone in local or world space
  95665. * @param rotation The euler rotation that the bone should be set to
  95666. * @param space The space that the rotation is in
  95667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95668. */
  95669. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95670. /**
  95671. * Set the quaternion rotation of the bone in local or world space
  95672. * @param quat The quaternion rotation that the bone should be set to
  95673. * @param space The space that the rotation is in
  95674. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95675. */
  95676. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95677. /**
  95678. * Set the rotation matrix of the bone in local or world space
  95679. * @param rotMat The rotation matrix that the bone should be set to
  95680. * @param space The space that the rotation is in
  95681. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95682. */
  95683. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95684. private _rotateWithMatrix;
  95685. private _getNegativeRotationToRef;
  95686. /**
  95687. * Get the position of the bone in local or world space
  95688. * @param space The space that the returned position is in
  95689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95690. * @returns The position of the bone
  95691. */
  95692. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95693. /**
  95694. * Copy the position of the bone to a vector3 in local or world space
  95695. * @param space The space that the returned position is in
  95696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95697. * @param result The vector3 to copy the position to
  95698. */
  95699. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95700. /**
  95701. * Get the absolute position of the bone (world space)
  95702. * @param mesh The mesh that this bone is attached to
  95703. * @returns The absolute position of the bone
  95704. */
  95705. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95706. /**
  95707. * Copy the absolute position of the bone (world space) to the result param
  95708. * @param mesh The mesh that this bone is attached to
  95709. * @param result The vector3 to copy the absolute position to
  95710. */
  95711. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95712. /**
  95713. * Compute the absolute transforms of this bone and its children
  95714. */
  95715. computeAbsoluteTransforms(): void;
  95716. /**
  95717. * Get the world direction from an axis that is in the local space of the bone
  95718. * @param localAxis The local direction that is used to compute the world direction
  95719. * @param mesh The mesh that this bone is attached to
  95720. * @returns The world direction
  95721. */
  95722. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95723. /**
  95724. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95725. * @param localAxis The local direction that is used to compute the world direction
  95726. * @param mesh The mesh that this bone is attached to
  95727. * @param result The vector3 that the world direction will be copied to
  95728. */
  95729. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95730. /**
  95731. * Get the euler rotation of the bone in local or world space
  95732. * @param space The space that the rotation should be in
  95733. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95734. * @returns The euler rotation
  95735. */
  95736. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95737. /**
  95738. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95739. * @param space The space that the rotation should be in
  95740. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95741. * @param result The vector3 that the rotation should be copied to
  95742. */
  95743. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95744. /**
  95745. * Get the quaternion rotation of the bone in either local or world space
  95746. * @param space The space that the rotation should be in
  95747. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95748. * @returns The quaternion rotation
  95749. */
  95750. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95751. /**
  95752. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95753. * @param space The space that the rotation should be in
  95754. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95755. * @param result The quaternion that the rotation should be copied to
  95756. */
  95757. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95758. /**
  95759. * Get the rotation matrix of the bone in local or world space
  95760. * @param space The space that the rotation should be in
  95761. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95762. * @returns The rotation matrix
  95763. */
  95764. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95765. /**
  95766. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95767. * @param space The space that the rotation should be in
  95768. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95769. * @param result The quaternion that the rotation should be copied to
  95770. */
  95771. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95772. /**
  95773. * Get the world position of a point that is in the local space of the bone
  95774. * @param position The local position
  95775. * @param mesh The mesh that this bone is attached to
  95776. * @returns The world position
  95777. */
  95778. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95779. /**
  95780. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95781. * @param position The local position
  95782. * @param mesh The mesh that this bone is attached to
  95783. * @param result The vector3 that the world position should be copied to
  95784. */
  95785. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95786. /**
  95787. * Get the local position of a point that is in world space
  95788. * @param position The world position
  95789. * @param mesh The mesh that this bone is attached to
  95790. * @returns The local position
  95791. */
  95792. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95793. /**
  95794. * Get the local position of a point that is in world space and copy it to the result param
  95795. * @param position The world position
  95796. * @param mesh The mesh that this bone is attached to
  95797. * @param result The vector3 that the local position should be copied to
  95798. */
  95799. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95800. /**
  95801. * Set the current local matrix as the restPose for this bone.
  95802. */
  95803. setCurrentPoseAsRest(): void;
  95804. }
  95805. }
  95806. declare module BABYLON {
  95807. /**
  95808. * Defines a runtime animation
  95809. */
  95810. export class RuntimeAnimation {
  95811. private _events;
  95812. /**
  95813. * The current frame of the runtime animation
  95814. */
  95815. private _currentFrame;
  95816. /**
  95817. * The animation used by the runtime animation
  95818. */
  95819. private _animation;
  95820. /**
  95821. * The target of the runtime animation
  95822. */
  95823. private _target;
  95824. /**
  95825. * The initiating animatable
  95826. */
  95827. private _host;
  95828. /**
  95829. * The original value of the runtime animation
  95830. */
  95831. private _originalValue;
  95832. /**
  95833. * The original blend value of the runtime animation
  95834. */
  95835. private _originalBlendValue;
  95836. /**
  95837. * The offsets cache of the runtime animation
  95838. */
  95839. private _offsetsCache;
  95840. /**
  95841. * The high limits cache of the runtime animation
  95842. */
  95843. private _highLimitsCache;
  95844. /**
  95845. * Specifies if the runtime animation has been stopped
  95846. */
  95847. private _stopped;
  95848. /**
  95849. * The blending factor of the runtime animation
  95850. */
  95851. private _blendingFactor;
  95852. /**
  95853. * The BabylonJS scene
  95854. */
  95855. private _scene;
  95856. /**
  95857. * The current value of the runtime animation
  95858. */
  95859. private _currentValue;
  95860. /** @hidden */
  95861. _animationState: _IAnimationState;
  95862. /**
  95863. * The active target of the runtime animation
  95864. */
  95865. private _activeTargets;
  95866. private _currentActiveTarget;
  95867. private _directTarget;
  95868. /**
  95869. * The target path of the runtime animation
  95870. */
  95871. private _targetPath;
  95872. /**
  95873. * The weight of the runtime animation
  95874. */
  95875. private _weight;
  95876. /**
  95877. * The ratio offset of the runtime animation
  95878. */
  95879. private _ratioOffset;
  95880. /**
  95881. * The previous delay of the runtime animation
  95882. */
  95883. private _previousDelay;
  95884. /**
  95885. * The previous ratio of the runtime animation
  95886. */
  95887. private _previousRatio;
  95888. private _enableBlending;
  95889. private _keys;
  95890. private _minFrame;
  95891. private _maxFrame;
  95892. private _minValue;
  95893. private _maxValue;
  95894. private _targetIsArray;
  95895. /**
  95896. * Gets the current frame of the runtime animation
  95897. */
  95898. get currentFrame(): number;
  95899. /**
  95900. * Gets the weight of the runtime animation
  95901. */
  95902. get weight(): number;
  95903. /**
  95904. * Gets the current value of the runtime animation
  95905. */
  95906. get currentValue(): any;
  95907. /**
  95908. * Gets the target path of the runtime animation
  95909. */
  95910. get targetPath(): string;
  95911. /**
  95912. * Gets the actual target of the runtime animation
  95913. */
  95914. get target(): any;
  95915. /**
  95916. * Gets the additive state of the runtime animation
  95917. */
  95918. get isAdditive(): boolean;
  95919. /** @hidden */
  95920. _onLoop: () => void;
  95921. /**
  95922. * Create a new RuntimeAnimation object
  95923. * @param target defines the target of the animation
  95924. * @param animation defines the source animation object
  95925. * @param scene defines the hosting scene
  95926. * @param host defines the initiating Animatable
  95927. */
  95928. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  95929. private _preparePath;
  95930. /**
  95931. * Gets the animation from the runtime animation
  95932. */
  95933. get animation(): Animation;
  95934. /**
  95935. * Resets the runtime animation to the beginning
  95936. * @param restoreOriginal defines whether to restore the target property to the original value
  95937. */
  95938. reset(restoreOriginal?: boolean): void;
  95939. /**
  95940. * Specifies if the runtime animation is stopped
  95941. * @returns Boolean specifying if the runtime animation is stopped
  95942. */
  95943. isStopped(): boolean;
  95944. /**
  95945. * Disposes of the runtime animation
  95946. */
  95947. dispose(): void;
  95948. /**
  95949. * Apply the interpolated value to the target
  95950. * @param currentValue defines the value computed by the animation
  95951. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  95952. */
  95953. setValue(currentValue: any, weight: number): void;
  95954. private _getOriginalValues;
  95955. private _setValue;
  95956. /**
  95957. * Gets the loop pmode of the runtime animation
  95958. * @returns Loop Mode
  95959. */
  95960. private _getCorrectLoopMode;
  95961. /**
  95962. * Move the current animation to a given frame
  95963. * @param frame defines the frame to move to
  95964. */
  95965. goToFrame(frame: number): void;
  95966. /**
  95967. * @hidden Internal use only
  95968. */
  95969. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  95970. /**
  95971. * Execute the current animation
  95972. * @param delay defines the delay to add to the current frame
  95973. * @param from defines the lower bound of the animation range
  95974. * @param to defines the upper bound of the animation range
  95975. * @param loop defines if the current animation must loop
  95976. * @param speedRatio defines the current speed ratio
  95977. * @param weight defines the weight of the animation (default is -1 so no weight)
  95978. * @param onLoop optional callback called when animation loops
  95979. * @returns a boolean indicating if the animation is running
  95980. */
  95981. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  95982. }
  95983. }
  95984. declare module BABYLON {
  95985. /**
  95986. * Class used to store an actual running animation
  95987. */
  95988. export class Animatable {
  95989. /** defines the target object */
  95990. target: any;
  95991. /** defines the starting frame number (default is 0) */
  95992. fromFrame: number;
  95993. /** defines the ending frame number (default is 100) */
  95994. toFrame: number;
  95995. /** defines if the animation must loop (default is false) */
  95996. loopAnimation: boolean;
  95997. /** defines a callback to call when animation ends if it is not looping */
  95998. onAnimationEnd?: (() => void) | null | undefined;
  95999. /** defines a callback to call when animation loops */
  96000. onAnimationLoop?: (() => void) | null | undefined;
  96001. /** defines whether the animation should be evaluated additively */
  96002. isAdditive: boolean;
  96003. private _localDelayOffset;
  96004. private _pausedDelay;
  96005. private _runtimeAnimations;
  96006. private _paused;
  96007. private _scene;
  96008. private _speedRatio;
  96009. private _weight;
  96010. private _syncRoot;
  96011. /**
  96012. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96013. * This will only apply for non looping animation (default is true)
  96014. */
  96015. disposeOnEnd: boolean;
  96016. /**
  96017. * Gets a boolean indicating if the animation has started
  96018. */
  96019. animationStarted: boolean;
  96020. /**
  96021. * Observer raised when the animation ends
  96022. */
  96023. onAnimationEndObservable: Observable<Animatable>;
  96024. /**
  96025. * Observer raised when the animation loops
  96026. */
  96027. onAnimationLoopObservable: Observable<Animatable>;
  96028. /**
  96029. * Gets the root Animatable used to synchronize and normalize animations
  96030. */
  96031. get syncRoot(): Nullable<Animatable>;
  96032. /**
  96033. * Gets the current frame of the first RuntimeAnimation
  96034. * Used to synchronize Animatables
  96035. */
  96036. get masterFrame(): number;
  96037. /**
  96038. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96039. */
  96040. get weight(): number;
  96041. set weight(value: number);
  96042. /**
  96043. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96044. */
  96045. get speedRatio(): number;
  96046. set speedRatio(value: number);
  96047. /**
  96048. * Creates a new Animatable
  96049. * @param scene defines the hosting scene
  96050. * @param target defines the target object
  96051. * @param fromFrame defines the starting frame number (default is 0)
  96052. * @param toFrame defines the ending frame number (default is 100)
  96053. * @param loopAnimation defines if the animation must loop (default is false)
  96054. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96055. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96056. * @param animations defines a group of animation to add to the new Animatable
  96057. * @param onAnimationLoop defines a callback to call when animation loops
  96058. * @param isAdditive defines whether the animation should be evaluated additively
  96059. */
  96060. constructor(scene: Scene,
  96061. /** defines the target object */
  96062. target: any,
  96063. /** defines the starting frame number (default is 0) */
  96064. fromFrame?: number,
  96065. /** defines the ending frame number (default is 100) */
  96066. toFrame?: number,
  96067. /** defines if the animation must loop (default is false) */
  96068. loopAnimation?: boolean, speedRatio?: number,
  96069. /** defines a callback to call when animation ends if it is not looping */
  96070. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96071. /** defines a callback to call when animation loops */
  96072. onAnimationLoop?: (() => void) | null | undefined,
  96073. /** defines whether the animation should be evaluated additively */
  96074. isAdditive?: boolean);
  96075. /**
  96076. * Synchronize and normalize current Animatable with a source Animatable
  96077. * This is useful when using animation weights and when animations are not of the same length
  96078. * @param root defines the root Animatable to synchronize with
  96079. * @returns the current Animatable
  96080. */
  96081. syncWith(root: Animatable): Animatable;
  96082. /**
  96083. * Gets the list of runtime animations
  96084. * @returns an array of RuntimeAnimation
  96085. */
  96086. getAnimations(): RuntimeAnimation[];
  96087. /**
  96088. * Adds more animations to the current animatable
  96089. * @param target defines the target of the animations
  96090. * @param animations defines the new animations to add
  96091. */
  96092. appendAnimations(target: any, animations: Animation[]): void;
  96093. /**
  96094. * Gets the source animation for a specific property
  96095. * @param property defines the propertyu to look for
  96096. * @returns null or the source animation for the given property
  96097. */
  96098. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96099. /**
  96100. * Gets the runtime animation for a specific property
  96101. * @param property defines the propertyu to look for
  96102. * @returns null or the runtime animation for the given property
  96103. */
  96104. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96105. /**
  96106. * Resets the animatable to its original state
  96107. */
  96108. reset(): void;
  96109. /**
  96110. * Allows the animatable to blend with current running animations
  96111. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96112. * @param blendingSpeed defines the blending speed to use
  96113. */
  96114. enableBlending(blendingSpeed: number): void;
  96115. /**
  96116. * Disable animation blending
  96117. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96118. */
  96119. disableBlending(): void;
  96120. /**
  96121. * Jump directly to a given frame
  96122. * @param frame defines the frame to jump to
  96123. */
  96124. goToFrame(frame: number): void;
  96125. /**
  96126. * Pause the animation
  96127. */
  96128. pause(): void;
  96129. /**
  96130. * Restart the animation
  96131. */
  96132. restart(): void;
  96133. private _raiseOnAnimationEnd;
  96134. /**
  96135. * Stop and delete the current animation
  96136. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96137. * @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)
  96138. */
  96139. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96140. /**
  96141. * Wait asynchronously for the animation to end
  96142. * @returns a promise which will be fullfilled when the animation ends
  96143. */
  96144. waitAsync(): Promise<Animatable>;
  96145. /** @hidden */
  96146. _animate(delay: number): boolean;
  96147. }
  96148. interface Scene {
  96149. /** @hidden */
  96150. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96151. /** @hidden */
  96152. _processLateAnimationBindingsForMatrices(holder: {
  96153. totalWeight: number;
  96154. totalAdditiveWeight: number;
  96155. animations: RuntimeAnimation[];
  96156. additiveAnimations: RuntimeAnimation[];
  96157. originalValue: Matrix;
  96158. }): any;
  96159. /** @hidden */
  96160. _processLateAnimationBindingsForQuaternions(holder: {
  96161. totalWeight: number;
  96162. totalAdditiveWeight: number;
  96163. animations: RuntimeAnimation[];
  96164. additiveAnimations: RuntimeAnimation[];
  96165. originalValue: Quaternion;
  96166. }, refQuaternion: Quaternion): Quaternion;
  96167. /** @hidden */
  96168. _processLateAnimationBindings(): void;
  96169. /**
  96170. * Will start the animation sequence of a given target
  96171. * @param target defines the target
  96172. * @param from defines from which frame should animation start
  96173. * @param to defines until which frame should animation run.
  96174. * @param weight defines the weight to apply to the animation (1.0 by default)
  96175. * @param loop defines if the animation loops
  96176. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96177. * @param onAnimationEnd defines the function to be executed when the animation ends
  96178. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96179. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96180. * @param onAnimationLoop defines the callback to call when an animation loops
  96181. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96182. * @returns the animatable object created for this animation
  96183. */
  96184. 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;
  96185. /**
  96186. * Will start the animation sequence of a given target
  96187. * @param target defines the target
  96188. * @param from defines from which frame should animation start
  96189. * @param to defines until which frame should animation run.
  96190. * @param loop defines if the animation loops
  96191. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96192. * @param onAnimationEnd defines the function to be executed when the animation ends
  96193. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96194. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96195. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96196. * @param onAnimationLoop defines the callback to call when an animation loops
  96197. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96198. * @returns the animatable object created for this animation
  96199. */
  96200. 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;
  96201. /**
  96202. * Will start the animation sequence of a given target and its hierarchy
  96203. * @param target defines the target
  96204. * @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.
  96205. * @param from defines from which frame should animation start
  96206. * @param to defines until which frame should animation run.
  96207. * @param loop defines if the animation loops
  96208. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96209. * @param onAnimationEnd defines the function to be executed when the animation ends
  96210. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96211. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96212. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96213. * @param onAnimationLoop defines the callback to call when an animation loops
  96214. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96215. * @returns the list of created animatables
  96216. */
  96217. 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[];
  96218. /**
  96219. * Begin a new animation on a given node
  96220. * @param target defines the target where the animation will take place
  96221. * @param animations defines the list of animations to start
  96222. * @param from defines the initial value
  96223. * @param to defines the final value
  96224. * @param loop defines if you want animation to loop (off by default)
  96225. * @param speedRatio defines the speed ratio to apply to all animations
  96226. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96227. * @param onAnimationLoop defines the callback to call when an animation loops
  96228. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96229. * @returns the list of created animatables
  96230. */
  96231. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96232. /**
  96233. * Begin a new animation on a given node and its hierarchy
  96234. * @param target defines the root node where the animation will take place
  96235. * @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.
  96236. * @param animations defines the list of animations to start
  96237. * @param from defines the initial value
  96238. * @param to defines the final value
  96239. * @param loop defines if you want animation to loop (off by default)
  96240. * @param speedRatio defines the speed ratio to apply to all animations
  96241. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96242. * @param onAnimationLoop defines the callback to call when an animation loops
  96243. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96244. * @returns the list of animatables created for all nodes
  96245. */
  96246. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96247. /**
  96248. * Gets the animatable associated with a specific target
  96249. * @param target defines the target of the animatable
  96250. * @returns the required animatable if found
  96251. */
  96252. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96253. /**
  96254. * Gets all animatables associated with a given target
  96255. * @param target defines the target to look animatables for
  96256. * @returns an array of Animatables
  96257. */
  96258. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96259. /**
  96260. * Stops and removes all animations that have been applied to the scene
  96261. */
  96262. stopAllAnimations(): void;
  96263. /**
  96264. * Gets the current delta time used by animation engine
  96265. */
  96266. deltaTime: number;
  96267. }
  96268. interface Bone {
  96269. /**
  96270. * Copy an animation range from another bone
  96271. * @param source defines the source bone
  96272. * @param rangeName defines the range name to copy
  96273. * @param frameOffset defines the frame offset
  96274. * @param rescaleAsRequired defines if rescaling must be applied if required
  96275. * @param skelDimensionsRatio defines the scaling ratio
  96276. * @returns true if operation was successful
  96277. */
  96278. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96279. }
  96280. }
  96281. declare module BABYLON {
  96282. /**
  96283. * Class used to handle skinning animations
  96284. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96285. */
  96286. export class Skeleton implements IAnimatable {
  96287. /** defines the skeleton name */
  96288. name: string;
  96289. /** defines the skeleton Id */
  96290. id: string;
  96291. /**
  96292. * Defines the list of child bones
  96293. */
  96294. bones: Bone[];
  96295. /**
  96296. * Defines an estimate of the dimension of the skeleton at rest
  96297. */
  96298. dimensionsAtRest: Vector3;
  96299. /**
  96300. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96301. */
  96302. needInitialSkinMatrix: boolean;
  96303. /**
  96304. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96305. */
  96306. overrideMesh: Nullable<AbstractMesh>;
  96307. /**
  96308. * Gets the list of animations attached to this skeleton
  96309. */
  96310. animations: Array<Animation>;
  96311. private _scene;
  96312. private _isDirty;
  96313. private _transformMatrices;
  96314. private _transformMatrixTexture;
  96315. private _meshesWithPoseMatrix;
  96316. private _animatables;
  96317. private _identity;
  96318. private _synchronizedWithMesh;
  96319. private _ranges;
  96320. private _lastAbsoluteTransformsUpdateId;
  96321. private _canUseTextureForBones;
  96322. private _uniqueId;
  96323. /** @hidden */
  96324. _numBonesWithLinkedTransformNode: number;
  96325. /** @hidden */
  96326. _hasWaitingData: Nullable<boolean>;
  96327. /** @hidden */
  96328. _waitingOverrideMeshId: Nullable<string>;
  96329. /**
  96330. * Specifies if the skeleton should be serialized
  96331. */
  96332. doNotSerialize: boolean;
  96333. private _useTextureToStoreBoneMatrices;
  96334. /**
  96335. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96336. * Please note that this option is not available if the hardware does not support it
  96337. */
  96338. get useTextureToStoreBoneMatrices(): boolean;
  96339. set useTextureToStoreBoneMatrices(value: boolean);
  96340. private _animationPropertiesOverride;
  96341. /**
  96342. * Gets or sets the animation properties override
  96343. */
  96344. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96345. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96346. /**
  96347. * List of inspectable custom properties (used by the Inspector)
  96348. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96349. */
  96350. inspectableCustomProperties: IInspectable[];
  96351. /**
  96352. * An observable triggered before computing the skeleton's matrices
  96353. */
  96354. onBeforeComputeObservable: Observable<Skeleton>;
  96355. /**
  96356. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96357. */
  96358. get isUsingTextureForMatrices(): boolean;
  96359. /**
  96360. * Gets the unique ID of this skeleton
  96361. */
  96362. get uniqueId(): number;
  96363. /**
  96364. * Creates a new skeleton
  96365. * @param name defines the skeleton name
  96366. * @param id defines the skeleton Id
  96367. * @param scene defines the hosting scene
  96368. */
  96369. constructor(
  96370. /** defines the skeleton name */
  96371. name: string,
  96372. /** defines the skeleton Id */
  96373. id: string, scene: Scene);
  96374. /**
  96375. * Gets the current object class name.
  96376. * @return the class name
  96377. */
  96378. getClassName(): string;
  96379. /**
  96380. * Returns an array containing the root bones
  96381. * @returns an array containing the root bones
  96382. */
  96383. getChildren(): Array<Bone>;
  96384. /**
  96385. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96386. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96387. * @returns a Float32Array containing matrices data
  96388. */
  96389. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96390. /**
  96391. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96392. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96393. * @returns a raw texture containing the data
  96394. */
  96395. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96396. /**
  96397. * Gets the current hosting scene
  96398. * @returns a scene object
  96399. */
  96400. getScene(): Scene;
  96401. /**
  96402. * Gets a string representing the current skeleton data
  96403. * @param fullDetails defines a boolean indicating if we want a verbose version
  96404. * @returns a string representing the current skeleton data
  96405. */
  96406. toString(fullDetails?: boolean): string;
  96407. /**
  96408. * Get bone's index searching by name
  96409. * @param name defines bone's name to search for
  96410. * @return the indice of the bone. Returns -1 if not found
  96411. */
  96412. getBoneIndexByName(name: string): number;
  96413. /**
  96414. * Creater a new animation range
  96415. * @param name defines the name of the range
  96416. * @param from defines the start key
  96417. * @param to defines the end key
  96418. */
  96419. createAnimationRange(name: string, from: number, to: number): void;
  96420. /**
  96421. * Delete a specific animation range
  96422. * @param name defines the name of the range
  96423. * @param deleteFrames defines if frames must be removed as well
  96424. */
  96425. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96426. /**
  96427. * Gets a specific animation range
  96428. * @param name defines the name of the range to look for
  96429. * @returns the requested animation range or null if not found
  96430. */
  96431. getAnimationRange(name: string): Nullable<AnimationRange>;
  96432. /**
  96433. * Gets the list of all animation ranges defined on this skeleton
  96434. * @returns an array
  96435. */
  96436. getAnimationRanges(): Nullable<AnimationRange>[];
  96437. /**
  96438. * Copy animation range from a source skeleton.
  96439. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96440. * @param source defines the source skeleton
  96441. * @param name defines the name of the range to copy
  96442. * @param rescaleAsRequired defines if rescaling must be applied if required
  96443. * @returns true if operation was successful
  96444. */
  96445. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96446. /**
  96447. * Forces the skeleton to go to rest pose
  96448. */
  96449. returnToRest(): void;
  96450. private _getHighestAnimationFrame;
  96451. /**
  96452. * Begin a specific animation range
  96453. * @param name defines the name of the range to start
  96454. * @param loop defines if looping must be turned on (false by default)
  96455. * @param speedRatio defines the speed ratio to apply (1 by default)
  96456. * @param onAnimationEnd defines a callback which will be called when animation will end
  96457. * @returns a new animatable
  96458. */
  96459. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96460. /**
  96461. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96462. * @param skeleton defines the Skeleton containing the animation range to convert
  96463. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96464. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96465. * @returns the original skeleton
  96466. */
  96467. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96468. /** @hidden */
  96469. _markAsDirty(): void;
  96470. /** @hidden */
  96471. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96472. /** @hidden */
  96473. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96474. private _computeTransformMatrices;
  96475. /**
  96476. * Build all resources required to render a skeleton
  96477. */
  96478. prepare(): void;
  96479. /**
  96480. * Gets the list of animatables currently running for this skeleton
  96481. * @returns an array of animatables
  96482. */
  96483. getAnimatables(): IAnimatable[];
  96484. /**
  96485. * Clone the current skeleton
  96486. * @param name defines the name of the new skeleton
  96487. * @param id defines the id of the new skeleton
  96488. * @returns the new skeleton
  96489. */
  96490. clone(name: string, id?: string): Skeleton;
  96491. /**
  96492. * Enable animation blending for this skeleton
  96493. * @param blendingSpeed defines the blending speed to apply
  96494. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96495. */
  96496. enableBlending(blendingSpeed?: number): void;
  96497. /**
  96498. * Releases all resources associated with the current skeleton
  96499. */
  96500. dispose(): void;
  96501. /**
  96502. * Serialize the skeleton in a JSON object
  96503. * @returns a JSON object
  96504. */
  96505. serialize(): any;
  96506. /**
  96507. * Creates a new skeleton from serialized data
  96508. * @param parsedSkeleton defines the serialized data
  96509. * @param scene defines the hosting scene
  96510. * @returns a new skeleton
  96511. */
  96512. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96513. /**
  96514. * Compute all node absolute transforms
  96515. * @param forceUpdate defines if computation must be done even if cache is up to date
  96516. */
  96517. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96518. /**
  96519. * Gets the root pose matrix
  96520. * @returns a matrix
  96521. */
  96522. getPoseMatrix(): Nullable<Matrix>;
  96523. /**
  96524. * Sorts bones per internal index
  96525. */
  96526. sortBones(): void;
  96527. private _sortBones;
  96528. /**
  96529. * Set the current local matrix as the restPose for all bones in the skeleton.
  96530. */
  96531. setCurrentPoseAsRest(): void;
  96532. }
  96533. }
  96534. declare module BABYLON {
  96535. /**
  96536. * Creates an instance based on a source mesh.
  96537. */
  96538. export class InstancedMesh extends AbstractMesh {
  96539. private _sourceMesh;
  96540. private _currentLOD;
  96541. /** @hidden */
  96542. _indexInSourceMeshInstanceArray: number;
  96543. constructor(name: string, source: Mesh);
  96544. /**
  96545. * Returns the string "InstancedMesh".
  96546. */
  96547. getClassName(): string;
  96548. /** Gets the list of lights affecting that mesh */
  96549. get lightSources(): Light[];
  96550. _resyncLightSources(): void;
  96551. _resyncLightSource(light: Light): void;
  96552. _removeLightSource(light: Light, dispose: boolean): void;
  96553. /**
  96554. * If the source mesh receives shadows
  96555. */
  96556. get receiveShadows(): boolean;
  96557. /**
  96558. * The material of the source mesh
  96559. */
  96560. get material(): Nullable<Material>;
  96561. /**
  96562. * Visibility of the source mesh
  96563. */
  96564. get visibility(): number;
  96565. /**
  96566. * Skeleton of the source mesh
  96567. */
  96568. get skeleton(): Nullable<Skeleton>;
  96569. /**
  96570. * Rendering ground id of the source mesh
  96571. */
  96572. get renderingGroupId(): number;
  96573. set renderingGroupId(value: number);
  96574. /**
  96575. * Returns the total number of vertices (integer).
  96576. */
  96577. getTotalVertices(): number;
  96578. /**
  96579. * Returns a positive integer : the total number of indices in this mesh geometry.
  96580. * @returns the numner of indices or zero if the mesh has no geometry.
  96581. */
  96582. getTotalIndices(): number;
  96583. /**
  96584. * The source mesh of the instance
  96585. */
  96586. get sourceMesh(): Mesh;
  96587. /**
  96588. * Creates a new InstancedMesh object from the mesh model.
  96589. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96590. * @param name defines the name of the new instance
  96591. * @returns a new InstancedMesh
  96592. */
  96593. createInstance(name: string): InstancedMesh;
  96594. /**
  96595. * Is this node ready to be used/rendered
  96596. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96597. * @return {boolean} is it ready
  96598. */
  96599. isReady(completeCheck?: boolean): boolean;
  96600. /**
  96601. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96602. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96603. * @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.
  96604. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96605. */
  96606. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96607. /**
  96608. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96609. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96610. * The `data` are either a numeric array either a Float32Array.
  96611. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96612. * 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).
  96613. * Note that a new underlying VertexBuffer object is created each call.
  96614. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96615. *
  96616. * Possible `kind` values :
  96617. * - VertexBuffer.PositionKind
  96618. * - VertexBuffer.UVKind
  96619. * - VertexBuffer.UV2Kind
  96620. * - VertexBuffer.UV3Kind
  96621. * - VertexBuffer.UV4Kind
  96622. * - VertexBuffer.UV5Kind
  96623. * - VertexBuffer.UV6Kind
  96624. * - VertexBuffer.ColorKind
  96625. * - VertexBuffer.MatricesIndicesKind
  96626. * - VertexBuffer.MatricesIndicesExtraKind
  96627. * - VertexBuffer.MatricesWeightsKind
  96628. * - VertexBuffer.MatricesWeightsExtraKind
  96629. *
  96630. * Returns the Mesh.
  96631. */
  96632. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96633. /**
  96634. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96635. * If the mesh has no geometry, it is simply returned as it is.
  96636. * The `data` are either a numeric array either a Float32Array.
  96637. * No new underlying VertexBuffer object is created.
  96638. * 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.
  96639. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96640. *
  96641. * Possible `kind` values :
  96642. * - VertexBuffer.PositionKind
  96643. * - VertexBuffer.UVKind
  96644. * - VertexBuffer.UV2Kind
  96645. * - VertexBuffer.UV3Kind
  96646. * - VertexBuffer.UV4Kind
  96647. * - VertexBuffer.UV5Kind
  96648. * - VertexBuffer.UV6Kind
  96649. * - VertexBuffer.ColorKind
  96650. * - VertexBuffer.MatricesIndicesKind
  96651. * - VertexBuffer.MatricesIndicesExtraKind
  96652. * - VertexBuffer.MatricesWeightsKind
  96653. * - VertexBuffer.MatricesWeightsExtraKind
  96654. *
  96655. * Returns the Mesh.
  96656. */
  96657. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96658. /**
  96659. * Sets the mesh indices.
  96660. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96661. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96662. * This method creates a new index buffer each call.
  96663. * Returns the Mesh.
  96664. */
  96665. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96666. /**
  96667. * Boolean : True if the mesh owns the requested kind of data.
  96668. */
  96669. isVerticesDataPresent(kind: string): boolean;
  96670. /**
  96671. * Returns an array of indices (IndicesArray).
  96672. */
  96673. getIndices(): Nullable<IndicesArray>;
  96674. get _positions(): Nullable<Vector3[]>;
  96675. /**
  96676. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96677. * This means the mesh underlying bounding box and sphere are recomputed.
  96678. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96679. * @returns the current mesh
  96680. */
  96681. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96682. /** @hidden */
  96683. _preActivate(): InstancedMesh;
  96684. /** @hidden */
  96685. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96686. /** @hidden */
  96687. _postActivate(): void;
  96688. getWorldMatrix(): Matrix;
  96689. get isAnInstance(): boolean;
  96690. /**
  96691. * Returns the current associated LOD AbstractMesh.
  96692. */
  96693. getLOD(camera: Camera): AbstractMesh;
  96694. /** @hidden */
  96695. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96696. /** @hidden */
  96697. _syncSubMeshes(): InstancedMesh;
  96698. /** @hidden */
  96699. _generatePointsArray(): boolean;
  96700. /** @hidden */
  96701. _updateBoundingInfo(): AbstractMesh;
  96702. /**
  96703. * Creates a new InstancedMesh from the current mesh.
  96704. * - name (string) : the cloned mesh name
  96705. * - newParent (optional Node) : the optional Node to parent the clone to.
  96706. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96707. *
  96708. * Returns the clone.
  96709. */
  96710. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96711. /**
  96712. * Disposes the InstancedMesh.
  96713. * Returns nothing.
  96714. */
  96715. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96716. }
  96717. interface Mesh {
  96718. /**
  96719. * Register a custom buffer that will be instanced
  96720. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96721. * @param kind defines the buffer kind
  96722. * @param stride defines the stride in floats
  96723. */
  96724. registerInstancedBuffer(kind: string, stride: number): void;
  96725. /**
  96726. * true to use the edge renderer for all instances of this mesh
  96727. */
  96728. edgesShareWithInstances: boolean;
  96729. /** @hidden */
  96730. _userInstancedBuffersStorage: {
  96731. data: {
  96732. [key: string]: Float32Array;
  96733. };
  96734. sizes: {
  96735. [key: string]: number;
  96736. };
  96737. vertexBuffers: {
  96738. [key: string]: Nullable<VertexBuffer>;
  96739. };
  96740. strides: {
  96741. [key: string]: number;
  96742. };
  96743. };
  96744. }
  96745. interface AbstractMesh {
  96746. /**
  96747. * Object used to store instanced buffers defined by user
  96748. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96749. */
  96750. instancedBuffers: {
  96751. [key: string]: any;
  96752. };
  96753. }
  96754. }
  96755. declare module BABYLON {
  96756. /**
  96757. * Defines the options associated with the creation of a shader material.
  96758. */
  96759. export interface IShaderMaterialOptions {
  96760. /**
  96761. * Does the material work in alpha blend mode
  96762. */
  96763. needAlphaBlending: boolean;
  96764. /**
  96765. * Does the material work in alpha test mode
  96766. */
  96767. needAlphaTesting: boolean;
  96768. /**
  96769. * The list of attribute names used in the shader
  96770. */
  96771. attributes: string[];
  96772. /**
  96773. * The list of unifrom names used in the shader
  96774. */
  96775. uniforms: string[];
  96776. /**
  96777. * The list of UBO names used in the shader
  96778. */
  96779. uniformBuffers: string[];
  96780. /**
  96781. * The list of sampler names used in the shader
  96782. */
  96783. samplers: string[];
  96784. /**
  96785. * The list of defines used in the shader
  96786. */
  96787. defines: string[];
  96788. }
  96789. /**
  96790. * 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.
  96791. *
  96792. * This returned material effects how the mesh will look based on the code in the shaders.
  96793. *
  96794. * @see https://doc.babylonjs.com/how_to/shader_material
  96795. */
  96796. export class ShaderMaterial extends Material {
  96797. private _shaderPath;
  96798. private _options;
  96799. private _textures;
  96800. private _textureArrays;
  96801. private _floats;
  96802. private _ints;
  96803. private _floatsArrays;
  96804. private _colors3;
  96805. private _colors3Arrays;
  96806. private _colors4;
  96807. private _colors4Arrays;
  96808. private _vectors2;
  96809. private _vectors3;
  96810. private _vectors4;
  96811. private _matrices;
  96812. private _matrixArrays;
  96813. private _matrices3x3;
  96814. private _matrices2x2;
  96815. private _vectors2Arrays;
  96816. private _vectors3Arrays;
  96817. private _vectors4Arrays;
  96818. private _cachedWorldViewMatrix;
  96819. private _cachedWorldViewProjectionMatrix;
  96820. private _renderId;
  96821. private _multiview;
  96822. private _cachedDefines;
  96823. /** Define the Url to load snippets */
  96824. static SnippetUrl: string;
  96825. /** Snippet ID if the material was created from the snippet server */
  96826. snippetId: string;
  96827. /**
  96828. * Instantiate a new shader material.
  96829. * 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.
  96830. * This returned material effects how the mesh will look based on the code in the shaders.
  96831. * @see https://doc.babylonjs.com/how_to/shader_material
  96832. * @param name Define the name of the material in the scene
  96833. * @param scene Define the scene the material belongs to
  96834. * @param shaderPath Defines the route to the shader code in one of three ways:
  96835. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96836. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96837. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96838. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96839. * @param options Define the options used to create the shader
  96840. */
  96841. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96842. /**
  96843. * Gets the shader path used to define the shader code
  96844. * It can be modified to trigger a new compilation
  96845. */
  96846. get shaderPath(): any;
  96847. /**
  96848. * Sets the shader path used to define the shader code
  96849. * It can be modified to trigger a new compilation
  96850. */
  96851. set shaderPath(shaderPath: any);
  96852. /**
  96853. * Gets the options used to compile the shader.
  96854. * They can be modified to trigger a new compilation
  96855. */
  96856. get options(): IShaderMaterialOptions;
  96857. /**
  96858. * Gets the current class name of the material e.g. "ShaderMaterial"
  96859. * Mainly use in serialization.
  96860. * @returns the class name
  96861. */
  96862. getClassName(): string;
  96863. /**
  96864. * Specifies if the material will require alpha blending
  96865. * @returns a boolean specifying if alpha blending is needed
  96866. */
  96867. needAlphaBlending(): boolean;
  96868. /**
  96869. * Specifies if this material should be rendered in alpha test mode
  96870. * @returns a boolean specifying if an alpha test is needed.
  96871. */
  96872. needAlphaTesting(): boolean;
  96873. private _checkUniform;
  96874. /**
  96875. * Set a texture in the shader.
  96876. * @param name Define the name of the uniform samplers as defined in the shader
  96877. * @param texture Define the texture to bind to this sampler
  96878. * @return the material itself allowing "fluent" like uniform updates
  96879. */
  96880. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96881. /**
  96882. * Set a texture array in the shader.
  96883. * @param name Define the name of the uniform sampler array as defined in the shader
  96884. * @param textures Define the list of textures to bind to this sampler
  96885. * @return the material itself allowing "fluent" like uniform updates
  96886. */
  96887. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96888. /**
  96889. * Set a float in the shader.
  96890. * @param name Define the name of the uniform as defined in the shader
  96891. * @param value Define the value to give to the uniform
  96892. * @return the material itself allowing "fluent" like uniform updates
  96893. */
  96894. setFloat(name: string, value: number): ShaderMaterial;
  96895. /**
  96896. * Set a int in the shader.
  96897. * @param name Define the name of the uniform as defined in the shader
  96898. * @param value Define the value to give to the uniform
  96899. * @return the material itself allowing "fluent" like uniform updates
  96900. */
  96901. setInt(name: string, value: number): ShaderMaterial;
  96902. /**
  96903. * Set an array of floats in the shader.
  96904. * @param name Define the name of the uniform as defined in the shader
  96905. * @param value Define the value to give to the uniform
  96906. * @return the material itself allowing "fluent" like uniform updates
  96907. */
  96908. setFloats(name: string, value: number[]): ShaderMaterial;
  96909. /**
  96910. * Set a vec3 in the shader from a Color3.
  96911. * @param name Define the name of the uniform as defined in the shader
  96912. * @param value Define the value to give to the uniform
  96913. * @return the material itself allowing "fluent" like uniform updates
  96914. */
  96915. setColor3(name: string, value: Color3): ShaderMaterial;
  96916. /**
  96917. * Set a vec3 array in the shader from a Color3 array.
  96918. * @param name Define the name of the uniform as defined in the shader
  96919. * @param value Define the value to give to the uniform
  96920. * @return the material itself allowing "fluent" like uniform updates
  96921. */
  96922. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  96923. /**
  96924. * Set a vec4 in the shader from a Color4.
  96925. * @param name Define the name of the uniform as defined in the shader
  96926. * @param value Define the value to give to the uniform
  96927. * @return the material itself allowing "fluent" like uniform updates
  96928. */
  96929. setColor4(name: string, value: Color4): ShaderMaterial;
  96930. /**
  96931. * Set a vec4 array in the shader from a Color4 array.
  96932. * @param name Define the name of the uniform as defined in the shader
  96933. * @param value Define the value to give to the uniform
  96934. * @return the material itself allowing "fluent" like uniform updates
  96935. */
  96936. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  96937. /**
  96938. * Set a vec2 in the shader from a Vector2.
  96939. * @param name Define the name of the uniform as defined in the shader
  96940. * @param value Define the value to give to the uniform
  96941. * @return the material itself allowing "fluent" like uniform updates
  96942. */
  96943. setVector2(name: string, value: Vector2): ShaderMaterial;
  96944. /**
  96945. * Set a vec3 in the shader from a Vector3.
  96946. * @param name Define the name of the uniform as defined in the shader
  96947. * @param value Define the value to give to the uniform
  96948. * @return the material itself allowing "fluent" like uniform updates
  96949. */
  96950. setVector3(name: string, value: Vector3): ShaderMaterial;
  96951. /**
  96952. * Set a vec4 in the shader from a Vector4.
  96953. * @param name Define the name of the uniform as defined in the shader
  96954. * @param value Define the value to give to the uniform
  96955. * @return the material itself allowing "fluent" like uniform updates
  96956. */
  96957. setVector4(name: string, value: Vector4): ShaderMaterial;
  96958. /**
  96959. * Set a mat4 in the shader from a Matrix.
  96960. * @param name Define the name of the uniform as defined in the shader
  96961. * @param value Define the value to give to the uniform
  96962. * @return the material itself allowing "fluent" like uniform updates
  96963. */
  96964. setMatrix(name: string, value: Matrix): ShaderMaterial;
  96965. /**
  96966. * Set a float32Array in the shader from a matrix array.
  96967. * @param name Define the name of the uniform as defined in the shader
  96968. * @param value Define the value to give to the uniform
  96969. * @return the material itself allowing "fluent" like uniform updates
  96970. */
  96971. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  96972. /**
  96973. * Set a mat3 in the shader from a Float32Array.
  96974. * @param name Define the name of the uniform as defined in the shader
  96975. * @param value Define the value to give to the uniform
  96976. * @return the material itself allowing "fluent" like uniform updates
  96977. */
  96978. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96979. /**
  96980. * Set a mat2 in the shader from a Float32Array.
  96981. * @param name Define the name of the uniform as defined in the shader
  96982. * @param value Define the value to give to the uniform
  96983. * @return the material itself allowing "fluent" like uniform updates
  96984. */
  96985. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96986. /**
  96987. * Set a vec2 array in the shader from a number array.
  96988. * @param name Define the name of the uniform as defined in the shader
  96989. * @param value Define the value to give to the uniform
  96990. * @return the material itself allowing "fluent" like uniform updates
  96991. */
  96992. setArray2(name: string, value: number[]): ShaderMaterial;
  96993. /**
  96994. * Set a vec3 array in the shader from a number array.
  96995. * @param name Define the name of the uniform as defined in the shader
  96996. * @param value Define the value to give to the uniform
  96997. * @return the material itself allowing "fluent" like uniform updates
  96998. */
  96999. setArray3(name: string, value: number[]): ShaderMaterial;
  97000. /**
  97001. * Set a vec4 array in the shader from a number array.
  97002. * @param name Define the name of the uniform as defined in the shader
  97003. * @param value Define the value to give to the uniform
  97004. * @return the material itself allowing "fluent" like uniform updates
  97005. */
  97006. setArray4(name: string, value: number[]): ShaderMaterial;
  97007. private _checkCache;
  97008. /**
  97009. * Specifies that the submesh is ready to be used
  97010. * @param mesh defines the mesh to check
  97011. * @param subMesh defines which submesh to check
  97012. * @param useInstances specifies that instances should be used
  97013. * @returns a boolean indicating that the submesh is ready or not
  97014. */
  97015. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97016. /**
  97017. * Checks if the material is ready to render the requested mesh
  97018. * @param mesh Define the mesh to render
  97019. * @param useInstances Define whether or not the material is used with instances
  97020. * @returns true if ready, otherwise false
  97021. */
  97022. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97023. /**
  97024. * Binds the world matrix to the material
  97025. * @param world defines the world transformation matrix
  97026. * @param effectOverride - If provided, use this effect instead of internal effect
  97027. */
  97028. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97029. /**
  97030. * Binds the submesh to this material by preparing the effect and shader to draw
  97031. * @param world defines the world transformation matrix
  97032. * @param mesh defines the mesh containing the submesh
  97033. * @param subMesh defines the submesh to bind the material to
  97034. */
  97035. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97036. /**
  97037. * Binds the material to the mesh
  97038. * @param world defines the world transformation matrix
  97039. * @param mesh defines the mesh to bind the material to
  97040. * @param effectOverride - If provided, use this effect instead of internal effect
  97041. */
  97042. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97043. protected _afterBind(mesh?: Mesh): void;
  97044. /**
  97045. * Gets the active textures from the material
  97046. * @returns an array of textures
  97047. */
  97048. getActiveTextures(): BaseTexture[];
  97049. /**
  97050. * Specifies if the material uses a texture
  97051. * @param texture defines the texture to check against the material
  97052. * @returns a boolean specifying if the material uses the texture
  97053. */
  97054. hasTexture(texture: BaseTexture): boolean;
  97055. /**
  97056. * Makes a duplicate of the material, and gives it a new name
  97057. * @param name defines the new name for the duplicated material
  97058. * @returns the cloned material
  97059. */
  97060. clone(name: string): ShaderMaterial;
  97061. /**
  97062. * Disposes the material
  97063. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97064. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97065. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97066. */
  97067. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97068. /**
  97069. * Serializes this material in a JSON representation
  97070. * @returns the serialized material object
  97071. */
  97072. serialize(): any;
  97073. /**
  97074. * Creates a shader material from parsed shader material data
  97075. * @param source defines the JSON represnetation of the material
  97076. * @param scene defines the hosting scene
  97077. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97078. * @returns a new material
  97079. */
  97080. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97081. /**
  97082. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97083. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97084. * @param url defines the url to load from
  97085. * @param scene defines the hosting scene
  97086. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97087. * @returns a promise that will resolve to the new ShaderMaterial
  97088. */
  97089. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97090. /**
  97091. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97092. * @param snippetId defines the snippet to load
  97093. * @param scene defines the hosting scene
  97094. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97095. * @returns a promise that will resolve to the new ShaderMaterial
  97096. */
  97097. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97098. }
  97099. }
  97100. declare module BABYLON {
  97101. /** @hidden */
  97102. export var colorPixelShader: {
  97103. name: string;
  97104. shader: string;
  97105. };
  97106. }
  97107. declare module BABYLON {
  97108. /** @hidden */
  97109. export var colorVertexShader: {
  97110. name: string;
  97111. shader: string;
  97112. };
  97113. }
  97114. declare module BABYLON {
  97115. /**
  97116. * Line mesh
  97117. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97118. */
  97119. export class LinesMesh extends Mesh {
  97120. /**
  97121. * If vertex color should be applied to the mesh
  97122. */
  97123. readonly useVertexColor?: boolean | undefined;
  97124. /**
  97125. * If vertex alpha should be applied to the mesh
  97126. */
  97127. readonly useVertexAlpha?: boolean | undefined;
  97128. /**
  97129. * Color of the line (Default: White)
  97130. */
  97131. color: Color3;
  97132. /**
  97133. * Alpha of the line (Default: 1)
  97134. */
  97135. alpha: number;
  97136. /**
  97137. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97138. * This margin is expressed in world space coordinates, so its value may vary.
  97139. * Default value is 0.1
  97140. */
  97141. intersectionThreshold: number;
  97142. private _colorShader;
  97143. private color4;
  97144. /**
  97145. * Creates a new LinesMesh
  97146. * @param name defines the name
  97147. * @param scene defines the hosting scene
  97148. * @param parent defines the parent mesh if any
  97149. * @param source defines the optional source LinesMesh used to clone data from
  97150. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97151. * When false, achieved by calling a clone(), also passing False.
  97152. * This will make creation of children, recursive.
  97153. * @param useVertexColor defines if this LinesMesh supports vertex color
  97154. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97155. */
  97156. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97157. /**
  97158. * If vertex color should be applied to the mesh
  97159. */
  97160. useVertexColor?: boolean | undefined,
  97161. /**
  97162. * If vertex alpha should be applied to the mesh
  97163. */
  97164. useVertexAlpha?: boolean | undefined);
  97165. private _addClipPlaneDefine;
  97166. private _removeClipPlaneDefine;
  97167. isReady(): boolean;
  97168. /**
  97169. * Returns the string "LineMesh"
  97170. */
  97171. getClassName(): string;
  97172. /**
  97173. * @hidden
  97174. */
  97175. get material(): Material;
  97176. /**
  97177. * @hidden
  97178. */
  97179. set material(value: Material);
  97180. /**
  97181. * @hidden
  97182. */
  97183. get checkCollisions(): boolean;
  97184. /** @hidden */
  97185. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97186. /** @hidden */
  97187. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97188. /**
  97189. * Disposes of the line mesh
  97190. * @param doNotRecurse If children should be disposed
  97191. */
  97192. dispose(doNotRecurse?: boolean): void;
  97193. /**
  97194. * Returns a new LineMesh object cloned from the current one.
  97195. */
  97196. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97197. /**
  97198. * Creates a new InstancedLinesMesh object from the mesh model.
  97199. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97200. * @param name defines the name of the new instance
  97201. * @returns a new InstancedLinesMesh
  97202. */
  97203. createInstance(name: string): InstancedLinesMesh;
  97204. }
  97205. /**
  97206. * Creates an instance based on a source LinesMesh
  97207. */
  97208. export class InstancedLinesMesh extends InstancedMesh {
  97209. /**
  97210. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97211. * This margin is expressed in world space coordinates, so its value may vary.
  97212. * Initilized with the intersectionThreshold value of the source LinesMesh
  97213. */
  97214. intersectionThreshold: number;
  97215. constructor(name: string, source: LinesMesh);
  97216. /**
  97217. * Returns the string "InstancedLinesMesh".
  97218. */
  97219. getClassName(): string;
  97220. }
  97221. }
  97222. declare module BABYLON {
  97223. /** @hidden */
  97224. export var linePixelShader: {
  97225. name: string;
  97226. shader: string;
  97227. };
  97228. }
  97229. declare module BABYLON {
  97230. /** @hidden */
  97231. export var lineVertexShader: {
  97232. name: string;
  97233. shader: string;
  97234. };
  97235. }
  97236. declare module BABYLON {
  97237. interface Scene {
  97238. /** @hidden */
  97239. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97240. }
  97241. interface AbstractMesh {
  97242. /**
  97243. * Gets the edgesRenderer associated with the mesh
  97244. */
  97245. edgesRenderer: Nullable<EdgesRenderer>;
  97246. }
  97247. interface LinesMesh {
  97248. /**
  97249. * Enables the edge rendering mode on the mesh.
  97250. * This mode makes the mesh edges visible
  97251. * @param epsilon defines the maximal distance between two angles to detect a face
  97252. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97253. * @returns the currentAbstractMesh
  97254. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97255. */
  97256. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97257. }
  97258. interface InstancedLinesMesh {
  97259. /**
  97260. * Enables the edge rendering mode on the mesh.
  97261. * This mode makes the mesh edges visible
  97262. * @param epsilon defines the maximal distance between two angles to detect a face
  97263. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97264. * @returns the current InstancedLinesMesh
  97265. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97266. */
  97267. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97268. }
  97269. /**
  97270. * Defines the minimum contract an Edges renderer should follow.
  97271. */
  97272. export interface IEdgesRenderer extends IDisposable {
  97273. /**
  97274. * Gets or sets a boolean indicating if the edgesRenderer is active
  97275. */
  97276. isEnabled: boolean;
  97277. /**
  97278. * Renders the edges of the attached mesh,
  97279. */
  97280. render(): void;
  97281. /**
  97282. * Checks wether or not the edges renderer is ready to render.
  97283. * @return true if ready, otherwise false.
  97284. */
  97285. isReady(): boolean;
  97286. /**
  97287. * List of instances to render in case the source mesh has instances
  97288. */
  97289. customInstances: SmartArray<Matrix>;
  97290. }
  97291. /**
  97292. * Defines the additional options of the edges renderer
  97293. */
  97294. export interface IEdgesRendererOptions {
  97295. /**
  97296. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97297. * If not defined, the default value is true
  97298. */
  97299. useAlternateEdgeFinder?: boolean;
  97300. /**
  97301. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97302. * If not defined, the default value is true.
  97303. * 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)
  97304. * This option is used only if useAlternateEdgeFinder = true
  97305. */
  97306. useFastVertexMerger?: boolean;
  97307. /**
  97308. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97309. * The default value is 1e-6
  97310. * This option is used only if useAlternateEdgeFinder = true
  97311. */
  97312. epsilonVertexMerge?: number;
  97313. /**
  97314. * 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
  97315. * 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.
  97316. * This option is used only if useAlternateEdgeFinder = true
  97317. */
  97318. applyTessellation?: boolean;
  97319. /**
  97320. * 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
  97321. * The default value is 1e-6
  97322. * This option is used only if useAlternateEdgeFinder = true
  97323. */
  97324. epsilonVertexAligned?: number;
  97325. }
  97326. /**
  97327. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97328. */
  97329. export class EdgesRenderer implements IEdgesRenderer {
  97330. /**
  97331. * Define the size of the edges with an orthographic camera
  97332. */
  97333. edgesWidthScalerForOrthographic: number;
  97334. /**
  97335. * Define the size of the edges with a perspective camera
  97336. */
  97337. edgesWidthScalerForPerspective: number;
  97338. protected _source: AbstractMesh;
  97339. protected _linesPositions: number[];
  97340. protected _linesNormals: number[];
  97341. protected _linesIndices: number[];
  97342. protected _epsilon: number;
  97343. protected _indicesCount: number;
  97344. protected _lineShader: ShaderMaterial;
  97345. protected _ib: DataBuffer;
  97346. protected _buffers: {
  97347. [key: string]: Nullable<VertexBuffer>;
  97348. };
  97349. protected _buffersForInstances: {
  97350. [key: string]: Nullable<VertexBuffer>;
  97351. };
  97352. protected _checkVerticesInsteadOfIndices: boolean;
  97353. protected _options: Nullable<IEdgesRendererOptions>;
  97354. private _meshRebuildObserver;
  97355. private _meshDisposeObserver;
  97356. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97357. isEnabled: boolean;
  97358. /**
  97359. * List of instances to render in case the source mesh has instances
  97360. */
  97361. customInstances: SmartArray<Matrix>;
  97362. private static GetShader;
  97363. /**
  97364. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97365. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97366. * @param source Mesh used to create edges
  97367. * @param epsilon sum of angles in adjacency to check for edge
  97368. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97369. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97370. * @param options The options to apply when generating the edges
  97371. */
  97372. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97373. protected _prepareRessources(): void;
  97374. /** @hidden */
  97375. _rebuild(): void;
  97376. /**
  97377. * Releases the required resources for the edges renderer
  97378. */
  97379. dispose(): void;
  97380. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97381. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97382. /**
  97383. * Checks if the pair of p0 and p1 is en edge
  97384. * @param faceIndex
  97385. * @param edge
  97386. * @param faceNormals
  97387. * @param p0
  97388. * @param p1
  97389. * @private
  97390. */
  97391. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97392. /**
  97393. * push line into the position, normal and index buffer
  97394. * @protected
  97395. */
  97396. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97397. /**
  97398. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97399. */
  97400. private _tessellateTriangle;
  97401. private _generateEdgesLinesAlternate;
  97402. /**
  97403. * Generates lines edges from adjacencjes
  97404. * @private
  97405. */
  97406. _generateEdgesLines(): void;
  97407. /**
  97408. * Checks wether or not the edges renderer is ready to render.
  97409. * @return true if ready, otherwise false.
  97410. */
  97411. isReady(): boolean;
  97412. /**
  97413. * Renders the edges of the attached mesh,
  97414. */
  97415. render(): void;
  97416. }
  97417. /**
  97418. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97419. */
  97420. export class LineEdgesRenderer extends EdgesRenderer {
  97421. /**
  97422. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97423. * @param source LineMesh used to generate edges
  97424. * @param epsilon not important (specified angle for edge detection)
  97425. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97426. */
  97427. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97428. /**
  97429. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97430. */
  97431. _generateEdgesLines(): void;
  97432. }
  97433. }
  97434. declare module BABYLON {
  97435. /**
  97436. * This represents the object necessary to create a rendering group.
  97437. * This is exclusively used and created by the rendering manager.
  97438. * To modify the behavior, you use the available helpers in your scene or meshes.
  97439. * @hidden
  97440. */
  97441. export class RenderingGroup {
  97442. index: number;
  97443. private static _zeroVector;
  97444. private _scene;
  97445. private _opaqueSubMeshes;
  97446. private _transparentSubMeshes;
  97447. private _alphaTestSubMeshes;
  97448. private _depthOnlySubMeshes;
  97449. private _particleSystems;
  97450. private _spriteManagers;
  97451. private _opaqueSortCompareFn;
  97452. private _alphaTestSortCompareFn;
  97453. private _transparentSortCompareFn;
  97454. private _renderOpaque;
  97455. private _renderAlphaTest;
  97456. private _renderTransparent;
  97457. /** @hidden */
  97458. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97459. onBeforeTransparentRendering: () => void;
  97460. /**
  97461. * Set the opaque sort comparison function.
  97462. * If null the sub meshes will be render in the order they were created
  97463. */
  97464. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97465. /**
  97466. * Set the alpha test sort comparison function.
  97467. * If null the sub meshes will be render in the order they were created
  97468. */
  97469. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97470. /**
  97471. * Set the transparent sort comparison function.
  97472. * If null the sub meshes will be render in the order they were created
  97473. */
  97474. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97475. /**
  97476. * Creates a new rendering group.
  97477. * @param index The rendering group index
  97478. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97479. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97480. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97481. */
  97482. 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>);
  97483. /**
  97484. * Render all the sub meshes contained in the group.
  97485. * @param customRenderFunction Used to override the default render behaviour of the group.
  97486. * @returns true if rendered some submeshes.
  97487. */
  97488. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97489. /**
  97490. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97491. * @param subMeshes The submeshes to render
  97492. */
  97493. private renderOpaqueSorted;
  97494. /**
  97495. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97496. * @param subMeshes The submeshes to render
  97497. */
  97498. private renderAlphaTestSorted;
  97499. /**
  97500. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97501. * @param subMeshes The submeshes to render
  97502. */
  97503. private renderTransparentSorted;
  97504. /**
  97505. * Renders the submeshes in a specified order.
  97506. * @param subMeshes The submeshes to sort before render
  97507. * @param sortCompareFn The comparison function use to sort
  97508. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97509. * @param transparent Specifies to activate blending if true
  97510. */
  97511. private static renderSorted;
  97512. /**
  97513. * Renders the submeshes in the order they were dispatched (no sort applied).
  97514. * @param subMeshes The submeshes to render
  97515. */
  97516. private static renderUnsorted;
  97517. /**
  97518. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97519. * are rendered back to front if in the same alpha index.
  97520. *
  97521. * @param a The first submesh
  97522. * @param b The second submesh
  97523. * @returns The result of the comparison
  97524. */
  97525. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97526. /**
  97527. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97528. * are rendered back to front.
  97529. *
  97530. * @param a The first submesh
  97531. * @param b The second submesh
  97532. * @returns The result of the comparison
  97533. */
  97534. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97535. /**
  97536. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97537. * are rendered front to back (prevent overdraw).
  97538. *
  97539. * @param a The first submesh
  97540. * @param b The second submesh
  97541. * @returns The result of the comparison
  97542. */
  97543. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97544. /**
  97545. * Resets the different lists of submeshes to prepare a new frame.
  97546. */
  97547. prepare(): void;
  97548. dispose(): void;
  97549. /**
  97550. * Inserts the submesh in its correct queue depending on its material.
  97551. * @param subMesh The submesh to dispatch
  97552. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97553. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97554. */
  97555. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97556. dispatchSprites(spriteManager: ISpriteManager): void;
  97557. dispatchParticles(particleSystem: IParticleSystem): void;
  97558. private _renderParticles;
  97559. private _renderSprites;
  97560. }
  97561. }
  97562. declare module BABYLON {
  97563. /**
  97564. * Interface describing the different options available in the rendering manager
  97565. * regarding Auto Clear between groups.
  97566. */
  97567. export interface IRenderingManagerAutoClearSetup {
  97568. /**
  97569. * Defines whether or not autoclear is enable.
  97570. */
  97571. autoClear: boolean;
  97572. /**
  97573. * Defines whether or not to autoclear the depth buffer.
  97574. */
  97575. depth: boolean;
  97576. /**
  97577. * Defines whether or not to autoclear the stencil buffer.
  97578. */
  97579. stencil: boolean;
  97580. }
  97581. /**
  97582. * This class is used by the onRenderingGroupObservable
  97583. */
  97584. export class RenderingGroupInfo {
  97585. /**
  97586. * The Scene that being rendered
  97587. */
  97588. scene: Scene;
  97589. /**
  97590. * The camera currently used for the rendering pass
  97591. */
  97592. camera: Nullable<Camera>;
  97593. /**
  97594. * The ID of the renderingGroup being processed
  97595. */
  97596. renderingGroupId: number;
  97597. }
  97598. /**
  97599. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97600. * It is enable to manage the different groups as well as the different necessary sort functions.
  97601. * This should not be used directly aside of the few static configurations
  97602. */
  97603. export class RenderingManager {
  97604. /**
  97605. * The max id used for rendering groups (not included)
  97606. */
  97607. static MAX_RENDERINGGROUPS: number;
  97608. /**
  97609. * The min id used for rendering groups (included)
  97610. */
  97611. static MIN_RENDERINGGROUPS: number;
  97612. /**
  97613. * Used to globally prevent autoclearing scenes.
  97614. */
  97615. static AUTOCLEAR: boolean;
  97616. /**
  97617. * @hidden
  97618. */
  97619. _useSceneAutoClearSetup: boolean;
  97620. private _scene;
  97621. private _renderingGroups;
  97622. private _depthStencilBufferAlreadyCleaned;
  97623. private _autoClearDepthStencil;
  97624. private _customOpaqueSortCompareFn;
  97625. private _customAlphaTestSortCompareFn;
  97626. private _customTransparentSortCompareFn;
  97627. private _renderingGroupInfo;
  97628. /**
  97629. * Instantiates a new rendering group for a particular scene
  97630. * @param scene Defines the scene the groups belongs to
  97631. */
  97632. constructor(scene: Scene);
  97633. private _clearDepthStencilBuffer;
  97634. /**
  97635. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97636. * @hidden
  97637. */
  97638. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97639. /**
  97640. * Resets the different information of the group to prepare a new frame
  97641. * @hidden
  97642. */
  97643. reset(): void;
  97644. /**
  97645. * Dispose and release the group and its associated resources.
  97646. * @hidden
  97647. */
  97648. dispose(): void;
  97649. /**
  97650. * Clear the info related to rendering groups preventing retention points during dispose.
  97651. */
  97652. freeRenderingGroups(): void;
  97653. private _prepareRenderingGroup;
  97654. /**
  97655. * Add a sprite manager to the rendering manager in order to render it this frame.
  97656. * @param spriteManager Define the sprite manager to render
  97657. */
  97658. dispatchSprites(spriteManager: ISpriteManager): void;
  97659. /**
  97660. * Add a particle system to the rendering manager in order to render it this frame.
  97661. * @param particleSystem Define the particle system to render
  97662. */
  97663. dispatchParticles(particleSystem: IParticleSystem): void;
  97664. /**
  97665. * Add a submesh to the manager in order to render it this frame
  97666. * @param subMesh The submesh to dispatch
  97667. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97668. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97669. */
  97670. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97671. /**
  97672. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97673. * This allowed control for front to back rendering or reversly depending of the special needs.
  97674. *
  97675. * @param renderingGroupId The rendering group id corresponding to its index
  97676. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97677. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97678. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97679. */
  97680. 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;
  97681. /**
  97682. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97683. *
  97684. * @param renderingGroupId The rendering group id corresponding to its index
  97685. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97686. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97687. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97688. */
  97689. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97690. /**
  97691. * Gets the current auto clear configuration for one rendering group of the rendering
  97692. * manager.
  97693. * @param index the rendering group index to get the information for
  97694. * @returns The auto clear setup for the requested rendering group
  97695. */
  97696. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97697. }
  97698. }
  97699. declare module BABYLON {
  97700. /**
  97701. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97702. */
  97703. export interface ICustomShaderOptions {
  97704. /**
  97705. * Gets or sets the custom shader name to use
  97706. */
  97707. shaderName: string;
  97708. /**
  97709. * The list of attribute names used in the shader
  97710. */
  97711. attributes?: string[];
  97712. /**
  97713. * The list of unifrom names used in the shader
  97714. */
  97715. uniforms?: string[];
  97716. /**
  97717. * The list of sampler names used in the shader
  97718. */
  97719. samplers?: string[];
  97720. /**
  97721. * The list of defines used in the shader
  97722. */
  97723. defines?: string[];
  97724. }
  97725. /**
  97726. * Interface to implement to create a shadow generator compatible with BJS.
  97727. */
  97728. export interface IShadowGenerator {
  97729. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97730. id: string;
  97731. /**
  97732. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97733. * @returns The render target texture if present otherwise, null
  97734. */
  97735. getShadowMap(): Nullable<RenderTargetTexture>;
  97736. /**
  97737. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97738. * @param subMesh The submesh we want to render in the shadow map
  97739. * @param useInstances Defines wether will draw in the map using instances
  97740. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97741. * @returns true if ready otherwise, false
  97742. */
  97743. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97744. /**
  97745. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97746. * @param defines Defines of the material we want to update
  97747. * @param lightIndex Index of the light in the enabled light list of the material
  97748. */
  97749. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97750. /**
  97751. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97752. * defined in the generator but impacting the effect).
  97753. * It implies the unifroms available on the materials are the standard BJS ones.
  97754. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97755. * @param effect The effect we are binfing the information for
  97756. */
  97757. bindShadowLight(lightIndex: string, effect: Effect): void;
  97758. /**
  97759. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97760. * (eq to shadow prjection matrix * light transform matrix)
  97761. * @returns The transform matrix used to create the shadow map
  97762. */
  97763. getTransformMatrix(): Matrix;
  97764. /**
  97765. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97766. * Cube and 2D textures for instance.
  97767. */
  97768. recreateShadowMap(): void;
  97769. /**
  97770. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97771. * @param onCompiled Callback triggered at the and of the effects compilation
  97772. * @param options Sets of optional options forcing the compilation with different modes
  97773. */
  97774. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97775. useInstances: boolean;
  97776. }>): void;
  97777. /**
  97778. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97779. * @param options Sets of optional options forcing the compilation with different modes
  97780. * @returns A promise that resolves when the compilation completes
  97781. */
  97782. forceCompilationAsync(options?: Partial<{
  97783. useInstances: boolean;
  97784. }>): Promise<void>;
  97785. /**
  97786. * Serializes the shadow generator setup to a json object.
  97787. * @returns The serialized JSON object
  97788. */
  97789. serialize(): any;
  97790. /**
  97791. * Disposes the Shadow map and related Textures and effects.
  97792. */
  97793. dispose(): void;
  97794. }
  97795. /**
  97796. * Default implementation IShadowGenerator.
  97797. * This is the main object responsible of generating shadows in the framework.
  97798. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97799. */
  97800. export class ShadowGenerator implements IShadowGenerator {
  97801. /**
  97802. * Name of the shadow generator class
  97803. */
  97804. static CLASSNAME: string;
  97805. /**
  97806. * Shadow generator mode None: no filtering applied.
  97807. */
  97808. static readonly FILTER_NONE: number;
  97809. /**
  97810. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97811. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97812. */
  97813. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97814. /**
  97815. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97816. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97817. */
  97818. static readonly FILTER_POISSONSAMPLING: number;
  97819. /**
  97820. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97821. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97822. */
  97823. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97824. /**
  97825. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97826. * edge artifacts on steep falloff.
  97827. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97828. */
  97829. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97830. /**
  97831. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97832. * edge artifacts on steep falloff.
  97833. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97834. */
  97835. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97836. /**
  97837. * Shadow generator mode PCF: Percentage Closer Filtering
  97838. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97839. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97840. */
  97841. static readonly FILTER_PCF: number;
  97842. /**
  97843. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97844. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97845. * Contact Hardening
  97846. */
  97847. static readonly FILTER_PCSS: number;
  97848. /**
  97849. * Reserved for PCF and PCSS
  97850. * Highest Quality.
  97851. *
  97852. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97853. *
  97854. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97855. */
  97856. static readonly QUALITY_HIGH: number;
  97857. /**
  97858. * Reserved for PCF and PCSS
  97859. * Good tradeoff for quality/perf cross devices
  97860. *
  97861. * Execute PCF on a 3*3 kernel.
  97862. *
  97863. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97864. */
  97865. static readonly QUALITY_MEDIUM: number;
  97866. /**
  97867. * Reserved for PCF and PCSS
  97868. * The lowest quality but the fastest.
  97869. *
  97870. * Execute PCF on a 1*1 kernel.
  97871. *
  97872. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97873. */
  97874. static readonly QUALITY_LOW: number;
  97875. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97876. id: string;
  97877. /** Gets or sets the custom shader name to use */
  97878. customShaderOptions: ICustomShaderOptions;
  97879. /**
  97880. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97881. */
  97882. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97883. /**
  97884. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97885. */
  97886. onAfterShadowMapRenderObservable: Observable<Effect>;
  97887. /**
  97888. * Observable triggered before a mesh is rendered in the shadow map.
  97889. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97890. */
  97891. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97892. /**
  97893. * Observable triggered after a mesh is rendered in the shadow map.
  97894. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97895. */
  97896. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97897. protected _bias: number;
  97898. /**
  97899. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97900. */
  97901. get bias(): number;
  97902. /**
  97903. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97904. */
  97905. set bias(bias: number);
  97906. protected _normalBias: number;
  97907. /**
  97908. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97909. */
  97910. get normalBias(): number;
  97911. /**
  97912. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97913. */
  97914. set normalBias(normalBias: number);
  97915. protected _blurBoxOffset: number;
  97916. /**
  97917. * Gets the blur box offset: offset applied during the blur pass.
  97918. * Only useful if useKernelBlur = false
  97919. */
  97920. get blurBoxOffset(): number;
  97921. /**
  97922. * Sets the blur box offset: offset applied during the blur pass.
  97923. * Only useful if useKernelBlur = false
  97924. */
  97925. set blurBoxOffset(value: number);
  97926. protected _blurScale: number;
  97927. /**
  97928. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  97929. * 2 means half of the size.
  97930. */
  97931. get blurScale(): number;
  97932. /**
  97933. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  97934. * 2 means half of the size.
  97935. */
  97936. set blurScale(value: number);
  97937. protected _blurKernel: number;
  97938. /**
  97939. * Gets the blur kernel: kernel size of the blur pass.
  97940. * Only useful if useKernelBlur = true
  97941. */
  97942. get blurKernel(): number;
  97943. /**
  97944. * Sets the blur kernel: kernel size of the blur pass.
  97945. * Only useful if useKernelBlur = true
  97946. */
  97947. set blurKernel(value: number);
  97948. protected _useKernelBlur: boolean;
  97949. /**
  97950. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  97951. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97952. */
  97953. get useKernelBlur(): boolean;
  97954. /**
  97955. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  97956. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97957. */
  97958. set useKernelBlur(value: boolean);
  97959. protected _depthScale: number;
  97960. /**
  97961. * Gets the depth scale used in ESM mode.
  97962. */
  97963. get depthScale(): number;
  97964. /**
  97965. * Sets the depth scale used in ESM mode.
  97966. * This can override the scale stored on the light.
  97967. */
  97968. set depthScale(value: number);
  97969. protected _validateFilter(filter: number): number;
  97970. protected _filter: number;
  97971. /**
  97972. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  97973. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97974. */
  97975. get filter(): number;
  97976. /**
  97977. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  97978. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97979. */
  97980. set filter(value: number);
  97981. /**
  97982. * Gets if the current filter is set to Poisson Sampling.
  97983. */
  97984. get usePoissonSampling(): boolean;
  97985. /**
  97986. * Sets the current filter to Poisson Sampling.
  97987. */
  97988. set usePoissonSampling(value: boolean);
  97989. /**
  97990. * Gets if the current filter is set to ESM.
  97991. */
  97992. get useExponentialShadowMap(): boolean;
  97993. /**
  97994. * Sets the current filter is to ESM.
  97995. */
  97996. set useExponentialShadowMap(value: boolean);
  97997. /**
  97998. * Gets if the current filter is set to filtered ESM.
  97999. */
  98000. get useBlurExponentialShadowMap(): boolean;
  98001. /**
  98002. * Gets if the current filter is set to filtered ESM.
  98003. */
  98004. set useBlurExponentialShadowMap(value: boolean);
  98005. /**
  98006. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98007. * exponential to prevent steep falloff artifacts).
  98008. */
  98009. get useCloseExponentialShadowMap(): boolean;
  98010. /**
  98011. * Sets the current filter to "close ESM" (using the inverse of the
  98012. * exponential to prevent steep falloff artifacts).
  98013. */
  98014. set useCloseExponentialShadowMap(value: boolean);
  98015. /**
  98016. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98017. * exponential to prevent steep falloff artifacts).
  98018. */
  98019. get useBlurCloseExponentialShadowMap(): boolean;
  98020. /**
  98021. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98022. * exponential to prevent steep falloff artifacts).
  98023. */
  98024. set useBlurCloseExponentialShadowMap(value: boolean);
  98025. /**
  98026. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98027. */
  98028. get usePercentageCloserFiltering(): boolean;
  98029. /**
  98030. * Sets the current filter to "PCF" (percentage closer filtering).
  98031. */
  98032. set usePercentageCloserFiltering(value: boolean);
  98033. protected _filteringQuality: number;
  98034. /**
  98035. * Gets the PCF or PCSS Quality.
  98036. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98037. */
  98038. get filteringQuality(): number;
  98039. /**
  98040. * Sets the PCF or PCSS Quality.
  98041. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98042. */
  98043. set filteringQuality(filteringQuality: number);
  98044. /**
  98045. * Gets if the current filter is set to "PCSS" (contact hardening).
  98046. */
  98047. get useContactHardeningShadow(): boolean;
  98048. /**
  98049. * Sets the current filter to "PCSS" (contact hardening).
  98050. */
  98051. set useContactHardeningShadow(value: boolean);
  98052. protected _contactHardeningLightSizeUVRatio: number;
  98053. /**
  98054. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98055. * Using a ratio helps keeping shape stability independently of the map size.
  98056. *
  98057. * It does not account for the light projection as it was having too much
  98058. * instability during the light setup or during light position changes.
  98059. *
  98060. * Only valid if useContactHardeningShadow is true.
  98061. */
  98062. get contactHardeningLightSizeUVRatio(): number;
  98063. /**
  98064. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98065. * Using a ratio helps keeping shape stability independently of the map size.
  98066. *
  98067. * It does not account for the light projection as it was having too much
  98068. * instability during the light setup or during light position changes.
  98069. *
  98070. * Only valid if useContactHardeningShadow is true.
  98071. */
  98072. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98073. protected _darkness: number;
  98074. /** Gets or sets the actual darkness of a shadow */
  98075. get darkness(): number;
  98076. set darkness(value: number);
  98077. /**
  98078. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98079. * 0 means strongest and 1 would means no shadow.
  98080. * @returns the darkness.
  98081. */
  98082. getDarkness(): number;
  98083. /**
  98084. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98085. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98086. * @returns the shadow generator allowing fluent coding.
  98087. */
  98088. setDarkness(darkness: number): ShadowGenerator;
  98089. protected _transparencyShadow: boolean;
  98090. /** Gets or sets the ability to have transparent shadow */
  98091. get transparencyShadow(): boolean;
  98092. set transparencyShadow(value: boolean);
  98093. /**
  98094. * Sets the ability to have transparent shadow (boolean).
  98095. * @param transparent True if transparent else False
  98096. * @returns the shadow generator allowing fluent coding
  98097. */
  98098. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98099. /**
  98100. * Enables or disables shadows with varying strength based on the transparency
  98101. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98102. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98103. * mesh.visibility * alphaTexture.a
  98104. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98105. */
  98106. enableSoftTransparentShadow: boolean;
  98107. protected _shadowMap: Nullable<RenderTargetTexture>;
  98108. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98109. /**
  98110. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98111. * @returns The render target texture if present otherwise, null
  98112. */
  98113. getShadowMap(): Nullable<RenderTargetTexture>;
  98114. /**
  98115. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98116. * @returns The render target texture if the shadow map is present otherwise, null
  98117. */
  98118. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98119. /**
  98120. * Gets the class name of that object
  98121. * @returns "ShadowGenerator"
  98122. */
  98123. getClassName(): string;
  98124. /**
  98125. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98126. * @param mesh Mesh to add
  98127. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98128. * @returns the Shadow Generator itself
  98129. */
  98130. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98131. /**
  98132. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98133. * @param mesh Mesh to remove
  98134. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98135. * @returns the Shadow Generator itself
  98136. */
  98137. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98138. /**
  98139. * Controls the extent to which the shadows fade out at the edge of the frustum
  98140. */
  98141. frustumEdgeFalloff: number;
  98142. protected _light: IShadowLight;
  98143. /**
  98144. * Returns the associated light object.
  98145. * @returns the light generating the shadow
  98146. */
  98147. getLight(): IShadowLight;
  98148. /**
  98149. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98150. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98151. * It might on the other hand introduce peter panning.
  98152. */
  98153. forceBackFacesOnly: boolean;
  98154. protected _scene: Scene;
  98155. protected _lightDirection: Vector3;
  98156. protected _effect: Effect;
  98157. protected _viewMatrix: Matrix;
  98158. protected _projectionMatrix: Matrix;
  98159. protected _transformMatrix: Matrix;
  98160. protected _cachedPosition: Vector3;
  98161. protected _cachedDirection: Vector3;
  98162. protected _cachedDefines: string;
  98163. protected _currentRenderID: number;
  98164. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98165. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98166. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98167. protected _blurPostProcesses: PostProcess[];
  98168. protected _mapSize: number;
  98169. protected _currentFaceIndex: number;
  98170. protected _currentFaceIndexCache: number;
  98171. protected _textureType: number;
  98172. protected _defaultTextureMatrix: Matrix;
  98173. protected _storedUniqueId: Nullable<number>;
  98174. /** @hidden */
  98175. static _SceneComponentInitialization: (scene: Scene) => void;
  98176. /**
  98177. * Creates a ShadowGenerator object.
  98178. * A ShadowGenerator is the required tool to use the shadows.
  98179. * Each light casting shadows needs to use its own ShadowGenerator.
  98180. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98181. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98182. * @param light The light object generating the shadows.
  98183. * @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.
  98184. */
  98185. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98186. protected _initializeGenerator(): void;
  98187. protected _createTargetRenderTexture(): void;
  98188. protected _initializeShadowMap(): void;
  98189. protected _initializeBlurRTTAndPostProcesses(): void;
  98190. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98191. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98192. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98193. protected _applyFilterValues(): void;
  98194. /**
  98195. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98196. * @param onCompiled Callback triggered at the and of the effects compilation
  98197. * @param options Sets of optional options forcing the compilation with different modes
  98198. */
  98199. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98200. useInstances: boolean;
  98201. }>): void;
  98202. /**
  98203. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98204. * @param options Sets of optional options forcing the compilation with different modes
  98205. * @returns A promise that resolves when the compilation completes
  98206. */
  98207. forceCompilationAsync(options?: Partial<{
  98208. useInstances: boolean;
  98209. }>): Promise<void>;
  98210. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98211. private _prepareShadowDefines;
  98212. /**
  98213. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98214. * @param subMesh The submesh we want to render in the shadow map
  98215. * @param useInstances Defines wether will draw in the map using instances
  98216. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98217. * @returns true if ready otherwise, false
  98218. */
  98219. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98220. /**
  98221. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98222. * @param defines Defines of the material we want to update
  98223. * @param lightIndex Index of the light in the enabled light list of the material
  98224. */
  98225. prepareDefines(defines: any, lightIndex: number): void;
  98226. /**
  98227. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98228. * defined in the generator but impacting the effect).
  98229. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98230. * @param effect The effect we are binfing the information for
  98231. */
  98232. bindShadowLight(lightIndex: string, effect: Effect): void;
  98233. /**
  98234. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98235. * (eq to shadow prjection matrix * light transform matrix)
  98236. * @returns The transform matrix used to create the shadow map
  98237. */
  98238. getTransformMatrix(): Matrix;
  98239. /**
  98240. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98241. * Cube and 2D textures for instance.
  98242. */
  98243. recreateShadowMap(): void;
  98244. protected _disposeBlurPostProcesses(): void;
  98245. protected _disposeRTTandPostProcesses(): void;
  98246. /**
  98247. * Disposes the ShadowGenerator.
  98248. * Returns nothing.
  98249. */
  98250. dispose(): void;
  98251. /**
  98252. * Serializes the shadow generator setup to a json object.
  98253. * @returns The serialized JSON object
  98254. */
  98255. serialize(): any;
  98256. /**
  98257. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98258. * @param parsedShadowGenerator The JSON object to parse
  98259. * @param scene The scene to create the shadow map for
  98260. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98261. * @returns The parsed shadow generator
  98262. */
  98263. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98264. }
  98265. }
  98266. declare module BABYLON {
  98267. /**
  98268. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98269. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98270. * 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.
  98271. */
  98272. export abstract class Light extends Node {
  98273. /**
  98274. * Falloff Default: light is falling off following the material specification:
  98275. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98276. */
  98277. static readonly FALLOFF_DEFAULT: number;
  98278. /**
  98279. * Falloff Physical: light is falling off following the inverse squared distance law.
  98280. */
  98281. static readonly FALLOFF_PHYSICAL: number;
  98282. /**
  98283. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98284. * to enhance interoperability with other engines.
  98285. */
  98286. static readonly FALLOFF_GLTF: number;
  98287. /**
  98288. * Falloff Standard: light is falling off like in the standard material
  98289. * to enhance interoperability with other materials.
  98290. */
  98291. static readonly FALLOFF_STANDARD: number;
  98292. /**
  98293. * If every light affecting the material is in this lightmapMode,
  98294. * material.lightmapTexture adds or multiplies
  98295. * (depends on material.useLightmapAsShadowmap)
  98296. * after every other light calculations.
  98297. */
  98298. static readonly LIGHTMAP_DEFAULT: number;
  98299. /**
  98300. * material.lightmapTexture as only diffuse lighting from this light
  98301. * adds only specular lighting from this light
  98302. * adds dynamic shadows
  98303. */
  98304. static readonly LIGHTMAP_SPECULAR: number;
  98305. /**
  98306. * material.lightmapTexture as only lighting
  98307. * no light calculation from this light
  98308. * only adds dynamic shadows from this light
  98309. */
  98310. static readonly LIGHTMAP_SHADOWSONLY: number;
  98311. /**
  98312. * Each light type uses the default quantity according to its type:
  98313. * point/spot lights use luminous intensity
  98314. * directional lights use illuminance
  98315. */
  98316. static readonly INTENSITYMODE_AUTOMATIC: number;
  98317. /**
  98318. * lumen (lm)
  98319. */
  98320. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98321. /**
  98322. * candela (lm/sr)
  98323. */
  98324. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98325. /**
  98326. * lux (lm/m^2)
  98327. */
  98328. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98329. /**
  98330. * nit (cd/m^2)
  98331. */
  98332. static readonly INTENSITYMODE_LUMINANCE: number;
  98333. /**
  98334. * Light type const id of the point light.
  98335. */
  98336. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98337. /**
  98338. * Light type const id of the directional light.
  98339. */
  98340. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98341. /**
  98342. * Light type const id of the spot light.
  98343. */
  98344. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98345. /**
  98346. * Light type const id of the hemispheric light.
  98347. */
  98348. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98349. /**
  98350. * Diffuse gives the basic color to an object.
  98351. */
  98352. diffuse: Color3;
  98353. /**
  98354. * Specular produces a highlight color on an object.
  98355. * Note: This is note affecting PBR materials.
  98356. */
  98357. specular: Color3;
  98358. /**
  98359. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98360. * falling off base on range or angle.
  98361. * This can be set to any values in Light.FALLOFF_x.
  98362. *
  98363. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98364. * other types of materials.
  98365. */
  98366. falloffType: number;
  98367. /**
  98368. * Strength of the light.
  98369. * Note: By default it is define in the framework own unit.
  98370. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98371. */
  98372. intensity: number;
  98373. private _range;
  98374. protected _inverseSquaredRange: number;
  98375. /**
  98376. * Defines how far from the source the light is impacting in scene units.
  98377. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98378. */
  98379. get range(): number;
  98380. /**
  98381. * Defines how far from the source the light is impacting in scene units.
  98382. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98383. */
  98384. set range(value: number);
  98385. /**
  98386. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98387. * of light.
  98388. */
  98389. private _photometricScale;
  98390. private _intensityMode;
  98391. /**
  98392. * Gets the photometric scale used to interpret the intensity.
  98393. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98394. */
  98395. get intensityMode(): number;
  98396. /**
  98397. * Sets the photometric scale used to interpret the intensity.
  98398. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98399. */
  98400. set intensityMode(value: number);
  98401. private _radius;
  98402. /**
  98403. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98404. */
  98405. get radius(): number;
  98406. /**
  98407. * sets the light radius used by PBR Materials to simulate soft area lights.
  98408. */
  98409. set radius(value: number);
  98410. private _renderPriority;
  98411. /**
  98412. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98413. * exceeding the number allowed of the materials.
  98414. */
  98415. renderPriority: number;
  98416. private _shadowEnabled;
  98417. /**
  98418. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98419. * the current shadow generator.
  98420. */
  98421. get shadowEnabled(): boolean;
  98422. /**
  98423. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98424. * the current shadow generator.
  98425. */
  98426. set shadowEnabled(value: boolean);
  98427. private _includedOnlyMeshes;
  98428. /**
  98429. * Gets the only meshes impacted by this light.
  98430. */
  98431. get includedOnlyMeshes(): AbstractMesh[];
  98432. /**
  98433. * Sets the only meshes impacted by this light.
  98434. */
  98435. set includedOnlyMeshes(value: AbstractMesh[]);
  98436. private _excludedMeshes;
  98437. /**
  98438. * Gets the meshes not impacted by this light.
  98439. */
  98440. get excludedMeshes(): AbstractMesh[];
  98441. /**
  98442. * Sets the meshes not impacted by this light.
  98443. */
  98444. set excludedMeshes(value: AbstractMesh[]);
  98445. private _excludeWithLayerMask;
  98446. /**
  98447. * Gets the layer id use to find what meshes are not impacted by the light.
  98448. * Inactive if 0
  98449. */
  98450. get excludeWithLayerMask(): number;
  98451. /**
  98452. * Sets the layer id use to find what meshes are not impacted by the light.
  98453. * Inactive if 0
  98454. */
  98455. set excludeWithLayerMask(value: number);
  98456. private _includeOnlyWithLayerMask;
  98457. /**
  98458. * Gets the layer id use to find what meshes are impacted by the light.
  98459. * Inactive if 0
  98460. */
  98461. get includeOnlyWithLayerMask(): number;
  98462. /**
  98463. * Sets the layer id use to find what meshes are impacted by the light.
  98464. * Inactive if 0
  98465. */
  98466. set includeOnlyWithLayerMask(value: number);
  98467. private _lightmapMode;
  98468. /**
  98469. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98470. */
  98471. get lightmapMode(): number;
  98472. /**
  98473. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98474. */
  98475. set lightmapMode(value: number);
  98476. /**
  98477. * Shadow generator associted to the light.
  98478. * @hidden Internal use only.
  98479. */
  98480. _shadowGenerator: Nullable<IShadowGenerator>;
  98481. /**
  98482. * @hidden Internal use only.
  98483. */
  98484. _excludedMeshesIds: string[];
  98485. /**
  98486. * @hidden Internal use only.
  98487. */
  98488. _includedOnlyMeshesIds: string[];
  98489. /**
  98490. * The current light unifom buffer.
  98491. * @hidden Internal use only.
  98492. */
  98493. _uniformBuffer: UniformBuffer;
  98494. /** @hidden */
  98495. _renderId: number;
  98496. /**
  98497. * Creates a Light object in the scene.
  98498. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98499. * @param name The firendly name of the light
  98500. * @param scene The scene the light belongs too
  98501. */
  98502. constructor(name: string, scene: Scene);
  98503. protected abstract _buildUniformLayout(): void;
  98504. /**
  98505. * Sets the passed Effect "effect" with the Light information.
  98506. * @param effect The effect to update
  98507. * @param lightIndex The index of the light in the effect to update
  98508. * @returns The light
  98509. */
  98510. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98511. /**
  98512. * Sets the passed Effect "effect" with the Light textures.
  98513. * @param effect The effect to update
  98514. * @param lightIndex The index of the light in the effect to update
  98515. * @returns The light
  98516. */
  98517. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98518. /**
  98519. * Binds the lights information from the scene to the effect for the given mesh.
  98520. * @param lightIndex Light index
  98521. * @param scene The scene where the light belongs to
  98522. * @param effect The effect we are binding the data to
  98523. * @param useSpecular Defines if specular is supported
  98524. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98525. */
  98526. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98527. /**
  98528. * Sets the passed Effect "effect" with the Light information.
  98529. * @param effect The effect to update
  98530. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98531. * @returns The light
  98532. */
  98533. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98534. /**
  98535. * Returns the string "Light".
  98536. * @returns the class name
  98537. */
  98538. getClassName(): string;
  98539. /** @hidden */
  98540. readonly _isLight: boolean;
  98541. /**
  98542. * Converts the light information to a readable string for debug purpose.
  98543. * @param fullDetails Supports for multiple levels of logging within scene loading
  98544. * @returns the human readable light info
  98545. */
  98546. toString(fullDetails?: boolean): string;
  98547. /** @hidden */
  98548. protected _syncParentEnabledState(): void;
  98549. /**
  98550. * Set the enabled state of this node.
  98551. * @param value - the new enabled state
  98552. */
  98553. setEnabled(value: boolean): void;
  98554. /**
  98555. * Returns the Light associated shadow generator if any.
  98556. * @return the associated shadow generator.
  98557. */
  98558. getShadowGenerator(): Nullable<IShadowGenerator>;
  98559. /**
  98560. * Returns a Vector3, the absolute light position in the World.
  98561. * @returns the world space position of the light
  98562. */
  98563. getAbsolutePosition(): Vector3;
  98564. /**
  98565. * Specifies if the light will affect the passed mesh.
  98566. * @param mesh The mesh to test against the light
  98567. * @return true the mesh is affected otherwise, false.
  98568. */
  98569. canAffectMesh(mesh: AbstractMesh): boolean;
  98570. /**
  98571. * Sort function to order lights for rendering.
  98572. * @param a First Light object to compare to second.
  98573. * @param b Second Light object to compare first.
  98574. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98575. */
  98576. static CompareLightsPriority(a: Light, b: Light): number;
  98577. /**
  98578. * Releases resources associated with this node.
  98579. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98580. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98581. */
  98582. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98583. /**
  98584. * Returns the light type ID (integer).
  98585. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98586. */
  98587. getTypeID(): number;
  98588. /**
  98589. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98590. * @returns the scaled intensity in intensity mode unit
  98591. */
  98592. getScaledIntensity(): number;
  98593. /**
  98594. * Returns a new Light object, named "name", from the current one.
  98595. * @param name The name of the cloned light
  98596. * @param newParent The parent of this light, if it has one
  98597. * @returns the new created light
  98598. */
  98599. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98600. /**
  98601. * Serializes the current light into a Serialization object.
  98602. * @returns the serialized object.
  98603. */
  98604. serialize(): any;
  98605. /**
  98606. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98607. * This new light is named "name" and added to the passed scene.
  98608. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98609. * @param name The friendly name of the light
  98610. * @param scene The scene the new light will belong to
  98611. * @returns the constructor function
  98612. */
  98613. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98614. /**
  98615. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98616. * @param parsedLight The JSON representation of the light
  98617. * @param scene The scene to create the parsed light in
  98618. * @returns the created light after parsing
  98619. */
  98620. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98621. private _hookArrayForExcluded;
  98622. private _hookArrayForIncludedOnly;
  98623. private _resyncMeshes;
  98624. /**
  98625. * Forces the meshes to update their light related information in their rendering used effects
  98626. * @hidden Internal Use Only
  98627. */
  98628. _markMeshesAsLightDirty(): void;
  98629. /**
  98630. * Recomputes the cached photometric scale if needed.
  98631. */
  98632. private _computePhotometricScale;
  98633. /**
  98634. * Returns the Photometric Scale according to the light type and intensity mode.
  98635. */
  98636. private _getPhotometricScale;
  98637. /**
  98638. * Reorder the light in the scene according to their defined priority.
  98639. * @hidden Internal Use Only
  98640. */
  98641. _reorderLightsInScene(): void;
  98642. /**
  98643. * Prepares the list of defines specific to the light type.
  98644. * @param defines the list of defines
  98645. * @param lightIndex defines the index of the light for the effect
  98646. */
  98647. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98648. }
  98649. }
  98650. declare module BABYLON {
  98651. /**
  98652. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98653. * This is the base of the follow, arc rotate cameras and Free camera
  98654. * @see https://doc.babylonjs.com/features/cameras
  98655. */
  98656. export class TargetCamera extends Camera {
  98657. private static _RigCamTransformMatrix;
  98658. private static _TargetTransformMatrix;
  98659. private static _TargetFocalPoint;
  98660. private _tmpUpVector;
  98661. private _tmpTargetVector;
  98662. /**
  98663. * Define the current direction the camera is moving to
  98664. */
  98665. cameraDirection: Vector3;
  98666. /**
  98667. * Define the current rotation the camera is rotating to
  98668. */
  98669. cameraRotation: Vector2;
  98670. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98671. ignoreParentScaling: boolean;
  98672. /**
  98673. * When set, the up vector of the camera will be updated by the rotation of the camera
  98674. */
  98675. updateUpVectorFromRotation: boolean;
  98676. private _tmpQuaternion;
  98677. /**
  98678. * Define the current rotation of the camera
  98679. */
  98680. rotation: Vector3;
  98681. /**
  98682. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98683. */
  98684. rotationQuaternion: Quaternion;
  98685. /**
  98686. * Define the current speed of the camera
  98687. */
  98688. speed: number;
  98689. /**
  98690. * Add constraint to the camera to prevent it to move freely in all directions and
  98691. * around all axis.
  98692. */
  98693. noRotationConstraint: boolean;
  98694. /**
  98695. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98696. * panning
  98697. */
  98698. invertRotation: boolean;
  98699. /**
  98700. * Speed multiplier for inverse camera panning
  98701. */
  98702. inverseRotationSpeed: number;
  98703. /**
  98704. * Define the current target of the camera as an object or a position.
  98705. */
  98706. lockedTarget: any;
  98707. /** @hidden */
  98708. _currentTarget: Vector3;
  98709. /** @hidden */
  98710. _initialFocalDistance: number;
  98711. /** @hidden */
  98712. _viewMatrix: Matrix;
  98713. /** @hidden */
  98714. _camMatrix: Matrix;
  98715. /** @hidden */
  98716. _cameraTransformMatrix: Matrix;
  98717. /** @hidden */
  98718. _cameraRotationMatrix: Matrix;
  98719. /** @hidden */
  98720. _referencePoint: Vector3;
  98721. /** @hidden */
  98722. _transformedReferencePoint: Vector3;
  98723. /** @hidden */
  98724. _reset: () => void;
  98725. private _defaultUp;
  98726. /**
  98727. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98728. * This is the base of the follow, arc rotate cameras and Free camera
  98729. * @see https://doc.babylonjs.com/features/cameras
  98730. * @param name Defines the name of the camera in the scene
  98731. * @param position Defines the start position of the camera in the scene
  98732. * @param scene Defines the scene the camera belongs to
  98733. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98734. */
  98735. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98736. /**
  98737. * Gets the position in front of the camera at a given distance.
  98738. * @param distance The distance from the camera we want the position to be
  98739. * @returns the position
  98740. */
  98741. getFrontPosition(distance: number): Vector3;
  98742. /** @hidden */
  98743. _getLockedTargetPosition(): Nullable<Vector3>;
  98744. private _storedPosition;
  98745. private _storedRotation;
  98746. private _storedRotationQuaternion;
  98747. /**
  98748. * Store current camera state of the camera (fov, position, rotation, etc..)
  98749. * @returns the camera
  98750. */
  98751. storeState(): Camera;
  98752. /**
  98753. * Restored camera state. You must call storeState() first
  98754. * @returns whether it was successful or not
  98755. * @hidden
  98756. */
  98757. _restoreStateValues(): boolean;
  98758. /** @hidden */
  98759. _initCache(): void;
  98760. /** @hidden */
  98761. _updateCache(ignoreParentClass?: boolean): void;
  98762. /** @hidden */
  98763. _isSynchronizedViewMatrix(): boolean;
  98764. /** @hidden */
  98765. _computeLocalCameraSpeed(): number;
  98766. /**
  98767. * Defines the target the camera should look at.
  98768. * @param target Defines the new target as a Vector or a mesh
  98769. */
  98770. setTarget(target: Vector3): void;
  98771. /**
  98772. * Defines the target point of the camera.
  98773. * The camera looks towards it form the radius distance.
  98774. */
  98775. get target(): Vector3;
  98776. set target(value: Vector3);
  98777. /**
  98778. * Return the current target position of the camera. This value is expressed in local space.
  98779. * @returns the target position
  98780. */
  98781. getTarget(): Vector3;
  98782. /** @hidden */
  98783. _decideIfNeedsToMove(): boolean;
  98784. /** @hidden */
  98785. _updatePosition(): void;
  98786. /** @hidden */
  98787. _checkInputs(): void;
  98788. protected _updateCameraRotationMatrix(): void;
  98789. /**
  98790. * 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)
  98791. * @returns the current camera
  98792. */
  98793. private _rotateUpVectorWithCameraRotationMatrix;
  98794. private _cachedRotationZ;
  98795. private _cachedQuaternionRotationZ;
  98796. /** @hidden */
  98797. _getViewMatrix(): Matrix;
  98798. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98799. /**
  98800. * @hidden
  98801. */
  98802. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98803. /**
  98804. * @hidden
  98805. */
  98806. _updateRigCameras(): void;
  98807. private _getRigCamPositionAndTarget;
  98808. /**
  98809. * Gets the current object class name.
  98810. * @return the class name
  98811. */
  98812. getClassName(): string;
  98813. }
  98814. }
  98815. declare module BABYLON {
  98816. /**
  98817. * Gather the list of keyboard event types as constants.
  98818. */
  98819. export class KeyboardEventTypes {
  98820. /**
  98821. * The keydown event is fired when a key becomes active (pressed).
  98822. */
  98823. static readonly KEYDOWN: number;
  98824. /**
  98825. * The keyup event is fired when a key has been released.
  98826. */
  98827. static readonly KEYUP: number;
  98828. }
  98829. /**
  98830. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98831. */
  98832. export class KeyboardInfo {
  98833. /**
  98834. * Defines the type of event (KeyboardEventTypes)
  98835. */
  98836. type: number;
  98837. /**
  98838. * Defines the related dom event
  98839. */
  98840. event: KeyboardEvent;
  98841. /**
  98842. * Instantiates a new keyboard info.
  98843. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98844. * @param type Defines the type of event (KeyboardEventTypes)
  98845. * @param event Defines the related dom event
  98846. */
  98847. constructor(
  98848. /**
  98849. * Defines the type of event (KeyboardEventTypes)
  98850. */
  98851. type: number,
  98852. /**
  98853. * Defines the related dom event
  98854. */
  98855. event: KeyboardEvent);
  98856. }
  98857. /**
  98858. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98859. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98860. */
  98861. export class KeyboardInfoPre extends KeyboardInfo {
  98862. /**
  98863. * Defines the type of event (KeyboardEventTypes)
  98864. */
  98865. type: number;
  98866. /**
  98867. * Defines the related dom event
  98868. */
  98869. event: KeyboardEvent;
  98870. /**
  98871. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98872. */
  98873. skipOnPointerObservable: boolean;
  98874. /**
  98875. * Instantiates a new keyboard pre info.
  98876. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98877. * @param type Defines the type of event (KeyboardEventTypes)
  98878. * @param event Defines the related dom event
  98879. */
  98880. constructor(
  98881. /**
  98882. * Defines the type of event (KeyboardEventTypes)
  98883. */
  98884. type: number,
  98885. /**
  98886. * Defines the related dom event
  98887. */
  98888. event: KeyboardEvent);
  98889. }
  98890. }
  98891. declare module BABYLON {
  98892. /**
  98893. * Manage the keyboard inputs to control the movement of a free camera.
  98894. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98895. */
  98896. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98897. /**
  98898. * Defines the camera the input is attached to.
  98899. */
  98900. camera: FreeCamera;
  98901. /**
  98902. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98903. */
  98904. keysUp: number[];
  98905. /**
  98906. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98907. */
  98908. keysUpward: number[];
  98909. /**
  98910. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98911. */
  98912. keysDown: number[];
  98913. /**
  98914. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98915. */
  98916. keysDownward: number[];
  98917. /**
  98918. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98919. */
  98920. keysLeft: number[];
  98921. /**
  98922. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98923. */
  98924. keysRight: number[];
  98925. private _keys;
  98926. private _onCanvasBlurObserver;
  98927. private _onKeyboardObserver;
  98928. private _engine;
  98929. private _scene;
  98930. /**
  98931. * Attach the input controls to a specific dom element to get the input from.
  98932. * @param element Defines the element the controls should be listened from
  98933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98934. */
  98935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98936. /**
  98937. * Detach the current controls from the specified dom element.
  98938. * @param element Defines the element to stop listening the inputs from
  98939. */
  98940. detachControl(element: Nullable<HTMLElement>): void;
  98941. /**
  98942. * Update the current camera state depending on the inputs that have been used this frame.
  98943. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98944. */
  98945. checkInputs(): void;
  98946. /**
  98947. * Gets the class name of the current intput.
  98948. * @returns the class name
  98949. */
  98950. getClassName(): string;
  98951. /** @hidden */
  98952. _onLostFocus(): void;
  98953. /**
  98954. * Get the friendly name associated with the input class.
  98955. * @returns the input friendly name
  98956. */
  98957. getSimpleName(): string;
  98958. }
  98959. }
  98960. declare module BABYLON {
  98961. /**
  98962. * Gather the list of pointer event types as constants.
  98963. */
  98964. export class PointerEventTypes {
  98965. /**
  98966. * 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.
  98967. */
  98968. static readonly POINTERDOWN: number;
  98969. /**
  98970. * The pointerup event is fired when a pointer is no longer active.
  98971. */
  98972. static readonly POINTERUP: number;
  98973. /**
  98974. * The pointermove event is fired when a pointer changes coordinates.
  98975. */
  98976. static readonly POINTERMOVE: number;
  98977. /**
  98978. * The pointerwheel event is fired when a mouse wheel has been rotated.
  98979. */
  98980. static readonly POINTERWHEEL: number;
  98981. /**
  98982. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  98983. */
  98984. static readonly POINTERPICK: number;
  98985. /**
  98986. * The pointertap event is fired when a the object has been touched and released without drag.
  98987. */
  98988. static readonly POINTERTAP: number;
  98989. /**
  98990. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  98991. */
  98992. static readonly POINTERDOUBLETAP: number;
  98993. }
  98994. /**
  98995. * Base class of pointer info types.
  98996. */
  98997. export class PointerInfoBase {
  98998. /**
  98999. * Defines the type of event (PointerEventTypes)
  99000. */
  99001. type: number;
  99002. /**
  99003. * Defines the related dom event
  99004. */
  99005. event: PointerEvent | MouseWheelEvent;
  99006. /**
  99007. * Instantiates the base class of pointers info.
  99008. * @param type Defines the type of event (PointerEventTypes)
  99009. * @param event Defines the related dom event
  99010. */
  99011. constructor(
  99012. /**
  99013. * Defines the type of event (PointerEventTypes)
  99014. */
  99015. type: number,
  99016. /**
  99017. * Defines the related dom event
  99018. */
  99019. event: PointerEvent | MouseWheelEvent);
  99020. }
  99021. /**
  99022. * This class is used to store pointer related info for the onPrePointerObservable event.
  99023. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99024. */
  99025. export class PointerInfoPre extends PointerInfoBase {
  99026. /**
  99027. * Ray from a pointer if availible (eg. 6dof controller)
  99028. */
  99029. ray: Nullable<Ray>;
  99030. /**
  99031. * Defines the local position of the pointer on the canvas.
  99032. */
  99033. localPosition: Vector2;
  99034. /**
  99035. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99036. */
  99037. skipOnPointerObservable: boolean;
  99038. /**
  99039. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99040. * @param type Defines the type of event (PointerEventTypes)
  99041. * @param event Defines the related dom event
  99042. * @param localX Defines the local x coordinates of the pointer when the event occured
  99043. * @param localY Defines the local y coordinates of the pointer when the event occured
  99044. */
  99045. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99046. }
  99047. /**
  99048. * This type contains all the data related to a pointer event in Babylon.js.
  99049. * 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.
  99050. */
  99051. export class PointerInfo extends PointerInfoBase {
  99052. /**
  99053. * Defines the picking info associated to the info (if any)\
  99054. */
  99055. pickInfo: Nullable<PickingInfo>;
  99056. /**
  99057. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99058. * @param type Defines the type of event (PointerEventTypes)
  99059. * @param event Defines the related dom event
  99060. * @param pickInfo Defines the picking info associated to the info (if any)\
  99061. */
  99062. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99063. /**
  99064. * Defines the picking info associated to the info (if any)\
  99065. */
  99066. pickInfo: Nullable<PickingInfo>);
  99067. }
  99068. /**
  99069. * Data relating to a touch event on the screen.
  99070. */
  99071. export interface PointerTouch {
  99072. /**
  99073. * X coordinate of touch.
  99074. */
  99075. x: number;
  99076. /**
  99077. * Y coordinate of touch.
  99078. */
  99079. y: number;
  99080. /**
  99081. * Id of touch. Unique for each finger.
  99082. */
  99083. pointerId: number;
  99084. /**
  99085. * Event type passed from DOM.
  99086. */
  99087. type: any;
  99088. }
  99089. }
  99090. declare module BABYLON {
  99091. /**
  99092. * Manage the mouse inputs to control the movement of a free camera.
  99093. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99094. */
  99095. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99096. /**
  99097. * Define if touch is enabled in the mouse input
  99098. */
  99099. touchEnabled: boolean;
  99100. /**
  99101. * Defines the camera the input is attached to.
  99102. */
  99103. camera: FreeCamera;
  99104. /**
  99105. * Defines the buttons associated with the input to handle camera move.
  99106. */
  99107. buttons: number[];
  99108. /**
  99109. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99110. */
  99111. angularSensibility: number;
  99112. private _pointerInput;
  99113. private _onMouseMove;
  99114. private _observer;
  99115. private previousPosition;
  99116. /**
  99117. * Observable for when a pointer move event occurs containing the move offset
  99118. */
  99119. onPointerMovedObservable: Observable<{
  99120. offsetX: number;
  99121. offsetY: number;
  99122. }>;
  99123. /**
  99124. * @hidden
  99125. * If the camera should be rotated automatically based on pointer movement
  99126. */
  99127. _allowCameraRotation: boolean;
  99128. /**
  99129. * Manage the mouse inputs to control the movement of a free camera.
  99130. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99131. * @param touchEnabled Defines if touch is enabled or not
  99132. */
  99133. constructor(
  99134. /**
  99135. * Define if touch is enabled in the mouse input
  99136. */
  99137. touchEnabled?: boolean);
  99138. /**
  99139. * Attach the input controls to a specific dom element to get the input from.
  99140. * @param element Defines the element the controls should be listened from
  99141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99142. */
  99143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99144. /**
  99145. * Called on JS contextmenu event.
  99146. * Override this method to provide functionality.
  99147. */
  99148. protected onContextMenu(evt: PointerEvent): void;
  99149. /**
  99150. * Detach the current controls from the specified dom element.
  99151. * @param element Defines the element to stop listening the inputs from
  99152. */
  99153. detachControl(element: Nullable<HTMLElement>): void;
  99154. /**
  99155. * Gets the class name of the current intput.
  99156. * @returns the class name
  99157. */
  99158. getClassName(): string;
  99159. /**
  99160. * Get the friendly name associated with the input class.
  99161. * @returns the input friendly name
  99162. */
  99163. getSimpleName(): string;
  99164. }
  99165. }
  99166. declare module BABYLON {
  99167. /**
  99168. * Manage the touch inputs to control the movement of a free camera.
  99169. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99170. */
  99171. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99172. /**
  99173. * Define if mouse events can be treated as touch events
  99174. */
  99175. allowMouse: boolean;
  99176. /**
  99177. * Defines the camera the input is attached to.
  99178. */
  99179. camera: FreeCamera;
  99180. /**
  99181. * Defines the touch sensibility for rotation.
  99182. * The higher the faster.
  99183. */
  99184. touchAngularSensibility: number;
  99185. /**
  99186. * Defines the touch sensibility for move.
  99187. * The higher the faster.
  99188. */
  99189. touchMoveSensibility: number;
  99190. private _offsetX;
  99191. private _offsetY;
  99192. private _pointerPressed;
  99193. private _pointerInput;
  99194. private _observer;
  99195. private _onLostFocus;
  99196. /**
  99197. * Manage the touch inputs to control the movement of a free camera.
  99198. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99199. * @param allowMouse Defines if mouse events can be treated as touch events
  99200. */
  99201. constructor(
  99202. /**
  99203. * Define if mouse events can be treated as touch events
  99204. */
  99205. allowMouse?: boolean);
  99206. /**
  99207. * Attach the input controls to a specific dom element to get the input from.
  99208. * @param element Defines the element the controls should be listened from
  99209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99210. */
  99211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99212. /**
  99213. * Detach the current controls from the specified dom element.
  99214. * @param element Defines the element to stop listening the inputs from
  99215. */
  99216. detachControl(element: Nullable<HTMLElement>): void;
  99217. /**
  99218. * Update the current camera state depending on the inputs that have been used this frame.
  99219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99220. */
  99221. checkInputs(): void;
  99222. /**
  99223. * Gets the class name of the current intput.
  99224. * @returns the class name
  99225. */
  99226. getClassName(): string;
  99227. /**
  99228. * Get the friendly name associated with the input class.
  99229. * @returns the input friendly name
  99230. */
  99231. getSimpleName(): string;
  99232. }
  99233. }
  99234. declare module BABYLON {
  99235. /**
  99236. * Default Inputs manager for the FreeCamera.
  99237. * It groups all the default supported inputs for ease of use.
  99238. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99239. */
  99240. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99241. /**
  99242. * @hidden
  99243. */
  99244. _mouseInput: Nullable<FreeCameraMouseInput>;
  99245. /**
  99246. * Instantiates a new FreeCameraInputsManager.
  99247. * @param camera Defines the camera the inputs belong to
  99248. */
  99249. constructor(camera: FreeCamera);
  99250. /**
  99251. * Add keyboard input support to the input manager.
  99252. * @returns the current input manager
  99253. */
  99254. addKeyboard(): FreeCameraInputsManager;
  99255. /**
  99256. * Add mouse input support to the input manager.
  99257. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99258. * @returns the current input manager
  99259. */
  99260. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99261. /**
  99262. * Removes the mouse input support from the manager
  99263. * @returns the current input manager
  99264. */
  99265. removeMouse(): FreeCameraInputsManager;
  99266. /**
  99267. * Add touch input support to the input manager.
  99268. * @returns the current input manager
  99269. */
  99270. addTouch(): FreeCameraInputsManager;
  99271. /**
  99272. * Remove all attached input methods from a camera
  99273. */
  99274. clear(): void;
  99275. }
  99276. }
  99277. declare module BABYLON {
  99278. /**
  99279. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99280. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99281. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99282. */
  99283. export class FreeCamera extends TargetCamera {
  99284. /**
  99285. * Define the collision ellipsoid of the camera.
  99286. * This is helpful to simulate a camera body like the player body around the camera
  99287. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99288. */
  99289. ellipsoid: Vector3;
  99290. /**
  99291. * Define an offset for the position of the ellipsoid around the camera.
  99292. * This can be helpful to determine the center of the body near the gravity center of the body
  99293. * instead of its head.
  99294. */
  99295. ellipsoidOffset: Vector3;
  99296. /**
  99297. * Enable or disable collisions of the camera with the rest of the scene objects.
  99298. */
  99299. checkCollisions: boolean;
  99300. /**
  99301. * Enable or disable gravity on the camera.
  99302. */
  99303. applyGravity: boolean;
  99304. /**
  99305. * Define the input manager associated to the camera.
  99306. */
  99307. inputs: FreeCameraInputsManager;
  99308. /**
  99309. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99310. * Higher values reduce sensitivity.
  99311. */
  99312. get angularSensibility(): number;
  99313. /**
  99314. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99315. * Higher values reduce sensitivity.
  99316. */
  99317. set angularSensibility(value: number);
  99318. /**
  99319. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99320. */
  99321. get keysUp(): number[];
  99322. set keysUp(value: number[]);
  99323. /**
  99324. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99325. */
  99326. get keysUpward(): number[];
  99327. set keysUpward(value: number[]);
  99328. /**
  99329. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99330. */
  99331. get keysDown(): number[];
  99332. set keysDown(value: number[]);
  99333. /**
  99334. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99335. */
  99336. get keysDownward(): number[];
  99337. set keysDownward(value: number[]);
  99338. /**
  99339. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99340. */
  99341. get keysLeft(): number[];
  99342. set keysLeft(value: number[]);
  99343. /**
  99344. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99345. */
  99346. get keysRight(): number[];
  99347. set keysRight(value: number[]);
  99348. /**
  99349. * Event raised when the camera collide with a mesh in the scene.
  99350. */
  99351. onCollide: (collidedMesh: AbstractMesh) => void;
  99352. private _collider;
  99353. private _needMoveForGravity;
  99354. private _oldPosition;
  99355. private _diffPosition;
  99356. private _newPosition;
  99357. /** @hidden */
  99358. _localDirection: Vector3;
  99359. /** @hidden */
  99360. _transformedDirection: Vector3;
  99361. /**
  99362. * Instantiates a Free Camera.
  99363. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99364. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99365. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99366. * @param name Define the name of the camera in the scene
  99367. * @param position Define the start position of the camera in the scene
  99368. * @param scene Define the scene the camera belongs to
  99369. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99370. */
  99371. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99372. /**
  99373. * Attached controls to the current camera.
  99374. * @param element Defines the element the controls should be listened from
  99375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99376. */
  99377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99378. /**
  99379. * Detach the current controls from the camera.
  99380. * The camera will stop reacting to inputs.
  99381. * @param element Defines the element to stop listening the inputs from
  99382. */
  99383. detachControl(element: HTMLElement): void;
  99384. private _collisionMask;
  99385. /**
  99386. * Define a collision mask to limit the list of object the camera can collide with
  99387. */
  99388. get collisionMask(): number;
  99389. set collisionMask(mask: number);
  99390. /** @hidden */
  99391. _collideWithWorld(displacement: Vector3): void;
  99392. private _onCollisionPositionChange;
  99393. /** @hidden */
  99394. _checkInputs(): void;
  99395. /** @hidden */
  99396. _decideIfNeedsToMove(): boolean;
  99397. /** @hidden */
  99398. _updatePosition(): void;
  99399. /**
  99400. * Destroy the camera and release the current resources hold by it.
  99401. */
  99402. dispose(): void;
  99403. /**
  99404. * Gets the current object class name.
  99405. * @return the class name
  99406. */
  99407. getClassName(): string;
  99408. }
  99409. }
  99410. declare module BABYLON {
  99411. /**
  99412. * Represents a gamepad control stick position
  99413. */
  99414. export class StickValues {
  99415. /**
  99416. * The x component of the control stick
  99417. */
  99418. x: number;
  99419. /**
  99420. * The y component of the control stick
  99421. */
  99422. y: number;
  99423. /**
  99424. * Initializes the gamepad x and y control stick values
  99425. * @param x The x component of the gamepad control stick value
  99426. * @param y The y component of the gamepad control stick value
  99427. */
  99428. constructor(
  99429. /**
  99430. * The x component of the control stick
  99431. */
  99432. x: number,
  99433. /**
  99434. * The y component of the control stick
  99435. */
  99436. y: number);
  99437. }
  99438. /**
  99439. * An interface which manages callbacks for gamepad button changes
  99440. */
  99441. export interface GamepadButtonChanges {
  99442. /**
  99443. * Called when a gamepad has been changed
  99444. */
  99445. changed: boolean;
  99446. /**
  99447. * Called when a gamepad press event has been triggered
  99448. */
  99449. pressChanged: boolean;
  99450. /**
  99451. * Called when a touch event has been triggered
  99452. */
  99453. touchChanged: boolean;
  99454. /**
  99455. * Called when a value has changed
  99456. */
  99457. valueChanged: boolean;
  99458. }
  99459. /**
  99460. * Represents a gamepad
  99461. */
  99462. export class Gamepad {
  99463. /**
  99464. * The id of the gamepad
  99465. */
  99466. id: string;
  99467. /**
  99468. * The index of the gamepad
  99469. */
  99470. index: number;
  99471. /**
  99472. * The browser gamepad
  99473. */
  99474. browserGamepad: any;
  99475. /**
  99476. * Specifies what type of gamepad this represents
  99477. */
  99478. type: number;
  99479. private _leftStick;
  99480. private _rightStick;
  99481. /** @hidden */
  99482. _isConnected: boolean;
  99483. private _leftStickAxisX;
  99484. private _leftStickAxisY;
  99485. private _rightStickAxisX;
  99486. private _rightStickAxisY;
  99487. /**
  99488. * Triggered when the left control stick has been changed
  99489. */
  99490. private _onleftstickchanged;
  99491. /**
  99492. * Triggered when the right control stick has been changed
  99493. */
  99494. private _onrightstickchanged;
  99495. /**
  99496. * Represents a gamepad controller
  99497. */
  99498. static GAMEPAD: number;
  99499. /**
  99500. * Represents a generic controller
  99501. */
  99502. static GENERIC: number;
  99503. /**
  99504. * Represents an XBox controller
  99505. */
  99506. static XBOX: number;
  99507. /**
  99508. * Represents a pose-enabled controller
  99509. */
  99510. static POSE_ENABLED: number;
  99511. /**
  99512. * Represents an Dual Shock controller
  99513. */
  99514. static DUALSHOCK: number;
  99515. /**
  99516. * Specifies whether the left control stick should be Y-inverted
  99517. */
  99518. protected _invertLeftStickY: boolean;
  99519. /**
  99520. * Specifies if the gamepad has been connected
  99521. */
  99522. get isConnected(): boolean;
  99523. /**
  99524. * Initializes the gamepad
  99525. * @param id The id of the gamepad
  99526. * @param index The index of the gamepad
  99527. * @param browserGamepad The browser gamepad
  99528. * @param leftStickX The x component of the left joystick
  99529. * @param leftStickY The y component of the left joystick
  99530. * @param rightStickX The x component of the right joystick
  99531. * @param rightStickY The y component of the right joystick
  99532. */
  99533. constructor(
  99534. /**
  99535. * The id of the gamepad
  99536. */
  99537. id: string,
  99538. /**
  99539. * The index of the gamepad
  99540. */
  99541. index: number,
  99542. /**
  99543. * The browser gamepad
  99544. */
  99545. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99546. /**
  99547. * Callback triggered when the left joystick has changed
  99548. * @param callback
  99549. */
  99550. onleftstickchanged(callback: (values: StickValues) => void): void;
  99551. /**
  99552. * Callback triggered when the right joystick has changed
  99553. * @param callback
  99554. */
  99555. onrightstickchanged(callback: (values: StickValues) => void): void;
  99556. /**
  99557. * Gets the left joystick
  99558. */
  99559. get leftStick(): StickValues;
  99560. /**
  99561. * Sets the left joystick values
  99562. */
  99563. set leftStick(newValues: StickValues);
  99564. /**
  99565. * Gets the right joystick
  99566. */
  99567. get rightStick(): StickValues;
  99568. /**
  99569. * Sets the right joystick value
  99570. */
  99571. set rightStick(newValues: StickValues);
  99572. /**
  99573. * Updates the gamepad joystick positions
  99574. */
  99575. update(): void;
  99576. /**
  99577. * Disposes the gamepad
  99578. */
  99579. dispose(): void;
  99580. }
  99581. /**
  99582. * Represents a generic gamepad
  99583. */
  99584. export class GenericPad extends Gamepad {
  99585. private _buttons;
  99586. private _onbuttondown;
  99587. private _onbuttonup;
  99588. /**
  99589. * Observable triggered when a button has been pressed
  99590. */
  99591. onButtonDownObservable: Observable<number>;
  99592. /**
  99593. * Observable triggered when a button has been released
  99594. */
  99595. onButtonUpObservable: Observable<number>;
  99596. /**
  99597. * Callback triggered when a button has been pressed
  99598. * @param callback Called when a button has been pressed
  99599. */
  99600. onbuttondown(callback: (buttonPressed: number) => void): void;
  99601. /**
  99602. * Callback triggered when a button has been released
  99603. * @param callback Called when a button has been released
  99604. */
  99605. onbuttonup(callback: (buttonReleased: number) => void): void;
  99606. /**
  99607. * Initializes the generic gamepad
  99608. * @param id The id of the generic gamepad
  99609. * @param index The index of the generic gamepad
  99610. * @param browserGamepad The browser gamepad
  99611. */
  99612. constructor(id: string, index: number, browserGamepad: any);
  99613. private _setButtonValue;
  99614. /**
  99615. * Updates the generic gamepad
  99616. */
  99617. update(): void;
  99618. /**
  99619. * Disposes the generic gamepad
  99620. */
  99621. dispose(): void;
  99622. }
  99623. }
  99624. declare module BABYLON {
  99625. /**
  99626. * Defines the types of pose enabled controllers that are supported
  99627. */
  99628. export enum PoseEnabledControllerType {
  99629. /**
  99630. * HTC Vive
  99631. */
  99632. VIVE = 0,
  99633. /**
  99634. * Oculus Rift
  99635. */
  99636. OCULUS = 1,
  99637. /**
  99638. * Windows mixed reality
  99639. */
  99640. WINDOWS = 2,
  99641. /**
  99642. * Samsung gear VR
  99643. */
  99644. GEAR_VR = 3,
  99645. /**
  99646. * Google Daydream
  99647. */
  99648. DAYDREAM = 4,
  99649. /**
  99650. * Generic
  99651. */
  99652. GENERIC = 5
  99653. }
  99654. /**
  99655. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99656. */
  99657. export interface MutableGamepadButton {
  99658. /**
  99659. * Value of the button/trigger
  99660. */
  99661. value: number;
  99662. /**
  99663. * If the button/trigger is currently touched
  99664. */
  99665. touched: boolean;
  99666. /**
  99667. * If the button/trigger is currently pressed
  99668. */
  99669. pressed: boolean;
  99670. }
  99671. /**
  99672. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99673. * @hidden
  99674. */
  99675. export interface ExtendedGamepadButton extends GamepadButton {
  99676. /**
  99677. * If the button/trigger is currently pressed
  99678. */
  99679. readonly pressed: boolean;
  99680. /**
  99681. * If the button/trigger is currently touched
  99682. */
  99683. readonly touched: boolean;
  99684. /**
  99685. * Value of the button/trigger
  99686. */
  99687. readonly value: number;
  99688. }
  99689. /** @hidden */
  99690. export interface _GamePadFactory {
  99691. /**
  99692. * Returns whether or not the current gamepad can be created for this type of controller.
  99693. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99694. * @returns true if it can be created, otherwise false
  99695. */
  99696. canCreate(gamepadInfo: any): boolean;
  99697. /**
  99698. * Creates a new instance of the Gamepad.
  99699. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99700. * @returns the new gamepad instance
  99701. */
  99702. create(gamepadInfo: any): Gamepad;
  99703. }
  99704. /**
  99705. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99706. */
  99707. export class PoseEnabledControllerHelper {
  99708. /** @hidden */
  99709. static _ControllerFactories: _GamePadFactory[];
  99710. /** @hidden */
  99711. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99712. /**
  99713. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99714. * @param vrGamepad the gamepad to initialized
  99715. * @returns a vr controller of the type the gamepad identified as
  99716. */
  99717. static InitiateController(vrGamepad: any): Gamepad;
  99718. }
  99719. /**
  99720. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99721. */
  99722. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99723. /**
  99724. * If the controller is used in a webXR session
  99725. */
  99726. isXR: boolean;
  99727. private _deviceRoomPosition;
  99728. private _deviceRoomRotationQuaternion;
  99729. /**
  99730. * The device position in babylon space
  99731. */
  99732. devicePosition: Vector3;
  99733. /**
  99734. * The device rotation in babylon space
  99735. */
  99736. deviceRotationQuaternion: Quaternion;
  99737. /**
  99738. * The scale factor of the device in babylon space
  99739. */
  99740. deviceScaleFactor: number;
  99741. /**
  99742. * (Likely devicePosition should be used instead) The device position in its room space
  99743. */
  99744. position: Vector3;
  99745. /**
  99746. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99747. */
  99748. rotationQuaternion: Quaternion;
  99749. /**
  99750. * The type of controller (Eg. Windows mixed reality)
  99751. */
  99752. controllerType: PoseEnabledControllerType;
  99753. protected _calculatedPosition: Vector3;
  99754. private _calculatedRotation;
  99755. /**
  99756. * The raw pose from the device
  99757. */
  99758. rawPose: DevicePose;
  99759. private _trackPosition;
  99760. private _maxRotationDistFromHeadset;
  99761. private _draggedRoomRotation;
  99762. /**
  99763. * @hidden
  99764. */
  99765. _disableTrackPosition(fixedPosition: Vector3): void;
  99766. /**
  99767. * Internal, the mesh attached to the controller
  99768. * @hidden
  99769. */
  99770. _mesh: Nullable<AbstractMesh>;
  99771. private _poseControlledCamera;
  99772. private _leftHandSystemQuaternion;
  99773. /**
  99774. * Internal, matrix used to convert room space to babylon space
  99775. * @hidden
  99776. */
  99777. _deviceToWorld: Matrix;
  99778. /**
  99779. * Node to be used when casting a ray from the controller
  99780. * @hidden
  99781. */
  99782. _pointingPoseNode: Nullable<TransformNode>;
  99783. /**
  99784. * Name of the child mesh that can be used to cast a ray from the controller
  99785. */
  99786. static readonly POINTING_POSE: string;
  99787. /**
  99788. * Creates a new PoseEnabledController from a gamepad
  99789. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99790. */
  99791. constructor(browserGamepad: any);
  99792. private _workingMatrix;
  99793. /**
  99794. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99795. */
  99796. update(): void;
  99797. /**
  99798. * Updates only the pose device and mesh without doing any button event checking
  99799. */
  99800. protected _updatePoseAndMesh(): void;
  99801. /**
  99802. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99803. * @param poseData raw pose fromthe device
  99804. */
  99805. updateFromDevice(poseData: DevicePose): void;
  99806. /**
  99807. * @hidden
  99808. */
  99809. _meshAttachedObservable: Observable<AbstractMesh>;
  99810. /**
  99811. * Attaches a mesh to the controller
  99812. * @param mesh the mesh to be attached
  99813. */
  99814. attachToMesh(mesh: AbstractMesh): void;
  99815. /**
  99816. * Attaches the controllers mesh to a camera
  99817. * @param camera the camera the mesh should be attached to
  99818. */
  99819. attachToPoseControlledCamera(camera: TargetCamera): void;
  99820. /**
  99821. * Disposes of the controller
  99822. */
  99823. dispose(): void;
  99824. /**
  99825. * The mesh that is attached to the controller
  99826. */
  99827. get mesh(): Nullable<AbstractMesh>;
  99828. /**
  99829. * Gets the ray of the controller in the direction the controller is pointing
  99830. * @param length the length the resulting ray should be
  99831. * @returns a ray in the direction the controller is pointing
  99832. */
  99833. getForwardRay(length?: number): Ray;
  99834. }
  99835. }
  99836. declare module BABYLON {
  99837. /**
  99838. * Defines the WebVRController object that represents controllers tracked in 3D space
  99839. */
  99840. export abstract class WebVRController extends PoseEnabledController {
  99841. /**
  99842. * Internal, the default controller model for the controller
  99843. */
  99844. protected _defaultModel: Nullable<AbstractMesh>;
  99845. /**
  99846. * Fired when the trigger state has changed
  99847. */
  99848. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99849. /**
  99850. * Fired when the main button state has changed
  99851. */
  99852. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99853. /**
  99854. * Fired when the secondary button state has changed
  99855. */
  99856. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99857. /**
  99858. * Fired when the pad state has changed
  99859. */
  99860. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99861. /**
  99862. * Fired when controllers stick values have changed
  99863. */
  99864. onPadValuesChangedObservable: Observable<StickValues>;
  99865. /**
  99866. * Array of button availible on the controller
  99867. */
  99868. protected _buttons: Array<MutableGamepadButton>;
  99869. private _onButtonStateChange;
  99870. /**
  99871. * Fired when a controller button's state has changed
  99872. * @param callback the callback containing the button that was modified
  99873. */
  99874. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99875. /**
  99876. * X and Y axis corresponding to the controllers joystick
  99877. */
  99878. pad: StickValues;
  99879. /**
  99880. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99881. */
  99882. hand: string;
  99883. /**
  99884. * The default controller model for the controller
  99885. */
  99886. get defaultModel(): Nullable<AbstractMesh>;
  99887. /**
  99888. * Creates a new WebVRController from a gamepad
  99889. * @param vrGamepad the gamepad that the WebVRController should be created from
  99890. */
  99891. constructor(vrGamepad: any);
  99892. /**
  99893. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99894. */
  99895. update(): void;
  99896. /**
  99897. * Function to be called when a button is modified
  99898. */
  99899. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99900. /**
  99901. * Loads a mesh and attaches it to the controller
  99902. * @param scene the scene the mesh should be added to
  99903. * @param meshLoaded callback for when the mesh has been loaded
  99904. */
  99905. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99906. private _setButtonValue;
  99907. private _changes;
  99908. private _checkChanges;
  99909. /**
  99910. * Disposes of th webVRCOntroller
  99911. */
  99912. dispose(): void;
  99913. }
  99914. }
  99915. declare module BABYLON {
  99916. /**
  99917. * The HemisphericLight simulates the ambient environment light,
  99918. * so the passed direction is the light reflection direction, not the incoming direction.
  99919. */
  99920. export class HemisphericLight extends Light {
  99921. /**
  99922. * The groundColor is the light in the opposite direction to the one specified during creation.
  99923. * 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.
  99924. */
  99925. groundColor: Color3;
  99926. /**
  99927. * The light reflection direction, not the incoming direction.
  99928. */
  99929. direction: Vector3;
  99930. /**
  99931. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  99932. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  99933. * The HemisphericLight can't cast shadows.
  99934. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99935. * @param name The friendly name of the light
  99936. * @param direction The direction of the light reflection
  99937. * @param scene The scene the light belongs to
  99938. */
  99939. constructor(name: string, direction: Vector3, scene: Scene);
  99940. protected _buildUniformLayout(): void;
  99941. /**
  99942. * Returns the string "HemisphericLight".
  99943. * @return The class name
  99944. */
  99945. getClassName(): string;
  99946. /**
  99947. * Sets the HemisphericLight direction towards the passed target (Vector3).
  99948. * Returns the updated direction.
  99949. * @param target The target the direction should point to
  99950. * @return The computed direction
  99951. */
  99952. setDirectionToTarget(target: Vector3): Vector3;
  99953. /**
  99954. * Returns the shadow generator associated to the light.
  99955. * @returns Always null for hemispheric lights because it does not support shadows.
  99956. */
  99957. getShadowGenerator(): Nullable<IShadowGenerator>;
  99958. /**
  99959. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  99960. * @param effect The effect to update
  99961. * @param lightIndex The index of the light in the effect to update
  99962. * @returns The hemispheric light
  99963. */
  99964. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  99965. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  99966. /**
  99967. * Computes the world matrix of the node
  99968. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99969. * @param useWasUpdatedFlag defines a reserved property
  99970. * @returns the world matrix
  99971. */
  99972. computeWorldMatrix(): Matrix;
  99973. /**
  99974. * Returns the integer 3.
  99975. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99976. */
  99977. getTypeID(): number;
  99978. /**
  99979. * Prepares the list of defines specific to the light type.
  99980. * @param defines the list of defines
  99981. * @param lightIndex defines the index of the light for the effect
  99982. */
  99983. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99984. }
  99985. }
  99986. declare module BABYLON {
  99987. /** @hidden */
  99988. export var vrMultiviewToSingleviewPixelShader: {
  99989. name: string;
  99990. shader: string;
  99991. };
  99992. }
  99993. declare module BABYLON {
  99994. /**
  99995. * Renders to multiple views with a single draw call
  99996. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  99997. */
  99998. export class MultiviewRenderTarget extends RenderTargetTexture {
  99999. /**
  100000. * Creates a multiview render target
  100001. * @param scene scene used with the render target
  100002. * @param size the size of the render target (used for each view)
  100003. */
  100004. constructor(scene: Scene, size?: number | {
  100005. width: number;
  100006. height: number;
  100007. } | {
  100008. ratio: number;
  100009. });
  100010. /**
  100011. * @hidden
  100012. * @param faceIndex the face index, if its a cube texture
  100013. */
  100014. _bindFrameBuffer(faceIndex?: number): void;
  100015. /**
  100016. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100017. * @returns the view count
  100018. */
  100019. getViewCount(): number;
  100020. }
  100021. }
  100022. declare module BABYLON {
  100023. interface Engine {
  100024. /**
  100025. * Creates a new multiview render target
  100026. * @param width defines the width of the texture
  100027. * @param height defines the height of the texture
  100028. * @returns the created multiview texture
  100029. */
  100030. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100031. /**
  100032. * Binds a multiview framebuffer to be drawn to
  100033. * @param multiviewTexture texture to bind
  100034. */
  100035. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100036. }
  100037. interface Camera {
  100038. /**
  100039. * @hidden
  100040. * 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)
  100041. */
  100042. _useMultiviewToSingleView: boolean;
  100043. /**
  100044. * @hidden
  100045. * 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)
  100046. */
  100047. _multiviewTexture: Nullable<RenderTargetTexture>;
  100048. /**
  100049. * @hidden
  100050. * ensures the multiview texture of the camera exists and has the specified width/height
  100051. * @param width height to set on the multiview texture
  100052. * @param height width to set on the multiview texture
  100053. */
  100054. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100055. }
  100056. interface Scene {
  100057. /** @hidden */
  100058. _transformMatrixR: Matrix;
  100059. /** @hidden */
  100060. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100061. /** @hidden */
  100062. _createMultiviewUbo(): void;
  100063. /** @hidden */
  100064. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100065. /** @hidden */
  100066. _renderMultiviewToSingleView(camera: Camera): void;
  100067. }
  100068. }
  100069. declare module BABYLON {
  100070. /**
  100071. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100072. * This will not be used for webXR as it supports displaying texture arrays directly
  100073. */
  100074. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100075. /**
  100076. * Gets a string identifying the name of the class
  100077. * @returns "VRMultiviewToSingleviewPostProcess" string
  100078. */
  100079. getClassName(): string;
  100080. /**
  100081. * Initializes a VRMultiviewToSingleview
  100082. * @param name name of the post process
  100083. * @param camera camera to be applied to
  100084. * @param scaleFactor scaling factor to the size of the output texture
  100085. */
  100086. constructor(name: string, camera: Camera, scaleFactor: number);
  100087. }
  100088. }
  100089. declare module BABYLON {
  100090. /**
  100091. * Interface used to define additional presentation attributes
  100092. */
  100093. export interface IVRPresentationAttributes {
  100094. /**
  100095. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100096. */
  100097. highRefreshRate: boolean;
  100098. /**
  100099. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100100. */
  100101. foveationLevel: number;
  100102. }
  100103. interface Engine {
  100104. /** @hidden */
  100105. _vrDisplay: any;
  100106. /** @hidden */
  100107. _vrSupported: boolean;
  100108. /** @hidden */
  100109. _oldSize: Size;
  100110. /** @hidden */
  100111. _oldHardwareScaleFactor: number;
  100112. /** @hidden */
  100113. _vrExclusivePointerMode: boolean;
  100114. /** @hidden */
  100115. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100116. /** @hidden */
  100117. _onVRDisplayPointerRestricted: () => void;
  100118. /** @hidden */
  100119. _onVRDisplayPointerUnrestricted: () => void;
  100120. /** @hidden */
  100121. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100122. /** @hidden */
  100123. _onVrDisplayDisconnect: Nullable<() => void>;
  100124. /** @hidden */
  100125. _onVrDisplayPresentChange: Nullable<() => void>;
  100126. /**
  100127. * Observable signaled when VR display mode changes
  100128. */
  100129. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100130. /**
  100131. * Observable signaled when VR request present is complete
  100132. */
  100133. onVRRequestPresentComplete: Observable<boolean>;
  100134. /**
  100135. * Observable signaled when VR request present starts
  100136. */
  100137. onVRRequestPresentStart: Observable<Engine>;
  100138. /**
  100139. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100140. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100141. */
  100142. isInVRExclusivePointerMode: boolean;
  100143. /**
  100144. * Gets a boolean indicating if a webVR device was detected
  100145. * @returns true if a webVR device was detected
  100146. */
  100147. isVRDevicePresent(): boolean;
  100148. /**
  100149. * Gets the current webVR device
  100150. * @returns the current webVR device (or null)
  100151. */
  100152. getVRDevice(): any;
  100153. /**
  100154. * Initializes a webVR display and starts listening to display change events
  100155. * The onVRDisplayChangedObservable will be notified upon these changes
  100156. * @returns A promise containing a VRDisplay and if vr is supported
  100157. */
  100158. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100159. /** @hidden */
  100160. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100161. /**
  100162. * Gets or sets the presentation attributes used to configure VR rendering
  100163. */
  100164. vrPresentationAttributes?: IVRPresentationAttributes;
  100165. /**
  100166. * Call this function to switch to webVR mode
  100167. * Will do nothing if webVR is not supported or if there is no webVR device
  100168. * @param options the webvr options provided to the camera. mainly used for multiview
  100169. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100170. */
  100171. enableVR(options: WebVROptions): void;
  100172. /** @hidden */
  100173. _onVRFullScreenTriggered(): void;
  100174. }
  100175. }
  100176. declare module BABYLON {
  100177. /**
  100178. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100179. * IMPORTANT!! The data is right-hand data.
  100180. * @export
  100181. * @interface DevicePose
  100182. */
  100183. export interface DevicePose {
  100184. /**
  100185. * The position of the device, values in array are [x,y,z].
  100186. */
  100187. readonly position: Nullable<Float32Array>;
  100188. /**
  100189. * The linearVelocity of the device, values in array are [x,y,z].
  100190. */
  100191. readonly linearVelocity: Nullable<Float32Array>;
  100192. /**
  100193. * The linearAcceleration of the device, values in array are [x,y,z].
  100194. */
  100195. readonly linearAcceleration: Nullable<Float32Array>;
  100196. /**
  100197. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100198. */
  100199. readonly orientation: Nullable<Float32Array>;
  100200. /**
  100201. * The angularVelocity of the device, values in array are [x,y,z].
  100202. */
  100203. readonly angularVelocity: Nullable<Float32Array>;
  100204. /**
  100205. * The angularAcceleration of the device, values in array are [x,y,z].
  100206. */
  100207. readonly angularAcceleration: Nullable<Float32Array>;
  100208. }
  100209. /**
  100210. * Interface representing a pose controlled object in Babylon.
  100211. * A pose controlled object has both regular pose values as well as pose values
  100212. * from an external device such as a VR head mounted display
  100213. */
  100214. export interface PoseControlled {
  100215. /**
  100216. * The position of the object in babylon space.
  100217. */
  100218. position: Vector3;
  100219. /**
  100220. * The rotation quaternion of the object in babylon space.
  100221. */
  100222. rotationQuaternion: Quaternion;
  100223. /**
  100224. * The position of the device in babylon space.
  100225. */
  100226. devicePosition?: Vector3;
  100227. /**
  100228. * The rotation quaternion of the device in babylon space.
  100229. */
  100230. deviceRotationQuaternion: Quaternion;
  100231. /**
  100232. * The raw pose coming from the device.
  100233. */
  100234. rawPose: Nullable<DevicePose>;
  100235. /**
  100236. * The scale of the device to be used when translating from device space to babylon space.
  100237. */
  100238. deviceScaleFactor: number;
  100239. /**
  100240. * Updates the poseControlled values based on the input device pose.
  100241. * @param poseData the pose data to update the object with
  100242. */
  100243. updateFromDevice(poseData: DevicePose): void;
  100244. }
  100245. /**
  100246. * Set of options to customize the webVRCamera
  100247. */
  100248. export interface WebVROptions {
  100249. /**
  100250. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100251. */
  100252. trackPosition?: boolean;
  100253. /**
  100254. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100255. */
  100256. positionScale?: number;
  100257. /**
  100258. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100259. */
  100260. displayName?: string;
  100261. /**
  100262. * Should the native controller meshes be initialized. (default: true)
  100263. */
  100264. controllerMeshes?: boolean;
  100265. /**
  100266. * Creating a default HemiLight only on controllers. (default: true)
  100267. */
  100268. defaultLightingOnControllers?: boolean;
  100269. /**
  100270. * If you don't want to use the default VR button of the helper. (default: false)
  100271. */
  100272. useCustomVRButton?: boolean;
  100273. /**
  100274. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100275. */
  100276. customVRButton?: HTMLButtonElement;
  100277. /**
  100278. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100279. */
  100280. rayLength?: number;
  100281. /**
  100282. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100283. */
  100284. defaultHeight?: number;
  100285. /**
  100286. * If multiview should be used if availible (default: false)
  100287. */
  100288. useMultiview?: boolean;
  100289. }
  100290. /**
  100291. * This represents a WebVR camera.
  100292. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100293. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100294. */
  100295. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100296. private webVROptions;
  100297. /**
  100298. * @hidden
  100299. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100300. */
  100301. _vrDevice: any;
  100302. /**
  100303. * The rawPose of the vrDevice.
  100304. */
  100305. rawPose: Nullable<DevicePose>;
  100306. private _onVREnabled;
  100307. private _specsVersion;
  100308. private _attached;
  100309. private _frameData;
  100310. protected _descendants: Array<Node>;
  100311. private _deviceRoomPosition;
  100312. /** @hidden */
  100313. _deviceRoomRotationQuaternion: Quaternion;
  100314. private _standingMatrix;
  100315. /**
  100316. * Represents device position in babylon space.
  100317. */
  100318. devicePosition: Vector3;
  100319. /**
  100320. * Represents device rotation in babylon space.
  100321. */
  100322. deviceRotationQuaternion: Quaternion;
  100323. /**
  100324. * The scale of the device to be used when translating from device space to babylon space.
  100325. */
  100326. deviceScaleFactor: number;
  100327. private _deviceToWorld;
  100328. private _worldToDevice;
  100329. /**
  100330. * References to the webVR controllers for the vrDevice.
  100331. */
  100332. controllers: Array<WebVRController>;
  100333. /**
  100334. * Emits an event when a controller is attached.
  100335. */
  100336. onControllersAttachedObservable: Observable<WebVRController[]>;
  100337. /**
  100338. * Emits an event when a controller's mesh has been loaded;
  100339. */
  100340. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100341. /**
  100342. * Emits an event when the HMD's pose has been updated.
  100343. */
  100344. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100345. private _poseSet;
  100346. /**
  100347. * If the rig cameras be used as parent instead of this camera.
  100348. */
  100349. rigParenting: boolean;
  100350. private _lightOnControllers;
  100351. private _defaultHeight?;
  100352. /**
  100353. * Instantiates a WebVRFreeCamera.
  100354. * @param name The name of the WebVRFreeCamera
  100355. * @param position The starting anchor position for the camera
  100356. * @param scene The scene the camera belongs to
  100357. * @param webVROptions a set of customizable options for the webVRCamera
  100358. */
  100359. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100360. /**
  100361. * Gets the device distance from the ground in meters.
  100362. * @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.
  100363. */
  100364. deviceDistanceToRoomGround(): number;
  100365. /**
  100366. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100367. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100368. */
  100369. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100370. /**
  100371. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100372. * @returns A promise with a boolean set to if the standing matrix is supported.
  100373. */
  100374. useStandingMatrixAsync(): Promise<boolean>;
  100375. /**
  100376. * Disposes the camera
  100377. */
  100378. dispose(): void;
  100379. /**
  100380. * Gets a vrController by name.
  100381. * @param name The name of the controller to retreive
  100382. * @returns the controller matching the name specified or null if not found
  100383. */
  100384. getControllerByName(name: string): Nullable<WebVRController>;
  100385. private _leftController;
  100386. /**
  100387. * The controller corresponding to the users left hand.
  100388. */
  100389. get leftController(): Nullable<WebVRController>;
  100390. private _rightController;
  100391. /**
  100392. * The controller corresponding to the users right hand.
  100393. */
  100394. get rightController(): Nullable<WebVRController>;
  100395. /**
  100396. * Casts a ray forward from the vrCamera's gaze.
  100397. * @param length Length of the ray (default: 100)
  100398. * @returns the ray corresponding to the gaze
  100399. */
  100400. getForwardRay(length?: number): Ray;
  100401. /**
  100402. * @hidden
  100403. * Updates the camera based on device's frame data
  100404. */
  100405. _checkInputs(): void;
  100406. /**
  100407. * Updates the poseControlled values based on the input device pose.
  100408. * @param poseData Pose coming from the device
  100409. */
  100410. updateFromDevice(poseData: DevicePose): void;
  100411. private _htmlElementAttached;
  100412. private _detachIfAttached;
  100413. /**
  100414. * WebVR's attach control will start broadcasting frames to the device.
  100415. * Note that in certain browsers (chrome for example) this function must be called
  100416. * within a user-interaction callback. Example:
  100417. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100418. *
  100419. * @param element html element to attach the vrDevice to
  100420. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100421. */
  100422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100423. /**
  100424. * Detaches the camera from the html element and disables VR
  100425. *
  100426. * @param element html element to detach from
  100427. */
  100428. detachControl(element: HTMLElement): void;
  100429. /**
  100430. * @returns the name of this class
  100431. */
  100432. getClassName(): string;
  100433. /**
  100434. * Calls resetPose on the vrDisplay
  100435. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100436. */
  100437. resetToCurrentRotation(): void;
  100438. /**
  100439. * @hidden
  100440. * Updates the rig cameras (left and right eye)
  100441. */
  100442. _updateRigCameras(): void;
  100443. private _workingVector;
  100444. private _oneVector;
  100445. private _workingMatrix;
  100446. private updateCacheCalled;
  100447. private _correctPositionIfNotTrackPosition;
  100448. /**
  100449. * @hidden
  100450. * Updates the cached values of the camera
  100451. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100452. */
  100453. _updateCache(ignoreParentClass?: boolean): void;
  100454. /**
  100455. * @hidden
  100456. * Get current device position in babylon world
  100457. */
  100458. _computeDevicePosition(): void;
  100459. /**
  100460. * Updates the current device position and rotation in the babylon world
  100461. */
  100462. update(): void;
  100463. /**
  100464. * @hidden
  100465. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100466. * @returns an identity matrix
  100467. */
  100468. _getViewMatrix(): Matrix;
  100469. private _tmpMatrix;
  100470. /**
  100471. * This function is called by the two RIG cameras.
  100472. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100473. * @hidden
  100474. */
  100475. _getWebVRViewMatrix(): Matrix;
  100476. /** @hidden */
  100477. _getWebVRProjectionMatrix(): Matrix;
  100478. private _onGamepadConnectedObserver;
  100479. private _onGamepadDisconnectedObserver;
  100480. private _updateCacheWhenTrackingDisabledObserver;
  100481. /**
  100482. * Initializes the controllers and their meshes
  100483. */
  100484. initControllers(): void;
  100485. }
  100486. }
  100487. declare module BABYLON {
  100488. /**
  100489. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100490. *
  100491. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100492. *
  100493. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100494. */
  100495. export class MaterialHelper {
  100496. /**
  100497. * Bind the current view position to an effect.
  100498. * @param effect The effect to be bound
  100499. * @param scene The scene the eyes position is used from
  100500. * @param variableName name of the shader variable that will hold the eye position
  100501. */
  100502. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100503. /**
  100504. * Helps preparing the defines values about the UVs in used in the effect.
  100505. * UVs are shared as much as we can accross channels in the shaders.
  100506. * @param texture The texture we are preparing the UVs for
  100507. * @param defines The defines to update
  100508. * @param key The channel key "diffuse", "specular"... used in the shader
  100509. */
  100510. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100511. /**
  100512. * Binds a texture matrix value to its corrsponding uniform
  100513. * @param texture The texture to bind the matrix for
  100514. * @param uniformBuffer The uniform buffer receivin the data
  100515. * @param key The channel key "diffuse", "specular"... used in the shader
  100516. */
  100517. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100518. /**
  100519. * Gets the current status of the fog (should it be enabled?)
  100520. * @param mesh defines the mesh to evaluate for fog support
  100521. * @param scene defines the hosting scene
  100522. * @returns true if fog must be enabled
  100523. */
  100524. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100525. /**
  100526. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100527. * @param mesh defines the current mesh
  100528. * @param scene defines the current scene
  100529. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100530. * @param pointsCloud defines if point cloud rendering has to be turned on
  100531. * @param fogEnabled defines if fog has to be turned on
  100532. * @param alphaTest defines if alpha testing has to be turned on
  100533. * @param defines defines the current list of defines
  100534. */
  100535. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100536. /**
  100537. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100538. * @param scene defines the current scene
  100539. * @param engine defines the current engine
  100540. * @param defines specifies the list of active defines
  100541. * @param useInstances defines if instances have to be turned on
  100542. * @param useClipPlane defines if clip plane have to be turned on
  100543. * @param useInstances defines if instances have to be turned on
  100544. * @param useThinInstances defines if thin instances have to be turned on
  100545. */
  100546. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100547. /**
  100548. * Prepares the defines for bones
  100549. * @param mesh The mesh containing the geometry data we will draw
  100550. * @param defines The defines to update
  100551. */
  100552. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100553. /**
  100554. * Prepares the defines for morph targets
  100555. * @param mesh The mesh containing the geometry data we will draw
  100556. * @param defines The defines to update
  100557. */
  100558. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100559. /**
  100560. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100561. * @param mesh The mesh containing the geometry data we will draw
  100562. * @param defines The defines to update
  100563. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100564. * @param useBones Precise whether bones should be used or not (override mesh info)
  100565. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100566. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100567. * @returns false if defines are considered not dirty and have not been checked
  100568. */
  100569. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100570. /**
  100571. * Prepares the defines related to multiview
  100572. * @param scene The scene we are intending to draw
  100573. * @param defines The defines to update
  100574. */
  100575. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100576. /**
  100577. * Prepares the defines related to the prepass
  100578. * @param scene The scene we are intending to draw
  100579. * @param defines The defines to update
  100580. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100581. */
  100582. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100583. /**
  100584. * Prepares the defines related to the light information passed in parameter
  100585. * @param scene The scene we are intending to draw
  100586. * @param mesh The mesh the effect is compiling for
  100587. * @param light The light the effect is compiling for
  100588. * @param lightIndex The index of the light
  100589. * @param defines The defines to update
  100590. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100591. * @param state Defines the current state regarding what is needed (normals, etc...)
  100592. */
  100593. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100594. needNormals: boolean;
  100595. needRebuild: boolean;
  100596. shadowEnabled: boolean;
  100597. specularEnabled: boolean;
  100598. lightmapMode: boolean;
  100599. }): void;
  100600. /**
  100601. * Prepares the defines related to the light information passed in parameter
  100602. * @param scene The scene we are intending to draw
  100603. * @param mesh The mesh the effect is compiling for
  100604. * @param defines The defines to update
  100605. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100606. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100607. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100608. * @returns true if normals will be required for the rest of the effect
  100609. */
  100610. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100611. /**
  100612. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100613. * @param lightIndex defines the light index
  100614. * @param uniformsList The uniform list
  100615. * @param samplersList The sampler list
  100616. * @param projectedLightTexture defines if projected texture must be used
  100617. * @param uniformBuffersList defines an optional list of uniform buffers
  100618. */
  100619. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100620. /**
  100621. * Prepares the uniforms and samplers list to be used in the effect
  100622. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100623. * @param samplersList The sampler list
  100624. * @param defines The defines helping in the list generation
  100625. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100626. */
  100627. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100628. /**
  100629. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100630. * @param defines The defines to update while falling back
  100631. * @param fallbacks The authorized effect fallbacks
  100632. * @param maxSimultaneousLights The maximum number of lights allowed
  100633. * @param rank the current rank of the Effect
  100634. * @returns The newly affected rank
  100635. */
  100636. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100637. private static _TmpMorphInfluencers;
  100638. /**
  100639. * Prepares the list of attributes required for morph targets according to the effect defines.
  100640. * @param attribs The current list of supported attribs
  100641. * @param mesh The mesh to prepare the morph targets attributes for
  100642. * @param influencers The number of influencers
  100643. */
  100644. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100645. /**
  100646. * Prepares the list of attributes required for morph targets according to the effect defines.
  100647. * @param attribs The current list of supported attribs
  100648. * @param mesh The mesh to prepare the morph targets attributes for
  100649. * @param defines The current Defines of the effect
  100650. */
  100651. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100652. /**
  100653. * Prepares the list of attributes required for bones according to the effect defines.
  100654. * @param attribs The current list of supported attribs
  100655. * @param mesh The mesh to prepare the bones attributes for
  100656. * @param defines The current Defines of the effect
  100657. * @param fallbacks The current efffect fallback strategy
  100658. */
  100659. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100660. /**
  100661. * Check and prepare the list of attributes required for instances according to the effect defines.
  100662. * @param attribs The current list of supported attribs
  100663. * @param defines The current MaterialDefines of the effect
  100664. */
  100665. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100666. /**
  100667. * Add the list of attributes required for instances to the attribs array.
  100668. * @param attribs The current list of supported attribs
  100669. */
  100670. static PushAttributesForInstances(attribs: string[]): void;
  100671. /**
  100672. * Binds the light information to the effect.
  100673. * @param light The light containing the generator
  100674. * @param effect The effect we are binding the data to
  100675. * @param lightIndex The light index in the effect used to render
  100676. */
  100677. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100678. /**
  100679. * Binds the lights information from the scene to the effect for the given mesh.
  100680. * @param light Light to bind
  100681. * @param lightIndex Light index
  100682. * @param scene The scene where the light belongs to
  100683. * @param effect The effect we are binding the data to
  100684. * @param useSpecular Defines if specular is supported
  100685. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100686. */
  100687. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100688. /**
  100689. * Binds the lights information from the scene to the effect for the given mesh.
  100690. * @param scene The scene the lights belongs to
  100691. * @param mesh The mesh we are binding the information to render
  100692. * @param effect The effect we are binding the data to
  100693. * @param defines The generated defines for the effect
  100694. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100695. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100696. */
  100697. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100698. private static _tempFogColor;
  100699. /**
  100700. * Binds the fog information from the scene to the effect for the given mesh.
  100701. * @param scene The scene the lights belongs to
  100702. * @param mesh The mesh we are binding the information to render
  100703. * @param effect The effect we are binding the data to
  100704. * @param linearSpace Defines if the fog effect is applied in linear space
  100705. */
  100706. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100707. /**
  100708. * Binds the bones information from the mesh to the effect.
  100709. * @param mesh The mesh we are binding the information to render
  100710. * @param effect The effect we are binding the data to
  100711. */
  100712. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100713. /**
  100714. * Binds the morph targets information from the mesh to the effect.
  100715. * @param abstractMesh The mesh we are binding the information to render
  100716. * @param effect The effect we are binding the data to
  100717. */
  100718. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100719. /**
  100720. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100721. * @param defines The generated defines used in the effect
  100722. * @param effect The effect we are binding the data to
  100723. * @param scene The scene we are willing to render with logarithmic scale for
  100724. */
  100725. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100726. /**
  100727. * Binds the clip plane information from the scene to the effect.
  100728. * @param scene The scene the clip plane information are extracted from
  100729. * @param effect The effect we are binding the data to
  100730. */
  100731. static BindClipPlane(effect: Effect, scene: Scene): void;
  100732. }
  100733. }
  100734. declare module BABYLON {
  100735. /**
  100736. * Block used to expose an input value
  100737. */
  100738. export class InputBlock extends NodeMaterialBlock {
  100739. private _mode;
  100740. private _associatedVariableName;
  100741. private _storedValue;
  100742. private _valueCallback;
  100743. private _type;
  100744. private _animationType;
  100745. /** Gets or set a value used to limit the range of float values */
  100746. min: number;
  100747. /** Gets or set a value used to limit the range of float values */
  100748. max: number;
  100749. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100750. isBoolean: boolean;
  100751. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100752. matrixMode: number;
  100753. /** @hidden */
  100754. _systemValue: Nullable<NodeMaterialSystemValues>;
  100755. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100756. isConstant: boolean;
  100757. /** Gets or sets the group to use to display this block in the Inspector */
  100758. groupInInspector: string;
  100759. /** Gets an observable raised when the value is changed */
  100760. onValueChangedObservable: Observable<InputBlock>;
  100761. /**
  100762. * Gets or sets the connection point type (default is float)
  100763. */
  100764. get type(): NodeMaterialBlockConnectionPointTypes;
  100765. /**
  100766. * Creates a new InputBlock
  100767. * @param name defines the block name
  100768. * @param target defines the target of that block (Vertex by default)
  100769. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100770. */
  100771. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100772. /**
  100773. * Validates if a name is a reserve word.
  100774. * @param newName the new name to be given to the node.
  100775. * @returns false if the name is a reserve word, else true.
  100776. */
  100777. validateBlockName(newName: string): boolean;
  100778. /**
  100779. * Gets the output component
  100780. */
  100781. get output(): NodeMaterialConnectionPoint;
  100782. /**
  100783. * Set the source of this connection point to a vertex attribute
  100784. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100785. * @returns the current connection point
  100786. */
  100787. setAsAttribute(attributeName?: string): InputBlock;
  100788. /**
  100789. * Set the source of this connection point to a system value
  100790. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100791. * @returns the current connection point
  100792. */
  100793. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100794. /**
  100795. * Gets or sets the value of that point.
  100796. * Please note that this value will be ignored if valueCallback is defined
  100797. */
  100798. get value(): any;
  100799. set value(value: any);
  100800. /**
  100801. * Gets or sets a callback used to get the value of that point.
  100802. * Please note that setting this value will force the connection point to ignore the value property
  100803. */
  100804. get valueCallback(): () => any;
  100805. set valueCallback(value: () => any);
  100806. /**
  100807. * Gets or sets the associated variable name in the shader
  100808. */
  100809. get associatedVariableName(): string;
  100810. set associatedVariableName(value: string);
  100811. /** Gets or sets the type of animation applied to the input */
  100812. get animationType(): AnimatedInputBlockTypes;
  100813. set animationType(value: AnimatedInputBlockTypes);
  100814. /**
  100815. * Gets a boolean indicating that this connection point not defined yet
  100816. */
  100817. get isUndefined(): boolean;
  100818. /**
  100819. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100820. * In this case the connection point name must be the name of the uniform to use.
  100821. * Can only be set on inputs
  100822. */
  100823. get isUniform(): boolean;
  100824. set isUniform(value: boolean);
  100825. /**
  100826. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100827. * In this case the connection point name must be the name of the attribute to use
  100828. * Can only be set on inputs
  100829. */
  100830. get isAttribute(): boolean;
  100831. set isAttribute(value: boolean);
  100832. /**
  100833. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100834. * Can only be set on exit points
  100835. */
  100836. get isVarying(): boolean;
  100837. set isVarying(value: boolean);
  100838. /**
  100839. * Gets a boolean indicating that the current connection point is a system value
  100840. */
  100841. get isSystemValue(): boolean;
  100842. /**
  100843. * Gets or sets the current well known value or null if not defined as a system value
  100844. */
  100845. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100846. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100847. /**
  100848. * Gets the current class name
  100849. * @returns the class name
  100850. */
  100851. getClassName(): string;
  100852. /**
  100853. * Animate the input if animationType !== None
  100854. * @param scene defines the rendering scene
  100855. */
  100856. animate(scene: Scene): void;
  100857. private _emitDefine;
  100858. initialize(state: NodeMaterialBuildState): void;
  100859. /**
  100860. * Set the input block to its default value (based on its type)
  100861. */
  100862. setDefaultValue(): void;
  100863. private _emitConstant;
  100864. /** @hidden */
  100865. get _noContextSwitch(): boolean;
  100866. private _emit;
  100867. /** @hidden */
  100868. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100869. /** @hidden */
  100870. _transmit(effect: Effect, scene: Scene): void;
  100871. protected _buildBlock(state: NodeMaterialBuildState): void;
  100872. protected _dumpPropertiesCode(): string;
  100873. dispose(): void;
  100874. serialize(): any;
  100875. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100876. }
  100877. }
  100878. declare module BABYLON {
  100879. /**
  100880. * Enum used to define the compatibility state between two connection points
  100881. */
  100882. export enum NodeMaterialConnectionPointCompatibilityStates {
  100883. /** Points are compatibles */
  100884. Compatible = 0,
  100885. /** Points are incompatible because of their types */
  100886. TypeIncompatible = 1,
  100887. /** Points are incompatible because of their targets (vertex vs fragment) */
  100888. TargetIncompatible = 2
  100889. }
  100890. /**
  100891. * Defines the direction of a connection point
  100892. */
  100893. export enum NodeMaterialConnectionPointDirection {
  100894. /** Input */
  100895. Input = 0,
  100896. /** Output */
  100897. Output = 1
  100898. }
  100899. /**
  100900. * Defines a connection point for a block
  100901. */
  100902. export class NodeMaterialConnectionPoint {
  100903. /** @hidden */
  100904. _ownerBlock: NodeMaterialBlock;
  100905. /** @hidden */
  100906. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100907. private _endpoints;
  100908. private _associatedVariableName;
  100909. private _direction;
  100910. /** @hidden */
  100911. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100912. /** @hidden */
  100913. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100914. private _type;
  100915. /** @hidden */
  100916. _enforceAssociatedVariableName: boolean;
  100917. /** Gets the direction of the point */
  100918. get direction(): NodeMaterialConnectionPointDirection;
  100919. /** Indicates that this connection point needs dual validation before being connected to another point */
  100920. needDualDirectionValidation: boolean;
  100921. /**
  100922. * Gets or sets the additional types supported by this connection point
  100923. */
  100924. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100925. /**
  100926. * Gets or sets the additional types excluded by this connection point
  100927. */
  100928. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100929. /**
  100930. * Observable triggered when this point is connected
  100931. */
  100932. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  100933. /**
  100934. * Gets or sets the associated variable name in the shader
  100935. */
  100936. get associatedVariableName(): string;
  100937. set associatedVariableName(value: string);
  100938. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  100939. get innerType(): NodeMaterialBlockConnectionPointTypes;
  100940. /**
  100941. * Gets or sets the connection point type (default is float)
  100942. */
  100943. get type(): NodeMaterialBlockConnectionPointTypes;
  100944. set type(value: NodeMaterialBlockConnectionPointTypes);
  100945. /**
  100946. * Gets or sets the connection point name
  100947. */
  100948. name: string;
  100949. /**
  100950. * Gets or sets the connection point name
  100951. */
  100952. displayName: string;
  100953. /**
  100954. * Gets or sets a boolean indicating that this connection point can be omitted
  100955. */
  100956. isOptional: boolean;
  100957. /**
  100958. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  100959. */
  100960. isExposedOnFrame: boolean;
  100961. /**
  100962. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  100963. */
  100964. define: string;
  100965. /** @hidden */
  100966. _prioritizeVertex: boolean;
  100967. private _target;
  100968. /** Gets or sets the target of that connection point */
  100969. get target(): NodeMaterialBlockTargets;
  100970. set target(value: NodeMaterialBlockTargets);
  100971. /**
  100972. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  100973. */
  100974. get isConnected(): boolean;
  100975. /**
  100976. * Gets a boolean indicating that the current point is connected to an input block
  100977. */
  100978. get isConnectedToInputBlock(): boolean;
  100979. /**
  100980. * Gets a the connected input block (if any)
  100981. */
  100982. get connectInputBlock(): Nullable<InputBlock>;
  100983. /** Get the other side of the connection (if any) */
  100984. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  100985. /** Get the block that owns this connection point */
  100986. get ownerBlock(): NodeMaterialBlock;
  100987. /** Get the block connected on the other side of this connection (if any) */
  100988. get sourceBlock(): Nullable<NodeMaterialBlock>;
  100989. /** Get the block connected on the endpoints of this connection (if any) */
  100990. get connectedBlocks(): Array<NodeMaterialBlock>;
  100991. /** Gets the list of connected endpoints */
  100992. get endpoints(): NodeMaterialConnectionPoint[];
  100993. /** Gets a boolean indicating if that output point is connected to at least one input */
  100994. get hasEndpoints(): boolean;
  100995. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  100996. get isConnectedInVertexShader(): boolean;
  100997. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  100998. get isConnectedInFragmentShader(): boolean;
  100999. /**
  101000. * Creates a block suitable to be used as an input for this input point.
  101001. * If null is returned, a block based on the point type will be created.
  101002. * @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
  101003. */
  101004. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101005. /**
  101006. * Creates a new connection point
  101007. * @param name defines the connection point name
  101008. * @param ownerBlock defines the block hosting this connection point
  101009. * @param direction defines the direction of the connection point
  101010. */
  101011. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101012. /**
  101013. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101014. * @returns the class name
  101015. */
  101016. getClassName(): string;
  101017. /**
  101018. * Gets a boolean indicating if the current point can be connected to another point
  101019. * @param connectionPoint defines the other connection point
  101020. * @returns a boolean
  101021. */
  101022. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101023. /**
  101024. * Gets a number indicating if the current point can be connected to another point
  101025. * @param connectionPoint defines the other connection point
  101026. * @returns a number defining the compatibility state
  101027. */
  101028. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101029. /**
  101030. * Connect this point to another connection point
  101031. * @param connectionPoint defines the other connection point
  101032. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101033. * @returns the current connection point
  101034. */
  101035. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101036. /**
  101037. * Disconnect this point from one of his endpoint
  101038. * @param endpoint defines the other connection point
  101039. * @returns the current connection point
  101040. */
  101041. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101042. /**
  101043. * Serializes this point in a JSON representation
  101044. * @param isInput defines if the connection point is an input (default is true)
  101045. * @returns the serialized point object
  101046. */
  101047. serialize(isInput?: boolean): any;
  101048. /**
  101049. * Release resources
  101050. */
  101051. dispose(): void;
  101052. }
  101053. }
  101054. declare module BABYLON {
  101055. /**
  101056. * Enum used to define the material modes
  101057. */
  101058. export enum NodeMaterialModes {
  101059. /** Regular material */
  101060. Material = 0,
  101061. /** For post process */
  101062. PostProcess = 1,
  101063. /** For particle system */
  101064. Particle = 2,
  101065. /** For procedural texture */
  101066. ProceduralTexture = 3
  101067. }
  101068. }
  101069. declare module BABYLON {
  101070. /**
  101071. * Block used to read a texture from a sampler
  101072. */
  101073. export class TextureBlock extends NodeMaterialBlock {
  101074. private _defineName;
  101075. private _linearDefineName;
  101076. private _gammaDefineName;
  101077. private _tempTextureRead;
  101078. private _samplerName;
  101079. private _transformedUVName;
  101080. private _textureTransformName;
  101081. private _textureInfoName;
  101082. private _mainUVName;
  101083. private _mainUVDefineName;
  101084. private _fragmentOnly;
  101085. /**
  101086. * Gets or sets the texture associated with the node
  101087. */
  101088. texture: Nullable<Texture>;
  101089. /**
  101090. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101091. */
  101092. convertToGammaSpace: boolean;
  101093. /**
  101094. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101095. */
  101096. convertToLinearSpace: boolean;
  101097. /**
  101098. * Create a new TextureBlock
  101099. * @param name defines the block name
  101100. */
  101101. constructor(name: string, fragmentOnly?: boolean);
  101102. /**
  101103. * Gets the current class name
  101104. * @returns the class name
  101105. */
  101106. getClassName(): string;
  101107. /**
  101108. * Gets the uv input component
  101109. */
  101110. get uv(): NodeMaterialConnectionPoint;
  101111. /**
  101112. * Gets the rgba output component
  101113. */
  101114. get rgba(): NodeMaterialConnectionPoint;
  101115. /**
  101116. * Gets the rgb output component
  101117. */
  101118. get rgb(): NodeMaterialConnectionPoint;
  101119. /**
  101120. * Gets the r output component
  101121. */
  101122. get r(): NodeMaterialConnectionPoint;
  101123. /**
  101124. * Gets the g output component
  101125. */
  101126. get g(): NodeMaterialConnectionPoint;
  101127. /**
  101128. * Gets the b output component
  101129. */
  101130. get b(): NodeMaterialConnectionPoint;
  101131. /**
  101132. * Gets the a output component
  101133. */
  101134. get a(): NodeMaterialConnectionPoint;
  101135. get target(): NodeMaterialBlockTargets;
  101136. autoConfigure(material: NodeMaterial): void;
  101137. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101138. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101139. isReady(): boolean;
  101140. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101141. private get _isMixed();
  101142. private _injectVertexCode;
  101143. private _writeTextureRead;
  101144. private _writeOutput;
  101145. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101146. protected _dumpPropertiesCode(): string;
  101147. serialize(): any;
  101148. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101149. }
  101150. }
  101151. declare module BABYLON {
  101152. /** @hidden */
  101153. export var reflectionFunction: {
  101154. name: string;
  101155. shader: string;
  101156. };
  101157. }
  101158. declare module BABYLON {
  101159. /**
  101160. * Base block used to read a reflection texture from a sampler
  101161. */
  101162. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101163. /** @hidden */
  101164. _define3DName: string;
  101165. /** @hidden */
  101166. _defineCubicName: string;
  101167. /** @hidden */
  101168. _defineExplicitName: string;
  101169. /** @hidden */
  101170. _defineProjectionName: string;
  101171. /** @hidden */
  101172. _defineLocalCubicName: string;
  101173. /** @hidden */
  101174. _defineSphericalName: string;
  101175. /** @hidden */
  101176. _definePlanarName: string;
  101177. /** @hidden */
  101178. _defineEquirectangularName: string;
  101179. /** @hidden */
  101180. _defineMirroredEquirectangularFixedName: string;
  101181. /** @hidden */
  101182. _defineEquirectangularFixedName: string;
  101183. /** @hidden */
  101184. _defineSkyboxName: string;
  101185. /** @hidden */
  101186. _defineOppositeZ: string;
  101187. /** @hidden */
  101188. _cubeSamplerName: string;
  101189. /** @hidden */
  101190. _2DSamplerName: string;
  101191. protected _positionUVWName: string;
  101192. protected _directionWName: string;
  101193. protected _reflectionVectorName: string;
  101194. /** @hidden */
  101195. _reflectionCoordsName: string;
  101196. /** @hidden */
  101197. _reflectionMatrixName: string;
  101198. protected _reflectionColorName: string;
  101199. /**
  101200. * Gets or sets the texture associated with the node
  101201. */
  101202. texture: Nullable<BaseTexture>;
  101203. /**
  101204. * Create a new ReflectionTextureBaseBlock
  101205. * @param name defines the block name
  101206. */
  101207. constructor(name: string);
  101208. /**
  101209. * Gets the current class name
  101210. * @returns the class name
  101211. */
  101212. getClassName(): string;
  101213. /**
  101214. * Gets the world position input component
  101215. */
  101216. abstract get position(): NodeMaterialConnectionPoint;
  101217. /**
  101218. * Gets the world position input component
  101219. */
  101220. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101221. /**
  101222. * Gets the world normal input component
  101223. */
  101224. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101225. /**
  101226. * Gets the world input component
  101227. */
  101228. abstract get world(): NodeMaterialConnectionPoint;
  101229. /**
  101230. * Gets the camera (or eye) position component
  101231. */
  101232. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101233. /**
  101234. * Gets the view input component
  101235. */
  101236. abstract get view(): NodeMaterialConnectionPoint;
  101237. protected _getTexture(): Nullable<BaseTexture>;
  101238. autoConfigure(material: NodeMaterial): void;
  101239. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101240. isReady(): boolean;
  101241. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101242. /**
  101243. * Gets the code to inject in the vertex shader
  101244. * @param state current state of the node material building
  101245. * @returns the shader code
  101246. */
  101247. handleVertexSide(state: NodeMaterialBuildState): string;
  101248. /**
  101249. * Handles the inits for the fragment code path
  101250. * @param state node material build state
  101251. */
  101252. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101253. /**
  101254. * Generates the reflection coords code for the fragment code path
  101255. * @param worldNormalVarName name of the world normal variable
  101256. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101257. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101258. * @returns the shader code
  101259. */
  101260. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101261. /**
  101262. * Generates the reflection color code for the fragment code path
  101263. * @param lodVarName name of the lod variable
  101264. * @param swizzleLookupTexture swizzle to use for the final color variable
  101265. * @returns the shader code
  101266. */
  101267. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101268. /**
  101269. * Generates the code corresponding to the connected output points
  101270. * @param state node material build state
  101271. * @param varName name of the variable to output
  101272. * @returns the shader code
  101273. */
  101274. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101275. protected _buildBlock(state: NodeMaterialBuildState): this;
  101276. protected _dumpPropertiesCode(): string;
  101277. serialize(): any;
  101278. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101279. }
  101280. }
  101281. declare module BABYLON {
  101282. /**
  101283. * Defines a connection point to be used for points with a custom object type
  101284. */
  101285. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101286. private _blockType;
  101287. private _blockName;
  101288. private _nameForCheking?;
  101289. /**
  101290. * Creates a new connection point
  101291. * @param name defines the connection point name
  101292. * @param ownerBlock defines the block hosting this connection point
  101293. * @param direction defines the direction of the connection point
  101294. */
  101295. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101296. /**
  101297. * Gets a number indicating if the current point can be connected to another point
  101298. * @param connectionPoint defines the other connection point
  101299. * @returns a number defining the compatibility state
  101300. */
  101301. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101302. /**
  101303. * Creates a block suitable to be used as an input for this input point.
  101304. * If null is returned, a block based on the point type will be created.
  101305. * @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
  101306. */
  101307. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101308. }
  101309. }
  101310. declare module BABYLON {
  101311. /**
  101312. * Enum defining the type of properties that can be edited in the property pages in the NME
  101313. */
  101314. export enum PropertyTypeForEdition {
  101315. /** property is a boolean */
  101316. Boolean = 0,
  101317. /** property is a float */
  101318. Float = 1,
  101319. /** property is a Vector2 */
  101320. Vector2 = 2,
  101321. /** property is a list of values */
  101322. List = 3
  101323. }
  101324. /**
  101325. * Interface that defines an option in a variable of type list
  101326. */
  101327. export interface IEditablePropertyListOption {
  101328. /** label of the option */
  101329. "label": string;
  101330. /** value of the option */
  101331. "value": number;
  101332. }
  101333. /**
  101334. * Interface that defines the options available for an editable property
  101335. */
  101336. export interface IEditablePropertyOption {
  101337. /** min value */
  101338. "min"?: number;
  101339. /** max value */
  101340. "max"?: number;
  101341. /** notifiers: indicates which actions to take when the property is changed */
  101342. "notifiers"?: {
  101343. /** the material should be rebuilt */
  101344. "rebuild"?: boolean;
  101345. /** the preview should be updated */
  101346. "update"?: boolean;
  101347. };
  101348. /** list of the options for a variable of type list */
  101349. "options"?: IEditablePropertyListOption[];
  101350. }
  101351. /**
  101352. * Interface that describes an editable property
  101353. */
  101354. export interface IPropertyDescriptionForEdition {
  101355. /** name of the property */
  101356. "propertyName": string;
  101357. /** display name of the property */
  101358. "displayName": string;
  101359. /** type of the property */
  101360. "type": PropertyTypeForEdition;
  101361. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101362. "groupName": string;
  101363. /** options for the property */
  101364. "options": IEditablePropertyOption;
  101365. }
  101366. /**
  101367. * Decorator that flags a property in a node material block as being editable
  101368. */
  101369. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101370. }
  101371. declare module BABYLON {
  101372. /**
  101373. * Block used to implement the refraction part of the sub surface module of the PBR material
  101374. */
  101375. export class RefractionBlock extends NodeMaterialBlock {
  101376. /** @hidden */
  101377. _define3DName: string;
  101378. /** @hidden */
  101379. _refractionMatrixName: string;
  101380. /** @hidden */
  101381. _defineLODRefractionAlpha: string;
  101382. /** @hidden */
  101383. _defineLinearSpecularRefraction: string;
  101384. /** @hidden */
  101385. _defineOppositeZ: string;
  101386. /** @hidden */
  101387. _cubeSamplerName: string;
  101388. /** @hidden */
  101389. _2DSamplerName: string;
  101390. /** @hidden */
  101391. _vRefractionMicrosurfaceInfosName: string;
  101392. /** @hidden */
  101393. _vRefractionInfosName: string;
  101394. private _scene;
  101395. /**
  101396. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101397. * Materials half opaque for instance using refraction could benefit from this control.
  101398. */
  101399. linkRefractionWithTransparency: boolean;
  101400. /**
  101401. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101402. */
  101403. invertRefractionY: boolean;
  101404. /**
  101405. * Gets or sets the texture associated with the node
  101406. */
  101407. texture: Nullable<BaseTexture>;
  101408. /**
  101409. * Create a new RefractionBlock
  101410. * @param name defines the block name
  101411. */
  101412. constructor(name: string);
  101413. /**
  101414. * Gets the current class name
  101415. * @returns the class name
  101416. */
  101417. getClassName(): string;
  101418. /**
  101419. * Gets the intensity input component
  101420. */
  101421. get intensity(): NodeMaterialConnectionPoint;
  101422. /**
  101423. * Gets the index of refraction input component
  101424. */
  101425. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101426. /**
  101427. * Gets the tint at distance input component
  101428. */
  101429. get tintAtDistance(): NodeMaterialConnectionPoint;
  101430. /**
  101431. * Gets the view input component
  101432. */
  101433. get view(): NodeMaterialConnectionPoint;
  101434. /**
  101435. * Gets the refraction object output component
  101436. */
  101437. get refraction(): NodeMaterialConnectionPoint;
  101438. /**
  101439. * Returns true if the block has a texture
  101440. */
  101441. get hasTexture(): boolean;
  101442. protected _getTexture(): Nullable<BaseTexture>;
  101443. autoConfigure(material: NodeMaterial): void;
  101444. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101445. isReady(): boolean;
  101446. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101447. /**
  101448. * Gets the main code of the block (fragment side)
  101449. * @param state current state of the node material building
  101450. * @returns the shader code
  101451. */
  101452. getCode(state: NodeMaterialBuildState): string;
  101453. protected _buildBlock(state: NodeMaterialBuildState): this;
  101454. protected _dumpPropertiesCode(): string;
  101455. serialize(): any;
  101456. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101457. }
  101458. }
  101459. declare module BABYLON {
  101460. /**
  101461. * Base block used as input for post process
  101462. */
  101463. export class CurrentScreenBlock extends NodeMaterialBlock {
  101464. private _samplerName;
  101465. private _linearDefineName;
  101466. private _gammaDefineName;
  101467. private _mainUVName;
  101468. private _tempTextureRead;
  101469. /**
  101470. * Gets or sets the texture associated with the node
  101471. */
  101472. texture: Nullable<BaseTexture>;
  101473. /**
  101474. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101475. */
  101476. convertToGammaSpace: boolean;
  101477. /**
  101478. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101479. */
  101480. convertToLinearSpace: boolean;
  101481. /**
  101482. * Create a new CurrentScreenBlock
  101483. * @param name defines the block name
  101484. */
  101485. constructor(name: string);
  101486. /**
  101487. * Gets the current class name
  101488. * @returns the class name
  101489. */
  101490. getClassName(): string;
  101491. /**
  101492. * Gets the uv input component
  101493. */
  101494. get uv(): NodeMaterialConnectionPoint;
  101495. /**
  101496. * Gets the rgba output component
  101497. */
  101498. get rgba(): NodeMaterialConnectionPoint;
  101499. /**
  101500. * Gets the rgb output component
  101501. */
  101502. get rgb(): NodeMaterialConnectionPoint;
  101503. /**
  101504. * Gets the r output component
  101505. */
  101506. get r(): NodeMaterialConnectionPoint;
  101507. /**
  101508. * Gets the g output component
  101509. */
  101510. get g(): NodeMaterialConnectionPoint;
  101511. /**
  101512. * Gets the b output component
  101513. */
  101514. get b(): NodeMaterialConnectionPoint;
  101515. /**
  101516. * Gets the a output component
  101517. */
  101518. get a(): NodeMaterialConnectionPoint;
  101519. /**
  101520. * Initialize the block and prepare the context for build
  101521. * @param state defines the state that will be used for the build
  101522. */
  101523. initialize(state: NodeMaterialBuildState): void;
  101524. get target(): NodeMaterialBlockTargets;
  101525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101526. isReady(): boolean;
  101527. private _injectVertexCode;
  101528. private _writeTextureRead;
  101529. private _writeOutput;
  101530. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101531. serialize(): any;
  101532. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101533. }
  101534. }
  101535. declare module BABYLON {
  101536. /**
  101537. * Base block used for the particle texture
  101538. */
  101539. export class ParticleTextureBlock extends NodeMaterialBlock {
  101540. private _samplerName;
  101541. private _linearDefineName;
  101542. private _gammaDefineName;
  101543. private _tempTextureRead;
  101544. /**
  101545. * Gets or sets the texture associated with the node
  101546. */
  101547. texture: Nullable<BaseTexture>;
  101548. /**
  101549. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101550. */
  101551. convertToGammaSpace: boolean;
  101552. /**
  101553. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101554. */
  101555. convertToLinearSpace: boolean;
  101556. /**
  101557. * Create a new ParticleTextureBlock
  101558. * @param name defines the block name
  101559. */
  101560. constructor(name: string);
  101561. /**
  101562. * Gets the current class name
  101563. * @returns the class name
  101564. */
  101565. getClassName(): string;
  101566. /**
  101567. * Gets the uv input component
  101568. */
  101569. get uv(): NodeMaterialConnectionPoint;
  101570. /**
  101571. * Gets the rgba output component
  101572. */
  101573. get rgba(): NodeMaterialConnectionPoint;
  101574. /**
  101575. * Gets the rgb output component
  101576. */
  101577. get rgb(): NodeMaterialConnectionPoint;
  101578. /**
  101579. * Gets the r output component
  101580. */
  101581. get r(): NodeMaterialConnectionPoint;
  101582. /**
  101583. * Gets the g output component
  101584. */
  101585. get g(): NodeMaterialConnectionPoint;
  101586. /**
  101587. * Gets the b output component
  101588. */
  101589. get b(): NodeMaterialConnectionPoint;
  101590. /**
  101591. * Gets the a output component
  101592. */
  101593. get a(): NodeMaterialConnectionPoint;
  101594. /**
  101595. * Initialize the block and prepare the context for build
  101596. * @param state defines the state that will be used for the build
  101597. */
  101598. initialize(state: NodeMaterialBuildState): void;
  101599. autoConfigure(material: NodeMaterial): void;
  101600. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101601. isReady(): boolean;
  101602. private _writeOutput;
  101603. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101604. serialize(): any;
  101605. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101606. }
  101607. }
  101608. declare module BABYLON {
  101609. /**
  101610. * Class used to store shared data between 2 NodeMaterialBuildState
  101611. */
  101612. export class NodeMaterialBuildStateSharedData {
  101613. /**
  101614. * Gets the list of emitted varyings
  101615. */
  101616. temps: string[];
  101617. /**
  101618. * Gets the list of emitted varyings
  101619. */
  101620. varyings: string[];
  101621. /**
  101622. * Gets the varying declaration string
  101623. */
  101624. varyingDeclaration: string;
  101625. /**
  101626. * Input blocks
  101627. */
  101628. inputBlocks: InputBlock[];
  101629. /**
  101630. * Input blocks
  101631. */
  101632. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101633. /**
  101634. * Bindable blocks (Blocks that need to set data to the effect)
  101635. */
  101636. bindableBlocks: NodeMaterialBlock[];
  101637. /**
  101638. * List of blocks that can provide a compilation fallback
  101639. */
  101640. blocksWithFallbacks: NodeMaterialBlock[];
  101641. /**
  101642. * List of blocks that can provide a define update
  101643. */
  101644. blocksWithDefines: NodeMaterialBlock[];
  101645. /**
  101646. * List of blocks that can provide a repeatable content
  101647. */
  101648. repeatableContentBlocks: NodeMaterialBlock[];
  101649. /**
  101650. * List of blocks that can provide a dynamic list of uniforms
  101651. */
  101652. dynamicUniformBlocks: NodeMaterialBlock[];
  101653. /**
  101654. * List of blocks that can block the isReady function for the material
  101655. */
  101656. blockingBlocks: NodeMaterialBlock[];
  101657. /**
  101658. * Gets the list of animated inputs
  101659. */
  101660. animatedInputs: InputBlock[];
  101661. /**
  101662. * Build Id used to avoid multiple recompilations
  101663. */
  101664. buildId: number;
  101665. /** List of emitted variables */
  101666. variableNames: {
  101667. [key: string]: number;
  101668. };
  101669. /** List of emitted defines */
  101670. defineNames: {
  101671. [key: string]: number;
  101672. };
  101673. /** Should emit comments? */
  101674. emitComments: boolean;
  101675. /** Emit build activity */
  101676. verbose: boolean;
  101677. /** Gets or sets the hosting scene */
  101678. scene: Scene;
  101679. /**
  101680. * Gets the compilation hints emitted at compilation time
  101681. */
  101682. hints: {
  101683. needWorldViewMatrix: boolean;
  101684. needWorldViewProjectionMatrix: boolean;
  101685. needAlphaBlending: boolean;
  101686. needAlphaTesting: boolean;
  101687. };
  101688. /**
  101689. * List of compilation checks
  101690. */
  101691. checks: {
  101692. emitVertex: boolean;
  101693. emitFragment: boolean;
  101694. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101695. };
  101696. /**
  101697. * Is vertex program allowed to be empty?
  101698. */
  101699. allowEmptyVertexProgram: boolean;
  101700. /** Creates a new shared data */
  101701. constructor();
  101702. /**
  101703. * Emits console errors and exceptions if there is a failing check
  101704. */
  101705. emitErrors(): void;
  101706. }
  101707. }
  101708. declare module BABYLON {
  101709. /**
  101710. * Class used to store node based material build state
  101711. */
  101712. export class NodeMaterialBuildState {
  101713. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101714. supportUniformBuffers: boolean;
  101715. /**
  101716. * Gets the list of emitted attributes
  101717. */
  101718. attributes: string[];
  101719. /**
  101720. * Gets the list of emitted uniforms
  101721. */
  101722. uniforms: string[];
  101723. /**
  101724. * Gets the list of emitted constants
  101725. */
  101726. constants: string[];
  101727. /**
  101728. * Gets the list of emitted samplers
  101729. */
  101730. samplers: string[];
  101731. /**
  101732. * Gets the list of emitted functions
  101733. */
  101734. functions: {
  101735. [key: string]: string;
  101736. };
  101737. /**
  101738. * Gets the list of emitted extensions
  101739. */
  101740. extensions: {
  101741. [key: string]: string;
  101742. };
  101743. /**
  101744. * Gets the target of the compilation state
  101745. */
  101746. target: NodeMaterialBlockTargets;
  101747. /**
  101748. * Gets the list of emitted counters
  101749. */
  101750. counters: {
  101751. [key: string]: number;
  101752. };
  101753. /**
  101754. * Shared data between multiple NodeMaterialBuildState instances
  101755. */
  101756. sharedData: NodeMaterialBuildStateSharedData;
  101757. /** @hidden */
  101758. _vertexState: NodeMaterialBuildState;
  101759. /** @hidden */
  101760. _attributeDeclaration: string;
  101761. /** @hidden */
  101762. _uniformDeclaration: string;
  101763. /** @hidden */
  101764. _constantDeclaration: string;
  101765. /** @hidden */
  101766. _samplerDeclaration: string;
  101767. /** @hidden */
  101768. _varyingTransfer: string;
  101769. /** @hidden */
  101770. _injectAtEnd: string;
  101771. private _repeatableContentAnchorIndex;
  101772. /** @hidden */
  101773. _builtCompilationString: string;
  101774. /**
  101775. * Gets the emitted compilation strings
  101776. */
  101777. compilationString: string;
  101778. /**
  101779. * Finalize the compilation strings
  101780. * @param state defines the current compilation state
  101781. */
  101782. finalize(state: NodeMaterialBuildState): void;
  101783. /** @hidden */
  101784. get _repeatableContentAnchor(): string;
  101785. /** @hidden */
  101786. _getFreeVariableName(prefix: string): string;
  101787. /** @hidden */
  101788. _getFreeDefineName(prefix: string): string;
  101789. /** @hidden */
  101790. _excludeVariableName(name: string): void;
  101791. /** @hidden */
  101792. _emit2DSampler(name: string): void;
  101793. /** @hidden */
  101794. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101795. /** @hidden */
  101796. _emitExtension(name: string, extension: string, define?: string): void;
  101797. /** @hidden */
  101798. _emitFunction(name: string, code: string, comments: string): void;
  101799. /** @hidden */
  101800. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101801. replaceStrings?: {
  101802. search: RegExp;
  101803. replace: string;
  101804. }[];
  101805. repeatKey?: string;
  101806. }): string;
  101807. /** @hidden */
  101808. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101809. repeatKey?: string;
  101810. removeAttributes?: boolean;
  101811. removeUniforms?: boolean;
  101812. removeVaryings?: boolean;
  101813. removeIfDef?: boolean;
  101814. replaceStrings?: {
  101815. search: RegExp;
  101816. replace: string;
  101817. }[];
  101818. }, storeKey?: string): void;
  101819. /** @hidden */
  101820. _registerTempVariable(name: string): boolean;
  101821. /** @hidden */
  101822. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101823. /** @hidden */
  101824. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101825. /** @hidden */
  101826. _emitFloat(value: number): string;
  101827. }
  101828. }
  101829. declare module BABYLON {
  101830. /**
  101831. * Helper class used to generate session unique ID
  101832. */
  101833. export class UniqueIdGenerator {
  101834. private static _UniqueIdCounter;
  101835. /**
  101836. * Gets an unique (relatively to the current scene) Id
  101837. */
  101838. static get UniqueId(): number;
  101839. }
  101840. }
  101841. declare module BABYLON {
  101842. /**
  101843. * Defines a block that can be used inside a node based material
  101844. */
  101845. export class NodeMaterialBlock {
  101846. private _buildId;
  101847. private _buildTarget;
  101848. private _target;
  101849. private _isFinalMerger;
  101850. private _isInput;
  101851. private _name;
  101852. protected _isUnique: boolean;
  101853. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101854. inputsAreExclusive: boolean;
  101855. /** @hidden */
  101856. _codeVariableName: string;
  101857. /** @hidden */
  101858. _inputs: NodeMaterialConnectionPoint[];
  101859. /** @hidden */
  101860. _outputs: NodeMaterialConnectionPoint[];
  101861. /** @hidden */
  101862. _preparationId: number;
  101863. /**
  101864. * Gets the name of the block
  101865. */
  101866. get name(): string;
  101867. /**
  101868. * Sets the name of the block. Will check if the name is valid.
  101869. */
  101870. set name(newName: string);
  101871. /**
  101872. * Gets or sets the unique id of the node
  101873. */
  101874. uniqueId: number;
  101875. /**
  101876. * Gets or sets the comments associated with this block
  101877. */
  101878. comments: string;
  101879. /**
  101880. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101881. */
  101882. get isUnique(): boolean;
  101883. /**
  101884. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101885. */
  101886. get isFinalMerger(): boolean;
  101887. /**
  101888. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101889. */
  101890. get isInput(): boolean;
  101891. /**
  101892. * Gets or sets the build Id
  101893. */
  101894. get buildId(): number;
  101895. set buildId(value: number);
  101896. /**
  101897. * Gets or sets the target of the block
  101898. */
  101899. get target(): NodeMaterialBlockTargets;
  101900. set target(value: NodeMaterialBlockTargets);
  101901. /**
  101902. * Gets the list of input points
  101903. */
  101904. get inputs(): NodeMaterialConnectionPoint[];
  101905. /** Gets the list of output points */
  101906. get outputs(): NodeMaterialConnectionPoint[];
  101907. /**
  101908. * Find an input by its name
  101909. * @param name defines the name of the input to look for
  101910. * @returns the input or null if not found
  101911. */
  101912. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101913. /**
  101914. * Find an output by its name
  101915. * @param name defines the name of the outputto look for
  101916. * @returns the output or null if not found
  101917. */
  101918. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101919. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  101920. visibleInInspector: boolean;
  101921. /**
  101922. * Creates a new NodeMaterialBlock
  101923. * @param name defines the block name
  101924. * @param target defines the target of that block (Vertex by default)
  101925. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  101926. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  101927. */
  101928. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  101929. /**
  101930. * Initialize the block and prepare the context for build
  101931. * @param state defines the state that will be used for the build
  101932. */
  101933. initialize(state: NodeMaterialBuildState): void;
  101934. /**
  101935. * Bind data to effect. Will only be called for blocks with isBindable === true
  101936. * @param effect defines the effect to bind data to
  101937. * @param nodeMaterial defines the hosting NodeMaterial
  101938. * @param mesh defines the mesh that will be rendered
  101939. * @param subMesh defines the submesh that will be rendered
  101940. */
  101941. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101942. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  101943. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  101944. protected _writeFloat(value: number): string;
  101945. /**
  101946. * Gets the current class name e.g. "NodeMaterialBlock"
  101947. * @returns the class name
  101948. */
  101949. getClassName(): string;
  101950. /**
  101951. * Register a new input. Must be called inside a block constructor
  101952. * @param name defines the connection point name
  101953. * @param type defines the connection point type
  101954. * @param isOptional defines a boolean indicating that this input can be omitted
  101955. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101956. * @param point an already created connection point. If not provided, create a new one
  101957. * @returns the current block
  101958. */
  101959. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101960. /**
  101961. * Register a new output. Must be called inside a block constructor
  101962. * @param name defines the connection point name
  101963. * @param type defines the connection point type
  101964. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101965. * @param point an already created connection point. If not provided, create a new one
  101966. * @returns the current block
  101967. */
  101968. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101969. /**
  101970. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  101971. * @param forOutput defines an optional connection point to check compatibility with
  101972. * @returns the first available input or null
  101973. */
  101974. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  101975. /**
  101976. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  101977. * @param forBlock defines an optional block to check compatibility with
  101978. * @returns the first available input or null
  101979. */
  101980. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  101981. /**
  101982. * Gets the sibling of the given output
  101983. * @param current defines the current output
  101984. * @returns the next output in the list or null
  101985. */
  101986. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  101987. /**
  101988. * Connect current block with another block
  101989. * @param other defines the block to connect with
  101990. * @param options define the various options to help pick the right connections
  101991. * @returns the current block
  101992. */
  101993. connectTo(other: NodeMaterialBlock, options?: {
  101994. input?: string;
  101995. output?: string;
  101996. outputSwizzle?: string;
  101997. }): this | undefined;
  101998. protected _buildBlock(state: NodeMaterialBuildState): void;
  101999. /**
  102000. * Add uniforms, samplers and uniform buffers at compilation time
  102001. * @param state defines the state to update
  102002. * @param nodeMaterial defines the node material requesting the update
  102003. * @param defines defines the material defines to update
  102004. * @param uniformBuffers defines the list of uniform buffer names
  102005. */
  102006. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102007. /**
  102008. * Add potential fallbacks if shader compilation fails
  102009. * @param mesh defines the mesh to be rendered
  102010. * @param fallbacks defines the current prioritized list of fallbacks
  102011. */
  102012. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102013. /**
  102014. * Initialize defines for shader compilation
  102015. * @param mesh defines the mesh to be rendered
  102016. * @param nodeMaterial defines the node material requesting the update
  102017. * @param defines defines the material defines to update
  102018. * @param useInstances specifies that instances should be used
  102019. */
  102020. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102021. /**
  102022. * Update defines for shader compilation
  102023. * @param mesh defines the mesh to be rendered
  102024. * @param nodeMaterial defines the node material requesting the update
  102025. * @param defines defines the material defines to update
  102026. * @param useInstances specifies that instances should be used
  102027. * @param subMesh defines which submesh to render
  102028. */
  102029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102030. /**
  102031. * Lets the block try to connect some inputs automatically
  102032. * @param material defines the hosting NodeMaterial
  102033. */
  102034. autoConfigure(material: NodeMaterial): void;
  102035. /**
  102036. * Function called when a block is declared as repeatable content generator
  102037. * @param vertexShaderState defines the current compilation state for the vertex shader
  102038. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102039. * @param mesh defines the mesh to be rendered
  102040. * @param defines defines the material defines to update
  102041. */
  102042. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102043. /**
  102044. * Checks if the block is ready
  102045. * @param mesh defines the mesh to be rendered
  102046. * @param nodeMaterial defines the node material requesting the update
  102047. * @param defines defines the material defines to update
  102048. * @param useInstances specifies that instances should be used
  102049. * @returns true if the block is ready
  102050. */
  102051. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102052. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102053. private _processBuild;
  102054. /**
  102055. * Validates the new name for the block node.
  102056. * @param newName the new name to be given to the node.
  102057. * @returns false if the name is a reserve word, else true.
  102058. */
  102059. validateBlockName(newName: string): boolean;
  102060. /**
  102061. * Compile the current node and generate the shader code
  102062. * @param state defines the current compilation state (uniforms, samplers, current string)
  102063. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102064. * @returns true if already built
  102065. */
  102066. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102067. protected _inputRename(name: string): string;
  102068. protected _outputRename(name: string): string;
  102069. protected _dumpPropertiesCode(): string;
  102070. /** @hidden */
  102071. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102072. /** @hidden */
  102073. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102074. /**
  102075. * Clone the current block to a new identical block
  102076. * @param scene defines the hosting scene
  102077. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102078. * @returns a copy of the current block
  102079. */
  102080. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102081. /**
  102082. * Serializes this block in a JSON representation
  102083. * @returns the serialized block object
  102084. */
  102085. serialize(): any;
  102086. /** @hidden */
  102087. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102088. private _deserializePortDisplayNamesAndExposedOnFrame;
  102089. /**
  102090. * Release resources
  102091. */
  102092. dispose(): void;
  102093. }
  102094. }
  102095. declare module BABYLON {
  102096. /**
  102097. * Base class of materials working in push mode in babylon JS
  102098. * @hidden
  102099. */
  102100. export class PushMaterial extends Material {
  102101. protected _activeEffect: Effect;
  102102. protected _normalMatrix: Matrix;
  102103. constructor(name: string, scene: Scene);
  102104. getEffect(): Effect;
  102105. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102106. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102107. /**
  102108. * Binds the given world matrix to the active effect
  102109. *
  102110. * @param world the matrix to bind
  102111. */
  102112. bindOnlyWorldMatrix(world: Matrix): void;
  102113. /**
  102114. * Binds the given normal matrix to the active effect
  102115. *
  102116. * @param normalMatrix the matrix to bind
  102117. */
  102118. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102119. bind(world: Matrix, mesh?: Mesh): void;
  102120. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102121. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102122. }
  102123. }
  102124. declare module BABYLON {
  102125. /**
  102126. * Root class for all node material optimizers
  102127. */
  102128. export class NodeMaterialOptimizer {
  102129. /**
  102130. * Function used to optimize a NodeMaterial graph
  102131. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102132. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102133. */
  102134. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102135. }
  102136. }
  102137. declare module BABYLON {
  102138. /**
  102139. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102140. */
  102141. export class TransformBlock extends NodeMaterialBlock {
  102142. /**
  102143. * Defines the value to use to complement W value to transform it to a Vector4
  102144. */
  102145. complementW: number;
  102146. /**
  102147. * Defines the value to use to complement z value to transform it to a Vector4
  102148. */
  102149. complementZ: number;
  102150. /**
  102151. * Creates a new TransformBlock
  102152. * @param name defines the block name
  102153. */
  102154. constructor(name: string);
  102155. /**
  102156. * Gets the current class name
  102157. * @returns the class name
  102158. */
  102159. getClassName(): string;
  102160. /**
  102161. * Gets the vector input
  102162. */
  102163. get vector(): NodeMaterialConnectionPoint;
  102164. /**
  102165. * Gets the output component
  102166. */
  102167. get output(): NodeMaterialConnectionPoint;
  102168. /**
  102169. * Gets the xyz output component
  102170. */
  102171. get xyz(): NodeMaterialConnectionPoint;
  102172. /**
  102173. * Gets the matrix transform input
  102174. */
  102175. get transform(): NodeMaterialConnectionPoint;
  102176. protected _buildBlock(state: NodeMaterialBuildState): this;
  102177. /**
  102178. * Update defines for shader compilation
  102179. * @param mesh defines the mesh to be rendered
  102180. * @param nodeMaterial defines the node material requesting the update
  102181. * @param defines defines the material defines to update
  102182. * @param useInstances specifies that instances should be used
  102183. * @param subMesh defines which submesh to render
  102184. */
  102185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102186. serialize(): any;
  102187. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102188. protected _dumpPropertiesCode(): string;
  102189. }
  102190. }
  102191. declare module BABYLON {
  102192. /**
  102193. * Block used to output the vertex position
  102194. */
  102195. export class VertexOutputBlock extends NodeMaterialBlock {
  102196. /**
  102197. * Creates a new VertexOutputBlock
  102198. * @param name defines the block name
  102199. */
  102200. constructor(name: string);
  102201. /**
  102202. * Gets the current class name
  102203. * @returns the class name
  102204. */
  102205. getClassName(): string;
  102206. /**
  102207. * Gets the vector input component
  102208. */
  102209. get vector(): NodeMaterialConnectionPoint;
  102210. protected _buildBlock(state: NodeMaterialBuildState): this;
  102211. }
  102212. }
  102213. declare module BABYLON {
  102214. /**
  102215. * Block used to output the final color
  102216. */
  102217. export class FragmentOutputBlock extends NodeMaterialBlock {
  102218. /**
  102219. * Create a new FragmentOutputBlock
  102220. * @param name defines the block name
  102221. */
  102222. constructor(name: string);
  102223. /**
  102224. * Gets the current class name
  102225. * @returns the class name
  102226. */
  102227. getClassName(): string;
  102228. /**
  102229. * Gets the rgba input component
  102230. */
  102231. get rgba(): NodeMaterialConnectionPoint;
  102232. /**
  102233. * Gets the rgb input component
  102234. */
  102235. get rgb(): NodeMaterialConnectionPoint;
  102236. /**
  102237. * Gets the a input component
  102238. */
  102239. get a(): NodeMaterialConnectionPoint;
  102240. protected _buildBlock(state: NodeMaterialBuildState): this;
  102241. }
  102242. }
  102243. declare module BABYLON {
  102244. /**
  102245. * Block used for the particle ramp gradient section
  102246. */
  102247. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102248. /**
  102249. * Create a new ParticleRampGradientBlock
  102250. * @param name defines the block name
  102251. */
  102252. constructor(name: string);
  102253. /**
  102254. * Gets the current class name
  102255. * @returns the class name
  102256. */
  102257. getClassName(): string;
  102258. /**
  102259. * Gets the color input component
  102260. */
  102261. get color(): NodeMaterialConnectionPoint;
  102262. /**
  102263. * Gets the rampColor output component
  102264. */
  102265. get rampColor(): NodeMaterialConnectionPoint;
  102266. /**
  102267. * Initialize the block and prepare the context for build
  102268. * @param state defines the state that will be used for the build
  102269. */
  102270. initialize(state: NodeMaterialBuildState): void;
  102271. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102272. }
  102273. }
  102274. declare module BABYLON {
  102275. /**
  102276. * Block used for the particle blend multiply section
  102277. */
  102278. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102279. /**
  102280. * Create a new ParticleBlendMultiplyBlock
  102281. * @param name defines the block name
  102282. */
  102283. constructor(name: string);
  102284. /**
  102285. * Gets the current class name
  102286. * @returns the class name
  102287. */
  102288. getClassName(): string;
  102289. /**
  102290. * Gets the color input component
  102291. */
  102292. get color(): NodeMaterialConnectionPoint;
  102293. /**
  102294. * Gets the alphaTexture input component
  102295. */
  102296. get alphaTexture(): NodeMaterialConnectionPoint;
  102297. /**
  102298. * Gets the alphaColor input component
  102299. */
  102300. get alphaColor(): NodeMaterialConnectionPoint;
  102301. /**
  102302. * Gets the blendColor output component
  102303. */
  102304. get blendColor(): NodeMaterialConnectionPoint;
  102305. /**
  102306. * Initialize the block and prepare the context for build
  102307. * @param state defines the state that will be used for the build
  102308. */
  102309. initialize(state: NodeMaterialBuildState): void;
  102310. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102311. }
  102312. }
  102313. declare module BABYLON {
  102314. /**
  102315. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102316. */
  102317. export class VectorMergerBlock extends NodeMaterialBlock {
  102318. /**
  102319. * Create a new VectorMergerBlock
  102320. * @param name defines the block name
  102321. */
  102322. constructor(name: string);
  102323. /**
  102324. * Gets the current class name
  102325. * @returns the class name
  102326. */
  102327. getClassName(): string;
  102328. /**
  102329. * Gets the xyz component (input)
  102330. */
  102331. get xyzIn(): NodeMaterialConnectionPoint;
  102332. /**
  102333. * Gets the xy component (input)
  102334. */
  102335. get xyIn(): NodeMaterialConnectionPoint;
  102336. /**
  102337. * Gets the x component (input)
  102338. */
  102339. get x(): NodeMaterialConnectionPoint;
  102340. /**
  102341. * Gets the y component (input)
  102342. */
  102343. get y(): NodeMaterialConnectionPoint;
  102344. /**
  102345. * Gets the z component (input)
  102346. */
  102347. get z(): NodeMaterialConnectionPoint;
  102348. /**
  102349. * Gets the w component (input)
  102350. */
  102351. get w(): NodeMaterialConnectionPoint;
  102352. /**
  102353. * Gets the xyzw component (output)
  102354. */
  102355. get xyzw(): NodeMaterialConnectionPoint;
  102356. /**
  102357. * Gets the xyz component (output)
  102358. */
  102359. get xyzOut(): NodeMaterialConnectionPoint;
  102360. /**
  102361. * Gets the xy component (output)
  102362. */
  102363. get xyOut(): NodeMaterialConnectionPoint;
  102364. /**
  102365. * Gets the xy component (output)
  102366. * @deprecated Please use xyOut instead.
  102367. */
  102368. get xy(): NodeMaterialConnectionPoint;
  102369. /**
  102370. * Gets the xyz component (output)
  102371. * @deprecated Please use xyzOut instead.
  102372. */
  102373. get xyz(): NodeMaterialConnectionPoint;
  102374. protected _buildBlock(state: NodeMaterialBuildState): this;
  102375. }
  102376. }
  102377. declare module BABYLON {
  102378. /**
  102379. * Block used to remap a float from a range to a new one
  102380. */
  102381. export class RemapBlock extends NodeMaterialBlock {
  102382. /**
  102383. * Gets or sets the source range
  102384. */
  102385. sourceRange: Vector2;
  102386. /**
  102387. * Gets or sets the target range
  102388. */
  102389. targetRange: Vector2;
  102390. /**
  102391. * Creates a new RemapBlock
  102392. * @param name defines the block name
  102393. */
  102394. constructor(name: string);
  102395. /**
  102396. * Gets the current class name
  102397. * @returns the class name
  102398. */
  102399. getClassName(): string;
  102400. /**
  102401. * Gets the input component
  102402. */
  102403. get input(): NodeMaterialConnectionPoint;
  102404. /**
  102405. * Gets the source min input component
  102406. */
  102407. get sourceMin(): NodeMaterialConnectionPoint;
  102408. /**
  102409. * Gets the source max input component
  102410. */
  102411. get sourceMax(): NodeMaterialConnectionPoint;
  102412. /**
  102413. * Gets the target min input component
  102414. */
  102415. get targetMin(): NodeMaterialConnectionPoint;
  102416. /**
  102417. * Gets the target max input component
  102418. */
  102419. get targetMax(): NodeMaterialConnectionPoint;
  102420. /**
  102421. * Gets the output component
  102422. */
  102423. get output(): NodeMaterialConnectionPoint;
  102424. protected _buildBlock(state: NodeMaterialBuildState): this;
  102425. protected _dumpPropertiesCode(): string;
  102426. serialize(): any;
  102427. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102428. }
  102429. }
  102430. declare module BABYLON {
  102431. /**
  102432. * Block used to multiply 2 values
  102433. */
  102434. export class MultiplyBlock extends NodeMaterialBlock {
  102435. /**
  102436. * Creates a new MultiplyBlock
  102437. * @param name defines the block name
  102438. */
  102439. constructor(name: string);
  102440. /**
  102441. * Gets the current class name
  102442. * @returns the class name
  102443. */
  102444. getClassName(): string;
  102445. /**
  102446. * Gets the left operand input component
  102447. */
  102448. get left(): NodeMaterialConnectionPoint;
  102449. /**
  102450. * Gets the right operand input component
  102451. */
  102452. get right(): NodeMaterialConnectionPoint;
  102453. /**
  102454. * Gets the output component
  102455. */
  102456. get output(): NodeMaterialConnectionPoint;
  102457. protected _buildBlock(state: NodeMaterialBuildState): this;
  102458. }
  102459. }
  102460. declare module BABYLON {
  102461. /**
  102462. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102463. */
  102464. export class ColorSplitterBlock extends NodeMaterialBlock {
  102465. /**
  102466. * Create a new ColorSplitterBlock
  102467. * @param name defines the block name
  102468. */
  102469. constructor(name: string);
  102470. /**
  102471. * Gets the current class name
  102472. * @returns the class name
  102473. */
  102474. getClassName(): string;
  102475. /**
  102476. * Gets the rgba component (input)
  102477. */
  102478. get rgba(): NodeMaterialConnectionPoint;
  102479. /**
  102480. * Gets the rgb component (input)
  102481. */
  102482. get rgbIn(): NodeMaterialConnectionPoint;
  102483. /**
  102484. * Gets the rgb component (output)
  102485. */
  102486. get rgbOut(): NodeMaterialConnectionPoint;
  102487. /**
  102488. * Gets the r component (output)
  102489. */
  102490. get r(): NodeMaterialConnectionPoint;
  102491. /**
  102492. * Gets the g component (output)
  102493. */
  102494. get g(): NodeMaterialConnectionPoint;
  102495. /**
  102496. * Gets the b component (output)
  102497. */
  102498. get b(): NodeMaterialConnectionPoint;
  102499. /**
  102500. * Gets the a component (output)
  102501. */
  102502. get a(): NodeMaterialConnectionPoint;
  102503. protected _inputRename(name: string): string;
  102504. protected _outputRename(name: string): string;
  102505. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102506. }
  102507. }
  102508. declare module BABYLON {
  102509. /**
  102510. * Operations supported by the Trigonometry block
  102511. */
  102512. export enum TrigonometryBlockOperations {
  102513. /** Cos */
  102514. Cos = 0,
  102515. /** Sin */
  102516. Sin = 1,
  102517. /** Abs */
  102518. Abs = 2,
  102519. /** Exp */
  102520. Exp = 3,
  102521. /** Exp2 */
  102522. Exp2 = 4,
  102523. /** Round */
  102524. Round = 5,
  102525. /** Floor */
  102526. Floor = 6,
  102527. /** Ceiling */
  102528. Ceiling = 7,
  102529. /** Square root */
  102530. Sqrt = 8,
  102531. /** Log */
  102532. Log = 9,
  102533. /** Tangent */
  102534. Tan = 10,
  102535. /** Arc tangent */
  102536. ArcTan = 11,
  102537. /** Arc cosinus */
  102538. ArcCos = 12,
  102539. /** Arc sinus */
  102540. ArcSin = 13,
  102541. /** Fraction */
  102542. Fract = 14,
  102543. /** Sign */
  102544. Sign = 15,
  102545. /** To radians (from degrees) */
  102546. Radians = 16,
  102547. /** To degrees (from radians) */
  102548. Degrees = 17
  102549. }
  102550. /**
  102551. * Block used to apply trigonometry operation to floats
  102552. */
  102553. export class TrigonometryBlock extends NodeMaterialBlock {
  102554. /**
  102555. * Gets or sets the operation applied by the block
  102556. */
  102557. operation: TrigonometryBlockOperations;
  102558. /**
  102559. * Creates a new TrigonometryBlock
  102560. * @param name defines the block name
  102561. */
  102562. constructor(name: string);
  102563. /**
  102564. * Gets the current class name
  102565. * @returns the class name
  102566. */
  102567. getClassName(): string;
  102568. /**
  102569. * Gets the input component
  102570. */
  102571. get input(): NodeMaterialConnectionPoint;
  102572. /**
  102573. * Gets the output component
  102574. */
  102575. get output(): NodeMaterialConnectionPoint;
  102576. protected _buildBlock(state: NodeMaterialBuildState): this;
  102577. serialize(): any;
  102578. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102579. protected _dumpPropertiesCode(): string;
  102580. }
  102581. }
  102582. declare module BABYLON {
  102583. /**
  102584. * Interface used to configure the node material editor
  102585. */
  102586. export interface INodeMaterialEditorOptions {
  102587. /** Define the URl to load node editor script */
  102588. editorURL?: string;
  102589. }
  102590. /** @hidden */
  102591. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102592. NORMAL: boolean;
  102593. TANGENT: boolean;
  102594. UV1: boolean;
  102595. /** BONES */
  102596. NUM_BONE_INFLUENCERS: number;
  102597. BonesPerMesh: number;
  102598. BONETEXTURE: boolean;
  102599. /** MORPH TARGETS */
  102600. MORPHTARGETS: boolean;
  102601. MORPHTARGETS_NORMAL: boolean;
  102602. MORPHTARGETS_TANGENT: boolean;
  102603. MORPHTARGETS_UV: boolean;
  102604. NUM_MORPH_INFLUENCERS: number;
  102605. /** IMAGE PROCESSING */
  102606. IMAGEPROCESSING: boolean;
  102607. VIGNETTE: boolean;
  102608. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102609. VIGNETTEBLENDMODEOPAQUE: boolean;
  102610. TONEMAPPING: boolean;
  102611. TONEMAPPING_ACES: boolean;
  102612. CONTRAST: boolean;
  102613. EXPOSURE: boolean;
  102614. COLORCURVES: boolean;
  102615. COLORGRADING: boolean;
  102616. COLORGRADING3D: boolean;
  102617. SAMPLER3DGREENDEPTH: boolean;
  102618. SAMPLER3DBGRMAP: boolean;
  102619. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102620. /** MISC. */
  102621. BUMPDIRECTUV: number;
  102622. constructor();
  102623. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102624. }
  102625. /**
  102626. * Class used to configure NodeMaterial
  102627. */
  102628. export interface INodeMaterialOptions {
  102629. /**
  102630. * Defines if blocks should emit comments
  102631. */
  102632. emitComments: boolean;
  102633. }
  102634. /**
  102635. * Class used to create a node based material built by assembling shader blocks
  102636. */
  102637. export class NodeMaterial extends PushMaterial {
  102638. private static _BuildIdGenerator;
  102639. private _options;
  102640. private _vertexCompilationState;
  102641. private _fragmentCompilationState;
  102642. private _sharedData;
  102643. private _buildId;
  102644. private _buildWasSuccessful;
  102645. private _cachedWorldViewMatrix;
  102646. private _cachedWorldViewProjectionMatrix;
  102647. private _optimizers;
  102648. private _animationFrame;
  102649. /** Define the Url to load node editor script */
  102650. static EditorURL: string;
  102651. /** Define the Url to load snippets */
  102652. static SnippetUrl: string;
  102653. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102654. static IgnoreTexturesAtLoadTime: boolean;
  102655. private BJSNODEMATERIALEDITOR;
  102656. /** Get the inspector from bundle or global */
  102657. private _getGlobalNodeMaterialEditor;
  102658. /**
  102659. * Snippet ID if the material was created from the snippet server
  102660. */
  102661. snippetId: string;
  102662. /**
  102663. * Gets or sets data used by visual editor
  102664. * @see https://nme.babylonjs.com
  102665. */
  102666. editorData: any;
  102667. /**
  102668. * 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)
  102669. */
  102670. ignoreAlpha: boolean;
  102671. /**
  102672. * Defines the maximum number of lights that can be used in the material
  102673. */
  102674. maxSimultaneousLights: number;
  102675. /**
  102676. * Observable raised when the material is built
  102677. */
  102678. onBuildObservable: Observable<NodeMaterial>;
  102679. /**
  102680. * Gets or sets the root nodes of the material vertex shader
  102681. */
  102682. _vertexOutputNodes: NodeMaterialBlock[];
  102683. /**
  102684. * Gets or sets the root nodes of the material fragment (pixel) shader
  102685. */
  102686. _fragmentOutputNodes: NodeMaterialBlock[];
  102687. /** Gets or sets options to control the node material overall behavior */
  102688. get options(): INodeMaterialOptions;
  102689. set options(options: INodeMaterialOptions);
  102690. /**
  102691. * Default configuration related to image processing available in the standard Material.
  102692. */
  102693. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102694. /**
  102695. * Gets the image processing configuration used either in this material.
  102696. */
  102697. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102698. /**
  102699. * Sets the Default image processing configuration used either in the this material.
  102700. *
  102701. * If sets to null, the scene one is in use.
  102702. */
  102703. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102704. /**
  102705. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102706. */
  102707. attachedBlocks: NodeMaterialBlock[];
  102708. /**
  102709. * Specifies the mode of the node material
  102710. * @hidden
  102711. */
  102712. _mode: NodeMaterialModes;
  102713. /**
  102714. * Gets the mode property
  102715. */
  102716. get mode(): NodeMaterialModes;
  102717. /**
  102718. * Create a new node based material
  102719. * @param name defines the material name
  102720. * @param scene defines the hosting scene
  102721. * @param options defines creation option
  102722. */
  102723. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102724. /**
  102725. * Gets the current class name of the material e.g. "NodeMaterial"
  102726. * @returns the class name
  102727. */
  102728. getClassName(): string;
  102729. /**
  102730. * Keep track of the image processing observer to allow dispose and replace.
  102731. */
  102732. private _imageProcessingObserver;
  102733. /**
  102734. * Attaches a new image processing configuration to the Standard Material.
  102735. * @param configuration
  102736. */
  102737. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102738. /**
  102739. * Get a block by its name
  102740. * @param name defines the name of the block to retrieve
  102741. * @returns the required block or null if not found
  102742. */
  102743. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102744. /**
  102745. * Get a block by its name
  102746. * @param predicate defines the predicate used to find the good candidate
  102747. * @returns the required block or null if not found
  102748. */
  102749. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102750. /**
  102751. * Get an input block by its name
  102752. * @param predicate defines the predicate used to find the good candidate
  102753. * @returns the required input block or null if not found
  102754. */
  102755. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102756. /**
  102757. * Gets the list of input blocks attached to this material
  102758. * @returns an array of InputBlocks
  102759. */
  102760. getInputBlocks(): InputBlock[];
  102761. /**
  102762. * Adds a new optimizer to the list of optimizers
  102763. * @param optimizer defines the optimizers to add
  102764. * @returns the current material
  102765. */
  102766. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102767. /**
  102768. * Remove an optimizer from the list of optimizers
  102769. * @param optimizer defines the optimizers to remove
  102770. * @returns the current material
  102771. */
  102772. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102773. /**
  102774. * Add a new block to the list of output nodes
  102775. * @param node defines the node to add
  102776. * @returns the current material
  102777. */
  102778. addOutputNode(node: NodeMaterialBlock): this;
  102779. /**
  102780. * Remove a block from the list of root nodes
  102781. * @param node defines the node to remove
  102782. * @returns the current material
  102783. */
  102784. removeOutputNode(node: NodeMaterialBlock): this;
  102785. private _addVertexOutputNode;
  102786. private _removeVertexOutputNode;
  102787. private _addFragmentOutputNode;
  102788. private _removeFragmentOutputNode;
  102789. /**
  102790. * Specifies if the material will require alpha blending
  102791. * @returns a boolean specifying if alpha blending is needed
  102792. */
  102793. needAlphaBlending(): boolean;
  102794. /**
  102795. * Specifies if this material should be rendered in alpha test mode
  102796. * @returns a boolean specifying if an alpha test is needed.
  102797. */
  102798. needAlphaTesting(): boolean;
  102799. private _initializeBlock;
  102800. private _resetDualBlocks;
  102801. /**
  102802. * Remove a block from the current node material
  102803. * @param block defines the block to remove
  102804. */
  102805. removeBlock(block: NodeMaterialBlock): void;
  102806. /**
  102807. * Build the material and generates the inner effect
  102808. * @param verbose defines if the build should log activity
  102809. */
  102810. build(verbose?: boolean): void;
  102811. /**
  102812. * Runs an otpimization phase to try to improve the shader code
  102813. */
  102814. optimize(): void;
  102815. private _prepareDefinesForAttributes;
  102816. /**
  102817. * Create a post process from the material
  102818. * @param camera The camera to apply the render pass to.
  102819. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102821. * @param engine The engine which the post process will be applied. (default: current engine)
  102822. * @param reusable If the post process can be reused on the same frame. (default: false)
  102823. * @param textureType Type of textures used when performing the post process. (default: 0)
  102824. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102825. * @returns the post process created
  102826. */
  102827. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  102828. /**
  102829. * Create the post process effect from the material
  102830. * @param postProcess The post process to create the effect for
  102831. */
  102832. createEffectForPostProcess(postProcess: PostProcess): void;
  102833. private _createEffectForPostProcess;
  102834. /**
  102835. * Create a new procedural texture based on this node material
  102836. * @param size defines the size of the texture
  102837. * @param scene defines the hosting scene
  102838. * @returns the new procedural texture attached to this node material
  102839. */
  102840. createProceduralTexture(size: number | {
  102841. width: number;
  102842. height: number;
  102843. layers?: number;
  102844. }, scene: Scene): Nullable<ProceduralTexture>;
  102845. private _createEffectForParticles;
  102846. private _checkInternals;
  102847. /**
  102848. * Create the effect to be used as the custom effect for a particle system
  102849. * @param particleSystem Particle system to create the effect for
  102850. * @param onCompiled defines a function to call when the effect creation is successful
  102851. * @param onError defines a function to call when the effect creation has failed
  102852. */
  102853. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102854. private _processDefines;
  102855. /**
  102856. * Get if the submesh is ready to be used and all its information available.
  102857. * Child classes can use it to update shaders
  102858. * @param mesh defines the mesh to check
  102859. * @param subMesh defines which submesh to check
  102860. * @param useInstances specifies that instances should be used
  102861. * @returns a boolean indicating that the submesh is ready or not
  102862. */
  102863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102864. /**
  102865. * Get a string representing the shaders built by the current node graph
  102866. */
  102867. get compiledShaders(): string;
  102868. /**
  102869. * Binds the world matrix to the material
  102870. * @param world defines the world transformation matrix
  102871. */
  102872. bindOnlyWorldMatrix(world: Matrix): void;
  102873. /**
  102874. * Binds the submesh to this material by preparing the effect and shader to draw
  102875. * @param world defines the world transformation matrix
  102876. * @param mesh defines the mesh containing the submesh
  102877. * @param subMesh defines the submesh to bind the material to
  102878. */
  102879. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102880. /**
  102881. * Gets the active textures from the material
  102882. * @returns an array of textures
  102883. */
  102884. getActiveTextures(): BaseTexture[];
  102885. /**
  102886. * Gets the list of texture blocks
  102887. * @returns an array of texture blocks
  102888. */
  102889. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102890. /**
  102891. * Specifies if the material uses a texture
  102892. * @param texture defines the texture to check against the material
  102893. * @returns a boolean specifying if the material uses the texture
  102894. */
  102895. hasTexture(texture: BaseTexture): boolean;
  102896. /**
  102897. * Disposes the material
  102898. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102899. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102900. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102901. */
  102902. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102903. /** Creates the node editor window. */
  102904. private _createNodeEditor;
  102905. /**
  102906. * Launch the node material editor
  102907. * @param config Define the configuration of the editor
  102908. * @return a promise fulfilled when the node editor is visible
  102909. */
  102910. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102911. /**
  102912. * Clear the current material
  102913. */
  102914. clear(): void;
  102915. /**
  102916. * Clear the current material and set it to a default state
  102917. */
  102918. setToDefault(): void;
  102919. /**
  102920. * Clear the current material and set it to a default state for post process
  102921. */
  102922. setToDefaultPostProcess(): void;
  102923. /**
  102924. * Clear the current material and set it to a default state for procedural texture
  102925. */
  102926. setToDefaultProceduralTexture(): void;
  102927. /**
  102928. * Clear the current material and set it to a default state for particle
  102929. */
  102930. setToDefaultParticle(): void;
  102931. /**
  102932. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102933. * @param url defines the url to load from
  102934. * @returns a promise that will fullfil when the material is fully loaded
  102935. */
  102936. loadAsync(url: string): Promise<void>;
  102937. private _gatherBlocks;
  102938. /**
  102939. * Generate a string containing the code declaration required to create an equivalent of this material
  102940. * @returns a string
  102941. */
  102942. generateCode(): string;
  102943. /**
  102944. * Serializes this material in a JSON representation
  102945. * @returns the serialized material object
  102946. */
  102947. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102948. private _restoreConnections;
  102949. /**
  102950. * Clear the current graph and load a new one from a serialization object
  102951. * @param source defines the JSON representation of the material
  102952. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102953. * @param merge defines whether or not the source must be merged or replace the current content
  102954. */
  102955. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  102956. /**
  102957. * Makes a duplicate of the current material.
  102958. * @param name - name to use for the new material.
  102959. */
  102960. clone(name: string): NodeMaterial;
  102961. /**
  102962. * Creates a node material from parsed material data
  102963. * @param source defines the JSON representation of the material
  102964. * @param scene defines the hosting scene
  102965. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102966. * @returns a new node material
  102967. */
  102968. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  102969. /**
  102970. * Creates a node material from a snippet saved in a remote file
  102971. * @param name defines the name of the material to create
  102972. * @param url defines the url to load from
  102973. * @param scene defines the hosting scene
  102974. * @returns a promise that will resolve to the new node material
  102975. */
  102976. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  102977. /**
  102978. * Creates a node material from a snippet saved by the node material editor
  102979. * @param snippetId defines the snippet to load
  102980. * @param scene defines the hosting scene
  102981. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102982. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  102983. * @returns a promise that will resolve to the new node material
  102984. */
  102985. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  102986. /**
  102987. * Creates a new node material set to default basic configuration
  102988. * @param name defines the name of the material
  102989. * @param scene defines the hosting scene
  102990. * @returns a new NodeMaterial
  102991. */
  102992. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  102993. }
  102994. }
  102995. declare module BABYLON {
  102996. /**
  102997. * Size options for a post process
  102998. */
  102999. export type PostProcessOptions = {
  103000. width: number;
  103001. height: number;
  103002. };
  103003. /**
  103004. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103005. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103006. */
  103007. export class PostProcess {
  103008. /**
  103009. * Gets or sets the unique id of the post process
  103010. */
  103011. uniqueId: number;
  103012. /** Name of the PostProcess. */
  103013. name: string;
  103014. /**
  103015. * Width of the texture to apply the post process on
  103016. */
  103017. width: number;
  103018. /**
  103019. * Height of the texture to apply the post process on
  103020. */
  103021. height: number;
  103022. /**
  103023. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103024. */
  103025. nodeMaterialSource: Nullable<NodeMaterial>;
  103026. /**
  103027. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103028. * @hidden
  103029. */
  103030. _outputTexture: Nullable<InternalTexture>;
  103031. /**
  103032. * Sampling mode used by the shader
  103033. * See https://doc.babylonjs.com/classes/3.1/texture
  103034. */
  103035. renderTargetSamplingMode: number;
  103036. /**
  103037. * Clear color to use when screen clearing
  103038. */
  103039. clearColor: Color4;
  103040. /**
  103041. * If the buffer needs to be cleared before applying the post process. (default: true)
  103042. * Should be set to false if shader will overwrite all previous pixels.
  103043. */
  103044. autoClear: boolean;
  103045. /**
  103046. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103047. */
  103048. alphaMode: number;
  103049. /**
  103050. * Sets the setAlphaBlendConstants of the babylon engine
  103051. */
  103052. alphaConstants: Color4;
  103053. /**
  103054. * Animations to be used for the post processing
  103055. */
  103056. animations: Animation[];
  103057. /**
  103058. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  103059. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  103060. */
  103061. enablePixelPerfectMode: boolean;
  103062. /**
  103063. * Force the postprocess to be applied without taking in account viewport
  103064. */
  103065. forceFullscreenViewport: boolean;
  103066. /**
  103067. * List of inspectable custom properties (used by the Inspector)
  103068. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103069. */
  103070. inspectableCustomProperties: IInspectable[];
  103071. /**
  103072. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  103073. *
  103074. * | Value | Type | Description |
  103075. * | ----- | ----------------------------------- | ----------- |
  103076. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  103077. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  103078. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  103079. *
  103080. */
  103081. scaleMode: number;
  103082. /**
  103083. * Force textures to be a power of two (default: false)
  103084. */
  103085. alwaysForcePOT: boolean;
  103086. private _samples;
  103087. /**
  103088. * Number of sample textures (default: 1)
  103089. */
  103090. get samples(): number;
  103091. set samples(n: number);
  103092. /**
  103093. * Modify the scale of the post process to be the same as the viewport (default: false)
  103094. */
  103095. adaptScaleToCurrentViewport: boolean;
  103096. private _camera;
  103097. protected _scene: Scene;
  103098. private _engine;
  103099. private _options;
  103100. private _reusable;
  103101. private _textureType;
  103102. private _textureFormat;
  103103. /**
  103104. * Smart array of input and output textures for the post process.
  103105. * @hidden
  103106. */
  103107. _textures: SmartArray<InternalTexture>;
  103108. /**
  103109. * The index in _textures that corresponds to the output texture.
  103110. * @hidden
  103111. */
  103112. _currentRenderTextureInd: number;
  103113. private _effect;
  103114. private _samplers;
  103115. private _fragmentUrl;
  103116. private _vertexUrl;
  103117. private _parameters;
  103118. private _scaleRatio;
  103119. protected _indexParameters: any;
  103120. private _shareOutputWithPostProcess;
  103121. private _texelSize;
  103122. private _forcedOutputTexture;
  103123. /**
  103124. * Returns the fragment url or shader name used in the post process.
  103125. * @returns the fragment url or name in the shader store.
  103126. */
  103127. getEffectName(): string;
  103128. /**
  103129. * An event triggered when the postprocess is activated.
  103130. */
  103131. onActivateObservable: Observable<Camera>;
  103132. private _onActivateObserver;
  103133. /**
  103134. * A function that is added to the onActivateObservable
  103135. */
  103136. set onActivate(callback: Nullable<(camera: Camera) => void>);
  103137. /**
  103138. * An event triggered when the postprocess changes its size.
  103139. */
  103140. onSizeChangedObservable: Observable<PostProcess>;
  103141. private _onSizeChangedObserver;
  103142. /**
  103143. * A function that is added to the onSizeChangedObservable
  103144. */
  103145. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  103146. /**
  103147. * An event triggered when the postprocess applies its effect.
  103148. */
  103149. onApplyObservable: Observable<Effect>;
  103150. private _onApplyObserver;
  103151. /**
  103152. * A function that is added to the onApplyObservable
  103153. */
  103154. set onApply(callback: (effect: Effect) => void);
  103155. /**
  103156. * An event triggered before rendering the postprocess
  103157. */
  103158. onBeforeRenderObservable: Observable<Effect>;
  103159. private _onBeforeRenderObserver;
  103160. /**
  103161. * A function that is added to the onBeforeRenderObservable
  103162. */
  103163. set onBeforeRender(callback: (effect: Effect) => void);
  103164. /**
  103165. * An event triggered after rendering the postprocess
  103166. */
  103167. onAfterRenderObservable: Observable<Effect>;
  103168. private _onAfterRenderObserver;
  103169. /**
  103170. * A function that is added to the onAfterRenderObservable
  103171. */
  103172. set onAfterRender(callback: (efect: Effect) => void);
  103173. /**
  103174. * 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
  103175. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  103176. */
  103177. get inputTexture(): InternalTexture;
  103178. set inputTexture(value: InternalTexture);
  103179. /**
  103180. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  103181. * the only way to unset it is to use this function to restore its internal state
  103182. */
  103183. restoreDefaultInputTexture(): void;
  103184. /**
  103185. * Gets the camera which post process is applied to.
  103186. * @returns The camera the post process is applied to.
  103187. */
  103188. getCamera(): Camera;
  103189. /**
  103190. * Gets the texel size of the postprocess.
  103191. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  103192. */
  103193. get texelSize(): Vector2;
  103194. /**
  103195. * Creates a new instance PostProcess
  103196. * @param name The name of the PostProcess.
  103197. * @param fragmentUrl The url of the fragment shader to be used.
  103198. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  103199. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  103200. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103201. * @param camera The camera to apply the render pass to.
  103202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103203. * @param engine The engine which the post process will be applied. (default: current engine)
  103204. * @param reusable If the post process can be reused on the same frame. (default: false)
  103205. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  103206. * @param textureType Type of textures used when performing the post process. (default: 0)
  103207. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  103208. * @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
  103209. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  103210. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103211. */
  103212. 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);
  103213. /**
  103214. * Gets a string identifying the name of the class
  103215. * @returns "PostProcess" string
  103216. */
  103217. getClassName(): string;
  103218. /**
  103219. * Gets the engine which this post process belongs to.
  103220. * @returns The engine the post process was enabled with.
  103221. */
  103222. getEngine(): Engine;
  103223. /**
  103224. * The effect that is created when initializing the post process.
  103225. * @returns The created effect corresponding the the postprocess.
  103226. */
  103227. getEffect(): Effect;
  103228. /**
  103229. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  103230. * @param postProcess The post process to share the output with.
  103231. * @returns This post process.
  103232. */
  103233. shareOutputWith(postProcess: PostProcess): PostProcess;
  103234. /**
  103235. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  103236. * This should be called if the post process that shares output with this post process is disabled/disposed.
  103237. */
  103238. useOwnOutput(): void;
  103239. /**
  103240. * Updates the effect with the current post process compile time values and recompiles the shader.
  103241. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103242. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103243. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103244. * @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
  103245. * @param onCompiled Called when the shader has been compiled.
  103246. * @param onError Called if there is an error when compiling a shader.
  103247. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  103248. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  103249. */
  103250. 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;
  103251. /**
  103252. * The post process is reusable if it can be used multiple times within one frame.
  103253. * @returns If the post process is reusable
  103254. */
  103255. isReusable(): boolean;
  103256. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  103257. markTextureDirty(): void;
  103258. /**
  103259. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  103260. * 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.
  103261. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  103262. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  103263. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  103264. * @returns The target texture that was bound to be written to.
  103265. */
  103266. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  103267. /**
  103268. * If the post process is supported.
  103269. */
  103270. get isSupported(): boolean;
  103271. /**
  103272. * The aspect ratio of the output texture.
  103273. */
  103274. get aspectRatio(): number;
  103275. /**
  103276. * Get a value indicating if the post-process is ready to be used
  103277. * @returns true if the post-process is ready (shader is compiled)
  103278. */
  103279. isReady(): boolean;
  103280. /**
  103281. * Binds all textures and uniforms to the shader, this will be run on every pass.
  103282. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  103283. */
  103284. apply(): Nullable<Effect>;
  103285. private _disposeTextures;
  103286. /**
  103287. * Disposes the post process.
  103288. * @param camera The camera to dispose the post process on.
  103289. */
  103290. dispose(camera?: Camera): void;
  103291. /**
  103292. * Serializes the particle system to a JSON object
  103293. * @returns the JSON object
  103294. */
  103295. serialize(): any;
  103296. /**
  103297. * Creates a material from parsed material data
  103298. * @param parsedPostProcess defines parsed post process data
  103299. * @param scene defines the hosting scene
  103300. * @param rootUrl defines the root URL to use to load textures
  103301. * @returns a new post process
  103302. */
  103303. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  103304. }
  103305. }
  103306. declare module BABYLON {
  103307. /** @hidden */
  103308. export var kernelBlurVaryingDeclaration: {
  103309. name: string;
  103310. shader: string;
  103311. };
  103312. }
  103313. declare module BABYLON {
  103314. /** @hidden */
  103315. export var kernelBlurFragment: {
  103316. name: string;
  103317. shader: string;
  103318. };
  103319. }
  103320. declare module BABYLON {
  103321. /** @hidden */
  103322. export var kernelBlurFragment2: {
  103323. name: string;
  103324. shader: string;
  103325. };
  103326. }
  103327. declare module BABYLON {
  103328. /** @hidden */
  103329. export var kernelBlurPixelShader: {
  103330. name: string;
  103331. shader: string;
  103332. };
  103333. }
  103334. declare module BABYLON {
  103335. /** @hidden */
  103336. export var kernelBlurVertex: {
  103337. name: string;
  103338. shader: string;
  103339. };
  103340. }
  103341. declare module BABYLON {
  103342. /** @hidden */
  103343. export var kernelBlurVertexShader: {
  103344. name: string;
  103345. shader: string;
  103346. };
  103347. }
  103348. declare module BABYLON {
  103349. /**
  103350. * The Blur Post Process which blurs an image based on a kernel and direction.
  103351. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  103352. */
  103353. export class BlurPostProcess extends PostProcess {
  103354. private blockCompilation;
  103355. protected _kernel: number;
  103356. protected _idealKernel: number;
  103357. protected _packedFloat: boolean;
  103358. private _staticDefines;
  103359. /** The direction in which to blur the image. */
  103360. direction: Vector2;
  103361. /**
  103362. * Sets the length in pixels of the blur sample region
  103363. */
  103364. set kernel(v: number);
  103365. /**
  103366. * Gets the length in pixels of the blur sample region
  103367. */
  103368. get kernel(): number;
  103369. /**
  103370. * Sets wether or not the blur needs to unpack/repack floats
  103371. */
  103372. set packedFloat(v: boolean);
  103373. /**
  103374. * Gets wether or not the blur is unpacking/repacking floats
  103375. */
  103376. get packedFloat(): boolean;
  103377. /**
  103378. * Gets a string identifying the name of the class
  103379. * @returns "BlurPostProcess" string
  103380. */
  103381. getClassName(): string;
  103382. /**
  103383. * Creates a new instance BlurPostProcess
  103384. * @param name The name of the effect.
  103385. * @param direction The direction in which to blur the image.
  103386. * @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.
  103387. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103388. * @param camera The camera to apply the render pass to.
  103389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103390. * @param engine The engine which the post process will be applied. (default: current engine)
  103391. * @param reusable If the post process can be reused on the same frame. (default: false)
  103392. * @param textureType Type of textures used when performing the post process. (default: 0)
  103393. * @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)
  103394. */
  103395. 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);
  103396. /**
  103397. * Updates the effect with the current post process compile time values and recompiles the shader.
  103398. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103399. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103400. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103401. * @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
  103402. * @param onCompiled Called when the shader has been compiled.
  103403. * @param onError Called if there is an error when compiling a shader.
  103404. */
  103405. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103406. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103407. /**
  103408. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  103409. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  103410. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  103411. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  103412. * The gaps between physical kernels are compensated for in the weighting of the samples
  103413. * @param idealKernel Ideal blur kernel.
  103414. * @return Nearest best kernel.
  103415. */
  103416. protected _nearestBestKernel(idealKernel: number): number;
  103417. /**
  103418. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  103419. * @param x The point on the Gaussian distribution to sample.
  103420. * @return the value of the Gaussian function at x.
  103421. */
  103422. protected _gaussianWeight(x: number): number;
  103423. /**
  103424. * Generates a string that can be used as a floating point number in GLSL.
  103425. * @param x Value to print.
  103426. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  103427. * @return GLSL float string.
  103428. */
  103429. protected _glslFloat(x: number, decimalFigures?: number): string;
  103430. /** @hidden */
  103431. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  103432. }
  103433. }
  103434. declare module BABYLON {
  103435. /**
  103436. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103437. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103438. * You can then easily use it as a reflectionTexture on a flat surface.
  103439. * In case the surface is not a plane, please consider relying on reflection probes.
  103440. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103441. */
  103442. export class MirrorTexture extends RenderTargetTexture {
  103443. private scene;
  103444. /**
  103445. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  103446. * 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.
  103447. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103448. */
  103449. mirrorPlane: Plane;
  103450. /**
  103451. * Define the blur ratio used to blur the reflection if needed.
  103452. */
  103453. set blurRatio(value: number);
  103454. get blurRatio(): number;
  103455. /**
  103456. * Define the adaptive blur kernel used to blur the reflection if needed.
  103457. * This will autocompute the closest best match for the `blurKernel`
  103458. */
  103459. set adaptiveBlurKernel(value: number);
  103460. /**
  103461. * Define the blur kernel used to blur the reflection if needed.
  103462. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103463. */
  103464. set blurKernel(value: number);
  103465. /**
  103466. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  103467. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103468. */
  103469. set blurKernelX(value: number);
  103470. get blurKernelX(): number;
  103471. /**
  103472. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  103473. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103474. */
  103475. set blurKernelY(value: number);
  103476. get blurKernelY(): number;
  103477. private _autoComputeBlurKernel;
  103478. protected _onRatioRescale(): void;
  103479. private _updateGammaSpace;
  103480. private _imageProcessingConfigChangeObserver;
  103481. private _transformMatrix;
  103482. private _mirrorMatrix;
  103483. private _savedViewMatrix;
  103484. private _blurX;
  103485. private _blurY;
  103486. private _adaptiveBlurKernel;
  103487. private _blurKernelX;
  103488. private _blurKernelY;
  103489. private _blurRatio;
  103490. /**
  103491. * Instantiates a Mirror Texture.
  103492. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103493. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103494. * You can then easily use it as a reflectionTexture on a flat surface.
  103495. * In case the surface is not a plane, please consider relying on reflection probes.
  103496. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103497. * @param name
  103498. * @param size
  103499. * @param scene
  103500. * @param generateMipMaps
  103501. * @param type
  103502. * @param samplingMode
  103503. * @param generateDepthBuffer
  103504. */
  103505. constructor(name: string, size: number | {
  103506. width: number;
  103507. height: number;
  103508. } | {
  103509. ratio: number;
  103510. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  103511. private _preparePostProcesses;
  103512. /**
  103513. * Clone the mirror texture.
  103514. * @returns the cloned texture
  103515. */
  103516. clone(): MirrorTexture;
  103517. /**
  103518. * Serialize the texture to a JSON representation you could use in Parse later on
  103519. * @returns the serialized JSON representation
  103520. */
  103521. serialize(): any;
  103522. /**
  103523. * Dispose the texture and release its associated resources.
  103524. */
  103525. dispose(): void;
  103526. }
  103527. }
  103528. declare module BABYLON {
  103529. /**
  103530. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103531. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103532. */
  103533. export class Texture extends BaseTexture {
  103534. /**
  103535. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  103536. */
  103537. static SerializeBuffers: boolean;
  103538. /** @hidden */
  103539. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  103540. /** @hidden */
  103541. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  103542. /** @hidden */
  103543. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  103544. /** nearest is mag = nearest and min = nearest and mip = linear */
  103545. static readonly NEAREST_SAMPLINGMODE: number;
  103546. /** nearest is mag = nearest and min = nearest and mip = linear */
  103547. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  103548. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103549. static readonly BILINEAR_SAMPLINGMODE: number;
  103550. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103551. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  103552. /** Trilinear is mag = linear and min = linear and mip = linear */
  103553. static readonly TRILINEAR_SAMPLINGMODE: number;
  103554. /** Trilinear is mag = linear and min = linear and mip = linear */
  103555. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  103556. /** mag = nearest and min = nearest and mip = nearest */
  103557. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  103558. /** mag = nearest and min = linear and mip = nearest */
  103559. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  103560. /** mag = nearest and min = linear and mip = linear */
  103561. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  103562. /** mag = nearest and min = linear and mip = none */
  103563. static readonly NEAREST_LINEAR: number;
  103564. /** mag = nearest and min = nearest and mip = none */
  103565. static readonly NEAREST_NEAREST: number;
  103566. /** mag = linear and min = nearest and mip = nearest */
  103567. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  103568. /** mag = linear and min = nearest and mip = linear */
  103569. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  103570. /** mag = linear and min = linear and mip = none */
  103571. static readonly LINEAR_LINEAR: number;
  103572. /** mag = linear and min = nearest and mip = none */
  103573. static readonly LINEAR_NEAREST: number;
  103574. /** Explicit coordinates mode */
  103575. static readonly EXPLICIT_MODE: number;
  103576. /** Spherical coordinates mode */
  103577. static readonly SPHERICAL_MODE: number;
  103578. /** Planar coordinates mode */
  103579. static readonly PLANAR_MODE: number;
  103580. /** Cubic coordinates mode */
  103581. static readonly CUBIC_MODE: number;
  103582. /** Projection coordinates mode */
  103583. static readonly PROJECTION_MODE: number;
  103584. /** Inverse Cubic coordinates mode */
  103585. static readonly SKYBOX_MODE: number;
  103586. /** Inverse Cubic coordinates mode */
  103587. static readonly INVCUBIC_MODE: number;
  103588. /** Equirectangular coordinates mode */
  103589. static readonly EQUIRECTANGULAR_MODE: number;
  103590. /** Equirectangular Fixed coordinates mode */
  103591. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  103592. /** Equirectangular Fixed Mirrored coordinates mode */
  103593. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103594. /** Texture is not repeating outside of 0..1 UVs */
  103595. static readonly CLAMP_ADDRESSMODE: number;
  103596. /** Texture is repeating outside of 0..1 UVs */
  103597. static readonly WRAP_ADDRESSMODE: number;
  103598. /** Texture is repeating and mirrored */
  103599. static readonly MIRROR_ADDRESSMODE: number;
  103600. /**
  103601. * 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
  103602. */
  103603. static UseSerializedUrlIfAny: boolean;
  103604. /**
  103605. * Define the url of the texture.
  103606. */
  103607. url: Nullable<string>;
  103608. /**
  103609. * Define an offset on the texture to offset the u coordinates of the UVs
  103610. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103611. */
  103612. uOffset: number;
  103613. /**
  103614. * Define an offset on the texture to offset the v coordinates of the UVs
  103615. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103616. */
  103617. vOffset: number;
  103618. /**
  103619. * Define an offset on the texture to scale the u coordinates of the UVs
  103620. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103621. */
  103622. uScale: number;
  103623. /**
  103624. * Define an offset on the texture to scale the v coordinates of the UVs
  103625. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103626. */
  103627. vScale: number;
  103628. /**
  103629. * Define an offset on the texture to rotate around the u coordinates of the UVs
  103630. * @see https://doc.babylonjs.com/how_to/more_materials
  103631. */
  103632. uAng: number;
  103633. /**
  103634. * Define an offset on the texture to rotate around the v coordinates of the UVs
  103635. * @see https://doc.babylonjs.com/how_to/more_materials
  103636. */
  103637. vAng: number;
  103638. /**
  103639. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  103640. * @see https://doc.babylonjs.com/how_to/more_materials
  103641. */
  103642. wAng: number;
  103643. /**
  103644. * Defines the center of rotation (U)
  103645. */
  103646. uRotationCenter: number;
  103647. /**
  103648. * Defines the center of rotation (V)
  103649. */
  103650. vRotationCenter: number;
  103651. /**
  103652. * Defines the center of rotation (W)
  103653. */
  103654. wRotationCenter: number;
  103655. /**
  103656. * Are mip maps generated for this texture or not.
  103657. */
  103658. get noMipmap(): boolean;
  103659. /**
  103660. * List of inspectable custom properties (used by the Inspector)
  103661. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103662. */
  103663. inspectableCustomProperties: Nullable<IInspectable[]>;
  103664. private _noMipmap;
  103665. /** @hidden */
  103666. _invertY: boolean;
  103667. private _rowGenerationMatrix;
  103668. private _cachedTextureMatrix;
  103669. private _projectionModeMatrix;
  103670. private _t0;
  103671. private _t1;
  103672. private _t2;
  103673. private _cachedUOffset;
  103674. private _cachedVOffset;
  103675. private _cachedUScale;
  103676. private _cachedVScale;
  103677. private _cachedUAng;
  103678. private _cachedVAng;
  103679. private _cachedWAng;
  103680. private _cachedProjectionMatrixId;
  103681. private _cachedCoordinatesMode;
  103682. /** @hidden */
  103683. protected _initialSamplingMode: number;
  103684. /** @hidden */
  103685. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103686. private _deleteBuffer;
  103687. protected _format: Nullable<number>;
  103688. private _delayedOnLoad;
  103689. private _delayedOnError;
  103690. private _mimeType?;
  103691. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  103692. get mimeType(): string | undefined;
  103693. /**
  103694. * Observable triggered once the texture has been loaded.
  103695. */
  103696. onLoadObservable: Observable<Texture>;
  103697. protected _isBlocking: boolean;
  103698. /**
  103699. * Is the texture preventing material to render while loading.
  103700. * If false, a default texture will be used instead of the loading one during the preparation step.
  103701. */
  103702. set isBlocking(value: boolean);
  103703. get isBlocking(): boolean;
  103704. /**
  103705. * Get the current sampling mode associated with the texture.
  103706. */
  103707. get samplingMode(): number;
  103708. /**
  103709. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  103710. */
  103711. get invertY(): boolean;
  103712. /**
  103713. * Instantiates a new texture.
  103714. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103715. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103716. * @param url defines the url of the picture to load as a texture
  103717. * @param sceneOrEngine defines the scene or engine the texture will belong to
  103718. * @param noMipmap defines if the texture will require mip maps or not
  103719. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  103720. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103721. * @param onLoad defines a callback triggered when the texture has been loaded
  103722. * @param onError defines a callback triggered when an error occurred during the loading session
  103723. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  103724. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  103725. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103726. * @param mimeType defines an optional mime type information
  103727. */
  103728. 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);
  103729. /**
  103730. * Update the url (and optional buffer) of this texture if url was null during construction.
  103731. * @param url the url of the texture
  103732. * @param buffer the buffer of the texture (defaults to null)
  103733. * @param onLoad callback called when the texture is loaded (defaults to null)
  103734. */
  103735. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  103736. /**
  103737. * Finish the loading sequence of a texture flagged as delayed load.
  103738. * @hidden
  103739. */
  103740. delayLoad(): void;
  103741. private _prepareRowForTextureGeneration;
  103742. /**
  103743. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  103744. * @returns the transform matrix of the texture.
  103745. */
  103746. getTextureMatrix(uBase?: number): Matrix;
  103747. /**
  103748. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  103749. * @returns The reflection texture transform
  103750. */
  103751. getReflectionTextureMatrix(): Matrix;
  103752. /**
  103753. * Clones the texture.
  103754. * @returns the cloned texture
  103755. */
  103756. clone(): Texture;
  103757. /**
  103758. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103759. * @returns The JSON representation of the texture
  103760. */
  103761. serialize(): any;
  103762. /**
  103763. * Get the current class name of the texture useful for serialization or dynamic coding.
  103764. * @returns "Texture"
  103765. */
  103766. getClassName(): string;
  103767. /**
  103768. * Dispose the texture and release its associated resources.
  103769. */
  103770. dispose(): void;
  103771. /**
  103772. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  103773. * @param parsedTexture Define the JSON representation of the texture
  103774. * @param scene Define the scene the parsed texture should be instantiated in
  103775. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103776. * @returns The parsed texture if successful
  103777. */
  103778. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  103779. /**
  103780. * Creates a texture from its base 64 representation.
  103781. * @param data Define the base64 payload without the data: prefix
  103782. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103783. * @param scene Define the scene the texture should belong to
  103784. * @param noMipmap Forces the texture to not create mip map information if true
  103785. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103786. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103787. * @param onLoad define a callback triggered when the texture has been loaded
  103788. * @param onError define a callback triggered when an error occurred during the loading session
  103789. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103790. * @returns the created texture
  103791. */
  103792. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103793. /**
  103794. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103795. * @param data Define the base64 payload without the data: prefix
  103796. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103797. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103798. * @param scene Define the scene the texture should belong to
  103799. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103800. * @param noMipmap Forces the texture to not create mip map information if true
  103801. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103802. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103803. * @param onLoad define a callback triggered when the texture has been loaded
  103804. * @param onError define a callback triggered when an error occurred during the loading session
  103805. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103806. * @returns the created texture
  103807. */
  103808. 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;
  103809. }
  103810. }
  103811. declare module BABYLON {
  103812. /**
  103813. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103814. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103815. */
  103816. export class PostProcessManager {
  103817. private _scene;
  103818. private _indexBuffer;
  103819. private _vertexBuffers;
  103820. /**
  103821. * Creates a new instance PostProcess
  103822. * @param scene The scene that the post process is associated with.
  103823. */
  103824. constructor(scene: Scene);
  103825. private _prepareBuffers;
  103826. private _buildIndexBuffer;
  103827. /**
  103828. * Rebuilds the vertex buffers of the manager.
  103829. * @hidden
  103830. */
  103831. _rebuild(): void;
  103832. /**
  103833. * Prepares a frame to be run through a post process.
  103834. * @param sourceTexture The input texture to the post procesess. (default: null)
  103835. * @param postProcesses An array of post processes to be run. (default: null)
  103836. * @returns True if the post processes were able to be run.
  103837. * @hidden
  103838. */
  103839. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103840. /**
  103841. * Manually render a set of post processes to a texture.
  103842. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103843. * @param postProcesses An array of post processes to be run.
  103844. * @param targetTexture The target texture to render to.
  103845. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103846. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103847. * @param lodLevel defines which lod of the texture to render to
  103848. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103849. */
  103850. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103851. /**
  103852. * Finalize the result of the output of the postprocesses.
  103853. * @param doNotPresent If true the result will not be displayed to the screen.
  103854. * @param targetTexture The target texture to render to.
  103855. * @param faceIndex The index of the face to bind the target texture to.
  103856. * @param postProcesses The array of post processes to render.
  103857. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103858. * @hidden
  103859. */
  103860. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103861. /**
  103862. * Disposes of the post process manager.
  103863. */
  103864. dispose(): void;
  103865. }
  103866. }
  103867. declare module BABYLON {
  103868. /**
  103869. * This Helps creating a texture that will be created from a camera in your scene.
  103870. * It is basically a dynamic texture that could be used to create special effects for instance.
  103871. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103872. */
  103873. export class RenderTargetTexture extends Texture {
  103874. /**
  103875. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103876. */
  103877. static readonly REFRESHRATE_RENDER_ONCE: number;
  103878. /**
  103879. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103880. */
  103881. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103882. /**
  103883. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103884. * the central point of your effect and can save a lot of performances.
  103885. */
  103886. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103887. /**
  103888. * Use this predicate to dynamically define the list of mesh you want to render.
  103889. * If set, the renderList property will be overwritten.
  103890. */
  103891. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103892. private _renderList;
  103893. /**
  103894. * Use this list to define the list of mesh you want to render.
  103895. */
  103896. get renderList(): Nullable<Array<AbstractMesh>>;
  103897. set renderList(value: Nullable<Array<AbstractMesh>>);
  103898. /**
  103899. * Use this function to overload the renderList array at rendering time.
  103900. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103901. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103902. * the cube (if the RTT is a cube, else layerOrFace=0).
  103903. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103904. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103905. * hold dummy elements!
  103906. */
  103907. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  103908. private _hookArray;
  103909. /**
  103910. * Define if particles should be rendered in your texture.
  103911. */
  103912. renderParticles: boolean;
  103913. /**
  103914. * Define if sprites should be rendered in your texture.
  103915. */
  103916. renderSprites: boolean;
  103917. /**
  103918. * Define the camera used to render the texture.
  103919. */
  103920. activeCamera: Nullable<Camera>;
  103921. /**
  103922. * Override the mesh isReady function with your own one.
  103923. */
  103924. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  103925. /**
  103926. * Override the render function of the texture with your own one.
  103927. */
  103928. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  103929. /**
  103930. * Define if camera post processes should be use while rendering the texture.
  103931. */
  103932. useCameraPostProcesses: boolean;
  103933. /**
  103934. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  103935. */
  103936. ignoreCameraViewport: boolean;
  103937. private _postProcessManager;
  103938. private _postProcesses;
  103939. private _resizeObserver;
  103940. /**
  103941. * An event triggered when the texture is unbind.
  103942. */
  103943. onBeforeBindObservable: Observable<RenderTargetTexture>;
  103944. /**
  103945. * An event triggered when the texture is unbind.
  103946. */
  103947. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  103948. private _onAfterUnbindObserver;
  103949. /**
  103950. * Set a after unbind callback in the texture.
  103951. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  103952. */
  103953. set onAfterUnbind(callback: () => void);
  103954. /**
  103955. * An event triggered before rendering the texture
  103956. */
  103957. onBeforeRenderObservable: Observable<number>;
  103958. private _onBeforeRenderObserver;
  103959. /**
  103960. * Set a before render callback in the texture.
  103961. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  103962. */
  103963. set onBeforeRender(callback: (faceIndex: number) => void);
  103964. /**
  103965. * An event triggered after rendering the texture
  103966. */
  103967. onAfterRenderObservable: Observable<number>;
  103968. private _onAfterRenderObserver;
  103969. /**
  103970. * Set a after render callback in the texture.
  103971. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  103972. */
  103973. set onAfterRender(callback: (faceIndex: number) => void);
  103974. /**
  103975. * An event triggered after the texture clear
  103976. */
  103977. onClearObservable: Observable<Engine>;
  103978. private _onClearObserver;
  103979. /**
  103980. * Set a clear callback in the texture.
  103981. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  103982. */
  103983. set onClear(callback: (Engine: Engine) => void);
  103984. /**
  103985. * An event triggered when the texture is resized.
  103986. */
  103987. onResizeObservable: Observable<RenderTargetTexture>;
  103988. /**
  103989. * Define the clear color of the Render Target if it should be different from the scene.
  103990. */
  103991. clearColor: Color4;
  103992. protected _size: number | {
  103993. width: number;
  103994. height: number;
  103995. layers?: number;
  103996. };
  103997. protected _initialSizeParameter: number | {
  103998. width: number;
  103999. height: number;
  104000. } | {
  104001. ratio: number;
  104002. };
  104003. protected _sizeRatio: Nullable<number>;
  104004. /** @hidden */
  104005. _generateMipMaps: boolean;
  104006. protected _renderingManager: RenderingManager;
  104007. /** @hidden */
  104008. _waitingRenderList?: string[];
  104009. protected _doNotChangeAspectRatio: boolean;
  104010. protected _currentRefreshId: number;
  104011. protected _refreshRate: number;
  104012. protected _textureMatrix: Matrix;
  104013. protected _samples: number;
  104014. protected _renderTargetOptions: RenderTargetCreationOptions;
  104015. /**
  104016. * Gets render target creation options that were used.
  104017. */
  104018. get renderTargetOptions(): RenderTargetCreationOptions;
  104019. protected _onRatioRescale(): void;
  104020. /**
  104021. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  104022. * It must define where the camera used to render the texture is set
  104023. */
  104024. boundingBoxPosition: Vector3;
  104025. private _boundingBoxSize;
  104026. /**
  104027. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  104028. * When defined, the cubemap will switch to local mode
  104029. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104030. * @example https://www.babylonjs-playground.com/#RNASML
  104031. */
  104032. set boundingBoxSize(value: Vector3);
  104033. get boundingBoxSize(): Vector3;
  104034. /**
  104035. * In case the RTT has been created with a depth texture, get the associated
  104036. * depth texture.
  104037. * Otherwise, return null.
  104038. */
  104039. get depthStencilTexture(): Nullable<InternalTexture>;
  104040. /**
  104041. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  104042. * or used a shadow, depth texture...
  104043. * @param name The friendly name of the texture
  104044. * @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)
  104045. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  104046. * @param generateMipMaps True if mip maps need to be generated after render.
  104047. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  104048. * @param type The type of the buffer in the RTT (int, half float, float...)
  104049. * @param isCube True if a cube texture needs to be created
  104050. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  104051. * @param generateDepthBuffer True to generate a depth buffer
  104052. * @param generateStencilBuffer True to generate a stencil buffer
  104053. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  104054. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  104055. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104056. */
  104057. constructor(name: string, size: number | {
  104058. width: number;
  104059. height: number;
  104060. layers?: number;
  104061. } | {
  104062. ratio: number;
  104063. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  104064. /**
  104065. * Creates a depth stencil texture.
  104066. * This is only available in WebGL 2 or with the depth texture extension available.
  104067. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  104068. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  104069. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  104070. */
  104071. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  104072. private _processSizeParameter;
  104073. /**
  104074. * Define the number of samples to use in case of MSAA.
  104075. * It defaults to one meaning no MSAA has been enabled.
  104076. */
  104077. get samples(): number;
  104078. set samples(value: number);
  104079. /**
  104080. * Resets the refresh counter of the texture and start bak from scratch.
  104081. * Could be useful to regenerate the texture if it is setup to render only once.
  104082. */
  104083. resetRefreshCounter(): void;
  104084. /**
  104085. * Define the refresh rate of the texture or the rendering frequency.
  104086. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  104087. */
  104088. get refreshRate(): number;
  104089. set refreshRate(value: number);
  104090. /**
  104091. * Adds a post process to the render target rendering passes.
  104092. * @param postProcess define the post process to add
  104093. */
  104094. addPostProcess(postProcess: PostProcess): void;
  104095. /**
  104096. * Clear all the post processes attached to the render target
  104097. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  104098. */
  104099. clearPostProcesses(dispose?: boolean): void;
  104100. /**
  104101. * Remove one of the post process from the list of attached post processes to the texture
  104102. * @param postProcess define the post process to remove from the list
  104103. */
  104104. removePostProcess(postProcess: PostProcess): void;
  104105. /** @hidden */
  104106. _shouldRender(): boolean;
  104107. /**
  104108. * Gets the actual render size of the texture.
  104109. * @returns the width of the render size
  104110. */
  104111. getRenderSize(): number;
  104112. /**
  104113. * Gets the actual render width of the texture.
  104114. * @returns the width of the render size
  104115. */
  104116. getRenderWidth(): number;
  104117. /**
  104118. * Gets the actual render height of the texture.
  104119. * @returns the height of the render size
  104120. */
  104121. getRenderHeight(): number;
  104122. /**
  104123. * Gets the actual number of layers of the texture.
  104124. * @returns the number of layers
  104125. */
  104126. getRenderLayers(): number;
  104127. /**
  104128. * Get if the texture can be rescaled or not.
  104129. */
  104130. get canRescale(): boolean;
  104131. /**
  104132. * Resize the texture using a ratio.
  104133. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  104134. */
  104135. scale(ratio: number): void;
  104136. /**
  104137. * Get the texture reflection matrix used to rotate/transform the reflection.
  104138. * @returns the reflection matrix
  104139. */
  104140. getReflectionTextureMatrix(): Matrix;
  104141. /**
  104142. * Resize the texture to a new desired size.
  104143. * Be carrefull as it will recreate all the data in the new texture.
  104144. * @param size Define the new size. It can be:
  104145. * - a number for squared texture,
  104146. * - an object containing { width: number, height: number }
  104147. * - or an object containing a ratio { ratio: number }
  104148. */
  104149. resize(size: number | {
  104150. width: number;
  104151. height: number;
  104152. } | {
  104153. ratio: number;
  104154. }): void;
  104155. private _defaultRenderListPrepared;
  104156. /**
  104157. * Renders all the objects from the render list into the texture.
  104158. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  104159. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  104160. */
  104161. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  104162. private _bestReflectionRenderTargetDimension;
  104163. private _prepareRenderingManager;
  104164. /**
  104165. * @hidden
  104166. * @param faceIndex face index to bind to if this is a cubetexture
  104167. * @param layer defines the index of the texture to bind in the array
  104168. */
  104169. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  104170. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104171. private renderToTarget;
  104172. /**
  104173. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  104174. * This allowed control for front to back rendering or reversly depending of the special needs.
  104175. *
  104176. * @param renderingGroupId The rendering group id corresponding to its index
  104177. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  104178. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  104179. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  104180. */
  104181. 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;
  104182. /**
  104183. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  104184. *
  104185. * @param renderingGroupId The rendering group id corresponding to its index
  104186. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104187. */
  104188. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104189. /**
  104190. * Clones the texture.
  104191. * @returns the cloned texture
  104192. */
  104193. clone(): RenderTargetTexture;
  104194. /**
  104195. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104196. * @returns The JSON representation of the texture
  104197. */
  104198. serialize(): any;
  104199. /**
  104200. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  104201. */
  104202. disposeFramebufferObjects(): void;
  104203. /**
  104204. * Dispose the texture and release its associated resources.
  104205. */
  104206. dispose(): void;
  104207. /** @hidden */
  104208. _rebuild(): void;
  104209. /**
  104210. * Clear the info related to rendering groups preventing retention point in material dispose.
  104211. */
  104212. freeRenderingGroups(): void;
  104213. /**
  104214. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  104215. * @returns the view count
  104216. */
  104217. getViewCount(): number;
  104218. }
  104219. }
  104220. declare module BABYLON {
  104221. /**
  104222. * Class used to manipulate GUIDs
  104223. */
  104224. export class GUID {
  104225. /**
  104226. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104227. * Be aware Math.random() could cause collisions, but:
  104228. * "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"
  104229. * @returns a pseudo random id
  104230. */
  104231. static RandomId(): string;
  104232. }
  104233. }
  104234. declare module BABYLON {
  104235. /**
  104236. * Options to be used when creating a shadow depth material
  104237. */
  104238. export interface IIOptionShadowDepthMaterial {
  104239. /** Variables in the vertex shader code that need to have their names remapped.
  104240. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  104241. * "var_name" should be either: worldPos or vNormalW
  104242. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  104243. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  104244. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  104245. */
  104246. remappedVariables?: string[];
  104247. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  104248. standalone?: boolean;
  104249. }
  104250. /**
  104251. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  104252. */
  104253. export class ShadowDepthWrapper {
  104254. private _scene;
  104255. private _options?;
  104256. private _baseMaterial;
  104257. private _onEffectCreatedObserver;
  104258. private _subMeshToEffect;
  104259. private _subMeshToDepthEffect;
  104260. private _meshes;
  104261. /** @hidden */
  104262. _matriceNames: any;
  104263. /** Gets the standalone status of the wrapper */
  104264. get standalone(): boolean;
  104265. /** Gets the base material the wrapper is built upon */
  104266. get baseMaterial(): Material;
  104267. /**
  104268. * Instantiate a new shadow depth wrapper.
  104269. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  104270. * generate the shadow depth map. For more information, please refer to the documentation:
  104271. * https://doc.babylonjs.com/babylon101/shadows
  104272. * @param baseMaterial Material to wrap
  104273. * @param scene Define the scene the material belongs to
  104274. * @param options Options used to create the wrapper
  104275. */
  104276. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  104277. /**
  104278. * Gets the effect to use to generate the depth map
  104279. * @param subMesh subMesh to get the effect for
  104280. * @param shadowGenerator shadow generator to get the effect for
  104281. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  104282. */
  104283. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  104284. /**
  104285. * Specifies that the submesh is ready to be used for depth rendering
  104286. * @param subMesh submesh to check
  104287. * @param defines the list of defines to take into account when checking the effect
  104288. * @param shadowGenerator combined with subMesh, it defines the effect to check
  104289. * @param useInstances specifies that instances should be used
  104290. * @returns a boolean indicating that the submesh is ready or not
  104291. */
  104292. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  104293. /**
  104294. * Disposes the resources
  104295. */
  104296. dispose(): void;
  104297. private _makeEffect;
  104298. }
  104299. }
  104300. declare module BABYLON {
  104301. interface ThinEngine {
  104302. /**
  104303. * Unbind a list of render target textures from the webGL context
  104304. * This is used only when drawBuffer extension or webGL2 are active
  104305. * @param textures defines the render target textures to unbind
  104306. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104307. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104308. */
  104309. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104310. /**
  104311. * Create a multi render target texture
  104312. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  104313. * @param size defines the size of the texture
  104314. * @param options defines the creation options
  104315. * @returns the cube texture as an InternalTexture
  104316. */
  104317. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104318. /**
  104319. * Update the sample count for a given multiple render target texture
  104320. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104321. * @param textures defines the textures to update
  104322. * @param samples defines the sample count to set
  104323. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104324. */
  104325. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104326. /**
  104327. * Select a subsets of attachments to draw to.
  104328. * @param attachments gl attachments
  104329. */
  104330. bindAttachments(attachments: number[]): void;
  104331. }
  104332. }
  104333. declare module BABYLON {
  104334. /**
  104335. * Creation options of the multi render target texture.
  104336. */
  104337. export interface IMultiRenderTargetOptions {
  104338. /**
  104339. * Define if the texture needs to create mip maps after render.
  104340. */
  104341. generateMipMaps?: boolean;
  104342. /**
  104343. * Define the types of all the draw buffers we want to create
  104344. */
  104345. types?: number[];
  104346. /**
  104347. * Define the sampling modes of all the draw buffers we want to create
  104348. */
  104349. samplingModes?: number[];
  104350. /**
  104351. * Define if a depth buffer is required
  104352. */
  104353. generateDepthBuffer?: boolean;
  104354. /**
  104355. * Define if a stencil buffer is required
  104356. */
  104357. generateStencilBuffer?: boolean;
  104358. /**
  104359. * Define if a depth texture is required instead of a depth buffer
  104360. */
  104361. generateDepthTexture?: boolean;
  104362. /**
  104363. * Define the number of desired draw buffers
  104364. */
  104365. textureCount?: number;
  104366. /**
  104367. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104368. */
  104369. doNotChangeAspectRatio?: boolean;
  104370. /**
  104371. * Define the default type of the buffers we are creating
  104372. */
  104373. defaultType?: number;
  104374. }
  104375. /**
  104376. * A multi render target, like a render target provides the ability to render to a texture.
  104377. * Unlike the render target, it can render to several draw buffers in one draw.
  104378. * This is specially interesting in deferred rendering or for any effects requiring more than
  104379. * just one color from a single pass.
  104380. */
  104381. export class MultiRenderTarget extends RenderTargetTexture {
  104382. private _internalTextures;
  104383. private _textures;
  104384. private _multiRenderTargetOptions;
  104385. private _count;
  104386. /**
  104387. * Get if draw buffers are currently supported by the used hardware and browser.
  104388. */
  104389. get isSupported(): boolean;
  104390. /**
  104391. * Get the list of textures generated by the multi render target.
  104392. */
  104393. get textures(): Texture[];
  104394. /**
  104395. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  104396. */
  104397. get count(): number;
  104398. /**
  104399. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104400. */
  104401. get depthTexture(): Texture;
  104402. /**
  104403. * Set the wrapping mode on U of all the textures we are rendering to.
  104404. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104405. */
  104406. set wrapU(wrap: number);
  104407. /**
  104408. * Set the wrapping mode on V of all the textures we are rendering to.
  104409. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104410. */
  104411. set wrapV(wrap: number);
  104412. /**
  104413. * Instantiate a new multi render target texture.
  104414. * A multi render target, like a render target provides the ability to render to a texture.
  104415. * Unlike the render target, it can render to several draw buffers in one draw.
  104416. * This is specially interesting in deferred rendering or for any effects requiring more than
  104417. * just one color from a single pass.
  104418. * @param name Define the name of the texture
  104419. * @param size Define the size of the buffers to render to
  104420. * @param count Define the number of target we are rendering into
  104421. * @param scene Define the scene the texture belongs to
  104422. * @param options Define the options used to create the multi render target
  104423. */
  104424. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104425. private _initTypes;
  104426. /** @hidden */
  104427. _rebuild(forceFullRebuild?: boolean): void;
  104428. private _createInternalTextures;
  104429. private _createTextures;
  104430. /**
  104431. * Define the number of samples used if MSAA is enabled.
  104432. */
  104433. get samples(): number;
  104434. set samples(value: number);
  104435. /**
  104436. * Resize all the textures in the multi render target.
  104437. * Be careful as it will recreate all the data in the new texture.
  104438. * @param size Define the new size
  104439. */
  104440. resize(size: any): void;
  104441. /**
  104442. * Changes the number of render targets in this MRT
  104443. * Be careful as it will recreate all the data in the new texture.
  104444. * @param count new texture count
  104445. * @param options Specifies texture types and sampling modes for new textures
  104446. */
  104447. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  104448. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104449. /**
  104450. * Dispose the render targets and their associated resources
  104451. */
  104452. dispose(): void;
  104453. /**
  104454. * Release all the underlying texture used as draw buffers.
  104455. */
  104456. releaseInternalTextures(): void;
  104457. }
  104458. }
  104459. declare module BABYLON {
  104460. /** @hidden */
  104461. export var imageProcessingPixelShader: {
  104462. name: string;
  104463. shader: string;
  104464. };
  104465. }
  104466. declare module BABYLON {
  104467. /**
  104468. * ImageProcessingPostProcess
  104469. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104470. */
  104471. export class ImageProcessingPostProcess extends PostProcess {
  104472. /**
  104473. * Default configuration related to image processing available in the PBR Material.
  104474. */
  104475. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104476. /**
  104477. * Gets the image processing configuration used either in this material.
  104478. */
  104479. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104480. /**
  104481. * Sets the Default image processing configuration used either in the this material.
  104482. *
  104483. * If sets to null, the scene one is in use.
  104484. */
  104485. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104486. /**
  104487. * Keep track of the image processing observer to allow dispose and replace.
  104488. */
  104489. private _imageProcessingObserver;
  104490. /**
  104491. * Attaches a new image processing configuration to the PBR Material.
  104492. * @param configuration
  104493. */
  104494. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104495. /**
  104496. * If the post process is supported.
  104497. */
  104498. get isSupported(): boolean;
  104499. /**
  104500. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104501. */
  104502. get colorCurves(): Nullable<ColorCurves>;
  104503. /**
  104504. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104505. */
  104506. set colorCurves(value: Nullable<ColorCurves>);
  104507. /**
  104508. * Gets wether the color curves effect is enabled.
  104509. */
  104510. get colorCurvesEnabled(): boolean;
  104511. /**
  104512. * Sets wether the color curves effect is enabled.
  104513. */
  104514. set colorCurvesEnabled(value: boolean);
  104515. /**
  104516. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104517. */
  104518. get colorGradingTexture(): Nullable<BaseTexture>;
  104519. /**
  104520. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104521. */
  104522. set colorGradingTexture(value: Nullable<BaseTexture>);
  104523. /**
  104524. * Gets wether the color grading effect is enabled.
  104525. */
  104526. get colorGradingEnabled(): boolean;
  104527. /**
  104528. * Gets wether the color grading effect is enabled.
  104529. */
  104530. set colorGradingEnabled(value: boolean);
  104531. /**
  104532. * Gets exposure used in the effect.
  104533. */
  104534. get exposure(): number;
  104535. /**
  104536. * Sets exposure used in the effect.
  104537. */
  104538. set exposure(value: number);
  104539. /**
  104540. * Gets wether tonemapping is enabled or not.
  104541. */
  104542. get toneMappingEnabled(): boolean;
  104543. /**
  104544. * Sets wether tonemapping is enabled or not
  104545. */
  104546. set toneMappingEnabled(value: boolean);
  104547. /**
  104548. * Gets the type of tone mapping effect.
  104549. */
  104550. get toneMappingType(): number;
  104551. /**
  104552. * Sets the type of tone mapping effect.
  104553. */
  104554. set toneMappingType(value: number);
  104555. /**
  104556. * Gets contrast used in the effect.
  104557. */
  104558. get contrast(): number;
  104559. /**
  104560. * Sets contrast used in the effect.
  104561. */
  104562. set contrast(value: number);
  104563. /**
  104564. * Gets Vignette stretch size.
  104565. */
  104566. get vignetteStretch(): number;
  104567. /**
  104568. * Sets Vignette stretch size.
  104569. */
  104570. set vignetteStretch(value: number);
  104571. /**
  104572. * Gets Vignette centre X Offset.
  104573. */
  104574. get vignetteCentreX(): number;
  104575. /**
  104576. * Sets Vignette centre X Offset.
  104577. */
  104578. set vignetteCentreX(value: number);
  104579. /**
  104580. * Gets Vignette centre Y Offset.
  104581. */
  104582. get vignetteCentreY(): number;
  104583. /**
  104584. * Sets Vignette centre Y Offset.
  104585. */
  104586. set vignetteCentreY(value: number);
  104587. /**
  104588. * Gets Vignette weight or intensity of the vignette effect.
  104589. */
  104590. get vignetteWeight(): number;
  104591. /**
  104592. * Sets Vignette weight or intensity of the vignette effect.
  104593. */
  104594. set vignetteWeight(value: number);
  104595. /**
  104596. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104597. * if vignetteEnabled is set to true.
  104598. */
  104599. get vignetteColor(): Color4;
  104600. /**
  104601. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104602. * if vignetteEnabled is set to true.
  104603. */
  104604. set vignetteColor(value: Color4);
  104605. /**
  104606. * Gets Camera field of view used by the Vignette effect.
  104607. */
  104608. get vignetteCameraFov(): number;
  104609. /**
  104610. * Sets Camera field of view used by the Vignette effect.
  104611. */
  104612. set vignetteCameraFov(value: number);
  104613. /**
  104614. * Gets the vignette blend mode allowing different kind of effect.
  104615. */
  104616. get vignetteBlendMode(): number;
  104617. /**
  104618. * Sets the vignette blend mode allowing different kind of effect.
  104619. */
  104620. set vignetteBlendMode(value: number);
  104621. /**
  104622. * Gets wether the vignette effect is enabled.
  104623. */
  104624. get vignetteEnabled(): boolean;
  104625. /**
  104626. * Sets wether the vignette effect is enabled.
  104627. */
  104628. set vignetteEnabled(value: boolean);
  104629. private _fromLinearSpace;
  104630. /**
  104631. * Gets wether the input of the processing is in Gamma or Linear Space.
  104632. */
  104633. get fromLinearSpace(): boolean;
  104634. /**
  104635. * Sets wether the input of the processing is in Gamma or Linear Space.
  104636. */
  104637. set fromLinearSpace(value: boolean);
  104638. /**
  104639. * Defines cache preventing GC.
  104640. */
  104641. private _defines;
  104642. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104643. /**
  104644. * "ImageProcessingPostProcess"
  104645. * @returns "ImageProcessingPostProcess"
  104646. */
  104647. getClassName(): string;
  104648. /**
  104649. * @hidden
  104650. */
  104651. _updateParameters(): void;
  104652. dispose(camera?: Camera): void;
  104653. }
  104654. }
  104655. declare module BABYLON {
  104656. /**
  104657. * Interface for defining prepass effects in the prepass post-process pipeline
  104658. */
  104659. export interface PrePassEffectConfiguration {
  104660. /**
  104661. * Name of the effect
  104662. */
  104663. name: string;
  104664. /**
  104665. * Post process to attach for this effect
  104666. */
  104667. postProcess?: PostProcess;
  104668. /**
  104669. * Textures required in the MRT
  104670. */
  104671. texturesRequired: number[];
  104672. /**
  104673. * Is the effect enabled
  104674. */
  104675. enabled: boolean;
  104676. /**
  104677. * Disposes the effect configuration
  104678. */
  104679. dispose(): void;
  104680. /**
  104681. * Creates the associated post process
  104682. */
  104683. createPostProcess?: () => PostProcess;
  104684. }
  104685. }
  104686. declare module BABYLON {
  104687. /**
  104688. * Renders a pre pass of the scene
  104689. * This means every mesh in the scene will be rendered to a render target texture
  104690. * And then this texture will be composited to the rendering canvas with post processes
  104691. * It is necessary for effects like subsurface scattering or deferred shading
  104692. */
  104693. export class PrePassRenderer {
  104694. /** @hidden */
  104695. static _SceneComponentInitialization: (scene: Scene) => void;
  104696. private _textureFormats;
  104697. private _textureIndices;
  104698. private _scene;
  104699. private _engine;
  104700. private _isDirty;
  104701. /**
  104702. * Number of textures in the multi render target texture where the scene is directly rendered
  104703. */
  104704. mrtCount: number;
  104705. /**
  104706. * The render target where the scene is directly rendered
  104707. */
  104708. prePassRT: MultiRenderTarget;
  104709. private _multiRenderAttachments;
  104710. private _defaultAttachments;
  104711. private _clearAttachments;
  104712. private _postProcesses;
  104713. private readonly _clearColor;
  104714. /**
  104715. * Image processing post process for composition
  104716. */
  104717. imageProcessingPostProcess: ImageProcessingPostProcess;
  104718. /**
  104719. * Configuration for prepass effects
  104720. */
  104721. private _effectConfigurations;
  104722. /**
  104723. * Should materials render their geometry on the MRT
  104724. */
  104725. materialsShouldRenderGeometry: boolean;
  104726. /**
  104727. * Should materials render the irradiance information on the MRT
  104728. */
  104729. materialsShouldRenderIrradiance: boolean;
  104730. private _mrtFormats;
  104731. private _mrtLayout;
  104732. private _enabled;
  104733. /**
  104734. * Indicates if the prepass is enabled
  104735. */
  104736. get enabled(): boolean;
  104737. /**
  104738. * How many samples are used for MSAA of the scene render target
  104739. */
  104740. get samples(): number;
  104741. set samples(n: number);
  104742. /**
  104743. * Instanciates a prepass renderer
  104744. * @param scene The scene
  104745. */
  104746. constructor(scene: Scene);
  104747. private _initializeAttachments;
  104748. private _createCompositionEffect;
  104749. /**
  104750. * Indicates if rendering a prepass is supported
  104751. */
  104752. get isSupported(): boolean;
  104753. /**
  104754. * Sets the proper output textures to draw in the engine.
  104755. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104756. */
  104757. bindAttachmentsForEffect(effect: Effect): void;
  104758. /**
  104759. * @hidden
  104760. */
  104761. _beforeCameraDraw(): void;
  104762. /**
  104763. * @hidden
  104764. */
  104765. _afterCameraDraw(): void;
  104766. private _checkRTSize;
  104767. private _bindFrameBuffer;
  104768. /**
  104769. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104770. */
  104771. clear(): void;
  104772. private _setState;
  104773. private _checkTextureType;
  104774. /**
  104775. * Adds an effect configuration to the prepass.
  104776. * If an effect has already been added, it won't add it twice and will return the configuration
  104777. * already present.
  104778. * @param cfg the effect configuration
  104779. * @return the effect configuration now used by the prepass
  104780. */
  104781. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  104782. /**
  104783. * Returns the index of a texture in the multi render target texture array.
  104784. * @param type Texture type
  104785. * @return The index
  104786. */
  104787. getIndex(type: number): number;
  104788. private _enable;
  104789. private _disable;
  104790. private _resetLayout;
  104791. private _resetPostProcessChain;
  104792. private _bindPostProcessChain;
  104793. /**
  104794. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104795. */
  104796. markAsDirty(): void;
  104797. /**
  104798. * Enables a texture on the MultiRenderTarget for prepass
  104799. */
  104800. private _enableTextures;
  104801. private _update;
  104802. /**
  104803. * Disposes the prepass renderer.
  104804. */
  104805. dispose(): void;
  104806. }
  104807. }
  104808. declare module BABYLON {
  104809. /**
  104810. * Options for compiling materials.
  104811. */
  104812. export interface IMaterialCompilationOptions {
  104813. /**
  104814. * Defines whether clip planes are enabled.
  104815. */
  104816. clipPlane: boolean;
  104817. /**
  104818. * Defines whether instances are enabled.
  104819. */
  104820. useInstances: boolean;
  104821. }
  104822. /**
  104823. * Options passed when calling customShaderNameResolve
  104824. */
  104825. export interface ICustomShaderNameResolveOptions {
  104826. /**
  104827. * 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
  104828. */
  104829. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104830. }
  104831. /**
  104832. * Base class for the main features of a material in Babylon.js
  104833. */
  104834. export class Material implements IAnimatable {
  104835. /**
  104836. * Returns the triangle fill mode
  104837. */
  104838. static readonly TriangleFillMode: number;
  104839. /**
  104840. * Returns the wireframe mode
  104841. */
  104842. static readonly WireFrameFillMode: number;
  104843. /**
  104844. * Returns the point fill mode
  104845. */
  104846. static readonly PointFillMode: number;
  104847. /**
  104848. * Returns the point list draw mode
  104849. */
  104850. static readonly PointListDrawMode: number;
  104851. /**
  104852. * Returns the line list draw mode
  104853. */
  104854. static readonly LineListDrawMode: number;
  104855. /**
  104856. * Returns the line loop draw mode
  104857. */
  104858. static readonly LineLoopDrawMode: number;
  104859. /**
  104860. * Returns the line strip draw mode
  104861. */
  104862. static readonly LineStripDrawMode: number;
  104863. /**
  104864. * Returns the triangle strip draw mode
  104865. */
  104866. static readonly TriangleStripDrawMode: number;
  104867. /**
  104868. * Returns the triangle fan draw mode
  104869. */
  104870. static readonly TriangleFanDrawMode: number;
  104871. /**
  104872. * Stores the clock-wise side orientation
  104873. */
  104874. static readonly ClockWiseSideOrientation: number;
  104875. /**
  104876. * Stores the counter clock-wise side orientation
  104877. */
  104878. static readonly CounterClockWiseSideOrientation: number;
  104879. /**
  104880. * The dirty texture flag value
  104881. */
  104882. static readonly TextureDirtyFlag: number;
  104883. /**
  104884. * The dirty light flag value
  104885. */
  104886. static readonly LightDirtyFlag: number;
  104887. /**
  104888. * The dirty fresnel flag value
  104889. */
  104890. static readonly FresnelDirtyFlag: number;
  104891. /**
  104892. * The dirty attribute flag value
  104893. */
  104894. static readonly AttributesDirtyFlag: number;
  104895. /**
  104896. * The dirty misc flag value
  104897. */
  104898. static readonly MiscDirtyFlag: number;
  104899. /**
  104900. * The all dirty flag value
  104901. */
  104902. static readonly AllDirtyFlag: number;
  104903. /**
  104904. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104905. */
  104906. static readonly MATERIAL_OPAQUE: number;
  104907. /**
  104908. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104909. */
  104910. static readonly MATERIAL_ALPHATEST: number;
  104911. /**
  104912. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104913. */
  104914. static readonly MATERIAL_ALPHABLEND: number;
  104915. /**
  104916. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104917. * They are also discarded below the alpha cutoff threshold to improve performances.
  104918. */
  104919. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  104920. /**
  104921. * The Whiteout method is used to blend normals.
  104922. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104923. */
  104924. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  104925. /**
  104926. * The Reoriented Normal Mapping method is used to blend normals.
  104927. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104928. */
  104929. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  104930. /**
  104931. * Custom callback helping to override the default shader used in the material.
  104932. */
  104933. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  104934. /**
  104935. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  104936. */
  104937. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  104938. /**
  104939. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  104940. * This means that the material can keep using a previous shader while a new one is being compiled.
  104941. * This is mostly used when shader parallel compilation is supported (true by default)
  104942. */
  104943. allowShaderHotSwapping: boolean;
  104944. /**
  104945. * The ID of the material
  104946. */
  104947. id: string;
  104948. /**
  104949. * Gets or sets the unique id of the material
  104950. */
  104951. uniqueId: number;
  104952. /**
  104953. * The name of the material
  104954. */
  104955. name: string;
  104956. /**
  104957. * Gets or sets user defined metadata
  104958. */
  104959. metadata: any;
  104960. /**
  104961. * For internal use only. Please do not use.
  104962. */
  104963. reservedDataStore: any;
  104964. /**
  104965. * Specifies if the ready state should be checked on each call
  104966. */
  104967. checkReadyOnEveryCall: boolean;
  104968. /**
  104969. * Specifies if the ready state should be checked once
  104970. */
  104971. checkReadyOnlyOnce: boolean;
  104972. /**
  104973. * The state of the material
  104974. */
  104975. state: string;
  104976. /**
  104977. * If the material can be rendered to several textures with MRT extension
  104978. */
  104979. get canRenderToMRT(): boolean;
  104980. /**
  104981. * The alpha value of the material
  104982. */
  104983. protected _alpha: number;
  104984. /**
  104985. * List of inspectable custom properties (used by the Inspector)
  104986. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104987. */
  104988. inspectableCustomProperties: IInspectable[];
  104989. /**
  104990. * Sets the alpha value of the material
  104991. */
  104992. set alpha(value: number);
  104993. /**
  104994. * Gets the alpha value of the material
  104995. */
  104996. get alpha(): number;
  104997. /**
  104998. * Specifies if back face culling is enabled
  104999. */
  105000. protected _backFaceCulling: boolean;
  105001. /**
  105002. * Sets the back-face culling state
  105003. */
  105004. set backFaceCulling(value: boolean);
  105005. /**
  105006. * Gets the back-face culling state
  105007. */
  105008. get backFaceCulling(): boolean;
  105009. /**
  105010. * Stores the value for side orientation
  105011. */
  105012. sideOrientation: number;
  105013. /**
  105014. * Callback triggered when the material is compiled
  105015. */
  105016. onCompiled: Nullable<(effect: Effect) => void>;
  105017. /**
  105018. * Callback triggered when an error occurs
  105019. */
  105020. onError: Nullable<(effect: Effect, errors: string) => void>;
  105021. /**
  105022. * Callback triggered to get the render target textures
  105023. */
  105024. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  105025. /**
  105026. * Gets a boolean indicating that current material needs to register RTT
  105027. */
  105028. get hasRenderTargetTextures(): boolean;
  105029. /**
  105030. * Specifies if the material should be serialized
  105031. */
  105032. doNotSerialize: boolean;
  105033. /**
  105034. * @hidden
  105035. */
  105036. _storeEffectOnSubMeshes: boolean;
  105037. /**
  105038. * Stores the animations for the material
  105039. */
  105040. animations: Nullable<Array<Animation>>;
  105041. /**
  105042. * An event triggered when the material is disposed
  105043. */
  105044. onDisposeObservable: Observable<Material>;
  105045. /**
  105046. * An observer which watches for dispose events
  105047. */
  105048. private _onDisposeObserver;
  105049. private _onUnBindObservable;
  105050. /**
  105051. * Called during a dispose event
  105052. */
  105053. set onDispose(callback: () => void);
  105054. private _onBindObservable;
  105055. /**
  105056. * An event triggered when the material is bound
  105057. */
  105058. get onBindObservable(): Observable<AbstractMesh>;
  105059. /**
  105060. * An observer which watches for bind events
  105061. */
  105062. private _onBindObserver;
  105063. /**
  105064. * Called during a bind event
  105065. */
  105066. set onBind(callback: (Mesh: AbstractMesh) => void);
  105067. /**
  105068. * An event triggered when the material is unbound
  105069. */
  105070. get onUnBindObservable(): Observable<Material>;
  105071. protected _onEffectCreatedObservable: Nullable<Observable<{
  105072. effect: Effect;
  105073. subMesh: Nullable<SubMesh>;
  105074. }>>;
  105075. /**
  105076. * An event triggered when the effect is (re)created
  105077. */
  105078. get onEffectCreatedObservable(): Observable<{
  105079. effect: Effect;
  105080. subMesh: Nullable<SubMesh>;
  105081. }>;
  105082. /**
  105083. * Stores the value of the alpha mode
  105084. */
  105085. private _alphaMode;
  105086. /**
  105087. * Sets the value of the alpha mode.
  105088. *
  105089. * | Value | Type | Description |
  105090. * | --- | --- | --- |
  105091. * | 0 | ALPHA_DISABLE | |
  105092. * | 1 | ALPHA_ADD | |
  105093. * | 2 | ALPHA_COMBINE | |
  105094. * | 3 | ALPHA_SUBTRACT | |
  105095. * | 4 | ALPHA_MULTIPLY | |
  105096. * | 5 | ALPHA_MAXIMIZED | |
  105097. * | 6 | ALPHA_ONEONE | |
  105098. * | 7 | ALPHA_PREMULTIPLIED | |
  105099. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  105100. * | 9 | ALPHA_INTERPOLATE | |
  105101. * | 10 | ALPHA_SCREENMODE | |
  105102. *
  105103. */
  105104. set alphaMode(value: number);
  105105. /**
  105106. * Gets the value of the alpha mode
  105107. */
  105108. get alphaMode(): number;
  105109. /**
  105110. * Stores the state of the need depth pre-pass value
  105111. */
  105112. private _needDepthPrePass;
  105113. /**
  105114. * Sets the need depth pre-pass value
  105115. */
  105116. set needDepthPrePass(value: boolean);
  105117. /**
  105118. * Gets the depth pre-pass value
  105119. */
  105120. get needDepthPrePass(): boolean;
  105121. /**
  105122. * Specifies if depth writing should be disabled
  105123. */
  105124. disableDepthWrite: boolean;
  105125. /**
  105126. * Specifies if color writing should be disabled
  105127. */
  105128. disableColorWrite: boolean;
  105129. /**
  105130. * Specifies if depth writing should be forced
  105131. */
  105132. forceDepthWrite: boolean;
  105133. /**
  105134. * Specifies the depth function that should be used. 0 means the default engine function
  105135. */
  105136. depthFunction: number;
  105137. /**
  105138. * Specifies if there should be a separate pass for culling
  105139. */
  105140. separateCullingPass: boolean;
  105141. /**
  105142. * Stores the state specifing if fog should be enabled
  105143. */
  105144. private _fogEnabled;
  105145. /**
  105146. * Sets the state for enabling fog
  105147. */
  105148. set fogEnabled(value: boolean);
  105149. /**
  105150. * Gets the value of the fog enabled state
  105151. */
  105152. get fogEnabled(): boolean;
  105153. /**
  105154. * Stores the size of points
  105155. */
  105156. pointSize: number;
  105157. /**
  105158. * Stores the z offset value
  105159. */
  105160. zOffset: number;
  105161. get wireframe(): boolean;
  105162. /**
  105163. * Sets the state of wireframe mode
  105164. */
  105165. set wireframe(value: boolean);
  105166. /**
  105167. * Gets the value specifying if point clouds are enabled
  105168. */
  105169. get pointsCloud(): boolean;
  105170. /**
  105171. * Sets the state of point cloud mode
  105172. */
  105173. set pointsCloud(value: boolean);
  105174. /**
  105175. * Gets the material fill mode
  105176. */
  105177. get fillMode(): number;
  105178. /**
  105179. * Sets the material fill mode
  105180. */
  105181. set fillMode(value: number);
  105182. /**
  105183. * @hidden
  105184. * Stores the effects for the material
  105185. */
  105186. _effect: Nullable<Effect>;
  105187. /**
  105188. * Specifies if uniform buffers should be used
  105189. */
  105190. private _useUBO;
  105191. /**
  105192. * Stores a reference to the scene
  105193. */
  105194. private _scene;
  105195. /**
  105196. * Stores the fill mode state
  105197. */
  105198. private _fillMode;
  105199. /**
  105200. * Specifies if the depth write state should be cached
  105201. */
  105202. private _cachedDepthWriteState;
  105203. /**
  105204. * Specifies if the color write state should be cached
  105205. */
  105206. private _cachedColorWriteState;
  105207. /**
  105208. * Specifies if the depth function state should be cached
  105209. */
  105210. private _cachedDepthFunctionState;
  105211. /**
  105212. * Stores the uniform buffer
  105213. */
  105214. protected _uniformBuffer: UniformBuffer;
  105215. /** @hidden */
  105216. _indexInSceneMaterialArray: number;
  105217. /** @hidden */
  105218. meshMap: Nullable<{
  105219. [id: string]: AbstractMesh | undefined;
  105220. }>;
  105221. /**
  105222. * Creates a material instance
  105223. * @param name defines the name of the material
  105224. * @param scene defines the scene to reference
  105225. * @param doNotAdd specifies if the material should be added to the scene
  105226. */
  105227. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  105228. /**
  105229. * Returns a string representation of the current material
  105230. * @param fullDetails defines a boolean indicating which levels of logging is desired
  105231. * @returns a string with material information
  105232. */
  105233. toString(fullDetails?: boolean): string;
  105234. /**
  105235. * Gets the class name of the material
  105236. * @returns a string with the class name of the material
  105237. */
  105238. getClassName(): string;
  105239. /**
  105240. * Specifies if updates for the material been locked
  105241. */
  105242. get isFrozen(): boolean;
  105243. /**
  105244. * Locks updates for the material
  105245. */
  105246. freeze(): void;
  105247. /**
  105248. * Unlocks updates for the material
  105249. */
  105250. unfreeze(): void;
  105251. /**
  105252. * Specifies if the material is ready to be used
  105253. * @param mesh defines the mesh to check
  105254. * @param useInstances specifies if instances should be used
  105255. * @returns a boolean indicating if the material is ready to be used
  105256. */
  105257. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105258. /**
  105259. * Specifies that the submesh is ready to be used
  105260. * @param mesh defines the mesh to check
  105261. * @param subMesh defines which submesh to check
  105262. * @param useInstances specifies that instances should be used
  105263. * @returns a boolean indicating that the submesh is ready or not
  105264. */
  105265. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105266. /**
  105267. * Returns the material effect
  105268. * @returns the effect associated with the material
  105269. */
  105270. getEffect(): Nullable<Effect>;
  105271. /**
  105272. * Returns the current scene
  105273. * @returns a Scene
  105274. */
  105275. getScene(): Scene;
  105276. /**
  105277. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105278. */
  105279. protected _forceAlphaTest: boolean;
  105280. /**
  105281. * The transparency mode of the material.
  105282. */
  105283. protected _transparencyMode: Nullable<number>;
  105284. /**
  105285. * Gets the current transparency mode.
  105286. */
  105287. get transparencyMode(): Nullable<number>;
  105288. /**
  105289. * Sets the transparency mode of the material.
  105290. *
  105291. * | Value | Type | Description |
  105292. * | ----- | ----------------------------------- | ----------- |
  105293. * | 0 | OPAQUE | |
  105294. * | 1 | ALPHATEST | |
  105295. * | 2 | ALPHABLEND | |
  105296. * | 3 | ALPHATESTANDBLEND | |
  105297. *
  105298. */
  105299. set transparencyMode(value: Nullable<number>);
  105300. /**
  105301. * Returns true if alpha blending should be disabled.
  105302. */
  105303. protected get _disableAlphaBlending(): boolean;
  105304. /**
  105305. * Specifies whether or not this material should be rendered in alpha blend mode.
  105306. * @returns a boolean specifying if alpha blending is needed
  105307. */
  105308. needAlphaBlending(): boolean;
  105309. /**
  105310. * Specifies if the mesh will require alpha blending
  105311. * @param mesh defines the mesh to check
  105312. * @returns a boolean specifying if alpha blending is needed for the mesh
  105313. */
  105314. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105315. /**
  105316. * Specifies whether or not this material should be rendered in alpha test mode.
  105317. * @returns a boolean specifying if an alpha test is needed.
  105318. */
  105319. needAlphaTesting(): boolean;
  105320. /**
  105321. * Specifies if material alpha testing should be turned on for the mesh
  105322. * @param mesh defines the mesh to check
  105323. */
  105324. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  105325. /**
  105326. * Gets the texture used for the alpha test
  105327. * @returns the texture to use for alpha testing
  105328. */
  105329. getAlphaTestTexture(): Nullable<BaseTexture>;
  105330. /**
  105331. * Marks the material to indicate that it needs to be re-calculated
  105332. */
  105333. markDirty(): void;
  105334. /** @hidden */
  105335. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  105336. /**
  105337. * Binds the material to the mesh
  105338. * @param world defines the world transformation matrix
  105339. * @param mesh defines the mesh to bind the material to
  105340. */
  105341. bind(world: Matrix, mesh?: Mesh): void;
  105342. /**
  105343. * Binds the submesh to the material
  105344. * @param world defines the world transformation matrix
  105345. * @param mesh defines the mesh containing the submesh
  105346. * @param subMesh defines the submesh to bind the material to
  105347. */
  105348. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105349. /**
  105350. * Binds the world matrix to the material
  105351. * @param world defines the world transformation matrix
  105352. */
  105353. bindOnlyWorldMatrix(world: Matrix): void;
  105354. /**
  105355. * Binds the scene's uniform buffer to the effect.
  105356. * @param effect defines the effect to bind to the scene uniform buffer
  105357. * @param sceneUbo defines the uniform buffer storing scene data
  105358. */
  105359. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  105360. /**
  105361. * Binds the view matrix to the effect
  105362. * @param effect defines the effect to bind the view matrix to
  105363. */
  105364. bindView(effect: Effect): void;
  105365. /**
  105366. * Binds the view projection matrix to the effect
  105367. * @param effect defines the effect to bind the view projection matrix to
  105368. */
  105369. bindViewProjection(effect: Effect): void;
  105370. /**
  105371. * Processes to execute after binding the material to a mesh
  105372. * @param mesh defines the rendered mesh
  105373. */
  105374. protected _afterBind(mesh?: Mesh): void;
  105375. /**
  105376. * Unbinds the material from the mesh
  105377. */
  105378. unbind(): void;
  105379. /**
  105380. * Gets the active textures from the material
  105381. * @returns an array of textures
  105382. */
  105383. getActiveTextures(): BaseTexture[];
  105384. /**
  105385. * Specifies if the material uses a texture
  105386. * @param texture defines the texture to check against the material
  105387. * @returns a boolean specifying if the material uses the texture
  105388. */
  105389. hasTexture(texture: BaseTexture): boolean;
  105390. /**
  105391. * Makes a duplicate of the material, and gives it a new name
  105392. * @param name defines the new name for the duplicated material
  105393. * @returns the cloned material
  105394. */
  105395. clone(name: string): Nullable<Material>;
  105396. /**
  105397. * Gets the meshes bound to the material
  105398. * @returns an array of meshes bound to the material
  105399. */
  105400. getBindedMeshes(): AbstractMesh[];
  105401. /**
  105402. * Force shader compilation
  105403. * @param mesh defines the mesh associated with this material
  105404. * @param onCompiled defines a function to execute once the material is compiled
  105405. * @param options defines the options to configure the compilation
  105406. * @param onError defines a function to execute if the material fails compiling
  105407. */
  105408. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  105409. /**
  105410. * Force shader compilation
  105411. * @param mesh defines the mesh that will use this material
  105412. * @param options defines additional options for compiling the shaders
  105413. * @returns a promise that resolves when the compilation completes
  105414. */
  105415. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  105416. private static readonly _AllDirtyCallBack;
  105417. private static readonly _ImageProcessingDirtyCallBack;
  105418. private static readonly _TextureDirtyCallBack;
  105419. private static readonly _FresnelDirtyCallBack;
  105420. private static readonly _MiscDirtyCallBack;
  105421. private static readonly _LightsDirtyCallBack;
  105422. private static readonly _AttributeDirtyCallBack;
  105423. private static _FresnelAndMiscDirtyCallBack;
  105424. private static _TextureAndMiscDirtyCallBack;
  105425. private static readonly _DirtyCallbackArray;
  105426. private static readonly _RunDirtyCallBacks;
  105427. /**
  105428. * Marks a define in the material to indicate that it needs to be re-computed
  105429. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  105430. */
  105431. markAsDirty(flag: number): void;
  105432. /**
  105433. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  105434. * @param func defines a function which checks material defines against the submeshes
  105435. */
  105436. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  105437. /**
  105438. * Indicates that the scene should check if the rendering now needs a prepass
  105439. */
  105440. protected _markScenePrePassDirty(): void;
  105441. /**
  105442. * Indicates that we need to re-calculated for all submeshes
  105443. */
  105444. protected _markAllSubMeshesAsAllDirty(): void;
  105445. /**
  105446. * Indicates that image processing needs to be re-calculated for all submeshes
  105447. */
  105448. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  105449. /**
  105450. * Indicates that textures need to be re-calculated for all submeshes
  105451. */
  105452. protected _markAllSubMeshesAsTexturesDirty(): void;
  105453. /**
  105454. * Indicates that fresnel needs to be re-calculated for all submeshes
  105455. */
  105456. protected _markAllSubMeshesAsFresnelDirty(): void;
  105457. /**
  105458. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  105459. */
  105460. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  105461. /**
  105462. * Indicates that lights need to be re-calculated for all submeshes
  105463. */
  105464. protected _markAllSubMeshesAsLightsDirty(): void;
  105465. /**
  105466. * Indicates that attributes need to be re-calculated for all submeshes
  105467. */
  105468. protected _markAllSubMeshesAsAttributesDirty(): void;
  105469. /**
  105470. * Indicates that misc needs to be re-calculated for all submeshes
  105471. */
  105472. protected _markAllSubMeshesAsMiscDirty(): void;
  105473. /**
  105474. * Indicates that textures and misc need to be re-calculated for all submeshes
  105475. */
  105476. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  105477. /**
  105478. * Sets the required values to the prepass renderer.
  105479. * @param prePassRenderer defines the prepass renderer to setup.
  105480. * @returns true if the pre pass is needed.
  105481. */
  105482. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  105483. /**
  105484. * Disposes the material
  105485. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105486. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105487. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  105488. */
  105489. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  105490. /** @hidden */
  105491. private releaseVertexArrayObject;
  105492. /**
  105493. * Serializes this material
  105494. * @returns the serialized material object
  105495. */
  105496. serialize(): any;
  105497. /**
  105498. * Creates a material from parsed material data
  105499. * @param parsedMaterial defines parsed material data
  105500. * @param scene defines the hosting scene
  105501. * @param rootUrl defines the root URL to use to load textures
  105502. * @returns a new material
  105503. */
  105504. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  105505. }
  105506. }
  105507. declare module BABYLON {
  105508. /**
  105509. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105510. * separate meshes. This can be use to improve performances.
  105511. * @see https://doc.babylonjs.com/how_to/multi_materials
  105512. */
  105513. export class MultiMaterial extends Material {
  105514. private _subMaterials;
  105515. /**
  105516. * Gets or Sets the list of Materials used within the multi material.
  105517. * They need to be ordered according to the submeshes order in the associated mesh
  105518. */
  105519. get subMaterials(): Nullable<Material>[];
  105520. set subMaterials(value: Nullable<Material>[]);
  105521. /**
  105522. * Function used to align with Node.getChildren()
  105523. * @returns the list of Materials used within the multi material
  105524. */
  105525. getChildren(): Nullable<Material>[];
  105526. /**
  105527. * Instantiates a new Multi Material
  105528. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105529. * separate meshes. This can be use to improve performances.
  105530. * @see https://doc.babylonjs.com/how_to/multi_materials
  105531. * @param name Define the name in the scene
  105532. * @param scene Define the scene the material belongs to
  105533. */
  105534. constructor(name: string, scene: Scene);
  105535. private _hookArray;
  105536. /**
  105537. * Get one of the submaterial by its index in the submaterials array
  105538. * @param index The index to look the sub material at
  105539. * @returns The Material if the index has been defined
  105540. */
  105541. getSubMaterial(index: number): Nullable<Material>;
  105542. /**
  105543. * Get the list of active textures for the whole sub materials list.
  105544. * @returns All the textures that will be used during the rendering
  105545. */
  105546. getActiveTextures(): BaseTexture[];
  105547. /**
  105548. * Gets the current class name of the material e.g. "MultiMaterial"
  105549. * Mainly use in serialization.
  105550. * @returns the class name
  105551. */
  105552. getClassName(): string;
  105553. /**
  105554. * Checks if the material is ready to render the requested sub mesh
  105555. * @param mesh Define the mesh the submesh belongs to
  105556. * @param subMesh Define the sub mesh to look readyness for
  105557. * @param useInstances Define whether or not the material is used with instances
  105558. * @returns true if ready, otherwise false
  105559. */
  105560. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105561. /**
  105562. * Clones the current material and its related sub materials
  105563. * @param name Define the name of the newly cloned material
  105564. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105565. * @returns the cloned material
  105566. */
  105567. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105568. /**
  105569. * Serializes the materials into a JSON representation.
  105570. * @returns the JSON representation
  105571. */
  105572. serialize(): any;
  105573. /**
  105574. * Dispose the material and release its associated resources
  105575. * @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)
  105576. * @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)
  105577. * @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)
  105578. */
  105579. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105580. /**
  105581. * Creates a MultiMaterial from parsed MultiMaterial data.
  105582. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105583. * @param scene defines the hosting scene
  105584. * @returns a new MultiMaterial
  105585. */
  105586. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105587. }
  105588. }
  105589. declare module BABYLON {
  105590. /**
  105591. * Defines a subdivision inside a mesh
  105592. */
  105593. export class SubMesh implements ICullable {
  105594. /** the material index to use */
  105595. materialIndex: number;
  105596. /** vertex index start */
  105597. verticesStart: number;
  105598. /** vertices count */
  105599. verticesCount: number;
  105600. /** index start */
  105601. indexStart: number;
  105602. /** indices count */
  105603. indexCount: number;
  105604. /** @hidden */
  105605. _materialDefines: Nullable<MaterialDefines>;
  105606. /** @hidden */
  105607. _materialEffect: Nullable<Effect>;
  105608. /** @hidden */
  105609. _effectOverride: Nullable<Effect>;
  105610. /**
  105611. * Gets material defines used by the effect associated to the sub mesh
  105612. */
  105613. get materialDefines(): Nullable<MaterialDefines>;
  105614. /**
  105615. * Sets material defines used by the effect associated to the sub mesh
  105616. */
  105617. set materialDefines(defines: Nullable<MaterialDefines>);
  105618. /**
  105619. * Gets associated effect
  105620. */
  105621. get effect(): Nullable<Effect>;
  105622. /**
  105623. * Sets associated effect (effect used to render this submesh)
  105624. * @param effect defines the effect to associate with
  105625. * @param defines defines the set of defines used to compile this effect
  105626. */
  105627. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105628. /** @hidden */
  105629. _linesIndexCount: number;
  105630. private _mesh;
  105631. private _renderingMesh;
  105632. private _boundingInfo;
  105633. private _linesIndexBuffer;
  105634. /** @hidden */
  105635. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105636. /** @hidden */
  105637. _trianglePlanes: Plane[];
  105638. /** @hidden */
  105639. _lastColliderTransformMatrix: Nullable<Matrix>;
  105640. /** @hidden */
  105641. _renderId: number;
  105642. /** @hidden */
  105643. _alphaIndex: number;
  105644. /** @hidden */
  105645. _distanceToCamera: number;
  105646. /** @hidden */
  105647. _id: number;
  105648. private _currentMaterial;
  105649. /**
  105650. * Add a new submesh to a mesh
  105651. * @param materialIndex defines the material index to use
  105652. * @param verticesStart defines vertex index start
  105653. * @param verticesCount defines vertices count
  105654. * @param indexStart defines index start
  105655. * @param indexCount defines indices count
  105656. * @param mesh defines the parent mesh
  105657. * @param renderingMesh defines an optional rendering mesh
  105658. * @param createBoundingBox defines if bounding box should be created for this submesh
  105659. * @returns the new submesh
  105660. */
  105661. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105662. /**
  105663. * Creates a new submesh
  105664. * @param materialIndex defines the material index to use
  105665. * @param verticesStart defines vertex index start
  105666. * @param verticesCount defines vertices count
  105667. * @param indexStart defines index start
  105668. * @param indexCount defines indices count
  105669. * @param mesh defines the parent mesh
  105670. * @param renderingMesh defines an optional rendering mesh
  105671. * @param createBoundingBox defines if bounding box should be created for this submesh
  105672. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105673. */
  105674. constructor(
  105675. /** the material index to use */
  105676. materialIndex: number,
  105677. /** vertex index start */
  105678. verticesStart: number,
  105679. /** vertices count */
  105680. verticesCount: number,
  105681. /** index start */
  105682. indexStart: number,
  105683. /** indices count */
  105684. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  105685. /**
  105686. * Returns true if this submesh covers the entire parent mesh
  105687. * @ignorenaming
  105688. */
  105689. get IsGlobal(): boolean;
  105690. /**
  105691. * Returns the submesh BoudingInfo object
  105692. * @returns current bounding info (or mesh's one if the submesh is global)
  105693. */
  105694. getBoundingInfo(): BoundingInfo;
  105695. /**
  105696. * Sets the submesh BoundingInfo
  105697. * @param boundingInfo defines the new bounding info to use
  105698. * @returns the SubMesh
  105699. */
  105700. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105701. /**
  105702. * Returns the mesh of the current submesh
  105703. * @return the parent mesh
  105704. */
  105705. getMesh(): AbstractMesh;
  105706. /**
  105707. * Returns the rendering mesh of the submesh
  105708. * @returns the rendering mesh (could be different from parent mesh)
  105709. */
  105710. getRenderingMesh(): Mesh;
  105711. /**
  105712. * Returns the replacement mesh of the submesh
  105713. * @returns the replacement mesh (could be different from parent mesh)
  105714. */
  105715. getReplacementMesh(): Nullable<AbstractMesh>;
  105716. /**
  105717. * Returns the effective mesh of the submesh
  105718. * @returns the effective mesh (could be different from parent mesh)
  105719. */
  105720. getEffectiveMesh(): AbstractMesh;
  105721. /**
  105722. * Returns the submesh material
  105723. * @returns null or the current material
  105724. */
  105725. getMaterial(): Nullable<Material>;
  105726. private _IsMultiMaterial;
  105727. /**
  105728. * Sets a new updated BoundingInfo object to the submesh
  105729. * @param data defines an optional position array to use to determine the bounding info
  105730. * @returns the SubMesh
  105731. */
  105732. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105733. /** @hidden */
  105734. _checkCollision(collider: Collider): boolean;
  105735. /**
  105736. * Updates the submesh BoundingInfo
  105737. * @param world defines the world matrix to use to update the bounding info
  105738. * @returns the submesh
  105739. */
  105740. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105741. /**
  105742. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105743. * @param frustumPlanes defines the frustum planes
  105744. * @returns true if the submesh is intersecting with the frustum
  105745. */
  105746. isInFrustum(frustumPlanes: Plane[]): boolean;
  105747. /**
  105748. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105749. * @param frustumPlanes defines the frustum planes
  105750. * @returns true if the submesh is inside the frustum
  105751. */
  105752. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105753. /**
  105754. * Renders the submesh
  105755. * @param enableAlphaMode defines if alpha needs to be used
  105756. * @returns the submesh
  105757. */
  105758. render(enableAlphaMode: boolean): SubMesh;
  105759. /**
  105760. * @hidden
  105761. */
  105762. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105763. /**
  105764. * Checks if the submesh intersects with a ray
  105765. * @param ray defines the ray to test
  105766. * @returns true is the passed ray intersects the submesh bounding box
  105767. */
  105768. canIntersects(ray: Ray): boolean;
  105769. /**
  105770. * Intersects current submesh with a ray
  105771. * @param ray defines the ray to test
  105772. * @param positions defines mesh's positions array
  105773. * @param indices defines mesh's indices array
  105774. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105775. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105776. * @returns intersection info or null if no intersection
  105777. */
  105778. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105779. /** @hidden */
  105780. private _intersectLines;
  105781. /** @hidden */
  105782. private _intersectUnIndexedLines;
  105783. /** @hidden */
  105784. private _intersectTriangles;
  105785. /** @hidden */
  105786. private _intersectUnIndexedTriangles;
  105787. /** @hidden */
  105788. _rebuild(): void;
  105789. /**
  105790. * Creates a new submesh from the passed mesh
  105791. * @param newMesh defines the new hosting mesh
  105792. * @param newRenderingMesh defines an optional rendering mesh
  105793. * @returns the new submesh
  105794. */
  105795. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105796. /**
  105797. * Release associated resources
  105798. */
  105799. dispose(): void;
  105800. /**
  105801. * Gets the class name
  105802. * @returns the string "SubMesh".
  105803. */
  105804. getClassName(): string;
  105805. /**
  105806. * Creates a new submesh from indices data
  105807. * @param materialIndex the index of the main mesh material
  105808. * @param startIndex the index where to start the copy in the mesh indices array
  105809. * @param indexCount the number of indices to copy then from the startIndex
  105810. * @param mesh the main mesh to create the submesh from
  105811. * @param renderingMesh the optional rendering mesh
  105812. * @returns a new submesh
  105813. */
  105814. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105815. }
  105816. }
  105817. declare module BABYLON {
  105818. /**
  105819. * Class used to represent data loading progression
  105820. */
  105821. export class SceneLoaderFlags {
  105822. private static _ForceFullSceneLoadingForIncremental;
  105823. private static _ShowLoadingScreen;
  105824. private static _CleanBoneMatrixWeights;
  105825. private static _loggingLevel;
  105826. /**
  105827. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105828. */
  105829. static get ForceFullSceneLoadingForIncremental(): boolean;
  105830. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105831. /**
  105832. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105833. */
  105834. static get ShowLoadingScreen(): boolean;
  105835. static set ShowLoadingScreen(value: boolean);
  105836. /**
  105837. * Defines the current logging level (while loading the scene)
  105838. * @ignorenaming
  105839. */
  105840. static get loggingLevel(): number;
  105841. static set loggingLevel(value: number);
  105842. /**
  105843. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105844. */
  105845. static get CleanBoneMatrixWeights(): boolean;
  105846. static set CleanBoneMatrixWeights(value: boolean);
  105847. }
  105848. }
  105849. declare module BABYLON {
  105850. /**
  105851. * Class used to store geometry data (vertex buffers + index buffer)
  105852. */
  105853. export class Geometry implements IGetSetVerticesData {
  105854. /**
  105855. * Gets or sets the ID of the geometry
  105856. */
  105857. id: string;
  105858. /**
  105859. * Gets or sets the unique ID of the geometry
  105860. */
  105861. uniqueId: number;
  105862. /**
  105863. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105864. */
  105865. delayLoadState: number;
  105866. /**
  105867. * Gets the file containing the data to load when running in delay load state
  105868. */
  105869. delayLoadingFile: Nullable<string>;
  105870. /**
  105871. * Callback called when the geometry is updated
  105872. */
  105873. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105874. private _scene;
  105875. private _engine;
  105876. private _meshes;
  105877. private _totalVertices;
  105878. /** @hidden */
  105879. _indices: IndicesArray;
  105880. /** @hidden */
  105881. _vertexBuffers: {
  105882. [key: string]: VertexBuffer;
  105883. };
  105884. private _isDisposed;
  105885. private _extend;
  105886. private _boundingBias;
  105887. /** @hidden */
  105888. _delayInfo: Array<string>;
  105889. private _indexBuffer;
  105890. private _indexBufferIsUpdatable;
  105891. /** @hidden */
  105892. _boundingInfo: Nullable<BoundingInfo>;
  105893. /** @hidden */
  105894. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105895. /** @hidden */
  105896. _softwareSkinningFrameId: number;
  105897. private _vertexArrayObjects;
  105898. private _updatable;
  105899. /** @hidden */
  105900. _positions: Nullable<Vector3[]>;
  105901. /**
  105902. * 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
  105903. */
  105904. get boundingBias(): Vector2;
  105905. /**
  105906. * 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
  105907. */
  105908. set boundingBias(value: Vector2);
  105909. /**
  105910. * Static function used to attach a new empty geometry to a mesh
  105911. * @param mesh defines the mesh to attach the geometry to
  105912. * @returns the new Geometry
  105913. */
  105914. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  105915. /** Get the list of meshes using this geometry */
  105916. get meshes(): Mesh[];
  105917. /**
  105918. * 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
  105919. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  105920. */
  105921. useBoundingInfoFromGeometry: boolean;
  105922. /**
  105923. * Creates a new geometry
  105924. * @param id defines the unique ID
  105925. * @param scene defines the hosting scene
  105926. * @param vertexData defines the VertexData used to get geometry data
  105927. * @param updatable defines if geometry must be updatable (false by default)
  105928. * @param mesh defines the mesh that will be associated with the geometry
  105929. */
  105930. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  105931. /**
  105932. * Gets the current extend of the geometry
  105933. */
  105934. get extend(): {
  105935. minimum: Vector3;
  105936. maximum: Vector3;
  105937. };
  105938. /**
  105939. * Gets the hosting scene
  105940. * @returns the hosting Scene
  105941. */
  105942. getScene(): Scene;
  105943. /**
  105944. * Gets the hosting engine
  105945. * @returns the hosting Engine
  105946. */
  105947. getEngine(): Engine;
  105948. /**
  105949. * Defines if the geometry is ready to use
  105950. * @returns true if the geometry is ready to be used
  105951. */
  105952. isReady(): boolean;
  105953. /**
  105954. * Gets a value indicating that the geometry should not be serialized
  105955. */
  105956. get doNotSerialize(): boolean;
  105957. /** @hidden */
  105958. _rebuild(): void;
  105959. /**
  105960. * Affects all geometry data in one call
  105961. * @param vertexData defines the geometry data
  105962. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  105963. */
  105964. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  105965. /**
  105966. * Set specific vertex data
  105967. * @param kind defines the data kind (Position, normal, etc...)
  105968. * @param data defines the vertex data to use
  105969. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105970. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105971. */
  105972. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  105973. /**
  105974. * Removes a specific vertex data
  105975. * @param kind defines the data kind (Position, normal, etc...)
  105976. */
  105977. removeVerticesData(kind: string): void;
  105978. /**
  105979. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  105980. * @param buffer defines the vertex buffer to use
  105981. * @param totalVertices defines the total number of vertices for position kind (could be null)
  105982. */
  105983. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  105984. /**
  105985. * Update a specific vertex buffer
  105986. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  105987. * It will do nothing if the buffer is not updatable
  105988. * @param kind defines the data kind (Position, normal, etc...)
  105989. * @param data defines the data to use
  105990. * @param offset defines the offset in the target buffer where to store the data
  105991. * @param useBytes set to true if the offset is in bytes
  105992. */
  105993. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  105994. /**
  105995. * Update a specific vertex buffer
  105996. * This function will create a new buffer if the current one is not updatable
  105997. * @param kind defines the data kind (Position, normal, etc...)
  105998. * @param data defines the data to use
  105999. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  106000. */
  106001. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  106002. private _updateBoundingInfo;
  106003. /** @hidden */
  106004. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  106005. /**
  106006. * Gets total number of vertices
  106007. * @returns the total number of vertices
  106008. */
  106009. getTotalVertices(): number;
  106010. /**
  106011. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106012. * @param kind defines the data kind (Position, normal, etc...)
  106013. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106014. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106015. * @returns a float array containing vertex data
  106016. */
  106017. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106018. /**
  106019. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  106020. * @param kind defines the data kind (Position, normal, etc...)
  106021. * @returns true if the vertex buffer with the specified kind is updatable
  106022. */
  106023. isVertexBufferUpdatable(kind: string): boolean;
  106024. /**
  106025. * Gets a specific vertex buffer
  106026. * @param kind defines the data kind (Position, normal, etc...)
  106027. * @returns a VertexBuffer
  106028. */
  106029. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  106030. /**
  106031. * Returns all vertex buffers
  106032. * @return an object holding all vertex buffers indexed by kind
  106033. */
  106034. getVertexBuffers(): Nullable<{
  106035. [key: string]: VertexBuffer;
  106036. }>;
  106037. /**
  106038. * Gets a boolean indicating if specific vertex buffer is present
  106039. * @param kind defines the data kind (Position, normal, etc...)
  106040. * @returns true if data is present
  106041. */
  106042. isVerticesDataPresent(kind: string): boolean;
  106043. /**
  106044. * Gets a list of all attached data kinds (Position, normal, etc...)
  106045. * @returns a list of string containing all kinds
  106046. */
  106047. getVerticesDataKinds(): string[];
  106048. /**
  106049. * Update index buffer
  106050. * @param indices defines the indices to store in the index buffer
  106051. * @param offset defines the offset in the target buffer where to store the data
  106052. * @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)
  106053. */
  106054. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  106055. /**
  106056. * Creates a new index buffer
  106057. * @param indices defines the indices to store in the index buffer
  106058. * @param totalVertices defines the total number of vertices (could be null)
  106059. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106060. */
  106061. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  106062. /**
  106063. * Return the total number of indices
  106064. * @returns the total number of indices
  106065. */
  106066. getTotalIndices(): number;
  106067. /**
  106068. * Gets the index buffer array
  106069. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106070. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106071. * @returns the index buffer array
  106072. */
  106073. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106074. /**
  106075. * Gets the index buffer
  106076. * @return the index buffer
  106077. */
  106078. getIndexBuffer(): Nullable<DataBuffer>;
  106079. /** @hidden */
  106080. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  106081. /**
  106082. * Release the associated resources for a specific mesh
  106083. * @param mesh defines the source mesh
  106084. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  106085. */
  106086. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  106087. /**
  106088. * Apply current geometry to a given mesh
  106089. * @param mesh defines the mesh to apply geometry to
  106090. */
  106091. applyToMesh(mesh: Mesh): void;
  106092. private _updateExtend;
  106093. private _applyToMesh;
  106094. private notifyUpdate;
  106095. /**
  106096. * Load the geometry if it was flagged as delay loaded
  106097. * @param scene defines the hosting scene
  106098. * @param onLoaded defines a callback called when the geometry is loaded
  106099. */
  106100. load(scene: Scene, onLoaded?: () => void): void;
  106101. private _queueLoad;
  106102. /**
  106103. * Invert the geometry to move from a right handed system to a left handed one.
  106104. */
  106105. toLeftHanded(): void;
  106106. /** @hidden */
  106107. _resetPointsArrayCache(): void;
  106108. /** @hidden */
  106109. _generatePointsArray(): boolean;
  106110. /**
  106111. * Gets a value indicating if the geometry is disposed
  106112. * @returns true if the geometry was disposed
  106113. */
  106114. isDisposed(): boolean;
  106115. private _disposeVertexArrayObjects;
  106116. /**
  106117. * Free all associated resources
  106118. */
  106119. dispose(): void;
  106120. /**
  106121. * Clone the current geometry into a new geometry
  106122. * @param id defines the unique ID of the new geometry
  106123. * @returns a new geometry object
  106124. */
  106125. copy(id: string): Geometry;
  106126. /**
  106127. * Serialize the current geometry info (and not the vertices data) into a JSON object
  106128. * @return a JSON representation of the current geometry data (without the vertices data)
  106129. */
  106130. serialize(): any;
  106131. private toNumberArray;
  106132. /**
  106133. * Serialize all vertices data into a JSON oject
  106134. * @returns a JSON representation of the current geometry data
  106135. */
  106136. serializeVerticeData(): any;
  106137. /**
  106138. * Extracts a clone of a mesh geometry
  106139. * @param mesh defines the source mesh
  106140. * @param id defines the unique ID of the new geometry object
  106141. * @returns the new geometry object
  106142. */
  106143. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  106144. /**
  106145. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  106146. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106147. * Be aware Math.random() could cause collisions, but:
  106148. * "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"
  106149. * @returns a string containing a new GUID
  106150. */
  106151. static RandomId(): string;
  106152. /** @hidden */
  106153. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  106154. private static _CleanMatricesWeights;
  106155. /**
  106156. * Create a new geometry from persisted data (Using .babylon file format)
  106157. * @param parsedVertexData defines the persisted data
  106158. * @param scene defines the hosting scene
  106159. * @param rootUrl defines the root url to use to load assets (like delayed data)
  106160. * @returns the new geometry object
  106161. */
  106162. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  106163. }
  106164. }
  106165. declare module BABYLON {
  106166. /**
  106167. * Define an interface for all classes that will get and set the data on vertices
  106168. */
  106169. export interface IGetSetVerticesData {
  106170. /**
  106171. * Gets a boolean indicating if specific vertex data is present
  106172. * @param kind defines the vertex data kind to use
  106173. * @returns true is data kind is present
  106174. */
  106175. isVerticesDataPresent(kind: string): boolean;
  106176. /**
  106177. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106178. * @param kind defines the data kind (Position, normal, etc...)
  106179. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106180. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106181. * @returns a float array containing vertex data
  106182. */
  106183. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106184. /**
  106185. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  106186. * @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.
  106187. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106188. * @returns the indices array or an empty array if the mesh has no geometry
  106189. */
  106190. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106191. /**
  106192. * Set specific vertex data
  106193. * @param kind defines the data kind (Position, normal, etc...)
  106194. * @param data defines the vertex data to use
  106195. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106196. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106197. */
  106198. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  106199. /**
  106200. * Update a specific associated vertex buffer
  106201. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106202. * - VertexBuffer.PositionKind
  106203. * - VertexBuffer.UVKind
  106204. * - VertexBuffer.UV2Kind
  106205. * - VertexBuffer.UV3Kind
  106206. * - VertexBuffer.UV4Kind
  106207. * - VertexBuffer.UV5Kind
  106208. * - VertexBuffer.UV6Kind
  106209. * - VertexBuffer.ColorKind
  106210. * - VertexBuffer.MatricesIndicesKind
  106211. * - VertexBuffer.MatricesIndicesExtraKind
  106212. * - VertexBuffer.MatricesWeightsKind
  106213. * - VertexBuffer.MatricesWeightsExtraKind
  106214. * @param data defines the data source
  106215. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  106216. * @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)
  106217. */
  106218. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  106219. /**
  106220. * Creates a new index buffer
  106221. * @param indices defines the indices to store in the index buffer
  106222. * @param totalVertices defines the total number of vertices (could be null)
  106223. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106224. */
  106225. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  106226. }
  106227. /**
  106228. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  106229. */
  106230. export class VertexData {
  106231. /**
  106232. * Mesh side orientation : usually the external or front surface
  106233. */
  106234. static readonly FRONTSIDE: number;
  106235. /**
  106236. * Mesh side orientation : usually the internal or back surface
  106237. */
  106238. static readonly BACKSIDE: number;
  106239. /**
  106240. * Mesh side orientation : both internal and external or front and back surfaces
  106241. */
  106242. static readonly DOUBLESIDE: number;
  106243. /**
  106244. * Mesh side orientation : by default, `FRONTSIDE`
  106245. */
  106246. static readonly DEFAULTSIDE: number;
  106247. /**
  106248. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  106249. */
  106250. positions: Nullable<FloatArray>;
  106251. /**
  106252. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  106253. */
  106254. normals: Nullable<FloatArray>;
  106255. /**
  106256. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  106257. */
  106258. tangents: Nullable<FloatArray>;
  106259. /**
  106260. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106261. */
  106262. uvs: Nullable<FloatArray>;
  106263. /**
  106264. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106265. */
  106266. uvs2: Nullable<FloatArray>;
  106267. /**
  106268. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106269. */
  106270. uvs3: Nullable<FloatArray>;
  106271. /**
  106272. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106273. */
  106274. uvs4: Nullable<FloatArray>;
  106275. /**
  106276. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106277. */
  106278. uvs5: Nullable<FloatArray>;
  106279. /**
  106280. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106281. */
  106282. uvs6: Nullable<FloatArray>;
  106283. /**
  106284. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  106285. */
  106286. colors: Nullable<FloatArray>;
  106287. /**
  106288. * 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).
  106289. */
  106290. matricesIndices: Nullable<FloatArray>;
  106291. /**
  106292. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  106293. */
  106294. matricesWeights: Nullable<FloatArray>;
  106295. /**
  106296. * An array extending the number of possible indices
  106297. */
  106298. matricesIndicesExtra: Nullable<FloatArray>;
  106299. /**
  106300. * An array extending the number of possible weights when the number of indices is extended
  106301. */
  106302. matricesWeightsExtra: Nullable<FloatArray>;
  106303. /**
  106304. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  106305. */
  106306. indices: Nullable<IndicesArray>;
  106307. /**
  106308. * Uses the passed data array to set the set the values for the specified kind of data
  106309. * @param data a linear array of floating numbers
  106310. * @param kind the type of data that is being set, eg positions, colors etc
  106311. */
  106312. set(data: FloatArray, kind: string): void;
  106313. /**
  106314. * Associates the vertexData to the passed Mesh.
  106315. * Sets it as updatable or not (default `false`)
  106316. * @param mesh the mesh the vertexData is applied to
  106317. * @param updatable when used and having the value true allows new data to update the vertexData
  106318. * @returns the VertexData
  106319. */
  106320. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  106321. /**
  106322. * Associates the vertexData to the passed Geometry.
  106323. * Sets it as updatable or not (default `false`)
  106324. * @param geometry the geometry the vertexData is applied to
  106325. * @param updatable when used and having the value true allows new data to update the vertexData
  106326. * @returns VertexData
  106327. */
  106328. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  106329. /**
  106330. * Updates the associated mesh
  106331. * @param mesh the mesh to be updated
  106332. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106333. * @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
  106334. * @returns VertexData
  106335. */
  106336. updateMesh(mesh: Mesh): VertexData;
  106337. /**
  106338. * Updates the associated geometry
  106339. * @param geometry the geometry to be updated
  106340. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106341. * @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
  106342. * @returns VertexData.
  106343. */
  106344. updateGeometry(geometry: Geometry): VertexData;
  106345. private _applyTo;
  106346. private _update;
  106347. /**
  106348. * Transforms each position and each normal of the vertexData according to the passed Matrix
  106349. * @param matrix the transforming matrix
  106350. * @returns the VertexData
  106351. */
  106352. transform(matrix: Matrix): VertexData;
  106353. /**
  106354. * Merges the passed VertexData into the current one
  106355. * @param other the VertexData to be merged into the current one
  106356. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  106357. * @returns the modified VertexData
  106358. */
  106359. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  106360. private _mergeElement;
  106361. private _validate;
  106362. /**
  106363. * Serializes the VertexData
  106364. * @returns a serialized object
  106365. */
  106366. serialize(): any;
  106367. /**
  106368. * Extracts the vertexData from a mesh
  106369. * @param mesh the mesh from which to extract the VertexData
  106370. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  106371. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106372. * @returns the object VertexData associated to the passed mesh
  106373. */
  106374. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106375. /**
  106376. * Extracts the vertexData from the geometry
  106377. * @param geometry the geometry from which to extract the VertexData
  106378. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  106379. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106380. * @returns the object VertexData associated to the passed mesh
  106381. */
  106382. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106383. private static _ExtractFrom;
  106384. /**
  106385. * Creates the VertexData for a Ribbon
  106386. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  106387. * * pathArray array of paths, each of which an array of successive Vector3
  106388. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  106389. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  106390. * * 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
  106391. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106392. * * 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)
  106393. * * 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)
  106394. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  106395. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  106396. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  106397. * @returns the VertexData of the ribbon
  106398. */
  106399. static CreateRibbon(options: {
  106400. pathArray: Vector3[][];
  106401. closeArray?: boolean;
  106402. closePath?: boolean;
  106403. offset?: number;
  106404. sideOrientation?: number;
  106405. frontUVs?: Vector4;
  106406. backUVs?: Vector4;
  106407. invertUV?: boolean;
  106408. uvs?: Vector2[];
  106409. colors?: Color4[];
  106410. }): VertexData;
  106411. /**
  106412. * Creates the VertexData for a box
  106413. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106414. * * size sets the width, height and depth of the box to the value of size, optional default 1
  106415. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  106416. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  106417. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  106418. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106419. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106421. * * 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)
  106422. * * 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)
  106423. * @returns the VertexData of the box
  106424. */
  106425. static CreateBox(options: {
  106426. size?: number;
  106427. width?: number;
  106428. height?: number;
  106429. depth?: number;
  106430. faceUV?: Vector4[];
  106431. faceColors?: Color4[];
  106432. sideOrientation?: number;
  106433. frontUVs?: Vector4;
  106434. backUVs?: Vector4;
  106435. }): VertexData;
  106436. /**
  106437. * Creates the VertexData for a tiled box
  106438. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106439. * * faceTiles sets the pattern, tile size and number of tiles for a face
  106440. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106441. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106442. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106443. * @returns the VertexData of the box
  106444. */
  106445. static CreateTiledBox(options: {
  106446. pattern?: number;
  106447. width?: number;
  106448. height?: number;
  106449. depth?: number;
  106450. tileSize?: number;
  106451. tileWidth?: number;
  106452. tileHeight?: number;
  106453. alignHorizontal?: number;
  106454. alignVertical?: number;
  106455. faceUV?: Vector4[];
  106456. faceColors?: Color4[];
  106457. sideOrientation?: number;
  106458. }): VertexData;
  106459. /**
  106460. * Creates the VertexData for a tiled plane
  106461. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106462. * * pattern a limited pattern arrangement depending on the number
  106463. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  106464. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  106465. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  106466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106467. * * 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)
  106468. * * 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)
  106469. * @returns the VertexData of the tiled plane
  106470. */
  106471. static CreateTiledPlane(options: {
  106472. pattern?: number;
  106473. tileSize?: number;
  106474. tileWidth?: number;
  106475. tileHeight?: number;
  106476. size?: number;
  106477. width?: number;
  106478. height?: number;
  106479. alignHorizontal?: number;
  106480. alignVertical?: number;
  106481. sideOrientation?: number;
  106482. frontUVs?: Vector4;
  106483. backUVs?: Vector4;
  106484. }): VertexData;
  106485. /**
  106486. * Creates the VertexData for an ellipsoid, defaults to a sphere
  106487. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106488. * * segments sets the number of horizontal strips optional, default 32
  106489. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  106490. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  106491. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  106492. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  106493. * * 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
  106494. * * 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
  106495. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106496. * * 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)
  106497. * * 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)
  106498. * @returns the VertexData of the ellipsoid
  106499. */
  106500. static CreateSphere(options: {
  106501. segments?: number;
  106502. diameter?: number;
  106503. diameterX?: number;
  106504. diameterY?: number;
  106505. diameterZ?: number;
  106506. arc?: number;
  106507. slice?: number;
  106508. sideOrientation?: number;
  106509. frontUVs?: Vector4;
  106510. backUVs?: Vector4;
  106511. }): VertexData;
  106512. /**
  106513. * Creates the VertexData for a cylinder, cone or prism
  106514. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106515. * * height sets the height (y direction) of the cylinder, optional, default 2
  106516. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106517. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106518. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106519. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106520. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106521. * * 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
  106522. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106523. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106524. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106525. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106526. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106527. * * 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)
  106528. * * 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)
  106529. * @returns the VertexData of the cylinder, cone or prism
  106530. */
  106531. static CreateCylinder(options: {
  106532. height?: number;
  106533. diameterTop?: number;
  106534. diameterBottom?: number;
  106535. diameter?: number;
  106536. tessellation?: number;
  106537. subdivisions?: number;
  106538. arc?: number;
  106539. faceColors?: Color4[];
  106540. faceUV?: Vector4[];
  106541. hasRings?: boolean;
  106542. enclose?: boolean;
  106543. sideOrientation?: number;
  106544. frontUVs?: Vector4;
  106545. backUVs?: Vector4;
  106546. }): VertexData;
  106547. /**
  106548. * Creates the VertexData for a torus
  106549. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106550. * * diameter the diameter of the torus, optional default 1
  106551. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106552. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106553. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106554. * * 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)
  106555. * * 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)
  106556. * @returns the VertexData of the torus
  106557. */
  106558. static CreateTorus(options: {
  106559. diameter?: number;
  106560. thickness?: number;
  106561. tessellation?: number;
  106562. sideOrientation?: number;
  106563. frontUVs?: Vector4;
  106564. backUVs?: Vector4;
  106565. }): VertexData;
  106566. /**
  106567. * Creates the VertexData of the LineSystem
  106568. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106569. * - lines an array of lines, each line being an array of successive Vector3
  106570. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106571. * @returns the VertexData of the LineSystem
  106572. */
  106573. static CreateLineSystem(options: {
  106574. lines: Vector3[][];
  106575. colors?: Nullable<Color4[][]>;
  106576. }): VertexData;
  106577. /**
  106578. * Create the VertexData for a DashedLines
  106579. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106580. * - points an array successive Vector3
  106581. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106582. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106583. * - dashNb the intended total number of dashes, optional, default 200
  106584. * @returns the VertexData for the DashedLines
  106585. */
  106586. static CreateDashedLines(options: {
  106587. points: Vector3[];
  106588. dashSize?: number;
  106589. gapSize?: number;
  106590. dashNb?: number;
  106591. }): VertexData;
  106592. /**
  106593. * Creates the VertexData for a Ground
  106594. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106595. * - width the width (x direction) of the ground, optional, default 1
  106596. * - height the height (z direction) of the ground, optional, default 1
  106597. * - subdivisions the number of subdivisions per side, optional, default 1
  106598. * @returns the VertexData of the Ground
  106599. */
  106600. static CreateGround(options: {
  106601. width?: number;
  106602. height?: number;
  106603. subdivisions?: number;
  106604. subdivisionsX?: number;
  106605. subdivisionsY?: number;
  106606. }): VertexData;
  106607. /**
  106608. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106609. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106610. * * xmin the ground minimum X coordinate, optional, default -1
  106611. * * zmin the ground minimum Z coordinate, optional, default -1
  106612. * * xmax the ground maximum X coordinate, optional, default 1
  106613. * * zmax the ground maximum Z coordinate, optional, default 1
  106614. * * 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}
  106615. * * 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}
  106616. * @returns the VertexData of the TiledGround
  106617. */
  106618. static CreateTiledGround(options: {
  106619. xmin: number;
  106620. zmin: number;
  106621. xmax: number;
  106622. zmax: number;
  106623. subdivisions?: {
  106624. w: number;
  106625. h: number;
  106626. };
  106627. precision?: {
  106628. w: number;
  106629. h: number;
  106630. };
  106631. }): VertexData;
  106632. /**
  106633. * Creates the VertexData of the Ground designed from a heightmap
  106634. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106635. * * width the width (x direction) of the ground
  106636. * * height the height (z direction) of the ground
  106637. * * subdivisions the number of subdivisions per side
  106638. * * minHeight the minimum altitude on the ground, optional, default 0
  106639. * * maxHeight the maximum altitude on the ground, optional default 1
  106640. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106641. * * buffer the array holding the image color data
  106642. * * bufferWidth the width of image
  106643. * * bufferHeight the height of image
  106644. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106645. * @returns the VertexData of the Ground designed from a heightmap
  106646. */
  106647. static CreateGroundFromHeightMap(options: {
  106648. width: number;
  106649. height: number;
  106650. subdivisions: number;
  106651. minHeight: number;
  106652. maxHeight: number;
  106653. colorFilter: Color3;
  106654. buffer: Uint8Array;
  106655. bufferWidth: number;
  106656. bufferHeight: number;
  106657. alphaFilter: number;
  106658. }): VertexData;
  106659. /**
  106660. * Creates the VertexData for a Plane
  106661. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106662. * * size sets the width and height of the plane to the value of size, optional default 1
  106663. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106664. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106665. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106666. * * 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)
  106667. * * 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)
  106668. * @returns the VertexData of the box
  106669. */
  106670. static CreatePlane(options: {
  106671. size?: number;
  106672. width?: number;
  106673. height?: number;
  106674. sideOrientation?: number;
  106675. frontUVs?: Vector4;
  106676. backUVs?: Vector4;
  106677. }): VertexData;
  106678. /**
  106679. * Creates the VertexData of the Disc or regular Polygon
  106680. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  106681. * * radius the radius of the disc, optional default 0.5
  106682. * * tessellation the number of polygon sides, optional, default 64
  106683. * * 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
  106684. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106685. * * 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)
  106686. * * 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)
  106687. * @returns the VertexData of the box
  106688. */
  106689. static CreateDisc(options: {
  106690. radius?: number;
  106691. tessellation?: number;
  106692. arc?: number;
  106693. sideOrientation?: number;
  106694. frontUVs?: Vector4;
  106695. backUVs?: Vector4;
  106696. }): VertexData;
  106697. /**
  106698. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106699. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106700. * @param polygon a mesh built from polygonTriangulation.build()
  106701. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106702. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106703. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106704. * @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)
  106705. * @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)
  106706. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106707. * @returns the VertexData of the Polygon
  106708. */
  106709. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106710. /**
  106711. * Creates the VertexData of the IcoSphere
  106712. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106713. * * radius the radius of the IcoSphere, optional default 1
  106714. * * radiusX allows stretching in the x direction, optional, default radius
  106715. * * radiusY allows stretching in the y direction, optional, default radius
  106716. * * radiusZ allows stretching in the z direction, optional, default radius
  106717. * * flat when true creates a flat shaded mesh, optional, default true
  106718. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106720. * * 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)
  106721. * * 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)
  106722. * @returns the VertexData of the IcoSphere
  106723. */
  106724. static CreateIcoSphere(options: {
  106725. radius?: number;
  106726. radiusX?: number;
  106727. radiusY?: number;
  106728. radiusZ?: number;
  106729. flat?: boolean;
  106730. subdivisions?: number;
  106731. sideOrientation?: number;
  106732. frontUVs?: Vector4;
  106733. backUVs?: Vector4;
  106734. }): VertexData;
  106735. /**
  106736. * Creates the VertexData for a Polyhedron
  106737. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106738. * * type provided types are:
  106739. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106740. * * 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)
  106741. * * size the size of the IcoSphere, optional default 1
  106742. * * sizeX allows stretching in the x direction, optional, default size
  106743. * * sizeY allows stretching in the y direction, optional, default size
  106744. * * sizeZ allows stretching in the z direction, optional, default size
  106745. * * 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
  106746. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106747. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106748. * * flat when true creates a flat shaded mesh, optional, default true
  106749. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106750. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106751. * * 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)
  106752. * * 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)
  106753. * @returns the VertexData of the Polyhedron
  106754. */
  106755. static CreatePolyhedron(options: {
  106756. type?: number;
  106757. size?: number;
  106758. sizeX?: number;
  106759. sizeY?: number;
  106760. sizeZ?: number;
  106761. custom?: any;
  106762. faceUV?: Vector4[];
  106763. faceColors?: Color4[];
  106764. flat?: boolean;
  106765. sideOrientation?: number;
  106766. frontUVs?: Vector4;
  106767. backUVs?: Vector4;
  106768. }): VertexData;
  106769. /**
  106770. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  106771. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  106772. * @returns the VertexData of the Capsule
  106773. */
  106774. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  106775. /**
  106776. * Creates the VertexData for a TorusKnot
  106777. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106778. * * radius the radius of the torus knot, optional, default 2
  106779. * * tube the thickness of the tube, optional, default 0.5
  106780. * * radialSegments the number of sides on each tube segments, optional, default 32
  106781. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106782. * * p the number of windings around the z axis, optional, default 2
  106783. * * q the number of windings around the x axis, optional, default 3
  106784. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106785. * * 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)
  106786. * * 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)
  106787. * @returns the VertexData of the Torus Knot
  106788. */
  106789. static CreateTorusKnot(options: {
  106790. radius?: number;
  106791. tube?: number;
  106792. radialSegments?: number;
  106793. tubularSegments?: number;
  106794. p?: number;
  106795. q?: number;
  106796. sideOrientation?: number;
  106797. frontUVs?: Vector4;
  106798. backUVs?: Vector4;
  106799. }): VertexData;
  106800. /**
  106801. * Compute normals for given positions and indices
  106802. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106803. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106804. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106805. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106806. * * facetNormals : optional array of facet normals (vector3)
  106807. * * facetPositions : optional array of facet positions (vector3)
  106808. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106809. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106810. * * bInfo : optional bounding info, required for facetPartitioning computation
  106811. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106812. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106813. * * useRightHandedSystem: optional boolean to for right handed system computation
  106814. * * depthSort : optional boolean to enable the facet depth sort computation
  106815. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106816. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106817. */
  106818. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106819. facetNormals?: any;
  106820. facetPositions?: any;
  106821. facetPartitioning?: any;
  106822. ratio?: number;
  106823. bInfo?: any;
  106824. bbSize?: Vector3;
  106825. subDiv?: any;
  106826. useRightHandedSystem?: boolean;
  106827. depthSort?: boolean;
  106828. distanceTo?: Vector3;
  106829. depthSortedFacets?: any;
  106830. }): void;
  106831. /** @hidden */
  106832. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106833. /**
  106834. * Applies VertexData created from the imported parameters to the geometry
  106835. * @param parsedVertexData the parsed data from an imported file
  106836. * @param geometry the geometry to apply the VertexData to
  106837. */
  106838. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106839. }
  106840. }
  106841. declare module BABYLON {
  106842. /**
  106843. * Defines a target to use with MorphTargetManager
  106844. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106845. */
  106846. export class MorphTarget implements IAnimatable {
  106847. /** defines the name of the target */
  106848. name: string;
  106849. /**
  106850. * Gets or sets the list of animations
  106851. */
  106852. animations: Animation[];
  106853. private _scene;
  106854. private _positions;
  106855. private _normals;
  106856. private _tangents;
  106857. private _uvs;
  106858. private _influence;
  106859. private _uniqueId;
  106860. /**
  106861. * Observable raised when the influence changes
  106862. */
  106863. onInfluenceChanged: Observable<boolean>;
  106864. /** @hidden */
  106865. _onDataLayoutChanged: Observable<void>;
  106866. /**
  106867. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106868. */
  106869. get influence(): number;
  106870. set influence(influence: number);
  106871. /**
  106872. * Gets or sets the id of the morph Target
  106873. */
  106874. id: string;
  106875. private _animationPropertiesOverride;
  106876. /**
  106877. * Gets or sets the animation properties override
  106878. */
  106879. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106880. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106881. /**
  106882. * Creates a new MorphTarget
  106883. * @param name defines the name of the target
  106884. * @param influence defines the influence to use
  106885. * @param scene defines the scene the morphtarget belongs to
  106886. */
  106887. constructor(
  106888. /** defines the name of the target */
  106889. name: string, influence?: number, scene?: Nullable<Scene>);
  106890. /**
  106891. * Gets the unique ID of this manager
  106892. */
  106893. get uniqueId(): number;
  106894. /**
  106895. * Gets a boolean defining if the target contains position data
  106896. */
  106897. get hasPositions(): boolean;
  106898. /**
  106899. * Gets a boolean defining if the target contains normal data
  106900. */
  106901. get hasNormals(): boolean;
  106902. /**
  106903. * Gets a boolean defining if the target contains tangent data
  106904. */
  106905. get hasTangents(): boolean;
  106906. /**
  106907. * Gets a boolean defining if the target contains texture coordinates data
  106908. */
  106909. get hasUVs(): boolean;
  106910. /**
  106911. * Affects position data to this target
  106912. * @param data defines the position data to use
  106913. */
  106914. setPositions(data: Nullable<FloatArray>): void;
  106915. /**
  106916. * Gets the position data stored in this target
  106917. * @returns a FloatArray containing the position data (or null if not present)
  106918. */
  106919. getPositions(): Nullable<FloatArray>;
  106920. /**
  106921. * Affects normal data to this target
  106922. * @param data defines the normal data to use
  106923. */
  106924. setNormals(data: Nullable<FloatArray>): void;
  106925. /**
  106926. * Gets the normal data stored in this target
  106927. * @returns a FloatArray containing the normal data (or null if not present)
  106928. */
  106929. getNormals(): Nullable<FloatArray>;
  106930. /**
  106931. * Affects tangent data to this target
  106932. * @param data defines the tangent data to use
  106933. */
  106934. setTangents(data: Nullable<FloatArray>): void;
  106935. /**
  106936. * Gets the tangent data stored in this target
  106937. * @returns a FloatArray containing the tangent data (or null if not present)
  106938. */
  106939. getTangents(): Nullable<FloatArray>;
  106940. /**
  106941. * Affects texture coordinates data to this target
  106942. * @param data defines the texture coordinates data to use
  106943. */
  106944. setUVs(data: Nullable<FloatArray>): void;
  106945. /**
  106946. * Gets the texture coordinates data stored in this target
  106947. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  106948. */
  106949. getUVs(): Nullable<FloatArray>;
  106950. /**
  106951. * Clone the current target
  106952. * @returns a new MorphTarget
  106953. */
  106954. clone(): MorphTarget;
  106955. /**
  106956. * Serializes the current target into a Serialization object
  106957. * @returns the serialized object
  106958. */
  106959. serialize(): any;
  106960. /**
  106961. * Returns the string "MorphTarget"
  106962. * @returns "MorphTarget"
  106963. */
  106964. getClassName(): string;
  106965. /**
  106966. * Creates a new target from serialized data
  106967. * @param serializationObject defines the serialized data to use
  106968. * @returns a new MorphTarget
  106969. */
  106970. static Parse(serializationObject: any): MorphTarget;
  106971. /**
  106972. * Creates a MorphTarget from mesh data
  106973. * @param mesh defines the source mesh
  106974. * @param name defines the name to use for the new target
  106975. * @param influence defines the influence to attach to the target
  106976. * @returns a new MorphTarget
  106977. */
  106978. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  106979. }
  106980. }
  106981. declare module BABYLON {
  106982. /**
  106983. * This class is used to deform meshes using morphing between different targets
  106984. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106985. */
  106986. export class MorphTargetManager {
  106987. private _targets;
  106988. private _targetInfluenceChangedObservers;
  106989. private _targetDataLayoutChangedObservers;
  106990. private _activeTargets;
  106991. private _scene;
  106992. private _influences;
  106993. private _supportsNormals;
  106994. private _supportsTangents;
  106995. private _supportsUVs;
  106996. private _vertexCount;
  106997. private _uniqueId;
  106998. private _tempInfluences;
  106999. /**
  107000. * Gets or sets a boolean indicating if normals must be morphed
  107001. */
  107002. enableNormalMorphing: boolean;
  107003. /**
  107004. * Gets or sets a boolean indicating if tangents must be morphed
  107005. */
  107006. enableTangentMorphing: boolean;
  107007. /**
  107008. * Gets or sets a boolean indicating if UV must be morphed
  107009. */
  107010. enableUVMorphing: boolean;
  107011. /**
  107012. * Creates a new MorphTargetManager
  107013. * @param scene defines the current scene
  107014. */
  107015. constructor(scene?: Nullable<Scene>);
  107016. /**
  107017. * Gets the unique ID of this manager
  107018. */
  107019. get uniqueId(): number;
  107020. /**
  107021. * Gets the number of vertices handled by this manager
  107022. */
  107023. get vertexCount(): number;
  107024. /**
  107025. * Gets a boolean indicating if this manager supports morphing of normals
  107026. */
  107027. get supportsNormals(): boolean;
  107028. /**
  107029. * Gets a boolean indicating if this manager supports morphing of tangents
  107030. */
  107031. get supportsTangents(): boolean;
  107032. /**
  107033. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  107034. */
  107035. get supportsUVs(): boolean;
  107036. /**
  107037. * Gets the number of targets stored in this manager
  107038. */
  107039. get numTargets(): number;
  107040. /**
  107041. * Gets the number of influencers (ie. the number of targets with influences > 0)
  107042. */
  107043. get numInfluencers(): number;
  107044. /**
  107045. * Gets the list of influences (one per target)
  107046. */
  107047. get influences(): Float32Array;
  107048. /**
  107049. * Gets the active target at specified index. An active target is a target with an influence > 0
  107050. * @param index defines the index to check
  107051. * @returns the requested target
  107052. */
  107053. getActiveTarget(index: number): MorphTarget;
  107054. /**
  107055. * Gets the target at specified index
  107056. * @param index defines the index to check
  107057. * @returns the requested target
  107058. */
  107059. getTarget(index: number): MorphTarget;
  107060. /**
  107061. * Add a new target to this manager
  107062. * @param target defines the target to add
  107063. */
  107064. addTarget(target: MorphTarget): void;
  107065. /**
  107066. * Removes a target from the manager
  107067. * @param target defines the target to remove
  107068. */
  107069. removeTarget(target: MorphTarget): void;
  107070. /**
  107071. * Clone the current manager
  107072. * @returns a new MorphTargetManager
  107073. */
  107074. clone(): MorphTargetManager;
  107075. /**
  107076. * Serializes the current manager into a Serialization object
  107077. * @returns the serialized object
  107078. */
  107079. serialize(): any;
  107080. private _syncActiveTargets;
  107081. /**
  107082. * Syncrhonize the targets with all the meshes using this morph target manager
  107083. */
  107084. synchronize(): void;
  107085. /**
  107086. * Creates a new MorphTargetManager from serialized data
  107087. * @param serializationObject defines the serialized data
  107088. * @param scene defines the hosting scene
  107089. * @returns the new MorphTargetManager
  107090. */
  107091. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  107092. }
  107093. }
  107094. declare module BABYLON {
  107095. /**
  107096. * Class used to represent a specific level of detail of a mesh
  107097. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107098. */
  107099. export class MeshLODLevel {
  107100. /** Defines the distance where this level should start being displayed */
  107101. distance: number;
  107102. /** Defines the mesh to use to render this level */
  107103. mesh: Nullable<Mesh>;
  107104. /**
  107105. * Creates a new LOD level
  107106. * @param distance defines the distance where this level should star being displayed
  107107. * @param mesh defines the mesh to use to render this level
  107108. */
  107109. constructor(
  107110. /** Defines the distance where this level should start being displayed */
  107111. distance: number,
  107112. /** Defines the mesh to use to render this level */
  107113. mesh: Nullable<Mesh>);
  107114. }
  107115. }
  107116. declare module BABYLON {
  107117. /**
  107118. * Helper class used to generate a canvas to manipulate images
  107119. */
  107120. export class CanvasGenerator {
  107121. /**
  107122. * Create a new canvas (or offscreen canvas depending on the context)
  107123. * @param width defines the expected width
  107124. * @param height defines the expected height
  107125. * @return a new canvas or offscreen canvas
  107126. */
  107127. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  107128. }
  107129. }
  107130. declare module BABYLON {
  107131. /**
  107132. * Mesh representing the gorund
  107133. */
  107134. export class GroundMesh extends Mesh {
  107135. /** If octree should be generated */
  107136. generateOctree: boolean;
  107137. private _heightQuads;
  107138. /** @hidden */
  107139. _subdivisionsX: number;
  107140. /** @hidden */
  107141. _subdivisionsY: number;
  107142. /** @hidden */
  107143. _width: number;
  107144. /** @hidden */
  107145. _height: number;
  107146. /** @hidden */
  107147. _minX: number;
  107148. /** @hidden */
  107149. _maxX: number;
  107150. /** @hidden */
  107151. _minZ: number;
  107152. /** @hidden */
  107153. _maxZ: number;
  107154. constructor(name: string, scene: Scene);
  107155. /**
  107156. * "GroundMesh"
  107157. * @returns "GroundMesh"
  107158. */
  107159. getClassName(): string;
  107160. /**
  107161. * The minimum of x and y subdivisions
  107162. */
  107163. get subdivisions(): number;
  107164. /**
  107165. * X subdivisions
  107166. */
  107167. get subdivisionsX(): number;
  107168. /**
  107169. * Y subdivisions
  107170. */
  107171. get subdivisionsY(): number;
  107172. /**
  107173. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  107174. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107175. * @param chunksCount the number of subdivisions for x and y
  107176. * @param octreeBlocksSize (Default: 32)
  107177. */
  107178. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  107179. /**
  107180. * Returns a height (y) value in the Worl system :
  107181. * the ground altitude at the coordinates (x, z) expressed in the World system.
  107182. * @param x x coordinate
  107183. * @param z z coordinate
  107184. * @returns the ground y position if (x, z) are outside the ground surface.
  107185. */
  107186. getHeightAtCoordinates(x: number, z: number): number;
  107187. /**
  107188. * Returns a normalized vector (Vector3) orthogonal to the ground
  107189. * at the ground coordinates (x, z) expressed in the World system.
  107190. * @param x x coordinate
  107191. * @param z z coordinate
  107192. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  107193. */
  107194. getNormalAtCoordinates(x: number, z: number): Vector3;
  107195. /**
  107196. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  107197. * at the ground coordinates (x, z) expressed in the World system.
  107198. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  107199. * @param x x coordinate
  107200. * @param z z coordinate
  107201. * @param ref vector to store the result
  107202. * @returns the GroundMesh.
  107203. */
  107204. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  107205. /**
  107206. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  107207. * if the ground has been updated.
  107208. * This can be used in the render loop.
  107209. * @returns the GroundMesh.
  107210. */
  107211. updateCoordinateHeights(): GroundMesh;
  107212. private _getFacetAt;
  107213. private _initHeightQuads;
  107214. private _computeHeightQuads;
  107215. /**
  107216. * Serializes this ground mesh
  107217. * @param serializationObject object to write serialization to
  107218. */
  107219. serialize(serializationObject: any): void;
  107220. /**
  107221. * Parses a serialized ground mesh
  107222. * @param parsedMesh the serialized mesh
  107223. * @param scene the scene to create the ground mesh in
  107224. * @returns the created ground mesh
  107225. */
  107226. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  107227. }
  107228. }
  107229. declare module BABYLON {
  107230. /**
  107231. * Interface for Physics-Joint data
  107232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107233. */
  107234. export interface PhysicsJointData {
  107235. /**
  107236. * The main pivot of the joint
  107237. */
  107238. mainPivot?: Vector3;
  107239. /**
  107240. * The connected pivot of the joint
  107241. */
  107242. connectedPivot?: Vector3;
  107243. /**
  107244. * The main axis of the joint
  107245. */
  107246. mainAxis?: Vector3;
  107247. /**
  107248. * The connected axis of the joint
  107249. */
  107250. connectedAxis?: Vector3;
  107251. /**
  107252. * The collision of the joint
  107253. */
  107254. collision?: boolean;
  107255. /**
  107256. * Native Oimo/Cannon/Energy data
  107257. */
  107258. nativeParams?: any;
  107259. }
  107260. /**
  107261. * This is a holder class for the physics joint created by the physics plugin
  107262. * It holds a set of functions to control the underlying joint
  107263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107264. */
  107265. export class PhysicsJoint {
  107266. /**
  107267. * The type of the physics joint
  107268. */
  107269. type: number;
  107270. /**
  107271. * The data for the physics joint
  107272. */
  107273. jointData: PhysicsJointData;
  107274. private _physicsJoint;
  107275. protected _physicsPlugin: IPhysicsEnginePlugin;
  107276. /**
  107277. * Initializes the physics joint
  107278. * @param type The type of the physics joint
  107279. * @param jointData The data for the physics joint
  107280. */
  107281. constructor(
  107282. /**
  107283. * The type of the physics joint
  107284. */
  107285. type: number,
  107286. /**
  107287. * The data for the physics joint
  107288. */
  107289. jointData: PhysicsJointData);
  107290. /**
  107291. * Gets the physics joint
  107292. */
  107293. get physicsJoint(): any;
  107294. /**
  107295. * Sets the physics joint
  107296. */
  107297. set physicsJoint(newJoint: any);
  107298. /**
  107299. * Sets the physics plugin
  107300. */
  107301. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  107302. /**
  107303. * Execute a function that is physics-plugin specific.
  107304. * @param {Function} func the function that will be executed.
  107305. * It accepts two parameters: the physics world and the physics joint
  107306. */
  107307. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  107308. /**
  107309. * Distance-Joint type
  107310. */
  107311. static DistanceJoint: number;
  107312. /**
  107313. * Hinge-Joint type
  107314. */
  107315. static HingeJoint: number;
  107316. /**
  107317. * Ball-and-Socket joint type
  107318. */
  107319. static BallAndSocketJoint: number;
  107320. /**
  107321. * Wheel-Joint type
  107322. */
  107323. static WheelJoint: number;
  107324. /**
  107325. * Slider-Joint type
  107326. */
  107327. static SliderJoint: number;
  107328. /**
  107329. * Prismatic-Joint type
  107330. */
  107331. static PrismaticJoint: number;
  107332. /**
  107333. * Universal-Joint type
  107334. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  107335. */
  107336. static UniversalJoint: number;
  107337. /**
  107338. * Hinge-Joint 2 type
  107339. */
  107340. static Hinge2Joint: number;
  107341. /**
  107342. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  107343. */
  107344. static PointToPointJoint: number;
  107345. /**
  107346. * Spring-Joint type
  107347. */
  107348. static SpringJoint: number;
  107349. /**
  107350. * Lock-Joint type
  107351. */
  107352. static LockJoint: number;
  107353. }
  107354. /**
  107355. * A class representing a physics distance joint
  107356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107357. */
  107358. export class DistanceJoint extends PhysicsJoint {
  107359. /**
  107360. *
  107361. * @param jointData The data for the Distance-Joint
  107362. */
  107363. constructor(jointData: DistanceJointData);
  107364. /**
  107365. * Update the predefined distance.
  107366. * @param maxDistance The maximum preferred distance
  107367. * @param minDistance The minimum preferred distance
  107368. */
  107369. updateDistance(maxDistance: number, minDistance?: number): void;
  107370. }
  107371. /**
  107372. * Represents a Motor-Enabled Joint
  107373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107374. */
  107375. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  107376. /**
  107377. * Initializes the Motor-Enabled Joint
  107378. * @param type The type of the joint
  107379. * @param jointData The physica joint data for the joint
  107380. */
  107381. constructor(type: number, jointData: PhysicsJointData);
  107382. /**
  107383. * Set the motor values.
  107384. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107385. * @param force the force to apply
  107386. * @param maxForce max force for this motor.
  107387. */
  107388. setMotor(force?: number, maxForce?: number): void;
  107389. /**
  107390. * Set the motor's limits.
  107391. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107392. * @param upperLimit The upper limit of the motor
  107393. * @param lowerLimit The lower limit of the motor
  107394. */
  107395. setLimit(upperLimit: number, lowerLimit?: number): void;
  107396. }
  107397. /**
  107398. * This class represents a single physics Hinge-Joint
  107399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107400. */
  107401. export class HingeJoint extends MotorEnabledJoint {
  107402. /**
  107403. * Initializes the Hinge-Joint
  107404. * @param jointData The joint data for the Hinge-Joint
  107405. */
  107406. constructor(jointData: PhysicsJointData);
  107407. /**
  107408. * Set the motor values.
  107409. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107410. * @param {number} force the force to apply
  107411. * @param {number} maxForce max force for this motor.
  107412. */
  107413. setMotor(force?: number, maxForce?: number): void;
  107414. /**
  107415. * Set the motor's limits.
  107416. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107417. * @param upperLimit The upper limit of the motor
  107418. * @param lowerLimit The lower limit of the motor
  107419. */
  107420. setLimit(upperLimit: number, lowerLimit?: number): void;
  107421. }
  107422. /**
  107423. * This class represents a dual hinge physics joint (same as wheel joint)
  107424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107425. */
  107426. export class Hinge2Joint extends MotorEnabledJoint {
  107427. /**
  107428. * Initializes the Hinge2-Joint
  107429. * @param jointData The joint data for the Hinge2-Joint
  107430. */
  107431. constructor(jointData: PhysicsJointData);
  107432. /**
  107433. * Set the motor values.
  107434. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107435. * @param {number} targetSpeed the speed the motor is to reach
  107436. * @param {number} maxForce max force for this motor.
  107437. * @param {motorIndex} the motor's index, 0 or 1.
  107438. */
  107439. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  107440. /**
  107441. * Set the motor limits.
  107442. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107443. * @param {number} upperLimit the upper limit
  107444. * @param {number} lowerLimit lower limit
  107445. * @param {motorIndex} the motor's index, 0 or 1.
  107446. */
  107447. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107448. }
  107449. /**
  107450. * Interface for a motor enabled joint
  107451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107452. */
  107453. export interface IMotorEnabledJoint {
  107454. /**
  107455. * Physics joint
  107456. */
  107457. physicsJoint: any;
  107458. /**
  107459. * Sets the motor of the motor-enabled joint
  107460. * @param force The force of the motor
  107461. * @param maxForce The maximum force of the motor
  107462. * @param motorIndex The index of the motor
  107463. */
  107464. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  107465. /**
  107466. * Sets the limit of the motor
  107467. * @param upperLimit The upper limit of the motor
  107468. * @param lowerLimit The lower limit of the motor
  107469. * @param motorIndex The index of the motor
  107470. */
  107471. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107472. }
  107473. /**
  107474. * Joint data for a Distance-Joint
  107475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107476. */
  107477. export interface DistanceJointData extends PhysicsJointData {
  107478. /**
  107479. * Max distance the 2 joint objects can be apart
  107480. */
  107481. maxDistance: number;
  107482. }
  107483. /**
  107484. * Joint data from a spring joint
  107485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107486. */
  107487. export interface SpringJointData extends PhysicsJointData {
  107488. /**
  107489. * Length of the spring
  107490. */
  107491. length: number;
  107492. /**
  107493. * Stiffness of the spring
  107494. */
  107495. stiffness: number;
  107496. /**
  107497. * Damping of the spring
  107498. */
  107499. damping: number;
  107500. /** this callback will be called when applying the force to the impostors. */
  107501. forceApplicationCallback: () => void;
  107502. }
  107503. }
  107504. declare module BABYLON {
  107505. /**
  107506. * Holds the data for the raycast result
  107507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107508. */
  107509. export class PhysicsRaycastResult {
  107510. private _hasHit;
  107511. private _hitDistance;
  107512. private _hitNormalWorld;
  107513. private _hitPointWorld;
  107514. private _rayFromWorld;
  107515. private _rayToWorld;
  107516. /**
  107517. * Gets if there was a hit
  107518. */
  107519. get hasHit(): boolean;
  107520. /**
  107521. * Gets the distance from the hit
  107522. */
  107523. get hitDistance(): number;
  107524. /**
  107525. * Gets the hit normal/direction in the world
  107526. */
  107527. get hitNormalWorld(): Vector3;
  107528. /**
  107529. * Gets the hit point in the world
  107530. */
  107531. get hitPointWorld(): Vector3;
  107532. /**
  107533. * Gets the ray "start point" of the ray in the world
  107534. */
  107535. get rayFromWorld(): Vector3;
  107536. /**
  107537. * Gets the ray "end point" of the ray in the world
  107538. */
  107539. get rayToWorld(): Vector3;
  107540. /**
  107541. * Sets the hit data (normal & point in world space)
  107542. * @param hitNormalWorld defines the normal in world space
  107543. * @param hitPointWorld defines the point in world space
  107544. */
  107545. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107546. /**
  107547. * Sets the distance from the start point to the hit point
  107548. * @param distance
  107549. */
  107550. setHitDistance(distance: number): void;
  107551. /**
  107552. * Calculates the distance manually
  107553. */
  107554. calculateHitDistance(): void;
  107555. /**
  107556. * Resets all the values to default
  107557. * @param from The from point on world space
  107558. * @param to The to point on world space
  107559. */
  107560. reset(from?: Vector3, to?: Vector3): void;
  107561. }
  107562. /**
  107563. * Interface for the size containing width and height
  107564. */
  107565. interface IXYZ {
  107566. /**
  107567. * X
  107568. */
  107569. x: number;
  107570. /**
  107571. * Y
  107572. */
  107573. y: number;
  107574. /**
  107575. * Z
  107576. */
  107577. z: number;
  107578. }
  107579. }
  107580. declare module BABYLON {
  107581. /**
  107582. * Interface used to describe a physics joint
  107583. */
  107584. export interface PhysicsImpostorJoint {
  107585. /** Defines the main impostor to which the joint is linked */
  107586. mainImpostor: PhysicsImpostor;
  107587. /** Defines the impostor that is connected to the main impostor using this joint */
  107588. connectedImpostor: PhysicsImpostor;
  107589. /** Defines the joint itself */
  107590. joint: PhysicsJoint;
  107591. }
  107592. /** @hidden */
  107593. export interface IPhysicsEnginePlugin {
  107594. world: any;
  107595. name: string;
  107596. setGravity(gravity: Vector3): void;
  107597. setTimeStep(timeStep: number): void;
  107598. getTimeStep(): number;
  107599. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107600. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107601. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107602. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107603. removePhysicsBody(impostor: PhysicsImpostor): void;
  107604. generateJoint(joint: PhysicsImpostorJoint): void;
  107605. removeJoint(joint: PhysicsImpostorJoint): void;
  107606. isSupported(): boolean;
  107607. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107608. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107609. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107610. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107611. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107612. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107613. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107614. getBodyMass(impostor: PhysicsImpostor): number;
  107615. getBodyFriction(impostor: PhysicsImpostor): number;
  107616. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107617. getBodyRestitution(impostor: PhysicsImpostor): number;
  107618. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107619. getBodyPressure?(impostor: PhysicsImpostor): number;
  107620. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107621. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107622. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107623. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107624. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107625. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107626. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107627. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107628. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107629. sleepBody(impostor: PhysicsImpostor): void;
  107630. wakeUpBody(impostor: PhysicsImpostor): void;
  107631. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107632. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107633. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107634. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107635. getRadius(impostor: PhysicsImpostor): number;
  107636. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107637. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107638. dispose(): void;
  107639. }
  107640. /**
  107641. * Interface used to define a physics engine
  107642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107643. */
  107644. export interface IPhysicsEngine {
  107645. /**
  107646. * Gets the gravity vector used by the simulation
  107647. */
  107648. gravity: Vector3;
  107649. /**
  107650. * Sets the gravity vector used by the simulation
  107651. * @param gravity defines the gravity vector to use
  107652. */
  107653. setGravity(gravity: Vector3): void;
  107654. /**
  107655. * Set the time step of the physics engine.
  107656. * Default is 1/60.
  107657. * To slow it down, enter 1/600 for example.
  107658. * To speed it up, 1/30
  107659. * @param newTimeStep the new timestep to apply to this world.
  107660. */
  107661. setTimeStep(newTimeStep: number): void;
  107662. /**
  107663. * Get the time step of the physics engine.
  107664. * @returns the current time step
  107665. */
  107666. getTimeStep(): number;
  107667. /**
  107668. * Set the sub time step of the physics engine.
  107669. * Default is 0 meaning there is no sub steps
  107670. * To increase physics resolution precision, set a small value (like 1 ms)
  107671. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107672. */
  107673. setSubTimeStep(subTimeStep: number): void;
  107674. /**
  107675. * Get the sub time step of the physics engine.
  107676. * @returns the current sub time step
  107677. */
  107678. getSubTimeStep(): number;
  107679. /**
  107680. * Release all resources
  107681. */
  107682. dispose(): void;
  107683. /**
  107684. * Gets the name of the current physics plugin
  107685. * @returns the name of the plugin
  107686. */
  107687. getPhysicsPluginName(): string;
  107688. /**
  107689. * Adding a new impostor for the impostor tracking.
  107690. * This will be done by the impostor itself.
  107691. * @param impostor the impostor to add
  107692. */
  107693. addImpostor(impostor: PhysicsImpostor): void;
  107694. /**
  107695. * Remove an impostor from the engine.
  107696. * This impostor and its mesh will not longer be updated by the physics engine.
  107697. * @param impostor the impostor to remove
  107698. */
  107699. removeImpostor(impostor: PhysicsImpostor): void;
  107700. /**
  107701. * Add a joint to the physics engine
  107702. * @param mainImpostor defines the main impostor to which the joint is added.
  107703. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107704. * @param joint defines the joint that will connect both impostors.
  107705. */
  107706. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107707. /**
  107708. * Removes a joint from the simulation
  107709. * @param mainImpostor defines the impostor used with the joint
  107710. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107711. * @param joint defines the joint to remove
  107712. */
  107713. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107714. /**
  107715. * Gets the current plugin used to run the simulation
  107716. * @returns current plugin
  107717. */
  107718. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107719. /**
  107720. * Gets the list of physic impostors
  107721. * @returns an array of PhysicsImpostor
  107722. */
  107723. getImpostors(): Array<PhysicsImpostor>;
  107724. /**
  107725. * Gets the impostor for a physics enabled object
  107726. * @param object defines the object impersonated by the impostor
  107727. * @returns the PhysicsImpostor or null if not found
  107728. */
  107729. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107730. /**
  107731. * Gets the impostor for a physics body object
  107732. * @param body defines physics body used by the impostor
  107733. * @returns the PhysicsImpostor or null if not found
  107734. */
  107735. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107736. /**
  107737. * Does a raycast in the physics world
  107738. * @param from when should the ray start?
  107739. * @param to when should the ray end?
  107740. * @returns PhysicsRaycastResult
  107741. */
  107742. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107743. /**
  107744. * Called by the scene. No need to call it.
  107745. * @param delta defines the timespam between frames
  107746. */
  107747. _step(delta: number): void;
  107748. }
  107749. }
  107750. declare module BABYLON {
  107751. /**
  107752. * The interface for the physics imposter parameters
  107753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107754. */
  107755. export interface PhysicsImpostorParameters {
  107756. /**
  107757. * The mass of the physics imposter
  107758. */
  107759. mass: number;
  107760. /**
  107761. * The friction of the physics imposter
  107762. */
  107763. friction?: number;
  107764. /**
  107765. * The coefficient of restitution of the physics imposter
  107766. */
  107767. restitution?: number;
  107768. /**
  107769. * The native options of the physics imposter
  107770. */
  107771. nativeOptions?: any;
  107772. /**
  107773. * Specifies if the parent should be ignored
  107774. */
  107775. ignoreParent?: boolean;
  107776. /**
  107777. * Specifies if bi-directional transformations should be disabled
  107778. */
  107779. disableBidirectionalTransformation?: boolean;
  107780. /**
  107781. * The pressure inside the physics imposter, soft object only
  107782. */
  107783. pressure?: number;
  107784. /**
  107785. * The stiffness the physics imposter, soft object only
  107786. */
  107787. stiffness?: number;
  107788. /**
  107789. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107790. */
  107791. velocityIterations?: number;
  107792. /**
  107793. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107794. */
  107795. positionIterations?: number;
  107796. /**
  107797. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107798. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107799. * Add to fix multiple points
  107800. */
  107801. fixedPoints?: number;
  107802. /**
  107803. * The collision margin around a soft object
  107804. */
  107805. margin?: number;
  107806. /**
  107807. * The collision margin around a soft object
  107808. */
  107809. damping?: number;
  107810. /**
  107811. * The path for a rope based on an extrusion
  107812. */
  107813. path?: any;
  107814. /**
  107815. * The shape of an extrusion used for a rope based on an extrusion
  107816. */
  107817. shape?: any;
  107818. }
  107819. /**
  107820. * Interface for a physics-enabled object
  107821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107822. */
  107823. export interface IPhysicsEnabledObject {
  107824. /**
  107825. * The position of the physics-enabled object
  107826. */
  107827. position: Vector3;
  107828. /**
  107829. * The rotation of the physics-enabled object
  107830. */
  107831. rotationQuaternion: Nullable<Quaternion>;
  107832. /**
  107833. * The scale of the physics-enabled object
  107834. */
  107835. scaling: Vector3;
  107836. /**
  107837. * The rotation of the physics-enabled object
  107838. */
  107839. rotation?: Vector3;
  107840. /**
  107841. * The parent of the physics-enabled object
  107842. */
  107843. parent?: any;
  107844. /**
  107845. * The bounding info of the physics-enabled object
  107846. * @returns The bounding info of the physics-enabled object
  107847. */
  107848. getBoundingInfo(): BoundingInfo;
  107849. /**
  107850. * Computes the world matrix
  107851. * @param force Specifies if the world matrix should be computed by force
  107852. * @returns A world matrix
  107853. */
  107854. computeWorldMatrix(force: boolean): Matrix;
  107855. /**
  107856. * Gets the world matrix
  107857. * @returns A world matrix
  107858. */
  107859. getWorldMatrix?(): Matrix;
  107860. /**
  107861. * Gets the child meshes
  107862. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107863. * @returns An array of abstract meshes
  107864. */
  107865. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107866. /**
  107867. * Gets the vertex data
  107868. * @param kind The type of vertex data
  107869. * @returns A nullable array of numbers, or a float32 array
  107870. */
  107871. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107872. /**
  107873. * Gets the indices from the mesh
  107874. * @returns A nullable array of index arrays
  107875. */
  107876. getIndices?(): Nullable<IndicesArray>;
  107877. /**
  107878. * Gets the scene from the mesh
  107879. * @returns the indices array or null
  107880. */
  107881. getScene?(): Scene;
  107882. /**
  107883. * Gets the absolute position from the mesh
  107884. * @returns the absolute position
  107885. */
  107886. getAbsolutePosition(): Vector3;
  107887. /**
  107888. * Gets the absolute pivot point from the mesh
  107889. * @returns the absolute pivot point
  107890. */
  107891. getAbsolutePivotPoint(): Vector3;
  107892. /**
  107893. * Rotates the mesh
  107894. * @param axis The axis of rotation
  107895. * @param amount The amount of rotation
  107896. * @param space The space of the rotation
  107897. * @returns The rotation transform node
  107898. */
  107899. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107900. /**
  107901. * Translates the mesh
  107902. * @param axis The axis of translation
  107903. * @param distance The distance of translation
  107904. * @param space The space of the translation
  107905. * @returns The transform node
  107906. */
  107907. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107908. /**
  107909. * Sets the absolute position of the mesh
  107910. * @param absolutePosition The absolute position of the mesh
  107911. * @returns The transform node
  107912. */
  107913. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107914. /**
  107915. * Gets the class name of the mesh
  107916. * @returns The class name
  107917. */
  107918. getClassName(): string;
  107919. }
  107920. /**
  107921. * Represents a physics imposter
  107922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107923. */
  107924. export class PhysicsImpostor {
  107925. /**
  107926. * The physics-enabled object used as the physics imposter
  107927. */
  107928. object: IPhysicsEnabledObject;
  107929. /**
  107930. * The type of the physics imposter
  107931. */
  107932. type: number;
  107933. private _options;
  107934. private _scene?;
  107935. /**
  107936. * The default object size of the imposter
  107937. */
  107938. static DEFAULT_OBJECT_SIZE: Vector3;
  107939. /**
  107940. * The identity quaternion of the imposter
  107941. */
  107942. static IDENTITY_QUATERNION: Quaternion;
  107943. /** @hidden */
  107944. _pluginData: any;
  107945. private _physicsEngine;
  107946. private _physicsBody;
  107947. private _bodyUpdateRequired;
  107948. private _onBeforePhysicsStepCallbacks;
  107949. private _onAfterPhysicsStepCallbacks;
  107950. /** @hidden */
  107951. _onPhysicsCollideCallbacks: Array<{
  107952. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  107953. otherImpostors: Array<PhysicsImpostor>;
  107954. }>;
  107955. private _deltaPosition;
  107956. private _deltaRotation;
  107957. private _deltaRotationConjugated;
  107958. /** @hidden */
  107959. _isFromLine: boolean;
  107960. private _parent;
  107961. private _isDisposed;
  107962. private static _tmpVecs;
  107963. private static _tmpQuat;
  107964. /**
  107965. * Specifies if the physics imposter is disposed
  107966. */
  107967. get isDisposed(): boolean;
  107968. /**
  107969. * Gets the mass of the physics imposter
  107970. */
  107971. get mass(): number;
  107972. set mass(value: number);
  107973. /**
  107974. * Gets the coefficient of friction
  107975. */
  107976. get friction(): number;
  107977. /**
  107978. * Sets the coefficient of friction
  107979. */
  107980. set friction(value: number);
  107981. /**
  107982. * Gets the coefficient of restitution
  107983. */
  107984. get restitution(): number;
  107985. /**
  107986. * Sets the coefficient of restitution
  107987. */
  107988. set restitution(value: number);
  107989. /**
  107990. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  107991. */
  107992. get pressure(): number;
  107993. /**
  107994. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  107995. */
  107996. set pressure(value: number);
  107997. /**
  107998. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107999. */
  108000. get stiffness(): number;
  108001. /**
  108002. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108003. */
  108004. set stiffness(value: number);
  108005. /**
  108006. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108007. */
  108008. get velocityIterations(): number;
  108009. /**
  108010. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108011. */
  108012. set velocityIterations(value: number);
  108013. /**
  108014. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108015. */
  108016. get positionIterations(): number;
  108017. /**
  108018. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108019. */
  108020. set positionIterations(value: number);
  108021. /**
  108022. * The unique id of the physics imposter
  108023. * set by the physics engine when adding this impostor to the array
  108024. */
  108025. uniqueId: number;
  108026. /**
  108027. * @hidden
  108028. */
  108029. soft: boolean;
  108030. /**
  108031. * @hidden
  108032. */
  108033. segments: number;
  108034. private _joints;
  108035. /**
  108036. * Initializes the physics imposter
  108037. * @param object The physics-enabled object used as the physics imposter
  108038. * @param type The type of the physics imposter
  108039. * @param _options The options for the physics imposter
  108040. * @param _scene The Babylon scene
  108041. */
  108042. constructor(
  108043. /**
  108044. * The physics-enabled object used as the physics imposter
  108045. */
  108046. object: IPhysicsEnabledObject,
  108047. /**
  108048. * The type of the physics imposter
  108049. */
  108050. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  108051. /**
  108052. * This function will completly initialize this impostor.
  108053. * It will create a new body - but only if this mesh has no parent.
  108054. * If it has, this impostor will not be used other than to define the impostor
  108055. * of the child mesh.
  108056. * @hidden
  108057. */
  108058. _init(): void;
  108059. private _getPhysicsParent;
  108060. /**
  108061. * Should a new body be generated.
  108062. * @returns boolean specifying if body initialization is required
  108063. */
  108064. isBodyInitRequired(): boolean;
  108065. /**
  108066. * Sets the updated scaling
  108067. * @param updated Specifies if the scaling is updated
  108068. */
  108069. setScalingUpdated(): void;
  108070. /**
  108071. * Force a regeneration of this or the parent's impostor's body.
  108072. * Use under cautious - This will remove all joints already implemented.
  108073. */
  108074. forceUpdate(): void;
  108075. /**
  108076. * Gets the body that holds this impostor. Either its own, or its parent.
  108077. */
  108078. get physicsBody(): any;
  108079. /**
  108080. * Get the parent of the physics imposter
  108081. * @returns Physics imposter or null
  108082. */
  108083. get parent(): Nullable<PhysicsImpostor>;
  108084. /**
  108085. * Sets the parent of the physics imposter
  108086. */
  108087. set parent(value: Nullable<PhysicsImpostor>);
  108088. /**
  108089. * Set the physics body. Used mainly by the physics engine/plugin
  108090. */
  108091. set physicsBody(physicsBody: any);
  108092. /**
  108093. * Resets the update flags
  108094. */
  108095. resetUpdateFlags(): void;
  108096. /**
  108097. * Gets the object extend size
  108098. * @returns the object extend size
  108099. */
  108100. getObjectExtendSize(): Vector3;
  108101. /**
  108102. * Gets the object center
  108103. * @returns The object center
  108104. */
  108105. getObjectCenter(): Vector3;
  108106. /**
  108107. * Get a specific parameter from the options parameters
  108108. * @param paramName The object parameter name
  108109. * @returns The object parameter
  108110. */
  108111. getParam(paramName: string): any;
  108112. /**
  108113. * Sets a specific parameter in the options given to the physics plugin
  108114. * @param paramName The parameter name
  108115. * @param value The value of the parameter
  108116. */
  108117. setParam(paramName: string, value: number): void;
  108118. /**
  108119. * Specifically change the body's mass option. Won't recreate the physics body object
  108120. * @param mass The mass of the physics imposter
  108121. */
  108122. setMass(mass: number): void;
  108123. /**
  108124. * Gets the linear velocity
  108125. * @returns linear velocity or null
  108126. */
  108127. getLinearVelocity(): Nullable<Vector3>;
  108128. /**
  108129. * Sets the linear velocity
  108130. * @param velocity linear velocity or null
  108131. */
  108132. setLinearVelocity(velocity: Nullable<Vector3>): void;
  108133. /**
  108134. * Gets the angular velocity
  108135. * @returns angular velocity or null
  108136. */
  108137. getAngularVelocity(): Nullable<Vector3>;
  108138. /**
  108139. * Sets the angular velocity
  108140. * @param velocity The velocity or null
  108141. */
  108142. setAngularVelocity(velocity: Nullable<Vector3>): void;
  108143. /**
  108144. * Execute a function with the physics plugin native code
  108145. * Provide a function the will have two variables - the world object and the physics body object
  108146. * @param func The function to execute with the physics plugin native code
  108147. */
  108148. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  108149. /**
  108150. * Register a function that will be executed before the physics world is stepping forward
  108151. * @param func The function to execute before the physics world is stepped forward
  108152. */
  108153. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108154. /**
  108155. * Unregister a function that will be executed before the physics world is stepping forward
  108156. * @param func The function to execute before the physics world is stepped forward
  108157. */
  108158. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108159. /**
  108160. * Register a function that will be executed after the physics step
  108161. * @param func The function to execute after physics step
  108162. */
  108163. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108164. /**
  108165. * Unregisters a function that will be executed after the physics step
  108166. * @param func The function to execute after physics step
  108167. */
  108168. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108169. /**
  108170. * register a function that will be executed when this impostor collides against a different body
  108171. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  108172. * @param func Callback that is executed on collision
  108173. */
  108174. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  108175. /**
  108176. * Unregisters the physics imposter on contact
  108177. * @param collideAgainst The physics object to collide against
  108178. * @param func Callback to execute on collision
  108179. */
  108180. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  108181. private _tmpQuat;
  108182. private _tmpQuat2;
  108183. /**
  108184. * Get the parent rotation
  108185. * @returns The parent rotation
  108186. */
  108187. getParentsRotation(): Quaternion;
  108188. /**
  108189. * this function is executed by the physics engine.
  108190. */
  108191. beforeStep: () => void;
  108192. /**
  108193. * this function is executed by the physics engine
  108194. */
  108195. afterStep: () => void;
  108196. /**
  108197. * Legacy collision detection event support
  108198. */
  108199. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  108200. /**
  108201. * event and body object due to cannon's event-based architecture.
  108202. */
  108203. onCollide: (e: {
  108204. body: any;
  108205. }) => void;
  108206. /**
  108207. * Apply a force
  108208. * @param force The force to apply
  108209. * @param contactPoint The contact point for the force
  108210. * @returns The physics imposter
  108211. */
  108212. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108213. /**
  108214. * Apply an impulse
  108215. * @param force The impulse force
  108216. * @param contactPoint The contact point for the impulse force
  108217. * @returns The physics imposter
  108218. */
  108219. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108220. /**
  108221. * A help function to create a joint
  108222. * @param otherImpostor A physics imposter used to create a joint
  108223. * @param jointType The type of joint
  108224. * @param jointData The data for the joint
  108225. * @returns The physics imposter
  108226. */
  108227. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  108228. /**
  108229. * Add a joint to this impostor with a different impostor
  108230. * @param otherImpostor A physics imposter used to add a joint
  108231. * @param joint The joint to add
  108232. * @returns The physics imposter
  108233. */
  108234. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  108235. /**
  108236. * Add an anchor to a cloth impostor
  108237. * @param otherImpostor rigid impostor to anchor to
  108238. * @param width ratio across width from 0 to 1
  108239. * @param height ratio up height from 0 to 1
  108240. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108241. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  108242. * @returns impostor the soft imposter
  108243. */
  108244. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108245. /**
  108246. * Add a hook to a rope impostor
  108247. * @param otherImpostor rigid impostor to anchor to
  108248. * @param length ratio across rope from 0 to 1
  108249. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  108250. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108251. * @returns impostor the rope imposter
  108252. */
  108253. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108254. /**
  108255. * Will keep this body still, in a sleep mode.
  108256. * @returns the physics imposter
  108257. */
  108258. sleep(): PhysicsImpostor;
  108259. /**
  108260. * Wake the body up.
  108261. * @returns The physics imposter
  108262. */
  108263. wakeUp(): PhysicsImpostor;
  108264. /**
  108265. * Clones the physics imposter
  108266. * @param newObject The physics imposter clones to this physics-enabled object
  108267. * @returns A nullable physics imposter
  108268. */
  108269. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108270. /**
  108271. * Disposes the physics imposter
  108272. */
  108273. dispose(): void;
  108274. /**
  108275. * Sets the delta position
  108276. * @param position The delta position amount
  108277. */
  108278. setDeltaPosition(position: Vector3): void;
  108279. /**
  108280. * Sets the delta rotation
  108281. * @param rotation The delta rotation amount
  108282. */
  108283. setDeltaRotation(rotation: Quaternion): void;
  108284. /**
  108285. * Gets the box size of the physics imposter and stores the result in the input parameter
  108286. * @param result Stores the box size
  108287. * @returns The physics imposter
  108288. */
  108289. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  108290. /**
  108291. * Gets the radius of the physics imposter
  108292. * @returns Radius of the physics imposter
  108293. */
  108294. getRadius(): number;
  108295. /**
  108296. * Sync a bone with this impostor
  108297. * @param bone The bone to sync to the impostor.
  108298. * @param boneMesh The mesh that the bone is influencing.
  108299. * @param jointPivot The pivot of the joint / bone in local space.
  108300. * @param distToJoint Optional distance from the impostor to the joint.
  108301. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108302. */
  108303. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  108304. /**
  108305. * Sync impostor to a bone
  108306. * @param bone The bone that the impostor will be synced to.
  108307. * @param boneMesh The mesh that the bone is influencing.
  108308. * @param jointPivot The pivot of the joint / bone in local space.
  108309. * @param distToJoint Optional distance from the impostor to the joint.
  108310. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108311. * @param boneAxis Optional vector3 axis the bone is aligned with
  108312. */
  108313. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  108314. /**
  108315. * No-Imposter type
  108316. */
  108317. static NoImpostor: number;
  108318. /**
  108319. * Sphere-Imposter type
  108320. */
  108321. static SphereImpostor: number;
  108322. /**
  108323. * Box-Imposter type
  108324. */
  108325. static BoxImpostor: number;
  108326. /**
  108327. * Plane-Imposter type
  108328. */
  108329. static PlaneImpostor: number;
  108330. /**
  108331. * Mesh-imposter type
  108332. */
  108333. static MeshImpostor: number;
  108334. /**
  108335. * Capsule-Impostor type (Ammo.js plugin only)
  108336. */
  108337. static CapsuleImpostor: number;
  108338. /**
  108339. * Cylinder-Imposter type
  108340. */
  108341. static CylinderImpostor: number;
  108342. /**
  108343. * Particle-Imposter type
  108344. */
  108345. static ParticleImpostor: number;
  108346. /**
  108347. * Heightmap-Imposter type
  108348. */
  108349. static HeightmapImpostor: number;
  108350. /**
  108351. * ConvexHull-Impostor type (Ammo.js plugin only)
  108352. */
  108353. static ConvexHullImpostor: number;
  108354. /**
  108355. * Custom-Imposter type (Ammo.js plugin only)
  108356. */
  108357. static CustomImpostor: number;
  108358. /**
  108359. * Rope-Imposter type
  108360. */
  108361. static RopeImpostor: number;
  108362. /**
  108363. * Cloth-Imposter type
  108364. */
  108365. static ClothImpostor: number;
  108366. /**
  108367. * Softbody-Imposter type
  108368. */
  108369. static SoftbodyImpostor: number;
  108370. }
  108371. }
  108372. declare module BABYLON {
  108373. /**
  108374. * @hidden
  108375. **/
  108376. export class _CreationDataStorage {
  108377. closePath?: boolean;
  108378. closeArray?: boolean;
  108379. idx: number[];
  108380. dashSize: number;
  108381. gapSize: number;
  108382. path3D: Path3D;
  108383. pathArray: Vector3[][];
  108384. arc: number;
  108385. radius: number;
  108386. cap: number;
  108387. tessellation: number;
  108388. }
  108389. /**
  108390. * @hidden
  108391. **/
  108392. class _InstanceDataStorage {
  108393. visibleInstances: any;
  108394. batchCache: _InstancesBatch;
  108395. instancesBufferSize: number;
  108396. instancesBuffer: Nullable<Buffer>;
  108397. instancesData: Float32Array;
  108398. overridenInstanceCount: number;
  108399. isFrozen: boolean;
  108400. previousBatch: Nullable<_InstancesBatch>;
  108401. hardwareInstancedRendering: boolean;
  108402. sideOrientation: number;
  108403. manualUpdate: boolean;
  108404. previousRenderId: number;
  108405. }
  108406. /**
  108407. * @hidden
  108408. **/
  108409. export class _InstancesBatch {
  108410. mustReturn: boolean;
  108411. visibleInstances: Nullable<InstancedMesh[]>[];
  108412. renderSelf: boolean[];
  108413. hardwareInstancedRendering: boolean[];
  108414. }
  108415. /**
  108416. * @hidden
  108417. **/
  108418. class _ThinInstanceDataStorage {
  108419. instancesCount: number;
  108420. matrixBuffer: Nullable<Buffer>;
  108421. matrixBufferSize: number;
  108422. matrixData: Nullable<Float32Array>;
  108423. boundingVectors: Array<Vector3>;
  108424. worldMatrices: Nullable<Matrix[]>;
  108425. }
  108426. /**
  108427. * Class used to represent renderable models
  108428. */
  108429. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  108430. /**
  108431. * Mesh side orientation : usually the external or front surface
  108432. */
  108433. static readonly FRONTSIDE: number;
  108434. /**
  108435. * Mesh side orientation : usually the internal or back surface
  108436. */
  108437. static readonly BACKSIDE: number;
  108438. /**
  108439. * Mesh side orientation : both internal and external or front and back surfaces
  108440. */
  108441. static readonly DOUBLESIDE: number;
  108442. /**
  108443. * Mesh side orientation : by default, `FRONTSIDE`
  108444. */
  108445. static readonly DEFAULTSIDE: number;
  108446. /**
  108447. * Mesh cap setting : no cap
  108448. */
  108449. static readonly NO_CAP: number;
  108450. /**
  108451. * Mesh cap setting : one cap at the beginning of the mesh
  108452. */
  108453. static readonly CAP_START: number;
  108454. /**
  108455. * Mesh cap setting : one cap at the end of the mesh
  108456. */
  108457. static readonly CAP_END: number;
  108458. /**
  108459. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  108460. */
  108461. static readonly CAP_ALL: number;
  108462. /**
  108463. * Mesh pattern setting : no flip or rotate
  108464. */
  108465. static readonly NO_FLIP: number;
  108466. /**
  108467. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  108468. */
  108469. static readonly FLIP_TILE: number;
  108470. /**
  108471. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  108472. */
  108473. static readonly ROTATE_TILE: number;
  108474. /**
  108475. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  108476. */
  108477. static readonly FLIP_ROW: number;
  108478. /**
  108479. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  108480. */
  108481. static readonly ROTATE_ROW: number;
  108482. /**
  108483. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  108484. */
  108485. static readonly FLIP_N_ROTATE_TILE: number;
  108486. /**
  108487. * Mesh pattern setting : rotate pattern and rotate
  108488. */
  108489. static readonly FLIP_N_ROTATE_ROW: number;
  108490. /**
  108491. * Mesh tile positioning : part tiles same on left/right or top/bottom
  108492. */
  108493. static readonly CENTER: number;
  108494. /**
  108495. * Mesh tile positioning : part tiles on left
  108496. */
  108497. static readonly LEFT: number;
  108498. /**
  108499. * Mesh tile positioning : part tiles on right
  108500. */
  108501. static readonly RIGHT: number;
  108502. /**
  108503. * Mesh tile positioning : part tiles on top
  108504. */
  108505. static readonly TOP: number;
  108506. /**
  108507. * Mesh tile positioning : part tiles on bottom
  108508. */
  108509. static readonly BOTTOM: number;
  108510. /**
  108511. * Gets the default side orientation.
  108512. * @param orientation the orientation to value to attempt to get
  108513. * @returns the default orientation
  108514. * @hidden
  108515. */
  108516. static _GetDefaultSideOrientation(orientation?: number): number;
  108517. private _internalMeshDataInfo;
  108518. get computeBonesUsingShaders(): boolean;
  108519. set computeBonesUsingShaders(value: boolean);
  108520. /**
  108521. * An event triggered before rendering the mesh
  108522. */
  108523. get onBeforeRenderObservable(): Observable<Mesh>;
  108524. /**
  108525. * An event triggered before binding the mesh
  108526. */
  108527. get onBeforeBindObservable(): Observable<Mesh>;
  108528. /**
  108529. * An event triggered after rendering the mesh
  108530. */
  108531. get onAfterRenderObservable(): Observable<Mesh>;
  108532. /**
  108533. * An event triggered before drawing the mesh
  108534. */
  108535. get onBeforeDrawObservable(): Observable<Mesh>;
  108536. private _onBeforeDrawObserver;
  108537. /**
  108538. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108539. */
  108540. set onBeforeDraw(callback: () => void);
  108541. get hasInstances(): boolean;
  108542. get hasThinInstances(): boolean;
  108543. /**
  108544. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108545. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108546. */
  108547. delayLoadState: number;
  108548. /**
  108549. * Gets the list of instances created from this mesh
  108550. * it is not supposed to be modified manually.
  108551. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108552. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108553. */
  108554. instances: InstancedMesh[];
  108555. /**
  108556. * Gets the file containing delay loading data for this mesh
  108557. */
  108558. delayLoadingFile: string;
  108559. /** @hidden */
  108560. _binaryInfo: any;
  108561. /**
  108562. * User defined function used to change how LOD level selection is done
  108563. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108564. */
  108565. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108566. /**
  108567. * Gets or sets the morph target manager
  108568. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108569. */
  108570. get morphTargetManager(): Nullable<MorphTargetManager>;
  108571. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108572. /** @hidden */
  108573. _creationDataStorage: Nullable<_CreationDataStorage>;
  108574. /** @hidden */
  108575. _geometry: Nullable<Geometry>;
  108576. /** @hidden */
  108577. _delayInfo: Array<string>;
  108578. /** @hidden */
  108579. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108580. /** @hidden */
  108581. _instanceDataStorage: _InstanceDataStorage;
  108582. /** @hidden */
  108583. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108584. private _effectiveMaterial;
  108585. /** @hidden */
  108586. _shouldGenerateFlatShading: boolean;
  108587. /** @hidden */
  108588. _originalBuilderSideOrientation: number;
  108589. /**
  108590. * Use this property to change the original side orientation defined at construction time
  108591. */
  108592. overrideMaterialSideOrientation: Nullable<number>;
  108593. /**
  108594. * Gets the source mesh (the one used to clone this one from)
  108595. */
  108596. get source(): Nullable<Mesh>;
  108597. /**
  108598. * Gets the list of clones of this mesh
  108599. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108600. * Note that useClonedMeshMap=true is the default setting
  108601. */
  108602. get cloneMeshMap(): Nullable<{
  108603. [id: string]: Mesh | undefined;
  108604. }>;
  108605. /**
  108606. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108607. */
  108608. get isUnIndexed(): boolean;
  108609. set isUnIndexed(value: boolean);
  108610. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108611. get worldMatrixInstancedBuffer(): Float32Array;
  108612. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108613. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108614. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108615. /**
  108616. * @constructor
  108617. * @param name The value used by scene.getMeshByName() to do a lookup.
  108618. * @param scene The scene to add this mesh to.
  108619. * @param parent The parent of this mesh, if it has one
  108620. * @param source An optional Mesh from which geometry is shared, cloned.
  108621. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108622. * When false, achieved by calling a clone(), also passing False.
  108623. * This will make creation of children, recursive.
  108624. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108625. */
  108626. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108627. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108628. doNotInstantiate: boolean;
  108629. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108630. /**
  108631. * Gets the class name
  108632. * @returns the string "Mesh".
  108633. */
  108634. getClassName(): string;
  108635. /** @hidden */
  108636. get _isMesh(): boolean;
  108637. /**
  108638. * Returns a description of this mesh
  108639. * @param fullDetails define if full details about this mesh must be used
  108640. * @returns a descriptive string representing this mesh
  108641. */
  108642. toString(fullDetails?: boolean): string;
  108643. /** @hidden */
  108644. _unBindEffect(): void;
  108645. /**
  108646. * Gets a boolean indicating if this mesh has LOD
  108647. */
  108648. get hasLODLevels(): boolean;
  108649. /**
  108650. * Gets the list of MeshLODLevel associated with the current mesh
  108651. * @returns an array of MeshLODLevel
  108652. */
  108653. getLODLevels(): MeshLODLevel[];
  108654. private _sortLODLevels;
  108655. /**
  108656. * Add a mesh as LOD level triggered at the given distance.
  108657. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108658. * @param distance The distance from the center of the object to show this level
  108659. * @param mesh The mesh to be added as LOD level (can be null)
  108660. * @return This mesh (for chaining)
  108661. */
  108662. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108663. /**
  108664. * Returns the LOD level mesh at the passed distance or null if not found.
  108665. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108666. * @param distance The distance from the center of the object to show this level
  108667. * @returns a Mesh or `null`
  108668. */
  108669. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108670. /**
  108671. * Remove a mesh from the LOD array
  108672. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108673. * @param mesh defines the mesh to be removed
  108674. * @return This mesh (for chaining)
  108675. */
  108676. removeLODLevel(mesh: Mesh): Mesh;
  108677. /**
  108678. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  108679. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108680. * @param camera defines the camera to use to compute distance
  108681. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  108682. * @return This mesh (for chaining)
  108683. */
  108684. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  108685. /**
  108686. * Gets the mesh internal Geometry object
  108687. */
  108688. get geometry(): Nullable<Geometry>;
  108689. /**
  108690. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  108691. * @returns the total number of vertices
  108692. */
  108693. getTotalVertices(): number;
  108694. /**
  108695. * Returns the content of an associated vertex buffer
  108696. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108697. * - VertexBuffer.PositionKind
  108698. * - VertexBuffer.UVKind
  108699. * - VertexBuffer.UV2Kind
  108700. * - VertexBuffer.UV3Kind
  108701. * - VertexBuffer.UV4Kind
  108702. * - VertexBuffer.UV5Kind
  108703. * - VertexBuffer.UV6Kind
  108704. * - VertexBuffer.ColorKind
  108705. * - VertexBuffer.MatricesIndicesKind
  108706. * - VertexBuffer.MatricesIndicesExtraKind
  108707. * - VertexBuffer.MatricesWeightsKind
  108708. * - VertexBuffer.MatricesWeightsExtraKind
  108709. * @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
  108710. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108711. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108712. */
  108713. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108714. /**
  108715. * Returns the mesh VertexBuffer object from the requested `kind`
  108716. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108717. * - VertexBuffer.PositionKind
  108718. * - VertexBuffer.NormalKind
  108719. * - VertexBuffer.UVKind
  108720. * - VertexBuffer.UV2Kind
  108721. * - VertexBuffer.UV3Kind
  108722. * - VertexBuffer.UV4Kind
  108723. * - VertexBuffer.UV5Kind
  108724. * - VertexBuffer.UV6Kind
  108725. * - VertexBuffer.ColorKind
  108726. * - VertexBuffer.MatricesIndicesKind
  108727. * - VertexBuffer.MatricesIndicesExtraKind
  108728. * - VertexBuffer.MatricesWeightsKind
  108729. * - VertexBuffer.MatricesWeightsExtraKind
  108730. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108731. */
  108732. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108733. /**
  108734. * Tests if a specific vertex buffer is associated with this mesh
  108735. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108736. * - VertexBuffer.PositionKind
  108737. * - VertexBuffer.NormalKind
  108738. * - VertexBuffer.UVKind
  108739. * - VertexBuffer.UV2Kind
  108740. * - VertexBuffer.UV3Kind
  108741. * - VertexBuffer.UV4Kind
  108742. * - VertexBuffer.UV5Kind
  108743. * - VertexBuffer.UV6Kind
  108744. * - VertexBuffer.ColorKind
  108745. * - VertexBuffer.MatricesIndicesKind
  108746. * - VertexBuffer.MatricesIndicesExtraKind
  108747. * - VertexBuffer.MatricesWeightsKind
  108748. * - VertexBuffer.MatricesWeightsExtraKind
  108749. * @returns a boolean
  108750. */
  108751. isVerticesDataPresent(kind: string): boolean;
  108752. /**
  108753. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108754. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108755. * - VertexBuffer.PositionKind
  108756. * - VertexBuffer.UVKind
  108757. * - VertexBuffer.UV2Kind
  108758. * - VertexBuffer.UV3Kind
  108759. * - VertexBuffer.UV4Kind
  108760. * - VertexBuffer.UV5Kind
  108761. * - VertexBuffer.UV6Kind
  108762. * - VertexBuffer.ColorKind
  108763. * - VertexBuffer.MatricesIndicesKind
  108764. * - VertexBuffer.MatricesIndicesExtraKind
  108765. * - VertexBuffer.MatricesWeightsKind
  108766. * - VertexBuffer.MatricesWeightsExtraKind
  108767. * @returns a boolean
  108768. */
  108769. isVertexBufferUpdatable(kind: string): boolean;
  108770. /**
  108771. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108772. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108773. * - VertexBuffer.PositionKind
  108774. * - VertexBuffer.NormalKind
  108775. * - VertexBuffer.UVKind
  108776. * - VertexBuffer.UV2Kind
  108777. * - VertexBuffer.UV3Kind
  108778. * - VertexBuffer.UV4Kind
  108779. * - VertexBuffer.UV5Kind
  108780. * - VertexBuffer.UV6Kind
  108781. * - VertexBuffer.ColorKind
  108782. * - VertexBuffer.MatricesIndicesKind
  108783. * - VertexBuffer.MatricesIndicesExtraKind
  108784. * - VertexBuffer.MatricesWeightsKind
  108785. * - VertexBuffer.MatricesWeightsExtraKind
  108786. * @returns an array of strings
  108787. */
  108788. getVerticesDataKinds(): string[];
  108789. /**
  108790. * Returns a positive integer : the total number of indices in this mesh geometry.
  108791. * @returns the numner of indices or zero if the mesh has no geometry.
  108792. */
  108793. getTotalIndices(): number;
  108794. /**
  108795. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108796. * @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.
  108797. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108798. * @returns the indices array or an empty array if the mesh has no geometry
  108799. */
  108800. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108801. get isBlocked(): boolean;
  108802. /**
  108803. * Determine if the current mesh is ready to be rendered
  108804. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108805. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108806. * @returns true if all associated assets are ready (material, textures, shaders)
  108807. */
  108808. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108809. /**
  108810. * 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.
  108811. */
  108812. get areNormalsFrozen(): boolean;
  108813. /**
  108814. * 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.
  108815. * @returns the current mesh
  108816. */
  108817. freezeNormals(): Mesh;
  108818. /**
  108819. * 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
  108820. * @returns the current mesh
  108821. */
  108822. unfreezeNormals(): Mesh;
  108823. /**
  108824. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108825. */
  108826. set overridenInstanceCount(count: number);
  108827. /** @hidden */
  108828. _preActivate(): Mesh;
  108829. /** @hidden */
  108830. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108831. /** @hidden */
  108832. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108833. protected _afterComputeWorldMatrix(): void;
  108834. /** @hidden */
  108835. _postActivate(): void;
  108836. /**
  108837. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108838. * This means the mesh underlying bounding box and sphere are recomputed.
  108839. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108840. * @returns the current mesh
  108841. */
  108842. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108843. /** @hidden */
  108844. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108845. /**
  108846. * This function will subdivide the mesh into multiple submeshes
  108847. * @param count defines the expected number of submeshes
  108848. */
  108849. subdivide(count: number): void;
  108850. /**
  108851. * Copy a FloatArray into a specific associated vertex buffer
  108852. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108853. * - VertexBuffer.PositionKind
  108854. * - VertexBuffer.UVKind
  108855. * - VertexBuffer.UV2Kind
  108856. * - VertexBuffer.UV3Kind
  108857. * - VertexBuffer.UV4Kind
  108858. * - VertexBuffer.UV5Kind
  108859. * - VertexBuffer.UV6Kind
  108860. * - VertexBuffer.ColorKind
  108861. * - VertexBuffer.MatricesIndicesKind
  108862. * - VertexBuffer.MatricesIndicesExtraKind
  108863. * - VertexBuffer.MatricesWeightsKind
  108864. * - VertexBuffer.MatricesWeightsExtraKind
  108865. * @param data defines the data source
  108866. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108867. * @param stride defines the data stride size (can be null)
  108868. * @returns the current mesh
  108869. */
  108870. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108871. /**
  108872. * Delete a vertex buffer associated with this mesh
  108873. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108874. * - VertexBuffer.PositionKind
  108875. * - VertexBuffer.UVKind
  108876. * - VertexBuffer.UV2Kind
  108877. * - VertexBuffer.UV3Kind
  108878. * - VertexBuffer.UV4Kind
  108879. * - VertexBuffer.UV5Kind
  108880. * - VertexBuffer.UV6Kind
  108881. * - VertexBuffer.ColorKind
  108882. * - VertexBuffer.MatricesIndicesKind
  108883. * - VertexBuffer.MatricesIndicesExtraKind
  108884. * - VertexBuffer.MatricesWeightsKind
  108885. * - VertexBuffer.MatricesWeightsExtraKind
  108886. */
  108887. removeVerticesData(kind: string): void;
  108888. /**
  108889. * Flags an associated vertex buffer as updatable
  108890. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108891. * - VertexBuffer.PositionKind
  108892. * - VertexBuffer.UVKind
  108893. * - VertexBuffer.UV2Kind
  108894. * - VertexBuffer.UV3Kind
  108895. * - VertexBuffer.UV4Kind
  108896. * - VertexBuffer.UV5Kind
  108897. * - VertexBuffer.UV6Kind
  108898. * - VertexBuffer.ColorKind
  108899. * - VertexBuffer.MatricesIndicesKind
  108900. * - VertexBuffer.MatricesIndicesExtraKind
  108901. * - VertexBuffer.MatricesWeightsKind
  108902. * - VertexBuffer.MatricesWeightsExtraKind
  108903. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108904. */
  108905. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  108906. /**
  108907. * Sets the mesh global Vertex Buffer
  108908. * @param buffer defines the buffer to use
  108909. * @returns the current mesh
  108910. */
  108911. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  108912. /**
  108913. * Update a specific associated vertex buffer
  108914. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108915. * - VertexBuffer.PositionKind
  108916. * - VertexBuffer.UVKind
  108917. * - VertexBuffer.UV2Kind
  108918. * - VertexBuffer.UV3Kind
  108919. * - VertexBuffer.UV4Kind
  108920. * - VertexBuffer.UV5Kind
  108921. * - VertexBuffer.UV6Kind
  108922. * - VertexBuffer.ColorKind
  108923. * - VertexBuffer.MatricesIndicesKind
  108924. * - VertexBuffer.MatricesIndicesExtraKind
  108925. * - VertexBuffer.MatricesWeightsKind
  108926. * - VertexBuffer.MatricesWeightsExtraKind
  108927. * @param data defines the data source
  108928. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  108929. * @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)
  108930. * @returns the current mesh
  108931. */
  108932. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108933. /**
  108934. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  108935. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  108936. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  108937. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  108938. * @returns the current mesh
  108939. */
  108940. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  108941. /**
  108942. * Creates a un-shared specific occurence of the geometry for the mesh.
  108943. * @returns the current mesh
  108944. */
  108945. makeGeometryUnique(): Mesh;
  108946. /**
  108947. * Set the index buffer of this mesh
  108948. * @param indices defines the source data
  108949. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  108950. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  108951. * @returns the current mesh
  108952. */
  108953. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  108954. /**
  108955. * Update the current index buffer
  108956. * @param indices defines the source data
  108957. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108958. * @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)
  108959. * @returns the current mesh
  108960. */
  108961. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108962. /**
  108963. * Invert the geometry to move from a right handed system to a left handed one.
  108964. * @returns the current mesh
  108965. */
  108966. toLeftHanded(): Mesh;
  108967. /** @hidden */
  108968. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  108969. /** @hidden */
  108970. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  108971. /**
  108972. * Registers for this mesh a javascript function called just before the rendering process
  108973. * @param func defines the function to call before rendering this mesh
  108974. * @returns the current mesh
  108975. */
  108976. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108977. /**
  108978. * Disposes a previously registered javascript function called before the rendering
  108979. * @param func defines the function to remove
  108980. * @returns the current mesh
  108981. */
  108982. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108983. /**
  108984. * Registers for this mesh a javascript function called just after the rendering is complete
  108985. * @param func defines the function to call after rendering this mesh
  108986. * @returns the current mesh
  108987. */
  108988. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108989. /**
  108990. * Disposes a previously registered javascript function called after the rendering.
  108991. * @param func defines the function to remove
  108992. * @returns the current mesh
  108993. */
  108994. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108995. /** @hidden */
  108996. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  108997. /** @hidden */
  108998. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  108999. /** @hidden */
  109000. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  109001. /** @hidden */
  109002. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  109003. /** @hidden */
  109004. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  109005. /** @hidden */
  109006. _rebuild(): void;
  109007. /** @hidden */
  109008. _freeze(): void;
  109009. /** @hidden */
  109010. _unFreeze(): void;
  109011. /**
  109012. * 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
  109013. * @param subMesh defines the subMesh to render
  109014. * @param enableAlphaMode defines if alpha mode can be changed
  109015. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  109016. * @returns the current mesh
  109017. */
  109018. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  109019. private _onBeforeDraw;
  109020. /**
  109021. * Renormalize the mesh and patch it up if there are no weights
  109022. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  109023. * However in the case of zero weights then we set just a single influence to 1.
  109024. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  109025. */
  109026. cleanMatrixWeights(): void;
  109027. private normalizeSkinFourWeights;
  109028. private normalizeSkinWeightsAndExtra;
  109029. /**
  109030. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  109031. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  109032. * the user know there was an issue with importing the mesh
  109033. * @returns a validation object with skinned, valid and report string
  109034. */
  109035. validateSkinning(): {
  109036. skinned: boolean;
  109037. valid: boolean;
  109038. report: string;
  109039. };
  109040. /** @hidden */
  109041. _checkDelayState(): Mesh;
  109042. private _queueLoad;
  109043. /**
  109044. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109045. * A mesh is in the frustum if its bounding box intersects the frustum
  109046. * @param frustumPlanes defines the frustum to test
  109047. * @returns true if the mesh is in the frustum planes
  109048. */
  109049. isInFrustum(frustumPlanes: Plane[]): boolean;
  109050. /**
  109051. * Sets the mesh material by the material or multiMaterial `id` property
  109052. * @param id is a string identifying the material or the multiMaterial
  109053. * @returns the current mesh
  109054. */
  109055. setMaterialByID(id: string): Mesh;
  109056. /**
  109057. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  109058. * @returns an array of IAnimatable
  109059. */
  109060. getAnimatables(): IAnimatable[];
  109061. /**
  109062. * Modifies the mesh geometry according to the passed transformation matrix.
  109063. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  109064. * The mesh normals are modified using the same transformation.
  109065. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109066. * @param transform defines the transform matrix to use
  109067. * @see https://doc.babylonjs.com/resources/baking_transformations
  109068. * @returns the current mesh
  109069. */
  109070. bakeTransformIntoVertices(transform: Matrix): Mesh;
  109071. /**
  109072. * Modifies the mesh geometry according to its own current World Matrix.
  109073. * The mesh World Matrix is then reset.
  109074. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  109075. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109076. * @see https://doc.babylonjs.com/resources/baking_transformations
  109077. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  109078. * @returns the current mesh
  109079. */
  109080. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  109081. /** @hidden */
  109082. get _positions(): Nullable<Vector3[]>;
  109083. /** @hidden */
  109084. _resetPointsArrayCache(): Mesh;
  109085. /** @hidden */
  109086. _generatePointsArray(): boolean;
  109087. /**
  109088. * Returns a new Mesh object generated from the current mesh properties.
  109089. * This method must not get confused with createInstance()
  109090. * @param name is a string, the name given to the new mesh
  109091. * @param newParent can be any Node object (default `null`)
  109092. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  109093. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  109094. * @returns a new mesh
  109095. */
  109096. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  109097. /**
  109098. * Releases resources associated with this mesh.
  109099. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109100. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109101. */
  109102. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109103. /** @hidden */
  109104. _disposeInstanceSpecificData(): void;
  109105. /** @hidden */
  109106. _disposeThinInstanceSpecificData(): void;
  109107. /**
  109108. * Modifies the mesh geometry according to a displacement map.
  109109. * 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.
  109110. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109111. * @param url is a string, the URL from the image file is to be downloaded.
  109112. * @param minHeight is the lower limit of the displacement.
  109113. * @param maxHeight is the upper limit of the displacement.
  109114. * @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.
  109115. * @param uvOffset is an optional vector2 used to offset UV.
  109116. * @param uvScale is an optional vector2 used to scale UV.
  109117. * @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.
  109118. * @returns the Mesh.
  109119. */
  109120. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109121. /**
  109122. * Modifies the mesh geometry according to a displacementMap buffer.
  109123. * 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.
  109124. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109125. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  109126. * @param heightMapWidth is the width of the buffer image.
  109127. * @param heightMapHeight is the height of the buffer image.
  109128. * @param minHeight is the lower limit of the displacement.
  109129. * @param maxHeight is the upper limit of the displacement.
  109130. * @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.
  109131. * @param uvOffset is an optional vector2 used to offset UV.
  109132. * @param uvScale is an optional vector2 used to scale UV.
  109133. * @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.
  109134. * @returns the Mesh.
  109135. */
  109136. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109137. /**
  109138. * Modify the mesh to get a flat shading rendering.
  109139. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  109140. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  109141. * @returns current mesh
  109142. */
  109143. convertToFlatShadedMesh(): Mesh;
  109144. /**
  109145. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  109146. * In other words, more vertices, no more indices and a single bigger VBO.
  109147. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  109148. * @returns current mesh
  109149. */
  109150. convertToUnIndexedMesh(): Mesh;
  109151. /**
  109152. * Inverses facet orientations.
  109153. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109154. * @param flipNormals will also inverts the normals
  109155. * @returns current mesh
  109156. */
  109157. flipFaces(flipNormals?: boolean): Mesh;
  109158. /**
  109159. * Increase the number of facets and hence vertices in a mesh
  109160. * Vertex normals are interpolated from existing vertex normals
  109161. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109162. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  109163. */
  109164. increaseVertices(numberPerEdge: number): void;
  109165. /**
  109166. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  109167. * This will undo any application of covertToFlatShadedMesh
  109168. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109169. */
  109170. forceSharedVertices(): void;
  109171. /** @hidden */
  109172. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  109173. /** @hidden */
  109174. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  109175. /**
  109176. * Creates a new InstancedMesh object from the mesh model.
  109177. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109178. * @param name defines the name of the new instance
  109179. * @returns a new InstancedMesh
  109180. */
  109181. createInstance(name: string): InstancedMesh;
  109182. /**
  109183. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  109184. * After this call, all the mesh instances have the same submeshes than the current mesh.
  109185. * @returns the current mesh
  109186. */
  109187. synchronizeInstances(): Mesh;
  109188. /**
  109189. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  109190. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  109191. * This should be used together with the simplification to avoid disappearing triangles.
  109192. * @param successCallback an optional success callback to be called after the optimization finished.
  109193. * @returns the current mesh
  109194. */
  109195. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  109196. /**
  109197. * Serialize current mesh
  109198. * @param serializationObject defines the object which will receive the serialization data
  109199. */
  109200. serialize(serializationObject: any): void;
  109201. /** @hidden */
  109202. _syncGeometryWithMorphTargetManager(): void;
  109203. /** @hidden */
  109204. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  109205. /**
  109206. * Returns a new Mesh object parsed from the source provided.
  109207. * @param parsedMesh is the source
  109208. * @param scene defines the hosting scene
  109209. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  109210. * @returns a new Mesh
  109211. */
  109212. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  109213. /**
  109214. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  109215. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109216. * @param name defines the name of the mesh to create
  109217. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  109218. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  109219. * @param closePath creates a seam between the first and the last points of each path of the path array
  109220. * @param offset is taken in account only if the `pathArray` is containing a single path
  109221. * @param scene defines the hosting scene
  109222. * @param updatable defines if the mesh must be flagged as updatable
  109223. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109224. * @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)
  109225. * @returns a new Mesh
  109226. */
  109227. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109228. /**
  109229. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  109230. * @param name defines the name of the mesh to create
  109231. * @param radius sets the radius size (float) of the polygon (default 0.5)
  109232. * @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
  109233. * @param scene defines the hosting scene
  109234. * @param updatable defines if the mesh must be flagged as updatable
  109235. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109236. * @returns a new Mesh
  109237. */
  109238. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109239. /**
  109240. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  109241. * @param name defines the name of the mesh to create
  109242. * @param size sets the size (float) of each box side (default 1)
  109243. * @param scene defines the hosting scene
  109244. * @param updatable defines if the mesh must be flagged as updatable
  109245. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109246. * @returns a new Mesh
  109247. */
  109248. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109249. /**
  109250. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  109251. * @param name defines the name of the mesh to create
  109252. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109253. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109254. * @param scene defines the hosting scene
  109255. * @param updatable defines if the mesh must be flagged as updatable
  109256. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109257. * @returns a new Mesh
  109258. */
  109259. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109260. /**
  109261. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  109262. * @param name defines the name of the mesh to create
  109263. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109264. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109265. * @param scene defines the hosting scene
  109266. * @returns a new Mesh
  109267. */
  109268. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  109269. /**
  109270. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  109271. * @param name defines the name of the mesh to create
  109272. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  109273. * @param diameterTop set the top cap diameter (floats, default 1)
  109274. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  109275. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  109276. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  109277. * @param scene defines the hosting scene
  109278. * @param updatable defines if the mesh must be flagged as updatable
  109279. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109280. * @returns a new Mesh
  109281. */
  109282. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  109283. /**
  109284. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  109285. * @param name defines the name of the mesh to create
  109286. * @param diameter sets the diameter size (float) of the torus (default 1)
  109287. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  109288. * @param tessellation sets the number of torus sides (postive integer, default 16)
  109289. * @param scene defines the hosting scene
  109290. * @param updatable defines if the mesh must be flagged as updatable
  109291. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109292. * @returns a new Mesh
  109293. */
  109294. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109295. /**
  109296. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  109297. * @param name defines the name of the mesh to create
  109298. * @param radius sets the global radius size (float) of the torus knot (default 2)
  109299. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  109300. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  109301. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  109302. * @param p the number of windings on X axis (positive integers, default 2)
  109303. * @param q the number of windings on Y axis (positive integers, default 3)
  109304. * @param scene defines the hosting scene
  109305. * @param updatable defines if the mesh must be flagged as updatable
  109306. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109307. * @returns a new Mesh
  109308. */
  109309. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109310. /**
  109311. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  109312. * @param name defines the name of the mesh to create
  109313. * @param points is an array successive Vector3
  109314. * @param scene defines the hosting scene
  109315. * @param updatable defines if the mesh must be flagged as updatable
  109316. * @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).
  109317. * @returns a new Mesh
  109318. */
  109319. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  109320. /**
  109321. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  109322. * @param name defines the name of the mesh to create
  109323. * @param points is an array successive Vector3
  109324. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  109325. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109326. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  109327. * @param scene defines the hosting scene
  109328. * @param updatable defines if the mesh must be flagged as updatable
  109329. * @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)
  109330. * @returns a new Mesh
  109331. */
  109332. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  109333. /**
  109334. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  109335. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  109336. * 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.
  109337. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109338. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109339. * Remember you can only change the shape positions, not their number when updating a polygon.
  109340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109341. * @param name defines the name of the mesh to create
  109342. * @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
  109343. * @param scene defines the hosting scene
  109344. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109345. * @param updatable defines if the mesh must be flagged as updatable
  109346. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109347. * @param earcutInjection can be used to inject your own earcut reference
  109348. * @returns a new Mesh
  109349. */
  109350. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109351. /**
  109352. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  109353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  109354. * @param name defines the name of the mesh to create
  109355. * @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
  109356. * @param depth defines the height of extrusion
  109357. * @param scene defines the hosting scene
  109358. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109359. * @param updatable defines if the mesh must be flagged as updatable
  109360. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109361. * @param earcutInjection can be used to inject your own earcut reference
  109362. * @returns a new Mesh
  109363. */
  109364. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109365. /**
  109366. * Creates an extruded shape mesh.
  109367. * 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
  109368. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109370. * @param name defines the name of the mesh to create
  109371. * @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
  109372. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109373. * @param scale is the value to scale the shape
  109374. * @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
  109375. * @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
  109376. * @param scene defines the hosting scene
  109377. * @param updatable defines if the mesh must be flagged as updatable
  109378. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109379. * @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)
  109380. * @returns a new Mesh
  109381. */
  109382. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109383. /**
  109384. * Creates an custom extruded shape mesh.
  109385. * The custom extrusion is a parametric shape.
  109386. * It has no predefined shape. Its final shape will depend on the input parameters.
  109387. * Please consider using the same method from the MeshBuilder class instead
  109388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109389. * @param name defines the name of the mesh to create
  109390. * @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
  109391. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109392. * @param scaleFunction is a custom Javascript function called on each path point
  109393. * @param rotationFunction is a custom Javascript function called on each path point
  109394. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109395. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  109396. * @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
  109397. * @param scene defines the hosting scene
  109398. * @param updatable defines if the mesh must be flagged as updatable
  109399. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109400. * @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)
  109401. * @returns a new Mesh
  109402. */
  109403. 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;
  109404. /**
  109405. * Creates lathe mesh.
  109406. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  109407. * Please consider using the same method from the MeshBuilder class instead
  109408. * @param name defines the name of the mesh to create
  109409. * @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
  109410. * @param radius is the radius value of the lathe
  109411. * @param tessellation is the side number of the lathe.
  109412. * @param scene defines the hosting scene
  109413. * @param updatable defines if the mesh must be flagged as updatable
  109414. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109415. * @returns a new Mesh
  109416. */
  109417. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109418. /**
  109419. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  109420. * @param name defines the name of the mesh to create
  109421. * @param size sets the size (float) of both sides of the plane at once (default 1)
  109422. * @param scene defines the hosting scene
  109423. * @param updatable defines if the mesh must be flagged as updatable
  109424. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109425. * @returns a new Mesh
  109426. */
  109427. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109428. /**
  109429. * Creates a ground mesh.
  109430. * Please consider using the same method from the MeshBuilder class instead
  109431. * @param name defines the name of the mesh to create
  109432. * @param width set the width of the ground
  109433. * @param height set the height of the ground
  109434. * @param subdivisions sets the number of subdivisions per side
  109435. * @param scene defines the hosting scene
  109436. * @param updatable defines if the mesh must be flagged as updatable
  109437. * @returns a new Mesh
  109438. */
  109439. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  109440. /**
  109441. * Creates a tiled ground mesh.
  109442. * Please consider using the same method from the MeshBuilder class instead
  109443. * @param name defines the name of the mesh to create
  109444. * @param xmin set the ground minimum X coordinate
  109445. * @param zmin set the ground minimum Y coordinate
  109446. * @param xmax set the ground maximum X coordinate
  109447. * @param zmax set the ground maximum Z coordinate
  109448. * @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
  109449. * @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
  109450. * @param scene defines the hosting scene
  109451. * @param updatable defines if the mesh must be flagged as updatable
  109452. * @returns a new Mesh
  109453. */
  109454. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  109455. w: number;
  109456. h: number;
  109457. }, precision: {
  109458. w: number;
  109459. h: number;
  109460. }, scene: Scene, updatable?: boolean): Mesh;
  109461. /**
  109462. * Creates a ground mesh from a height map.
  109463. * Please consider using the same method from the MeshBuilder class instead
  109464. * @see https://doc.babylonjs.com/babylon101/height_map
  109465. * @param name defines the name of the mesh to create
  109466. * @param url sets the URL of the height map image resource
  109467. * @param width set the ground width size
  109468. * @param height set the ground height size
  109469. * @param subdivisions sets the number of subdivision per side
  109470. * @param minHeight is the minimum altitude on the ground
  109471. * @param maxHeight is the maximum altitude on the ground
  109472. * @param scene defines the hosting scene
  109473. * @param updatable defines if the mesh must be flagged as updatable
  109474. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  109475. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109476. * @returns a new Mesh
  109477. */
  109478. 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;
  109479. /**
  109480. * Creates a tube mesh.
  109481. * The tube is a parametric shape.
  109482. * It has no predefined shape. Its final shape will depend on the input parameters.
  109483. * Please consider using the same method from the MeshBuilder class instead
  109484. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109485. * @param name defines the name of the mesh to create
  109486. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  109487. * @param radius sets the tube radius size
  109488. * @param tessellation is the number of sides on the tubular surface
  109489. * @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
  109490. * @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
  109491. * @param scene defines the hosting scene
  109492. * @param updatable defines if the mesh must be flagged as updatable
  109493. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109494. * @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)
  109495. * @returns a new Mesh
  109496. */
  109497. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  109498. (i: number, distance: number): number;
  109499. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109500. /**
  109501. * Creates a polyhedron mesh.
  109502. * Please consider using the same method from the MeshBuilder class instead.
  109503. * * 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
  109504. * * The parameter `size` (positive float, default 1) sets the polygon size
  109505. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109506. * * 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`
  109507. * * 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
  109508. * * 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)`)
  109509. * * 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
  109510. * * 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
  109511. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109514. * @param name defines the name of the mesh to create
  109515. * @param options defines the options used to create the mesh
  109516. * @param scene defines the hosting scene
  109517. * @returns a new Mesh
  109518. */
  109519. static CreatePolyhedron(name: string, options: {
  109520. type?: number;
  109521. size?: number;
  109522. sizeX?: number;
  109523. sizeY?: number;
  109524. sizeZ?: number;
  109525. custom?: any;
  109526. faceUV?: Vector4[];
  109527. faceColors?: Color4[];
  109528. updatable?: boolean;
  109529. sideOrientation?: number;
  109530. }, scene: Scene): Mesh;
  109531. /**
  109532. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109533. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109534. * * 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`)
  109535. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109536. * * 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
  109537. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109540. * @param name defines the name of the mesh
  109541. * @param options defines the options used to create the mesh
  109542. * @param scene defines the hosting scene
  109543. * @returns a new Mesh
  109544. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109545. */
  109546. static CreateIcoSphere(name: string, options: {
  109547. radius?: number;
  109548. flat?: boolean;
  109549. subdivisions?: number;
  109550. sideOrientation?: number;
  109551. updatable?: boolean;
  109552. }, scene: Scene): Mesh;
  109553. /**
  109554. * Creates a decal mesh.
  109555. * Please consider using the same method from the MeshBuilder class instead.
  109556. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109557. * @param name defines the name of the mesh
  109558. * @param sourceMesh defines the mesh receiving the decal
  109559. * @param position sets the position of the decal in world coordinates
  109560. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109561. * @param size sets the decal scaling
  109562. * @param angle sets the angle to rotate the decal
  109563. * @returns a new Mesh
  109564. */
  109565. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109566. /** Creates a Capsule Mesh
  109567. * @param name defines the name of the mesh.
  109568. * @param options the constructors options used to shape the mesh.
  109569. * @param scene defines the scene the mesh is scoped to.
  109570. * @returns the capsule mesh
  109571. * @see https://doc.babylonjs.com/how_to/capsule_shape
  109572. */
  109573. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  109574. /**
  109575. * Prepare internal position array for software CPU skinning
  109576. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109577. */
  109578. setPositionsForCPUSkinning(): Float32Array;
  109579. /**
  109580. * Prepare internal normal array for software CPU skinning
  109581. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109582. */
  109583. setNormalsForCPUSkinning(): Float32Array;
  109584. /**
  109585. * Updates the vertex buffer by applying transformation from the bones
  109586. * @param skeleton defines the skeleton to apply to current mesh
  109587. * @returns the current mesh
  109588. */
  109589. applySkeleton(skeleton: Skeleton): Mesh;
  109590. /**
  109591. * 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
  109592. * @param meshes defines the list of meshes to scan
  109593. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109594. */
  109595. static MinMax(meshes: AbstractMesh[]): {
  109596. min: Vector3;
  109597. max: Vector3;
  109598. };
  109599. /**
  109600. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109601. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109602. * @returns a vector3
  109603. */
  109604. static Center(meshesOrMinMaxVector: {
  109605. min: Vector3;
  109606. max: Vector3;
  109607. } | AbstractMesh[]): Vector3;
  109608. /**
  109609. * Merge the array of meshes into a single mesh for performance reasons.
  109610. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109611. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109612. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109613. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109614. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109615. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109616. * @returns a new mesh
  109617. */
  109618. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109619. /** @hidden */
  109620. addInstance(instance: InstancedMesh): void;
  109621. /** @hidden */
  109622. removeInstance(instance: InstancedMesh): void;
  109623. }
  109624. }
  109625. declare module BABYLON {
  109626. /**
  109627. * This is the base class of all the camera used in the application.
  109628. * @see https://doc.babylonjs.com/features/cameras
  109629. */
  109630. export class Camera extends Node {
  109631. /** @hidden */
  109632. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109633. /**
  109634. * This is the default projection mode used by the cameras.
  109635. * It helps recreating a feeling of perspective and better appreciate depth.
  109636. * This is the best way to simulate real life cameras.
  109637. */
  109638. static readonly PERSPECTIVE_CAMERA: number;
  109639. /**
  109640. * This helps creating camera with an orthographic mode.
  109641. * 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.
  109642. */
  109643. static readonly ORTHOGRAPHIC_CAMERA: number;
  109644. /**
  109645. * This is the default FOV mode for perspective cameras.
  109646. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109647. */
  109648. static readonly FOVMODE_VERTICAL_FIXED: number;
  109649. /**
  109650. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109651. */
  109652. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109653. /**
  109654. * This specifies ther is no need for a camera rig.
  109655. * Basically only one eye is rendered corresponding to the camera.
  109656. */
  109657. static readonly RIG_MODE_NONE: number;
  109658. /**
  109659. * Simulates a camera Rig with one blue eye and one red eye.
  109660. * This can be use with 3d blue and red glasses.
  109661. */
  109662. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109663. /**
  109664. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109665. */
  109666. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109667. /**
  109668. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109669. */
  109670. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109671. /**
  109672. * Defines that both eyes of the camera will be rendered over under each other.
  109673. */
  109674. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109675. /**
  109676. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109677. */
  109678. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  109679. /**
  109680. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  109681. */
  109682. static readonly RIG_MODE_VR: number;
  109683. /**
  109684. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  109685. */
  109686. static readonly RIG_MODE_WEBVR: number;
  109687. /**
  109688. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  109689. */
  109690. static readonly RIG_MODE_CUSTOM: number;
  109691. /**
  109692. * Defines if by default attaching controls should prevent the default javascript event to continue.
  109693. */
  109694. static ForceAttachControlToAlwaysPreventDefault: boolean;
  109695. /**
  109696. * Define the input manager associated with the camera.
  109697. */
  109698. inputs: CameraInputsManager<Camera>;
  109699. /** @hidden */
  109700. _position: Vector3;
  109701. /**
  109702. * Define the current local position of the camera in the scene
  109703. */
  109704. get position(): Vector3;
  109705. set position(newPosition: Vector3);
  109706. protected _upVector: Vector3;
  109707. /**
  109708. * The vector the camera should consider as up.
  109709. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  109710. */
  109711. set upVector(vec: Vector3);
  109712. get upVector(): Vector3;
  109713. /**
  109714. * Define the current limit on the left side for an orthographic camera
  109715. * In scene unit
  109716. */
  109717. orthoLeft: Nullable<number>;
  109718. /**
  109719. * Define the current limit on the right side for an orthographic camera
  109720. * In scene unit
  109721. */
  109722. orthoRight: Nullable<number>;
  109723. /**
  109724. * Define the current limit on the bottom side for an orthographic camera
  109725. * In scene unit
  109726. */
  109727. orthoBottom: Nullable<number>;
  109728. /**
  109729. * Define the current limit on the top side for an orthographic camera
  109730. * In scene unit
  109731. */
  109732. orthoTop: Nullable<number>;
  109733. /**
  109734. * Field Of View is set in Radians. (default is 0.8)
  109735. */
  109736. fov: number;
  109737. /**
  109738. * Define the minimum distance the camera can see from.
  109739. * This is important to note that the depth buffer are not infinite and the closer it starts
  109740. * the more your scene might encounter depth fighting issue.
  109741. */
  109742. minZ: number;
  109743. /**
  109744. * Define the maximum distance the camera can see to.
  109745. * This is important to note that the depth buffer are not infinite and the further it end
  109746. * the more your scene might encounter depth fighting issue.
  109747. */
  109748. maxZ: number;
  109749. /**
  109750. * Define the default inertia of the camera.
  109751. * This helps giving a smooth feeling to the camera movement.
  109752. */
  109753. inertia: number;
  109754. /**
  109755. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109756. */
  109757. mode: number;
  109758. /**
  109759. * Define whether the camera is intermediate.
  109760. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109761. */
  109762. isIntermediate: boolean;
  109763. /**
  109764. * Define the viewport of the camera.
  109765. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109766. */
  109767. viewport: Viewport;
  109768. /**
  109769. * Restricts the camera to viewing objects with the same layerMask.
  109770. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109771. */
  109772. layerMask: number;
  109773. /**
  109774. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109775. */
  109776. fovMode: number;
  109777. /**
  109778. * Rig mode of the camera.
  109779. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109780. * This is normally controlled byt the camera themselves as internal use.
  109781. */
  109782. cameraRigMode: number;
  109783. /**
  109784. * Defines the distance between both "eyes" in case of a RIG
  109785. */
  109786. interaxialDistance: number;
  109787. /**
  109788. * Defines if stereoscopic rendering is done side by side or over under.
  109789. */
  109790. isStereoscopicSideBySide: boolean;
  109791. /**
  109792. * 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
  109793. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109794. * else in the scene. (Eg. security camera)
  109795. *
  109796. * 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)
  109797. */
  109798. customRenderTargets: RenderTargetTexture[];
  109799. /**
  109800. * When set, the camera will render to this render target instead of the default canvas
  109801. *
  109802. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109803. */
  109804. outputRenderTarget: Nullable<RenderTargetTexture>;
  109805. /**
  109806. * Observable triggered when the camera view matrix has changed.
  109807. */
  109808. onViewMatrixChangedObservable: Observable<Camera>;
  109809. /**
  109810. * Observable triggered when the camera Projection matrix has changed.
  109811. */
  109812. onProjectionMatrixChangedObservable: Observable<Camera>;
  109813. /**
  109814. * Observable triggered when the inputs have been processed.
  109815. */
  109816. onAfterCheckInputsObservable: Observable<Camera>;
  109817. /**
  109818. * Observable triggered when reset has been called and applied to the camera.
  109819. */
  109820. onRestoreStateObservable: Observable<Camera>;
  109821. /**
  109822. * Is this camera a part of a rig system?
  109823. */
  109824. isRigCamera: boolean;
  109825. /**
  109826. * If isRigCamera set to true this will be set with the parent camera.
  109827. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109828. */
  109829. rigParent?: Camera;
  109830. /** @hidden */
  109831. _cameraRigParams: any;
  109832. /** @hidden */
  109833. _rigCameras: Camera[];
  109834. /** @hidden */
  109835. _rigPostProcess: Nullable<PostProcess>;
  109836. protected _webvrViewMatrix: Matrix;
  109837. /** @hidden */
  109838. _skipRendering: boolean;
  109839. /** @hidden */
  109840. _projectionMatrix: Matrix;
  109841. /** @hidden */
  109842. _postProcesses: Nullable<PostProcess>[];
  109843. /** @hidden */
  109844. _activeMeshes: SmartArray<AbstractMesh>;
  109845. protected _globalPosition: Vector3;
  109846. /** @hidden */
  109847. _computedViewMatrix: Matrix;
  109848. private _doNotComputeProjectionMatrix;
  109849. private _transformMatrix;
  109850. private _frustumPlanes;
  109851. private _refreshFrustumPlanes;
  109852. private _storedFov;
  109853. private _stateStored;
  109854. /**
  109855. * Instantiates a new camera object.
  109856. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109857. * @see https://doc.babylonjs.com/features/cameras
  109858. * @param name Defines the name of the camera in the scene
  109859. * @param position Defines the position of the camera
  109860. * @param scene Defines the scene the camera belongs too
  109861. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109862. */
  109863. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109864. /**
  109865. * Store current camera state (fov, position, etc..)
  109866. * @returns the camera
  109867. */
  109868. storeState(): Camera;
  109869. /**
  109870. * Restores the camera state values if it has been stored. You must call storeState() first
  109871. */
  109872. protected _restoreStateValues(): boolean;
  109873. /**
  109874. * Restored camera state. You must call storeState() first.
  109875. * @returns true if restored and false otherwise
  109876. */
  109877. restoreState(): boolean;
  109878. /**
  109879. * Gets the class name of the camera.
  109880. * @returns the class name
  109881. */
  109882. getClassName(): string;
  109883. /** @hidden */
  109884. readonly _isCamera: boolean;
  109885. /**
  109886. * Gets a string representation of the camera useful for debug purpose.
  109887. * @param fullDetails Defines that a more verboe level of logging is required
  109888. * @returns the string representation
  109889. */
  109890. toString(fullDetails?: boolean): string;
  109891. /**
  109892. * Gets the current world space position of the camera.
  109893. */
  109894. get globalPosition(): Vector3;
  109895. /**
  109896. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109897. * @returns the active meshe list
  109898. */
  109899. getActiveMeshes(): SmartArray<AbstractMesh>;
  109900. /**
  109901. * Check whether a mesh is part of the current active mesh list of the camera
  109902. * @param mesh Defines the mesh to check
  109903. * @returns true if active, false otherwise
  109904. */
  109905. isActiveMesh(mesh: Mesh): boolean;
  109906. /**
  109907. * Is this camera ready to be used/rendered
  109908. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  109909. * @return true if the camera is ready
  109910. */
  109911. isReady(completeCheck?: boolean): boolean;
  109912. /** @hidden */
  109913. _initCache(): void;
  109914. /** @hidden */
  109915. _updateCache(ignoreParentClass?: boolean): void;
  109916. /** @hidden */
  109917. _isSynchronized(): boolean;
  109918. /** @hidden */
  109919. _isSynchronizedViewMatrix(): boolean;
  109920. /** @hidden */
  109921. _isSynchronizedProjectionMatrix(): boolean;
  109922. /**
  109923. * Attach the input controls to a specific dom element to get the input from.
  109924. * @param element Defines the element the controls should be listened from
  109925. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109926. */
  109927. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109928. /**
  109929. * Detach the current controls from the specified dom element.
  109930. * @param element Defines the element to stop listening the inputs from
  109931. */
  109932. detachControl(element: HTMLElement): void;
  109933. /**
  109934. * Update the camera state according to the different inputs gathered during the frame.
  109935. */
  109936. update(): void;
  109937. /** @hidden */
  109938. _checkInputs(): void;
  109939. /** @hidden */
  109940. get rigCameras(): Camera[];
  109941. /**
  109942. * Gets the post process used by the rig cameras
  109943. */
  109944. get rigPostProcess(): Nullable<PostProcess>;
  109945. /**
  109946. * Internal, gets the first post proces.
  109947. * @returns the first post process to be run on this camera.
  109948. */
  109949. _getFirstPostProcess(): Nullable<PostProcess>;
  109950. private _cascadePostProcessesToRigCams;
  109951. /**
  109952. * Attach a post process to the camera.
  109953. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109954. * @param postProcess The post process to attach to the camera
  109955. * @param insertAt The position of the post process in case several of them are in use in the scene
  109956. * @returns the position the post process has been inserted at
  109957. */
  109958. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  109959. /**
  109960. * Detach a post process to the camera.
  109961. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109962. * @param postProcess The post process to detach from the camera
  109963. */
  109964. detachPostProcess(postProcess: PostProcess): void;
  109965. /**
  109966. * Gets the current world matrix of the camera
  109967. */
  109968. getWorldMatrix(): Matrix;
  109969. /** @hidden */
  109970. _getViewMatrix(): Matrix;
  109971. /**
  109972. * Gets the current view matrix of the camera.
  109973. * @param force forces the camera to recompute the matrix without looking at the cached state
  109974. * @returns the view matrix
  109975. */
  109976. getViewMatrix(force?: boolean): Matrix;
  109977. /**
  109978. * Freeze the projection matrix.
  109979. * It will prevent the cache check of the camera projection compute and can speed up perf
  109980. * if no parameter of the camera are meant to change
  109981. * @param projection Defines manually a projection if necessary
  109982. */
  109983. freezeProjectionMatrix(projection?: Matrix): void;
  109984. /**
  109985. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  109986. */
  109987. unfreezeProjectionMatrix(): void;
  109988. /**
  109989. * Gets the current projection matrix of the camera.
  109990. * @param force forces the camera to recompute the matrix without looking at the cached state
  109991. * @returns the projection matrix
  109992. */
  109993. getProjectionMatrix(force?: boolean): Matrix;
  109994. /**
  109995. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  109996. * @returns a Matrix
  109997. */
  109998. getTransformationMatrix(): Matrix;
  109999. private _updateFrustumPlanes;
  110000. /**
  110001. * Checks if a cullable object (mesh...) is in the camera frustum
  110002. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  110003. * @param target The object to check
  110004. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  110005. * @returns true if the object is in frustum otherwise false
  110006. */
  110007. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  110008. /**
  110009. * Checks if a cullable object (mesh...) is in the camera frustum
  110010. * Unlike isInFrustum this cheks the full bounding box
  110011. * @param target The object to check
  110012. * @returns true if the object is in frustum otherwise false
  110013. */
  110014. isCompletelyInFrustum(target: ICullable): boolean;
  110015. /**
  110016. * Gets a ray in the forward direction from the camera.
  110017. * @param length Defines the length of the ray to create
  110018. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110019. * @param origin Defines the start point of the ray which defaults to the camera position
  110020. * @returns the forward ray
  110021. */
  110022. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110023. /**
  110024. * Gets a ray in the forward direction from the camera.
  110025. * @param refRay the ray to (re)use when setting the values
  110026. * @param length Defines the length of the ray to create
  110027. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110028. * @param origin Defines the start point of the ray which defaults to the camera position
  110029. * @returns the forward ray
  110030. */
  110031. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110032. /**
  110033. * Releases resources associated with this node.
  110034. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110035. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110036. */
  110037. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110038. /** @hidden */
  110039. _isLeftCamera: boolean;
  110040. /**
  110041. * Gets the left camera of a rig setup in case of Rigged Camera
  110042. */
  110043. get isLeftCamera(): boolean;
  110044. /** @hidden */
  110045. _isRightCamera: boolean;
  110046. /**
  110047. * Gets the right camera of a rig setup in case of Rigged Camera
  110048. */
  110049. get isRightCamera(): boolean;
  110050. /**
  110051. * Gets the left camera of a rig setup in case of Rigged Camera
  110052. */
  110053. get leftCamera(): Nullable<FreeCamera>;
  110054. /**
  110055. * Gets the right camera of a rig setup in case of Rigged Camera
  110056. */
  110057. get rightCamera(): Nullable<FreeCamera>;
  110058. /**
  110059. * Gets the left camera target of a rig setup in case of Rigged Camera
  110060. * @returns the target position
  110061. */
  110062. getLeftTarget(): Nullable<Vector3>;
  110063. /**
  110064. * Gets the right camera target of a rig setup in case of Rigged Camera
  110065. * @returns the target position
  110066. */
  110067. getRightTarget(): Nullable<Vector3>;
  110068. /**
  110069. * @hidden
  110070. */
  110071. setCameraRigMode(mode: number, rigParams: any): void;
  110072. /** @hidden */
  110073. static _setStereoscopicRigMode(camera: Camera): void;
  110074. /** @hidden */
  110075. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  110076. /** @hidden */
  110077. static _setVRRigMode(camera: Camera, rigParams: any): void;
  110078. /** @hidden */
  110079. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  110080. /** @hidden */
  110081. _getVRProjectionMatrix(): Matrix;
  110082. protected _updateCameraRotationMatrix(): void;
  110083. protected _updateWebVRCameraRotationMatrix(): void;
  110084. /**
  110085. * This function MUST be overwritten by the different WebVR cameras available.
  110086. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110087. * @hidden
  110088. */
  110089. _getWebVRProjectionMatrix(): Matrix;
  110090. /**
  110091. * This function MUST be overwritten by the different WebVR cameras available.
  110092. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110093. * @hidden
  110094. */
  110095. _getWebVRViewMatrix(): Matrix;
  110096. /** @hidden */
  110097. setCameraRigParameter(name: string, value: any): void;
  110098. /**
  110099. * needs to be overridden by children so sub has required properties to be copied
  110100. * @hidden
  110101. */
  110102. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  110103. /**
  110104. * May need to be overridden by children
  110105. * @hidden
  110106. */
  110107. _updateRigCameras(): void;
  110108. /** @hidden */
  110109. _setupInputs(): void;
  110110. /**
  110111. * Serialiaze the camera setup to a json represention
  110112. * @returns the JSON representation
  110113. */
  110114. serialize(): any;
  110115. /**
  110116. * Clones the current camera.
  110117. * @param name The cloned camera name
  110118. * @returns the cloned camera
  110119. */
  110120. clone(name: string): Camera;
  110121. /**
  110122. * Gets the direction of the camera relative to a given local axis.
  110123. * @param localAxis Defines the reference axis to provide a relative direction.
  110124. * @return the direction
  110125. */
  110126. getDirection(localAxis: Vector3): Vector3;
  110127. /**
  110128. * Returns the current camera absolute rotation
  110129. */
  110130. get absoluteRotation(): Quaternion;
  110131. /**
  110132. * Gets the direction of the camera relative to a given local axis into a passed vector.
  110133. * @param localAxis Defines the reference axis to provide a relative direction.
  110134. * @param result Defines the vector to store the result in
  110135. */
  110136. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  110137. /**
  110138. * Gets a camera constructor for a given camera type
  110139. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  110140. * @param name The name of the camera the result will be able to instantiate
  110141. * @param scene The scene the result will construct the camera in
  110142. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  110143. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  110144. * @returns a factory method to construc the camera
  110145. */
  110146. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  110147. /**
  110148. * Compute the world matrix of the camera.
  110149. * @returns the camera world matrix
  110150. */
  110151. computeWorldMatrix(): Matrix;
  110152. /**
  110153. * Parse a JSON and creates the camera from the parsed information
  110154. * @param parsedCamera The JSON to parse
  110155. * @param scene The scene to instantiate the camera in
  110156. * @returns the newly constructed camera
  110157. */
  110158. static Parse(parsedCamera: any, scene: Scene): Camera;
  110159. }
  110160. }
  110161. declare module BABYLON {
  110162. /**
  110163. * Class containing static functions to help procedurally build meshes
  110164. */
  110165. export class DiscBuilder {
  110166. /**
  110167. * Creates a plane polygonal mesh. By default, this is a disc
  110168. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110169. * * 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
  110170. * * 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
  110171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110174. * @param name defines the name of the mesh
  110175. * @param options defines the options used to create the mesh
  110176. * @param scene defines the hosting scene
  110177. * @returns the plane polygonal mesh
  110178. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110179. */
  110180. static CreateDisc(name: string, options: {
  110181. radius?: number;
  110182. tessellation?: number;
  110183. arc?: number;
  110184. updatable?: boolean;
  110185. sideOrientation?: number;
  110186. frontUVs?: Vector4;
  110187. backUVs?: Vector4;
  110188. }, scene?: Nullable<Scene>): Mesh;
  110189. }
  110190. }
  110191. declare module BABYLON {
  110192. /**
  110193. * Options to be used when creating a FresnelParameters.
  110194. */
  110195. export type IFresnelParametersCreationOptions = {
  110196. /**
  110197. * Define the color used on edges (grazing angle)
  110198. */
  110199. leftColor?: Color3;
  110200. /**
  110201. * Define the color used on center
  110202. */
  110203. rightColor?: Color3;
  110204. /**
  110205. * Define bias applied to computed fresnel term
  110206. */
  110207. bias?: number;
  110208. /**
  110209. * Defined the power exponent applied to fresnel term
  110210. */
  110211. power?: number;
  110212. /**
  110213. * Define if the fresnel effect is enable or not.
  110214. */
  110215. isEnabled?: boolean;
  110216. };
  110217. /**
  110218. * Serialized format for FresnelParameters.
  110219. */
  110220. export type IFresnelParametersSerialized = {
  110221. /**
  110222. * Define the color used on edges (grazing angle) [as an array]
  110223. */
  110224. leftColor: number[];
  110225. /**
  110226. * Define the color used on center [as an array]
  110227. */
  110228. rightColor: number[];
  110229. /**
  110230. * Define bias applied to computed fresnel term
  110231. */
  110232. bias: number;
  110233. /**
  110234. * Defined the power exponent applied to fresnel term
  110235. */
  110236. power?: number;
  110237. /**
  110238. * Define if the fresnel effect is enable or not.
  110239. */
  110240. isEnabled: boolean;
  110241. };
  110242. /**
  110243. * This represents all the required information to add a fresnel effect on a material:
  110244. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110245. */
  110246. export class FresnelParameters {
  110247. private _isEnabled;
  110248. /**
  110249. * Define if the fresnel effect is enable or not.
  110250. */
  110251. get isEnabled(): boolean;
  110252. set isEnabled(value: boolean);
  110253. /**
  110254. * Define the color used on edges (grazing angle)
  110255. */
  110256. leftColor: Color3;
  110257. /**
  110258. * Define the color used on center
  110259. */
  110260. rightColor: Color3;
  110261. /**
  110262. * Define bias applied to computed fresnel term
  110263. */
  110264. bias: number;
  110265. /**
  110266. * Defined the power exponent applied to fresnel term
  110267. */
  110268. power: number;
  110269. /**
  110270. * Creates a new FresnelParameters object.
  110271. *
  110272. * @param options provide your own settings to optionally to override defaults
  110273. */
  110274. constructor(options?: IFresnelParametersCreationOptions);
  110275. /**
  110276. * Clones the current fresnel and its valuues
  110277. * @returns a clone fresnel configuration
  110278. */
  110279. clone(): FresnelParameters;
  110280. /**
  110281. * Determines equality between FresnelParameters objects
  110282. * @param otherFresnelParameters defines the second operand
  110283. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  110284. */
  110285. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  110286. /**
  110287. * Serializes the current fresnel parameters to a JSON representation.
  110288. * @return the JSON serialization
  110289. */
  110290. serialize(): IFresnelParametersSerialized;
  110291. /**
  110292. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  110293. * @param parsedFresnelParameters Define the JSON representation
  110294. * @returns the parsed parameters
  110295. */
  110296. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  110297. }
  110298. }
  110299. declare module BABYLON {
  110300. /**
  110301. * This groups all the flags used to control the materials channel.
  110302. */
  110303. export class MaterialFlags {
  110304. private static _DiffuseTextureEnabled;
  110305. /**
  110306. * Are diffuse textures enabled in the application.
  110307. */
  110308. static get DiffuseTextureEnabled(): boolean;
  110309. static set DiffuseTextureEnabled(value: boolean);
  110310. private static _DetailTextureEnabled;
  110311. /**
  110312. * Are detail textures enabled in the application.
  110313. */
  110314. static get DetailTextureEnabled(): boolean;
  110315. static set DetailTextureEnabled(value: boolean);
  110316. private static _AmbientTextureEnabled;
  110317. /**
  110318. * Are ambient textures enabled in the application.
  110319. */
  110320. static get AmbientTextureEnabled(): boolean;
  110321. static set AmbientTextureEnabled(value: boolean);
  110322. private static _OpacityTextureEnabled;
  110323. /**
  110324. * Are opacity textures enabled in the application.
  110325. */
  110326. static get OpacityTextureEnabled(): boolean;
  110327. static set OpacityTextureEnabled(value: boolean);
  110328. private static _ReflectionTextureEnabled;
  110329. /**
  110330. * Are reflection textures enabled in the application.
  110331. */
  110332. static get ReflectionTextureEnabled(): boolean;
  110333. static set ReflectionTextureEnabled(value: boolean);
  110334. private static _EmissiveTextureEnabled;
  110335. /**
  110336. * Are emissive textures enabled in the application.
  110337. */
  110338. static get EmissiveTextureEnabled(): boolean;
  110339. static set EmissiveTextureEnabled(value: boolean);
  110340. private static _SpecularTextureEnabled;
  110341. /**
  110342. * Are specular textures enabled in the application.
  110343. */
  110344. static get SpecularTextureEnabled(): boolean;
  110345. static set SpecularTextureEnabled(value: boolean);
  110346. private static _BumpTextureEnabled;
  110347. /**
  110348. * Are bump textures enabled in the application.
  110349. */
  110350. static get BumpTextureEnabled(): boolean;
  110351. static set BumpTextureEnabled(value: boolean);
  110352. private static _LightmapTextureEnabled;
  110353. /**
  110354. * Are lightmap textures enabled in the application.
  110355. */
  110356. static get LightmapTextureEnabled(): boolean;
  110357. static set LightmapTextureEnabled(value: boolean);
  110358. private static _RefractionTextureEnabled;
  110359. /**
  110360. * Are refraction textures enabled in the application.
  110361. */
  110362. static get RefractionTextureEnabled(): boolean;
  110363. static set RefractionTextureEnabled(value: boolean);
  110364. private static _ColorGradingTextureEnabled;
  110365. /**
  110366. * Are color grading textures enabled in the application.
  110367. */
  110368. static get ColorGradingTextureEnabled(): boolean;
  110369. static set ColorGradingTextureEnabled(value: boolean);
  110370. private static _FresnelEnabled;
  110371. /**
  110372. * Are fresnels enabled in the application.
  110373. */
  110374. static get FresnelEnabled(): boolean;
  110375. static set FresnelEnabled(value: boolean);
  110376. private static _ClearCoatTextureEnabled;
  110377. /**
  110378. * Are clear coat textures enabled in the application.
  110379. */
  110380. static get ClearCoatTextureEnabled(): boolean;
  110381. static set ClearCoatTextureEnabled(value: boolean);
  110382. private static _ClearCoatBumpTextureEnabled;
  110383. /**
  110384. * Are clear coat bump textures enabled in the application.
  110385. */
  110386. static get ClearCoatBumpTextureEnabled(): boolean;
  110387. static set ClearCoatBumpTextureEnabled(value: boolean);
  110388. private static _ClearCoatTintTextureEnabled;
  110389. /**
  110390. * Are clear coat tint textures enabled in the application.
  110391. */
  110392. static get ClearCoatTintTextureEnabled(): boolean;
  110393. static set ClearCoatTintTextureEnabled(value: boolean);
  110394. private static _SheenTextureEnabled;
  110395. /**
  110396. * Are sheen textures enabled in the application.
  110397. */
  110398. static get SheenTextureEnabled(): boolean;
  110399. static set SheenTextureEnabled(value: boolean);
  110400. private static _AnisotropicTextureEnabled;
  110401. /**
  110402. * Are anisotropic textures enabled in the application.
  110403. */
  110404. static get AnisotropicTextureEnabled(): boolean;
  110405. static set AnisotropicTextureEnabled(value: boolean);
  110406. private static _ThicknessTextureEnabled;
  110407. /**
  110408. * Are thickness textures enabled in the application.
  110409. */
  110410. static get ThicknessTextureEnabled(): boolean;
  110411. static set ThicknessTextureEnabled(value: boolean);
  110412. }
  110413. }
  110414. declare module BABYLON {
  110415. /** @hidden */
  110416. export var defaultFragmentDeclaration: {
  110417. name: string;
  110418. shader: string;
  110419. };
  110420. }
  110421. declare module BABYLON {
  110422. /** @hidden */
  110423. export var defaultUboDeclaration: {
  110424. name: string;
  110425. shader: string;
  110426. };
  110427. }
  110428. declare module BABYLON {
  110429. /** @hidden */
  110430. export var prePassDeclaration: {
  110431. name: string;
  110432. shader: string;
  110433. };
  110434. }
  110435. declare module BABYLON {
  110436. /** @hidden */
  110437. export var lightFragmentDeclaration: {
  110438. name: string;
  110439. shader: string;
  110440. };
  110441. }
  110442. declare module BABYLON {
  110443. /** @hidden */
  110444. export var lightUboDeclaration: {
  110445. name: string;
  110446. shader: string;
  110447. };
  110448. }
  110449. declare module BABYLON {
  110450. /** @hidden */
  110451. export var lightsFragmentFunctions: {
  110452. name: string;
  110453. shader: string;
  110454. };
  110455. }
  110456. declare module BABYLON {
  110457. /** @hidden */
  110458. export var shadowsFragmentFunctions: {
  110459. name: string;
  110460. shader: string;
  110461. };
  110462. }
  110463. declare module BABYLON {
  110464. /** @hidden */
  110465. export var fresnelFunction: {
  110466. name: string;
  110467. shader: string;
  110468. };
  110469. }
  110470. declare module BABYLON {
  110471. /** @hidden */
  110472. export var bumpFragmentMainFunctions: {
  110473. name: string;
  110474. shader: string;
  110475. };
  110476. }
  110477. declare module BABYLON {
  110478. /** @hidden */
  110479. export var bumpFragmentFunctions: {
  110480. name: string;
  110481. shader: string;
  110482. };
  110483. }
  110484. declare module BABYLON {
  110485. /** @hidden */
  110486. export var logDepthDeclaration: {
  110487. name: string;
  110488. shader: string;
  110489. };
  110490. }
  110491. declare module BABYLON {
  110492. /** @hidden */
  110493. export var bumpFragment: {
  110494. name: string;
  110495. shader: string;
  110496. };
  110497. }
  110498. declare module BABYLON {
  110499. /** @hidden */
  110500. export var depthPrePass: {
  110501. name: string;
  110502. shader: string;
  110503. };
  110504. }
  110505. declare module BABYLON {
  110506. /** @hidden */
  110507. export var lightFragment: {
  110508. name: string;
  110509. shader: string;
  110510. };
  110511. }
  110512. declare module BABYLON {
  110513. /** @hidden */
  110514. export var logDepthFragment: {
  110515. name: string;
  110516. shader: string;
  110517. };
  110518. }
  110519. declare module BABYLON {
  110520. /** @hidden */
  110521. export var defaultPixelShader: {
  110522. name: string;
  110523. shader: string;
  110524. };
  110525. }
  110526. declare module BABYLON {
  110527. /** @hidden */
  110528. export var defaultVertexDeclaration: {
  110529. name: string;
  110530. shader: string;
  110531. };
  110532. }
  110533. declare module BABYLON {
  110534. /** @hidden */
  110535. export var bumpVertexDeclaration: {
  110536. name: string;
  110537. shader: string;
  110538. };
  110539. }
  110540. declare module BABYLON {
  110541. /** @hidden */
  110542. export var bumpVertex: {
  110543. name: string;
  110544. shader: string;
  110545. };
  110546. }
  110547. declare module BABYLON {
  110548. /** @hidden */
  110549. export var fogVertex: {
  110550. name: string;
  110551. shader: string;
  110552. };
  110553. }
  110554. declare module BABYLON {
  110555. /** @hidden */
  110556. export var shadowsVertex: {
  110557. name: string;
  110558. shader: string;
  110559. };
  110560. }
  110561. declare module BABYLON {
  110562. /** @hidden */
  110563. export var pointCloudVertex: {
  110564. name: string;
  110565. shader: string;
  110566. };
  110567. }
  110568. declare module BABYLON {
  110569. /** @hidden */
  110570. export var logDepthVertex: {
  110571. name: string;
  110572. shader: string;
  110573. };
  110574. }
  110575. declare module BABYLON {
  110576. /** @hidden */
  110577. export var defaultVertexShader: {
  110578. name: string;
  110579. shader: string;
  110580. };
  110581. }
  110582. declare module BABYLON {
  110583. /**
  110584. * @hidden
  110585. */
  110586. export interface IMaterialDetailMapDefines {
  110587. DETAIL: boolean;
  110588. DETAILDIRECTUV: number;
  110589. DETAIL_NORMALBLENDMETHOD: number;
  110590. /** @hidden */
  110591. _areTexturesDirty: boolean;
  110592. }
  110593. /**
  110594. * Define the code related to the detail map parameters of a material
  110595. *
  110596. * Inspired from:
  110597. * 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
  110598. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110599. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110600. */
  110601. export class DetailMapConfiguration {
  110602. private _texture;
  110603. /**
  110604. * The detail texture of the material.
  110605. */
  110606. texture: Nullable<BaseTexture>;
  110607. /**
  110608. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110609. * Bigger values mean stronger blending
  110610. */
  110611. diffuseBlendLevel: number;
  110612. /**
  110613. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110614. * Bigger values mean stronger blending. Only used with PBR materials
  110615. */
  110616. roughnessBlendLevel: number;
  110617. /**
  110618. * Defines how strong the bump effect from the detail map is
  110619. * Bigger values mean stronger effect
  110620. */
  110621. bumpLevel: number;
  110622. private _normalBlendMethod;
  110623. /**
  110624. * The method used to blend the bump and detail normals together
  110625. */
  110626. normalBlendMethod: number;
  110627. private _isEnabled;
  110628. /**
  110629. * Enable or disable the detail map on this material
  110630. */
  110631. isEnabled: boolean;
  110632. /** @hidden */
  110633. private _internalMarkAllSubMeshesAsTexturesDirty;
  110634. /** @hidden */
  110635. _markAllSubMeshesAsTexturesDirty(): void;
  110636. /**
  110637. * Instantiate a new detail map
  110638. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110639. */
  110640. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110641. /**
  110642. * Gets whether the submesh is ready to be used or not.
  110643. * @param defines the list of "defines" to update.
  110644. * @param scene defines the scene the material belongs to.
  110645. * @returns - boolean indicating that the submesh is ready or not.
  110646. */
  110647. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110648. /**
  110649. * Update the defines for detail map usage
  110650. * @param defines the list of "defines" to update.
  110651. * @param scene defines the scene the material belongs to.
  110652. */
  110653. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110654. /**
  110655. * Binds the material data.
  110656. * @param uniformBuffer defines the Uniform buffer to fill in.
  110657. * @param scene defines the scene the material belongs to.
  110658. * @param isFrozen defines whether the material is frozen or not.
  110659. */
  110660. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110661. /**
  110662. * Checks to see if a texture is used in the material.
  110663. * @param texture - Base texture to use.
  110664. * @returns - Boolean specifying if a texture is used in the material.
  110665. */
  110666. hasTexture(texture: BaseTexture): boolean;
  110667. /**
  110668. * Returns an array of the actively used textures.
  110669. * @param activeTextures Array of BaseTextures
  110670. */
  110671. getActiveTextures(activeTextures: BaseTexture[]): void;
  110672. /**
  110673. * Returns the animatable textures.
  110674. * @param animatables Array of animatable textures.
  110675. */
  110676. getAnimatables(animatables: IAnimatable[]): void;
  110677. /**
  110678. * Disposes the resources of the material.
  110679. * @param forceDisposeTextures - Forces the disposal of all textures.
  110680. */
  110681. dispose(forceDisposeTextures?: boolean): void;
  110682. /**
  110683. * Get the current class name useful for serialization or dynamic coding.
  110684. * @returns "DetailMap"
  110685. */
  110686. getClassName(): string;
  110687. /**
  110688. * Add the required uniforms to the current list.
  110689. * @param uniforms defines the current uniform list.
  110690. */
  110691. static AddUniforms(uniforms: string[]): void;
  110692. /**
  110693. * Add the required samplers to the current list.
  110694. * @param samplers defines the current sampler list.
  110695. */
  110696. static AddSamplers(samplers: string[]): void;
  110697. /**
  110698. * Add the required uniforms to the current buffer.
  110699. * @param uniformBuffer defines the current uniform buffer.
  110700. */
  110701. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110702. /**
  110703. * Makes a duplicate of the current instance into another one.
  110704. * @param detailMap define the instance where to copy the info
  110705. */
  110706. copyTo(detailMap: DetailMapConfiguration): void;
  110707. /**
  110708. * Serializes this detail map instance
  110709. * @returns - An object with the serialized instance.
  110710. */
  110711. serialize(): any;
  110712. /**
  110713. * Parses a detail map setting from a serialized object.
  110714. * @param source - Serialized object.
  110715. * @param scene Defines the scene we are parsing for
  110716. * @param rootUrl Defines the rootUrl to load from
  110717. */
  110718. parse(source: any, scene: Scene, rootUrl: string): void;
  110719. }
  110720. }
  110721. declare module BABYLON {
  110722. /** @hidden */
  110723. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110724. MAINUV1: boolean;
  110725. MAINUV2: boolean;
  110726. DIFFUSE: boolean;
  110727. DIFFUSEDIRECTUV: number;
  110728. DETAIL: boolean;
  110729. DETAILDIRECTUV: number;
  110730. DETAIL_NORMALBLENDMETHOD: number;
  110731. AMBIENT: boolean;
  110732. AMBIENTDIRECTUV: number;
  110733. OPACITY: boolean;
  110734. OPACITYDIRECTUV: number;
  110735. OPACITYRGB: boolean;
  110736. REFLECTION: boolean;
  110737. EMISSIVE: boolean;
  110738. EMISSIVEDIRECTUV: number;
  110739. SPECULAR: boolean;
  110740. SPECULARDIRECTUV: number;
  110741. BUMP: boolean;
  110742. BUMPDIRECTUV: number;
  110743. PARALLAX: boolean;
  110744. PARALLAXOCCLUSION: boolean;
  110745. SPECULAROVERALPHA: boolean;
  110746. CLIPPLANE: boolean;
  110747. CLIPPLANE2: boolean;
  110748. CLIPPLANE3: boolean;
  110749. CLIPPLANE4: boolean;
  110750. CLIPPLANE5: boolean;
  110751. CLIPPLANE6: boolean;
  110752. ALPHATEST: boolean;
  110753. DEPTHPREPASS: boolean;
  110754. ALPHAFROMDIFFUSE: boolean;
  110755. POINTSIZE: boolean;
  110756. FOG: boolean;
  110757. SPECULARTERM: boolean;
  110758. DIFFUSEFRESNEL: boolean;
  110759. OPACITYFRESNEL: boolean;
  110760. REFLECTIONFRESNEL: boolean;
  110761. REFRACTIONFRESNEL: boolean;
  110762. EMISSIVEFRESNEL: boolean;
  110763. FRESNEL: boolean;
  110764. NORMAL: boolean;
  110765. UV1: boolean;
  110766. UV2: boolean;
  110767. VERTEXCOLOR: boolean;
  110768. VERTEXALPHA: boolean;
  110769. NUM_BONE_INFLUENCERS: number;
  110770. BonesPerMesh: number;
  110771. BONETEXTURE: boolean;
  110772. INSTANCES: boolean;
  110773. THIN_INSTANCES: boolean;
  110774. GLOSSINESS: boolean;
  110775. ROUGHNESS: boolean;
  110776. EMISSIVEASILLUMINATION: boolean;
  110777. LINKEMISSIVEWITHDIFFUSE: boolean;
  110778. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110779. LIGHTMAP: boolean;
  110780. LIGHTMAPDIRECTUV: number;
  110781. OBJECTSPACE_NORMALMAP: boolean;
  110782. USELIGHTMAPASSHADOWMAP: boolean;
  110783. REFLECTIONMAP_3D: boolean;
  110784. REFLECTIONMAP_SPHERICAL: boolean;
  110785. REFLECTIONMAP_PLANAR: boolean;
  110786. REFLECTIONMAP_CUBIC: boolean;
  110787. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110788. REFLECTIONMAP_PROJECTION: boolean;
  110789. REFLECTIONMAP_SKYBOX: boolean;
  110790. REFLECTIONMAP_EXPLICIT: boolean;
  110791. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110792. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110793. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110794. INVERTCUBICMAP: boolean;
  110795. LOGARITHMICDEPTH: boolean;
  110796. REFRACTION: boolean;
  110797. REFRACTIONMAP_3D: boolean;
  110798. REFLECTIONOVERALPHA: boolean;
  110799. TWOSIDEDLIGHTING: boolean;
  110800. SHADOWFLOAT: boolean;
  110801. MORPHTARGETS: boolean;
  110802. MORPHTARGETS_NORMAL: boolean;
  110803. MORPHTARGETS_TANGENT: boolean;
  110804. MORPHTARGETS_UV: boolean;
  110805. NUM_MORPH_INFLUENCERS: number;
  110806. NONUNIFORMSCALING: boolean;
  110807. PREMULTIPLYALPHA: boolean;
  110808. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110809. ALPHABLEND: boolean;
  110810. PREPASS: boolean;
  110811. PREPASS_IRRADIANCE: boolean;
  110812. PREPASS_IRRADIANCE_INDEX: number;
  110813. PREPASS_ALBEDO: boolean;
  110814. PREPASS_ALBEDO_INDEX: number;
  110815. PREPASS_DEPTHNORMAL: boolean;
  110816. PREPASS_DEPTHNORMAL_INDEX: number;
  110817. SCENE_MRT_COUNT: number;
  110818. RGBDLIGHTMAP: boolean;
  110819. RGBDREFLECTION: boolean;
  110820. RGBDREFRACTION: boolean;
  110821. IMAGEPROCESSING: boolean;
  110822. VIGNETTE: boolean;
  110823. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110824. VIGNETTEBLENDMODEOPAQUE: boolean;
  110825. TONEMAPPING: boolean;
  110826. TONEMAPPING_ACES: boolean;
  110827. CONTRAST: boolean;
  110828. COLORCURVES: boolean;
  110829. COLORGRADING: boolean;
  110830. COLORGRADING3D: boolean;
  110831. SAMPLER3DGREENDEPTH: boolean;
  110832. SAMPLER3DBGRMAP: boolean;
  110833. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110834. MULTIVIEW: boolean;
  110835. /**
  110836. * If the reflection texture on this material is in linear color space
  110837. * @hidden
  110838. */
  110839. IS_REFLECTION_LINEAR: boolean;
  110840. /**
  110841. * If the refraction texture on this material is in linear color space
  110842. * @hidden
  110843. */
  110844. IS_REFRACTION_LINEAR: boolean;
  110845. EXPOSURE: boolean;
  110846. constructor();
  110847. setReflectionMode(modeToEnable: string): void;
  110848. }
  110849. /**
  110850. * This is the default material used in Babylon. It is the best trade off between quality
  110851. * and performances.
  110852. * @see https://doc.babylonjs.com/babylon101/materials
  110853. */
  110854. export class StandardMaterial extends PushMaterial {
  110855. private _diffuseTexture;
  110856. /**
  110857. * The basic texture of the material as viewed under a light.
  110858. */
  110859. diffuseTexture: Nullable<BaseTexture>;
  110860. private _ambientTexture;
  110861. /**
  110862. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110863. */
  110864. ambientTexture: Nullable<BaseTexture>;
  110865. private _opacityTexture;
  110866. /**
  110867. * Define the transparency of the material from a texture.
  110868. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110869. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110870. */
  110871. opacityTexture: Nullable<BaseTexture>;
  110872. private _reflectionTexture;
  110873. /**
  110874. * Define the texture used to display the reflection.
  110875. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110876. */
  110877. reflectionTexture: Nullable<BaseTexture>;
  110878. private _emissiveTexture;
  110879. /**
  110880. * Define texture of the material as if self lit.
  110881. * This will be mixed in the final result even in the absence of light.
  110882. */
  110883. emissiveTexture: Nullable<BaseTexture>;
  110884. private _specularTexture;
  110885. /**
  110886. * Define how the color and intensity of the highlight given by the light in the material.
  110887. */
  110888. specularTexture: Nullable<BaseTexture>;
  110889. private _bumpTexture;
  110890. /**
  110891. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110892. * 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.
  110893. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110894. */
  110895. bumpTexture: Nullable<BaseTexture>;
  110896. private _lightmapTexture;
  110897. /**
  110898. * Complex lighting can be computationally expensive to compute at runtime.
  110899. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110900. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110901. */
  110902. lightmapTexture: Nullable<BaseTexture>;
  110903. private _refractionTexture;
  110904. /**
  110905. * Define the texture used to display the refraction.
  110906. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110907. */
  110908. refractionTexture: Nullable<BaseTexture>;
  110909. /**
  110910. * The color of the material lit by the environmental background lighting.
  110911. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  110912. */
  110913. ambientColor: Color3;
  110914. /**
  110915. * The basic color of the material as viewed under a light.
  110916. */
  110917. diffuseColor: Color3;
  110918. /**
  110919. * Define how the color and intensity of the highlight given by the light in the material.
  110920. */
  110921. specularColor: Color3;
  110922. /**
  110923. * Define the color of the material as if self lit.
  110924. * This will be mixed in the final result even in the absence of light.
  110925. */
  110926. emissiveColor: Color3;
  110927. /**
  110928. * Defines how sharp are the highlights in the material.
  110929. * The bigger the value the sharper giving a more glossy feeling to the result.
  110930. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  110931. */
  110932. specularPower: number;
  110933. private _useAlphaFromDiffuseTexture;
  110934. /**
  110935. * Does the transparency come from the diffuse texture alpha channel.
  110936. */
  110937. useAlphaFromDiffuseTexture: boolean;
  110938. private _useEmissiveAsIllumination;
  110939. /**
  110940. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  110941. */
  110942. useEmissiveAsIllumination: boolean;
  110943. private _linkEmissiveWithDiffuse;
  110944. /**
  110945. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  110946. * the emissive level when the final color is close to one.
  110947. */
  110948. linkEmissiveWithDiffuse: boolean;
  110949. private _useSpecularOverAlpha;
  110950. /**
  110951. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110952. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110953. */
  110954. useSpecularOverAlpha: boolean;
  110955. private _useReflectionOverAlpha;
  110956. /**
  110957. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110958. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110959. */
  110960. useReflectionOverAlpha: boolean;
  110961. private _disableLighting;
  110962. /**
  110963. * Does lights from the scene impacts this material.
  110964. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  110965. */
  110966. disableLighting: boolean;
  110967. private _useObjectSpaceNormalMap;
  110968. /**
  110969. * Allows using an object space normal map (instead of tangent space).
  110970. */
  110971. useObjectSpaceNormalMap: boolean;
  110972. private _useParallax;
  110973. /**
  110974. * Is parallax enabled or not.
  110975. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110976. */
  110977. useParallax: boolean;
  110978. private _useParallaxOcclusion;
  110979. /**
  110980. * Is parallax occlusion enabled or not.
  110981. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  110982. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110983. */
  110984. useParallaxOcclusion: boolean;
  110985. /**
  110986. * 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.
  110987. */
  110988. parallaxScaleBias: number;
  110989. private _roughness;
  110990. /**
  110991. * Helps to define how blurry the reflections should appears in the material.
  110992. */
  110993. roughness: number;
  110994. /**
  110995. * In case of refraction, define the value of the index of refraction.
  110996. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110997. */
  110998. indexOfRefraction: number;
  110999. /**
  111000. * Invert the refraction texture alongside the y axis.
  111001. * It can be useful with procedural textures or probe for instance.
  111002. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111003. */
  111004. invertRefractionY: boolean;
  111005. /**
  111006. * Defines the alpha limits in alpha test mode.
  111007. */
  111008. alphaCutOff: number;
  111009. private _useLightmapAsShadowmap;
  111010. /**
  111011. * In case of light mapping, define whether the map contains light or shadow informations.
  111012. */
  111013. useLightmapAsShadowmap: boolean;
  111014. private _diffuseFresnelParameters;
  111015. /**
  111016. * Define the diffuse fresnel parameters of the material.
  111017. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111018. */
  111019. diffuseFresnelParameters: FresnelParameters;
  111020. private _opacityFresnelParameters;
  111021. /**
  111022. * Define the opacity fresnel parameters of the material.
  111023. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111024. */
  111025. opacityFresnelParameters: FresnelParameters;
  111026. private _reflectionFresnelParameters;
  111027. /**
  111028. * Define the reflection fresnel parameters of the material.
  111029. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111030. */
  111031. reflectionFresnelParameters: FresnelParameters;
  111032. private _refractionFresnelParameters;
  111033. /**
  111034. * Define the refraction fresnel parameters of the material.
  111035. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111036. */
  111037. refractionFresnelParameters: FresnelParameters;
  111038. private _emissiveFresnelParameters;
  111039. /**
  111040. * Define the emissive fresnel parameters of the material.
  111041. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111042. */
  111043. emissiveFresnelParameters: FresnelParameters;
  111044. private _useReflectionFresnelFromSpecular;
  111045. /**
  111046. * If true automatically deducts the fresnels values from the material specularity.
  111047. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111048. */
  111049. useReflectionFresnelFromSpecular: boolean;
  111050. private _useGlossinessFromSpecularMapAlpha;
  111051. /**
  111052. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  111053. */
  111054. useGlossinessFromSpecularMapAlpha: boolean;
  111055. private _maxSimultaneousLights;
  111056. /**
  111057. * Defines the maximum number of lights that can be used in the material
  111058. */
  111059. maxSimultaneousLights: number;
  111060. private _invertNormalMapX;
  111061. /**
  111062. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111063. */
  111064. invertNormalMapX: boolean;
  111065. private _invertNormalMapY;
  111066. /**
  111067. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111068. */
  111069. invertNormalMapY: boolean;
  111070. private _twoSidedLighting;
  111071. /**
  111072. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111073. */
  111074. twoSidedLighting: boolean;
  111075. /**
  111076. * Default configuration related to image processing available in the standard Material.
  111077. */
  111078. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111079. /**
  111080. * Gets the image processing configuration used either in this material.
  111081. */
  111082. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111083. /**
  111084. * Sets the Default image processing configuration used either in the this material.
  111085. *
  111086. * If sets to null, the scene one is in use.
  111087. */
  111088. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  111089. /**
  111090. * Keep track of the image processing observer to allow dispose and replace.
  111091. */
  111092. private _imageProcessingObserver;
  111093. /**
  111094. * Attaches a new image processing configuration to the Standard Material.
  111095. * @param configuration
  111096. */
  111097. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111098. /**
  111099. * Gets wether the color curves effect is enabled.
  111100. */
  111101. get cameraColorCurvesEnabled(): boolean;
  111102. /**
  111103. * Sets wether the color curves effect is enabled.
  111104. */
  111105. set cameraColorCurvesEnabled(value: boolean);
  111106. /**
  111107. * Gets wether the color grading effect is enabled.
  111108. */
  111109. get cameraColorGradingEnabled(): boolean;
  111110. /**
  111111. * Gets wether the color grading effect is enabled.
  111112. */
  111113. set cameraColorGradingEnabled(value: boolean);
  111114. /**
  111115. * Gets wether tonemapping is enabled or not.
  111116. */
  111117. get cameraToneMappingEnabled(): boolean;
  111118. /**
  111119. * Sets wether tonemapping is enabled or not
  111120. */
  111121. set cameraToneMappingEnabled(value: boolean);
  111122. /**
  111123. * The camera exposure used on this material.
  111124. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111125. * This corresponds to a photographic exposure.
  111126. */
  111127. get cameraExposure(): number;
  111128. /**
  111129. * The camera exposure used on this material.
  111130. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111131. * This corresponds to a photographic exposure.
  111132. */
  111133. set cameraExposure(value: number);
  111134. /**
  111135. * Gets The camera contrast used on this material.
  111136. */
  111137. get cameraContrast(): number;
  111138. /**
  111139. * Sets The camera contrast used on this material.
  111140. */
  111141. set cameraContrast(value: number);
  111142. /**
  111143. * Gets the Color Grading 2D Lookup Texture.
  111144. */
  111145. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  111146. /**
  111147. * Sets the Color Grading 2D Lookup Texture.
  111148. */
  111149. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  111150. /**
  111151. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111152. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111153. * 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;
  111154. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111155. */
  111156. get cameraColorCurves(): Nullable<ColorCurves>;
  111157. /**
  111158. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111159. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111160. * 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;
  111161. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111162. */
  111163. set cameraColorCurves(value: Nullable<ColorCurves>);
  111164. /**
  111165. * Can this material render to several textures at once
  111166. */
  111167. get canRenderToMRT(): boolean;
  111168. /**
  111169. * Defines the detail map parameters for the material.
  111170. */
  111171. readonly detailMap: DetailMapConfiguration;
  111172. protected _renderTargets: SmartArray<RenderTargetTexture>;
  111173. protected _worldViewProjectionMatrix: Matrix;
  111174. protected _globalAmbientColor: Color3;
  111175. protected _useLogarithmicDepth: boolean;
  111176. protected _rebuildInParallel: boolean;
  111177. /**
  111178. * Instantiates a new standard material.
  111179. * This is the default material used in Babylon. It is the best trade off between quality
  111180. * and performances.
  111181. * @see https://doc.babylonjs.com/babylon101/materials
  111182. * @param name Define the name of the material in the scene
  111183. * @param scene Define the scene the material belong to
  111184. */
  111185. constructor(name: string, scene: Scene);
  111186. /**
  111187. * Gets a boolean indicating that current material needs to register RTT
  111188. */
  111189. get hasRenderTargetTextures(): boolean;
  111190. /**
  111191. * Gets the current class name of the material e.g. "StandardMaterial"
  111192. * Mainly use in serialization.
  111193. * @returns the class name
  111194. */
  111195. getClassName(): string;
  111196. /**
  111197. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  111198. * You can try switching to logarithmic depth.
  111199. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  111200. */
  111201. get useLogarithmicDepth(): boolean;
  111202. set useLogarithmicDepth(value: boolean);
  111203. /**
  111204. * Specifies if the material will require alpha blending
  111205. * @returns a boolean specifying if alpha blending is needed
  111206. */
  111207. needAlphaBlending(): boolean;
  111208. /**
  111209. * Specifies if this material should be rendered in alpha test mode
  111210. * @returns a boolean specifying if an alpha test is needed.
  111211. */
  111212. needAlphaTesting(): boolean;
  111213. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  111214. /**
  111215. * Get the texture used for alpha test purpose.
  111216. * @returns the diffuse texture in case of the standard material.
  111217. */
  111218. getAlphaTestTexture(): Nullable<BaseTexture>;
  111219. /**
  111220. * Get if the submesh is ready to be used and all its information available.
  111221. * Child classes can use it to update shaders
  111222. * @param mesh defines the mesh to check
  111223. * @param subMesh defines which submesh to check
  111224. * @param useInstances specifies that instances should be used
  111225. * @returns a boolean indicating that the submesh is ready or not
  111226. */
  111227. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111228. /**
  111229. * Builds the material UBO layouts.
  111230. * Used internally during the effect preparation.
  111231. */
  111232. buildUniformLayout(): void;
  111233. /**
  111234. * Unbinds the material from the mesh
  111235. */
  111236. unbind(): void;
  111237. /**
  111238. * Binds the submesh to this material by preparing the effect and shader to draw
  111239. * @param world defines the world transformation matrix
  111240. * @param mesh defines the mesh containing the submesh
  111241. * @param subMesh defines the submesh to bind the material to
  111242. */
  111243. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111244. /**
  111245. * Get the list of animatables in the material.
  111246. * @returns the list of animatables object used in the material
  111247. */
  111248. getAnimatables(): IAnimatable[];
  111249. /**
  111250. * Gets the active textures from the material
  111251. * @returns an array of textures
  111252. */
  111253. getActiveTextures(): BaseTexture[];
  111254. /**
  111255. * Specifies if the material uses a texture
  111256. * @param texture defines the texture to check against the material
  111257. * @returns a boolean specifying if the material uses the texture
  111258. */
  111259. hasTexture(texture: BaseTexture): boolean;
  111260. /**
  111261. * Disposes the material
  111262. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111263. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111264. */
  111265. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111266. /**
  111267. * Makes a duplicate of the material, and gives it a new name
  111268. * @param name defines the new name for the duplicated material
  111269. * @returns the cloned material
  111270. */
  111271. clone(name: string): StandardMaterial;
  111272. /**
  111273. * Serializes this material in a JSON representation
  111274. * @returns the serialized material object
  111275. */
  111276. serialize(): any;
  111277. /**
  111278. * Creates a standard material from parsed material data
  111279. * @param source defines the JSON representation of the material
  111280. * @param scene defines the hosting scene
  111281. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  111282. * @returns a new standard material
  111283. */
  111284. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  111285. /**
  111286. * Are diffuse textures enabled in the application.
  111287. */
  111288. static get DiffuseTextureEnabled(): boolean;
  111289. static set DiffuseTextureEnabled(value: boolean);
  111290. /**
  111291. * Are detail textures enabled in the application.
  111292. */
  111293. static get DetailTextureEnabled(): boolean;
  111294. static set DetailTextureEnabled(value: boolean);
  111295. /**
  111296. * Are ambient textures enabled in the application.
  111297. */
  111298. static get AmbientTextureEnabled(): boolean;
  111299. static set AmbientTextureEnabled(value: boolean);
  111300. /**
  111301. * Are opacity textures enabled in the application.
  111302. */
  111303. static get OpacityTextureEnabled(): boolean;
  111304. static set OpacityTextureEnabled(value: boolean);
  111305. /**
  111306. * Are reflection textures enabled in the application.
  111307. */
  111308. static get ReflectionTextureEnabled(): boolean;
  111309. static set ReflectionTextureEnabled(value: boolean);
  111310. /**
  111311. * Are emissive textures enabled in the application.
  111312. */
  111313. static get EmissiveTextureEnabled(): boolean;
  111314. static set EmissiveTextureEnabled(value: boolean);
  111315. /**
  111316. * Are specular textures enabled in the application.
  111317. */
  111318. static get SpecularTextureEnabled(): boolean;
  111319. static set SpecularTextureEnabled(value: boolean);
  111320. /**
  111321. * Are bump textures enabled in the application.
  111322. */
  111323. static get BumpTextureEnabled(): boolean;
  111324. static set BumpTextureEnabled(value: boolean);
  111325. /**
  111326. * Are lightmap textures enabled in the application.
  111327. */
  111328. static get LightmapTextureEnabled(): boolean;
  111329. static set LightmapTextureEnabled(value: boolean);
  111330. /**
  111331. * Are refraction textures enabled in the application.
  111332. */
  111333. static get RefractionTextureEnabled(): boolean;
  111334. static set RefractionTextureEnabled(value: boolean);
  111335. /**
  111336. * Are color grading textures enabled in the application.
  111337. */
  111338. static get ColorGradingTextureEnabled(): boolean;
  111339. static set ColorGradingTextureEnabled(value: boolean);
  111340. /**
  111341. * Are fresnels enabled in the application.
  111342. */
  111343. static get FresnelEnabled(): boolean;
  111344. static set FresnelEnabled(value: boolean);
  111345. }
  111346. }
  111347. declare module BABYLON {
  111348. /**
  111349. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111350. *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.
  111351. * The SPS is also a particle system. It provides some methods to manage the particles.
  111352. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111353. *
  111354. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  111355. */
  111356. export class SolidParticleSystem implements IDisposable {
  111357. /**
  111358. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111359. * Example : var p = SPS.particles[i];
  111360. */
  111361. particles: SolidParticle[];
  111362. /**
  111363. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111364. */
  111365. nbParticles: number;
  111366. /**
  111367. * If the particles must ever face the camera (default false). Useful for planar particles.
  111368. */
  111369. billboard: boolean;
  111370. /**
  111371. * Recompute normals when adding a shape
  111372. */
  111373. recomputeNormals: boolean;
  111374. /**
  111375. * This a counter ofr your own usage. It's not set by any SPS functions.
  111376. */
  111377. counter: number;
  111378. /**
  111379. * The SPS name. This name is also given to the underlying mesh.
  111380. */
  111381. name: string;
  111382. /**
  111383. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  111384. */
  111385. mesh: Mesh;
  111386. /**
  111387. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111388. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  111389. */
  111390. vars: any;
  111391. /**
  111392. * This array is populated when the SPS is set as 'pickable'.
  111393. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  111394. * Each element of this array is an object `{idx: int, faceId: int}`.
  111395. * `idx` is the picked particle index in the `SPS.particles` array
  111396. * `faceId` is the picked face index counted within this particle.
  111397. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  111398. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  111399. * Use the method SPS.pickedParticle(pickingInfo) instead.
  111400. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111401. */
  111402. pickedParticles: {
  111403. idx: number;
  111404. faceId: number;
  111405. }[];
  111406. /**
  111407. * This array is populated when the SPS is set as 'pickable'
  111408. * Each key of this array is a submesh index.
  111409. * Each element of this array is a second array defined like this :
  111410. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  111411. * Each element of this second array is an object `{idx: int, faceId: int}`.
  111412. * `idx` is the picked particle index in the `SPS.particles` array
  111413. * `faceId` is the picked face index counted within this particle.
  111414. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  111415. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111416. */
  111417. pickedBySubMesh: {
  111418. idx: number;
  111419. faceId: number;
  111420. }[][];
  111421. /**
  111422. * This array is populated when `enableDepthSort` is set to true.
  111423. * Each element of this array is an instance of the class DepthSortedParticle.
  111424. */
  111425. depthSortedParticles: DepthSortedParticle[];
  111426. /**
  111427. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111428. * @hidden
  111429. */
  111430. _bSphereOnly: boolean;
  111431. /**
  111432. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111433. * @hidden
  111434. */
  111435. _bSphereRadiusFactor: number;
  111436. private _scene;
  111437. private _positions;
  111438. private _indices;
  111439. private _normals;
  111440. private _colors;
  111441. private _uvs;
  111442. private _indices32;
  111443. private _positions32;
  111444. private _normals32;
  111445. private _fixedNormal32;
  111446. private _colors32;
  111447. private _uvs32;
  111448. private _index;
  111449. private _updatable;
  111450. private _pickable;
  111451. private _isVisibilityBoxLocked;
  111452. private _alwaysVisible;
  111453. private _depthSort;
  111454. private _expandable;
  111455. private _shapeCounter;
  111456. private _copy;
  111457. private _color;
  111458. private _computeParticleColor;
  111459. private _computeParticleTexture;
  111460. private _computeParticleRotation;
  111461. private _computeParticleVertex;
  111462. private _computeBoundingBox;
  111463. private _depthSortParticles;
  111464. private _camera;
  111465. private _mustUnrotateFixedNormals;
  111466. private _particlesIntersect;
  111467. private _needs32Bits;
  111468. private _isNotBuilt;
  111469. private _lastParticleId;
  111470. private _idxOfId;
  111471. private _multimaterialEnabled;
  111472. private _useModelMaterial;
  111473. private _indicesByMaterial;
  111474. private _materialIndexes;
  111475. private _depthSortFunction;
  111476. private _materialSortFunction;
  111477. private _materials;
  111478. private _multimaterial;
  111479. private _materialIndexesById;
  111480. private _defaultMaterial;
  111481. private _autoUpdateSubMeshes;
  111482. private _tmpVertex;
  111483. /**
  111484. * Creates a SPS (Solid Particle System) object.
  111485. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111486. * @param scene (Scene) is the scene in which the SPS is added.
  111487. * @param options defines the options of the sps e.g.
  111488. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111489. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111490. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111491. * * 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.
  111492. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  111493. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  111494. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111495. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111496. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111497. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111498. */
  111499. constructor(name: string, scene: Scene, options?: {
  111500. updatable?: boolean;
  111501. isPickable?: boolean;
  111502. enableDepthSort?: boolean;
  111503. particleIntersection?: boolean;
  111504. boundingSphereOnly?: boolean;
  111505. bSphereRadiusFactor?: number;
  111506. expandable?: boolean;
  111507. useModelMaterial?: boolean;
  111508. enableMultiMaterial?: boolean;
  111509. });
  111510. /**
  111511. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111512. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111513. * @returns the created mesh
  111514. */
  111515. buildMesh(): Mesh;
  111516. /**
  111517. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111518. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111519. * Thus the particles generated from `digest()` have their property `position` set yet.
  111520. * @param mesh ( Mesh ) is the mesh to be digested
  111521. * @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
  111522. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111523. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111524. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111525. * @returns the current SPS
  111526. */
  111527. digest(mesh: Mesh, options?: {
  111528. facetNb?: number;
  111529. number?: number;
  111530. delta?: number;
  111531. storage?: [];
  111532. }): SolidParticleSystem;
  111533. /**
  111534. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111535. * @hidden
  111536. */
  111537. private _unrotateFixedNormals;
  111538. /**
  111539. * Resets the temporary working copy particle
  111540. * @hidden
  111541. */
  111542. private _resetCopy;
  111543. /**
  111544. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111545. * @param p the current index in the positions array to be updated
  111546. * @param ind the current index in the indices array
  111547. * @param shape a Vector3 array, the shape geometry
  111548. * @param positions the positions array to be updated
  111549. * @param meshInd the shape indices array
  111550. * @param indices the indices array to be updated
  111551. * @param meshUV the shape uv array
  111552. * @param uvs the uv array to be updated
  111553. * @param meshCol the shape color array
  111554. * @param colors the color array to be updated
  111555. * @param meshNor the shape normals array
  111556. * @param normals the normals array to be updated
  111557. * @param idx the particle index
  111558. * @param idxInShape the particle index in its shape
  111559. * @param options the addShape() method passed options
  111560. * @model the particle model
  111561. * @hidden
  111562. */
  111563. private _meshBuilder;
  111564. /**
  111565. * Returns a shape Vector3 array from positions float array
  111566. * @param positions float array
  111567. * @returns a vector3 array
  111568. * @hidden
  111569. */
  111570. private _posToShape;
  111571. /**
  111572. * Returns a shapeUV array from a float uvs (array deep copy)
  111573. * @param uvs as a float array
  111574. * @returns a shapeUV array
  111575. * @hidden
  111576. */
  111577. private _uvsToShapeUV;
  111578. /**
  111579. * Adds a new particle object in the particles array
  111580. * @param idx particle index in particles array
  111581. * @param id particle id
  111582. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111583. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111584. * @param model particle ModelShape object
  111585. * @param shapeId model shape identifier
  111586. * @param idxInShape index of the particle in the current model
  111587. * @param bInfo model bounding info object
  111588. * @param storage target storage array, if any
  111589. * @hidden
  111590. */
  111591. private _addParticle;
  111592. /**
  111593. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111594. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111595. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111596. * @param nb (positive integer) the number of particles to be created from this model
  111597. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111598. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111599. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111600. * @returns the number of shapes in the system
  111601. */
  111602. addShape(mesh: Mesh, nb: number, options?: {
  111603. positionFunction?: any;
  111604. vertexFunction?: any;
  111605. storage?: [];
  111606. }): number;
  111607. /**
  111608. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111609. * @hidden
  111610. */
  111611. private _rebuildParticle;
  111612. /**
  111613. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111614. * @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.
  111615. * @returns the SPS.
  111616. */
  111617. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111618. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111619. * Returns an array with the removed particles.
  111620. * 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.
  111621. * The SPS can't be empty so at least one particle needs to remain in place.
  111622. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111623. * @param start index of the first particle to remove
  111624. * @param end index of the last particle to remove (included)
  111625. * @returns an array populated with the removed particles
  111626. */
  111627. removeParticles(start: number, end: number): SolidParticle[];
  111628. /**
  111629. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111630. * @param solidParticleArray an array populated with Solid Particles objects
  111631. * @returns the SPS
  111632. */
  111633. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111634. /**
  111635. * Creates a new particle and modifies the SPS mesh geometry :
  111636. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111637. * - calls _addParticle() to populate the particle array
  111638. * factorized code from addShape() and insertParticlesFromArray()
  111639. * @param idx particle index in the particles array
  111640. * @param i particle index in its shape
  111641. * @param modelShape particle ModelShape object
  111642. * @param shape shape vertex array
  111643. * @param meshInd shape indices array
  111644. * @param meshUV shape uv array
  111645. * @param meshCol shape color array
  111646. * @param meshNor shape normals array
  111647. * @param bbInfo shape bounding info
  111648. * @param storage target particle storage
  111649. * @options addShape() passed options
  111650. * @hidden
  111651. */
  111652. private _insertNewParticle;
  111653. /**
  111654. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111655. * This method calls `updateParticle()` for each particle of the SPS.
  111656. * For an animated SPS, it is usually called within the render loop.
  111657. * 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.
  111658. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111659. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111660. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111661. * @returns the SPS.
  111662. */
  111663. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  111664. /**
  111665. * Disposes the SPS.
  111666. */
  111667. dispose(): void;
  111668. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  111669. * idx is the particle index in the SPS
  111670. * faceId is the picked face index counted within this particle.
  111671. * Returns null if the pickInfo can't identify a picked particle.
  111672. * @param pickingInfo (PickingInfo object)
  111673. * @returns {idx: number, faceId: number} or null
  111674. */
  111675. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  111676. idx: number;
  111677. faceId: number;
  111678. }>;
  111679. /**
  111680. * Returns a SolidParticle object from its identifier : particle.id
  111681. * @param id (integer) the particle Id
  111682. * @returns the searched particle or null if not found in the SPS.
  111683. */
  111684. getParticleById(id: number): Nullable<SolidParticle>;
  111685. /**
  111686. * Returns a new array populated with the particles having the passed shapeId.
  111687. * @param shapeId (integer) the shape identifier
  111688. * @returns a new solid particle array
  111689. */
  111690. getParticlesByShapeId(shapeId: number): SolidParticle[];
  111691. /**
  111692. * Populates the passed array "ref" with the particles having the passed shapeId.
  111693. * @param shapeId the shape identifier
  111694. * @returns the SPS
  111695. * @param ref
  111696. */
  111697. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  111698. /**
  111699. * Computes the required SubMeshes according the materials assigned to the particles.
  111700. * @returns the solid particle system.
  111701. * Does nothing if called before the SPS mesh is built.
  111702. */
  111703. computeSubMeshes(): SolidParticleSystem;
  111704. /**
  111705. * Sorts the solid particles by material when MultiMaterial is enabled.
  111706. * Updates the indices32 array.
  111707. * Updates the indicesByMaterial array.
  111708. * Updates the mesh indices array.
  111709. * @returns the SPS
  111710. * @hidden
  111711. */
  111712. private _sortParticlesByMaterial;
  111713. /**
  111714. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  111715. * @hidden
  111716. */
  111717. private _setMaterialIndexesById;
  111718. /**
  111719. * Returns an array with unique values of Materials from the passed array
  111720. * @param array the material array to be checked and filtered
  111721. * @hidden
  111722. */
  111723. private _filterUniqueMaterialId;
  111724. /**
  111725. * Sets a new Standard Material as _defaultMaterial if not already set.
  111726. * @hidden
  111727. */
  111728. private _setDefaultMaterial;
  111729. /**
  111730. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111731. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111732. * @returns the SPS.
  111733. */
  111734. refreshVisibleSize(): SolidParticleSystem;
  111735. /**
  111736. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111737. * @param size the size (float) of the visibility box
  111738. * note : this doesn't lock the SPS mesh bounding box.
  111739. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111740. */
  111741. setVisibilityBox(size: number): void;
  111742. /**
  111743. * Gets whether the SPS as always visible or not
  111744. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111745. */
  111746. get isAlwaysVisible(): boolean;
  111747. /**
  111748. * Sets the SPS as always visible or not
  111749. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111750. */
  111751. set isAlwaysVisible(val: boolean);
  111752. /**
  111753. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111754. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111755. */
  111756. set isVisibilityBoxLocked(val: boolean);
  111757. /**
  111758. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111759. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111760. */
  111761. get isVisibilityBoxLocked(): boolean;
  111762. /**
  111763. * Tells to `setParticles()` to compute the particle rotations or not.
  111764. * Default value : true. The SPS is faster when it's set to false.
  111765. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111766. */
  111767. set computeParticleRotation(val: boolean);
  111768. /**
  111769. * Tells to `setParticles()` to compute the particle colors or not.
  111770. * Default value : true. The SPS is faster when it's set to false.
  111771. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111772. */
  111773. set computeParticleColor(val: boolean);
  111774. set computeParticleTexture(val: boolean);
  111775. /**
  111776. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111777. * Default value : false. The SPS is faster when it's set to false.
  111778. * Note : the particle custom vertex positions aren't stored values.
  111779. */
  111780. set computeParticleVertex(val: boolean);
  111781. /**
  111782. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111783. */
  111784. set computeBoundingBox(val: boolean);
  111785. /**
  111786. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111787. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111788. * Default : `true`
  111789. */
  111790. set depthSortParticles(val: boolean);
  111791. /**
  111792. * Gets if `setParticles()` computes the particle rotations or not.
  111793. * Default value : true. The SPS is faster when it's set to false.
  111794. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111795. */
  111796. get computeParticleRotation(): boolean;
  111797. /**
  111798. * Gets if `setParticles()` computes the particle colors or not.
  111799. * Default value : true. The SPS is faster when it's set to false.
  111800. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111801. */
  111802. get computeParticleColor(): boolean;
  111803. /**
  111804. * Gets if `setParticles()` computes the particle textures or not.
  111805. * Default value : true. The SPS is faster when it's set to false.
  111806. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111807. */
  111808. get computeParticleTexture(): boolean;
  111809. /**
  111810. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111811. * Default value : false. The SPS is faster when it's set to false.
  111812. * Note : the particle custom vertex positions aren't stored values.
  111813. */
  111814. get computeParticleVertex(): boolean;
  111815. /**
  111816. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111817. */
  111818. get computeBoundingBox(): boolean;
  111819. /**
  111820. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111821. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111822. * Default : `true`
  111823. */
  111824. get depthSortParticles(): boolean;
  111825. /**
  111826. * Gets if the SPS is created as expandable at construction time.
  111827. * Default : `false`
  111828. */
  111829. get expandable(): boolean;
  111830. /**
  111831. * Gets if the SPS supports the Multi Materials
  111832. */
  111833. get multimaterialEnabled(): boolean;
  111834. /**
  111835. * Gets if the SPS uses the model materials for its own multimaterial.
  111836. */
  111837. get useModelMaterial(): boolean;
  111838. /**
  111839. * The SPS used material array.
  111840. */
  111841. get materials(): Material[];
  111842. /**
  111843. * Sets the SPS MultiMaterial from the passed materials.
  111844. * Note : the passed array is internally copied and not used then by reference.
  111845. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111846. */
  111847. setMultiMaterial(materials: Material[]): void;
  111848. /**
  111849. * The SPS computed multimaterial object
  111850. */
  111851. get multimaterial(): MultiMaterial;
  111852. set multimaterial(mm: MultiMaterial);
  111853. /**
  111854. * If the subMeshes must be updated on the next call to setParticles()
  111855. */
  111856. get autoUpdateSubMeshes(): boolean;
  111857. set autoUpdateSubMeshes(val: boolean);
  111858. /**
  111859. * This function does nothing. It may be overwritten to set all the particle first values.
  111860. * The SPS doesn't call this function, you may have to call it by your own.
  111861. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111862. */
  111863. initParticles(): void;
  111864. /**
  111865. * This function does nothing. It may be overwritten to recycle a particle.
  111866. * The SPS doesn't call this function, you may have to call it by your own.
  111867. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111868. * @param particle The particle to recycle
  111869. * @returns the recycled particle
  111870. */
  111871. recycleParticle(particle: SolidParticle): SolidParticle;
  111872. /**
  111873. * Updates a particle : this function should be overwritten by the user.
  111874. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111875. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111876. * @example : just set a particle position or velocity and recycle conditions
  111877. * @param particle The particle to update
  111878. * @returns the updated particle
  111879. */
  111880. updateParticle(particle: SolidParticle): SolidParticle;
  111881. /**
  111882. * Updates a vertex of a particle : it can be overwritten by the user.
  111883. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111884. * @param particle the current particle
  111885. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111886. * @param pt the index of the current vertex in the particle shape
  111887. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111888. * @example : just set a vertex particle position or color
  111889. * @returns the sps
  111890. */
  111891. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111892. /**
  111893. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111894. * This does nothing and may be overwritten by the user.
  111895. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111896. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111897. * @param update the boolean update value actually passed to setParticles()
  111898. */
  111899. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111900. /**
  111901. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111902. * This will be passed three parameters.
  111903. * This does nothing and may be overwritten by the user.
  111904. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111905. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111906. * @param update the boolean update value actually passed to setParticles()
  111907. */
  111908. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111909. }
  111910. }
  111911. declare module BABYLON {
  111912. /**
  111913. * Represents one particle of a solid particle system.
  111914. */
  111915. export class SolidParticle {
  111916. /**
  111917. * particle global index
  111918. */
  111919. idx: number;
  111920. /**
  111921. * particle identifier
  111922. */
  111923. id: number;
  111924. /**
  111925. * The color of the particle
  111926. */
  111927. color: Nullable<Color4>;
  111928. /**
  111929. * The world space position of the particle.
  111930. */
  111931. position: Vector3;
  111932. /**
  111933. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111934. */
  111935. rotation: Vector3;
  111936. /**
  111937. * The world space rotation quaternion of the particle.
  111938. */
  111939. rotationQuaternion: Nullable<Quaternion>;
  111940. /**
  111941. * The scaling of the particle.
  111942. */
  111943. scaling: Vector3;
  111944. /**
  111945. * The uvs of the particle.
  111946. */
  111947. uvs: Vector4;
  111948. /**
  111949. * The current speed of the particle.
  111950. */
  111951. velocity: Vector3;
  111952. /**
  111953. * The pivot point in the particle local space.
  111954. */
  111955. pivot: Vector3;
  111956. /**
  111957. * Must the particle be translated from its pivot point in its local space ?
  111958. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  111959. * Default : false
  111960. */
  111961. translateFromPivot: boolean;
  111962. /**
  111963. * Is the particle active or not ?
  111964. */
  111965. alive: boolean;
  111966. /**
  111967. * Is the particle visible or not ?
  111968. */
  111969. isVisible: boolean;
  111970. /**
  111971. * Index of this particle in the global "positions" array (Internal use)
  111972. * @hidden
  111973. */
  111974. _pos: number;
  111975. /**
  111976. * @hidden Index of this particle in the global "indices" array (Internal use)
  111977. */
  111978. _ind: number;
  111979. /**
  111980. * @hidden ModelShape of this particle (Internal use)
  111981. */
  111982. _model: ModelShape;
  111983. /**
  111984. * ModelShape id of this particle
  111985. */
  111986. shapeId: number;
  111987. /**
  111988. * Index of the particle in its shape id
  111989. */
  111990. idxInShape: number;
  111991. /**
  111992. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  111993. */
  111994. _modelBoundingInfo: BoundingInfo;
  111995. /**
  111996. * @hidden Particle BoundingInfo object (Internal use)
  111997. */
  111998. _boundingInfo: BoundingInfo;
  111999. /**
  112000. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  112001. */
  112002. _sps: SolidParticleSystem;
  112003. /**
  112004. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  112005. */
  112006. _stillInvisible: boolean;
  112007. /**
  112008. * @hidden Last computed particle rotation matrix
  112009. */
  112010. _rotationMatrix: number[];
  112011. /**
  112012. * Parent particle Id, if any.
  112013. * Default null.
  112014. */
  112015. parentId: Nullable<number>;
  112016. /**
  112017. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  112018. */
  112019. materialIndex: Nullable<number>;
  112020. /**
  112021. * Custom object or properties.
  112022. */
  112023. props: Nullable<any>;
  112024. /**
  112025. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  112026. * The possible values are :
  112027. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112028. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112029. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112030. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112031. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112032. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  112033. * */
  112034. cullingStrategy: number;
  112035. /**
  112036. * @hidden Internal global position in the SPS.
  112037. */
  112038. _globalPosition: Vector3;
  112039. /**
  112040. * Creates a Solid Particle object.
  112041. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  112042. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  112043. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  112044. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  112045. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  112046. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  112047. * @param shapeId (integer) is the model shape identifier in the SPS.
  112048. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  112049. * @param sps defines the sps it is associated to
  112050. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  112051. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  112052. */
  112053. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  112054. /**
  112055. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  112056. * @param target the particle target
  112057. * @returns the current particle
  112058. */
  112059. copyToRef(target: SolidParticle): SolidParticle;
  112060. /**
  112061. * Legacy support, changed scale to scaling
  112062. */
  112063. get scale(): Vector3;
  112064. /**
  112065. * Legacy support, changed scale to scaling
  112066. */
  112067. set scale(scale: Vector3);
  112068. /**
  112069. * Legacy support, changed quaternion to rotationQuaternion
  112070. */
  112071. get quaternion(): Nullable<Quaternion>;
  112072. /**
  112073. * Legacy support, changed quaternion to rotationQuaternion
  112074. */
  112075. set quaternion(q: Nullable<Quaternion>);
  112076. /**
  112077. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  112078. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  112079. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  112080. * @returns true if it intersects
  112081. */
  112082. intersectsMesh(target: Mesh | SolidParticle): boolean;
  112083. /**
  112084. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  112085. * A particle is in the frustum if its bounding box intersects the frustum
  112086. * @param frustumPlanes defines the frustum to test
  112087. * @returns true if the particle is in the frustum planes
  112088. */
  112089. isInFrustum(frustumPlanes: Plane[]): boolean;
  112090. /**
  112091. * get the rotation matrix of the particle
  112092. * @hidden
  112093. */
  112094. getRotationMatrix(m: Matrix): void;
  112095. }
  112096. /**
  112097. * Represents the shape of the model used by one particle of a solid particle system.
  112098. * SPS internal tool, don't use it manually.
  112099. */
  112100. export class ModelShape {
  112101. /**
  112102. * The shape id
  112103. * @hidden
  112104. */
  112105. shapeID: number;
  112106. /**
  112107. * flat array of model positions (internal use)
  112108. * @hidden
  112109. */
  112110. _shape: Vector3[];
  112111. /**
  112112. * flat array of model UVs (internal use)
  112113. * @hidden
  112114. */
  112115. _shapeUV: number[];
  112116. /**
  112117. * color array of the model
  112118. * @hidden
  112119. */
  112120. _shapeColors: number[];
  112121. /**
  112122. * indices array of the model
  112123. * @hidden
  112124. */
  112125. _indices: number[];
  112126. /**
  112127. * normals array of the model
  112128. * @hidden
  112129. */
  112130. _normals: number[];
  112131. /**
  112132. * length of the shape in the model indices array (internal use)
  112133. * @hidden
  112134. */
  112135. _indicesLength: number;
  112136. /**
  112137. * Custom position function (internal use)
  112138. * @hidden
  112139. */
  112140. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  112141. /**
  112142. * Custom vertex function (internal use)
  112143. * @hidden
  112144. */
  112145. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  112146. /**
  112147. * Model material (internal use)
  112148. * @hidden
  112149. */
  112150. _material: Nullable<Material>;
  112151. /**
  112152. * 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.
  112153. * SPS internal tool, don't use it manually.
  112154. * @hidden
  112155. */
  112156. 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>);
  112157. }
  112158. /**
  112159. * Represents a Depth Sorted Particle in the solid particle system.
  112160. * @hidden
  112161. */
  112162. export class DepthSortedParticle {
  112163. /**
  112164. * Particle index
  112165. */
  112166. idx: number;
  112167. /**
  112168. * Index of the particle in the "indices" array
  112169. */
  112170. ind: number;
  112171. /**
  112172. * Length of the particle shape in the "indices" array
  112173. */
  112174. indicesLength: number;
  112175. /**
  112176. * Squared distance from the particle to the camera
  112177. */
  112178. sqDistance: number;
  112179. /**
  112180. * Material index when used with MultiMaterials
  112181. */
  112182. materialIndex: number;
  112183. /**
  112184. * Creates a new sorted particle
  112185. * @param materialIndex
  112186. */
  112187. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  112188. }
  112189. /**
  112190. * Represents a solid particle vertex
  112191. */
  112192. export class SolidParticleVertex {
  112193. /**
  112194. * Vertex position
  112195. */
  112196. position: Vector3;
  112197. /**
  112198. * Vertex color
  112199. */
  112200. color: Color4;
  112201. /**
  112202. * Vertex UV
  112203. */
  112204. uv: Vector2;
  112205. /**
  112206. * Creates a new solid particle vertex
  112207. */
  112208. constructor();
  112209. /** Vertex x coordinate */
  112210. get x(): number;
  112211. set x(val: number);
  112212. /** Vertex y coordinate */
  112213. get y(): number;
  112214. set y(val: number);
  112215. /** Vertex z coordinate */
  112216. get z(): number;
  112217. set z(val: number);
  112218. }
  112219. }
  112220. declare module BABYLON {
  112221. /**
  112222. * @hidden
  112223. */
  112224. export class _MeshCollisionData {
  112225. _checkCollisions: boolean;
  112226. _collisionMask: number;
  112227. _collisionGroup: number;
  112228. _surroundingMeshes: Nullable<AbstractMesh[]>;
  112229. _collider: Nullable<Collider>;
  112230. _oldPositionForCollisions: Vector3;
  112231. _diffPositionForCollisions: Vector3;
  112232. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  112233. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  112234. _collisionResponse: boolean;
  112235. }
  112236. }
  112237. declare module BABYLON {
  112238. /** @hidden */
  112239. class _FacetDataStorage {
  112240. facetPositions: Vector3[];
  112241. facetNormals: Vector3[];
  112242. facetPartitioning: number[][];
  112243. facetNb: number;
  112244. partitioningSubdivisions: number;
  112245. partitioningBBoxRatio: number;
  112246. facetDataEnabled: boolean;
  112247. facetParameters: any;
  112248. bbSize: Vector3;
  112249. subDiv: {
  112250. max: number;
  112251. X: number;
  112252. Y: number;
  112253. Z: number;
  112254. };
  112255. facetDepthSort: boolean;
  112256. facetDepthSortEnabled: boolean;
  112257. depthSortedIndices: IndicesArray;
  112258. depthSortedFacets: {
  112259. ind: number;
  112260. sqDistance: number;
  112261. }[];
  112262. facetDepthSortFunction: (f1: {
  112263. ind: number;
  112264. sqDistance: number;
  112265. }, f2: {
  112266. ind: number;
  112267. sqDistance: number;
  112268. }) => number;
  112269. facetDepthSortFrom: Vector3;
  112270. facetDepthSortOrigin: Vector3;
  112271. invertedMatrix: Matrix;
  112272. }
  112273. /**
  112274. * @hidden
  112275. **/
  112276. class _InternalAbstractMeshDataInfo {
  112277. _hasVertexAlpha: boolean;
  112278. _useVertexColors: boolean;
  112279. _numBoneInfluencers: number;
  112280. _applyFog: boolean;
  112281. _receiveShadows: boolean;
  112282. _facetData: _FacetDataStorage;
  112283. _visibility: number;
  112284. _skeleton: Nullable<Skeleton>;
  112285. _layerMask: number;
  112286. _computeBonesUsingShaders: boolean;
  112287. _isActive: boolean;
  112288. _onlyForInstances: boolean;
  112289. _isActiveIntermediate: boolean;
  112290. _onlyForInstancesIntermediate: boolean;
  112291. _actAsRegularMesh: boolean;
  112292. }
  112293. /**
  112294. * Class used to store all common mesh properties
  112295. */
  112296. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  112297. /** No occlusion */
  112298. static OCCLUSION_TYPE_NONE: number;
  112299. /** Occlusion set to optimisitic */
  112300. static OCCLUSION_TYPE_OPTIMISTIC: number;
  112301. /** Occlusion set to strict */
  112302. static OCCLUSION_TYPE_STRICT: number;
  112303. /** Use an accurante occlusion algorithm */
  112304. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  112305. /** Use a conservative occlusion algorithm */
  112306. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  112307. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  112308. * Test order :
  112309. * Is the bounding sphere outside the frustum ?
  112310. * If not, are the bounding box vertices outside the frustum ?
  112311. * It not, then the cullable object is in the frustum.
  112312. */
  112313. static readonly CULLINGSTRATEGY_STANDARD: number;
  112314. /** Culling strategy : Bounding Sphere Only.
  112315. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  112316. * It's also less accurate than the standard because some not visible objects can still be selected.
  112317. * Test : is the bounding sphere outside the frustum ?
  112318. * If not, then the cullable object is in the frustum.
  112319. */
  112320. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  112321. /** Culling strategy : Optimistic Inclusion.
  112322. * This in an inclusion test first, then the standard exclusion test.
  112323. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  112324. * 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.
  112325. * Anyway, it's as accurate as the standard strategy.
  112326. * Test :
  112327. * Is the cullable object bounding sphere center in the frustum ?
  112328. * If not, apply the default culling strategy.
  112329. */
  112330. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  112331. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  112332. * This in an inclusion test first, then the bounding sphere only exclusion test.
  112333. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  112334. * 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.
  112335. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  112336. * Test :
  112337. * Is the cullable object bounding sphere center in the frustum ?
  112338. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  112339. */
  112340. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  112341. /**
  112342. * No billboard
  112343. */
  112344. static get BILLBOARDMODE_NONE(): number;
  112345. /** Billboard on X axis */
  112346. static get BILLBOARDMODE_X(): number;
  112347. /** Billboard on Y axis */
  112348. static get BILLBOARDMODE_Y(): number;
  112349. /** Billboard on Z axis */
  112350. static get BILLBOARDMODE_Z(): number;
  112351. /** Billboard on all axes */
  112352. static get BILLBOARDMODE_ALL(): number;
  112353. /** Billboard on using position instead of orientation */
  112354. static get BILLBOARDMODE_USE_POSITION(): number;
  112355. /** @hidden */
  112356. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  112357. /**
  112358. * The culling strategy to use to check whether the mesh must be rendered or not.
  112359. * This value can be changed at any time and will be used on the next render mesh selection.
  112360. * The possible values are :
  112361. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112362. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112363. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112364. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112365. * Please read each static variable documentation to get details about the culling process.
  112366. * */
  112367. cullingStrategy: number;
  112368. /**
  112369. * Gets the number of facets in the mesh
  112370. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112371. */
  112372. get facetNb(): number;
  112373. /**
  112374. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  112375. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112376. */
  112377. get partitioningSubdivisions(): number;
  112378. set partitioningSubdivisions(nb: number);
  112379. /**
  112380. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  112381. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  112382. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112383. */
  112384. get partitioningBBoxRatio(): number;
  112385. set partitioningBBoxRatio(ratio: number);
  112386. /**
  112387. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  112388. * Works only for updatable meshes.
  112389. * Doesn't work with multi-materials
  112390. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112391. */
  112392. get mustDepthSortFacets(): boolean;
  112393. set mustDepthSortFacets(sort: boolean);
  112394. /**
  112395. * The location (Vector3) where the facet depth sort must be computed from.
  112396. * By default, the active camera position.
  112397. * Used only when facet depth sort is enabled
  112398. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112399. */
  112400. get facetDepthSortFrom(): Vector3;
  112401. set facetDepthSortFrom(location: Vector3);
  112402. /**
  112403. * gets a boolean indicating if facetData is enabled
  112404. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112405. */
  112406. get isFacetDataEnabled(): boolean;
  112407. /** @hidden */
  112408. _updateNonUniformScalingState(value: boolean): boolean;
  112409. /**
  112410. * An event triggered when this mesh collides with another one
  112411. */
  112412. onCollideObservable: Observable<AbstractMesh>;
  112413. /** Set a function to call when this mesh collides with another one */
  112414. set onCollide(callback: () => void);
  112415. /**
  112416. * An event triggered when the collision's position changes
  112417. */
  112418. onCollisionPositionChangeObservable: Observable<Vector3>;
  112419. /** Set a function to call when the collision's position changes */
  112420. set onCollisionPositionChange(callback: () => void);
  112421. /**
  112422. * An event triggered when material is changed
  112423. */
  112424. onMaterialChangedObservable: Observable<AbstractMesh>;
  112425. /**
  112426. * Gets or sets the orientation for POV movement & rotation
  112427. */
  112428. definedFacingForward: boolean;
  112429. /** @hidden */
  112430. _occlusionQuery: Nullable<WebGLQuery>;
  112431. /** @hidden */
  112432. _renderingGroup: Nullable<RenderingGroup>;
  112433. /**
  112434. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112435. */
  112436. get visibility(): number;
  112437. /**
  112438. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112439. */
  112440. set visibility(value: number);
  112441. /** Gets or sets the alpha index used to sort transparent meshes
  112442. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  112443. */
  112444. alphaIndex: number;
  112445. /**
  112446. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  112447. */
  112448. isVisible: boolean;
  112449. /**
  112450. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  112451. */
  112452. isPickable: boolean;
  112453. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  112454. showSubMeshesBoundingBox: boolean;
  112455. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  112456. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112457. */
  112458. isBlocker: boolean;
  112459. /**
  112460. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  112461. */
  112462. enablePointerMoveEvents: boolean;
  112463. private _renderingGroupId;
  112464. /**
  112465. * Specifies the rendering group id for this mesh (0 by default)
  112466. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  112467. */
  112468. get renderingGroupId(): number;
  112469. set renderingGroupId(value: number);
  112470. private _material;
  112471. /** Gets or sets current material */
  112472. get material(): Nullable<Material>;
  112473. set material(value: Nullable<Material>);
  112474. /**
  112475. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  112476. * @see https://doc.babylonjs.com/babylon101/shadows
  112477. */
  112478. get receiveShadows(): boolean;
  112479. set receiveShadows(value: boolean);
  112480. /** Defines color to use when rendering outline */
  112481. outlineColor: Color3;
  112482. /** Define width to use when rendering outline */
  112483. outlineWidth: number;
  112484. /** Defines color to use when rendering overlay */
  112485. overlayColor: Color3;
  112486. /** Defines alpha to use when rendering overlay */
  112487. overlayAlpha: number;
  112488. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  112489. get hasVertexAlpha(): boolean;
  112490. set hasVertexAlpha(value: boolean);
  112491. /** 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) */
  112492. get useVertexColors(): boolean;
  112493. set useVertexColors(value: boolean);
  112494. /**
  112495. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  112496. */
  112497. get computeBonesUsingShaders(): boolean;
  112498. set computeBonesUsingShaders(value: boolean);
  112499. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  112500. get numBoneInfluencers(): number;
  112501. set numBoneInfluencers(value: number);
  112502. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  112503. get applyFog(): boolean;
  112504. set applyFog(value: boolean);
  112505. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  112506. useOctreeForRenderingSelection: boolean;
  112507. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  112508. useOctreeForPicking: boolean;
  112509. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  112510. useOctreeForCollisions: boolean;
  112511. /**
  112512. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  112513. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  112514. */
  112515. get layerMask(): number;
  112516. set layerMask(value: number);
  112517. /**
  112518. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  112519. */
  112520. alwaysSelectAsActiveMesh: boolean;
  112521. /**
  112522. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  112523. */
  112524. doNotSyncBoundingInfo: boolean;
  112525. /**
  112526. * Gets or sets the current action manager
  112527. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112528. */
  112529. actionManager: Nullable<AbstractActionManager>;
  112530. private _meshCollisionData;
  112531. /**
  112532. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  112533. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112534. */
  112535. ellipsoid: Vector3;
  112536. /**
  112537. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112538. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112539. */
  112540. ellipsoidOffset: Vector3;
  112541. /**
  112542. * Gets or sets a collision mask used to mask collisions (default is -1).
  112543. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112544. */
  112545. get collisionMask(): number;
  112546. set collisionMask(mask: number);
  112547. /**
  112548. * Gets or sets a collision response flag (default is true).
  112549. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112550. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112551. * to respond to the collision.
  112552. */
  112553. get collisionResponse(): boolean;
  112554. set collisionResponse(response: boolean);
  112555. /**
  112556. * Gets or sets the current collision group mask (-1 by default).
  112557. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112558. */
  112559. get collisionGroup(): number;
  112560. set collisionGroup(mask: number);
  112561. /**
  112562. * Gets or sets current surrounding meshes (null by default).
  112563. *
  112564. * By default collision detection is tested against every mesh in the scene.
  112565. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112566. * meshes will be tested for the collision.
  112567. *
  112568. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112569. */
  112570. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112571. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112572. /**
  112573. * Defines edge width used when edgesRenderer is enabled
  112574. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112575. */
  112576. edgesWidth: number;
  112577. /**
  112578. * Defines edge color used when edgesRenderer is enabled
  112579. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112580. */
  112581. edgesColor: Color4;
  112582. /** @hidden */
  112583. _edgesRenderer: Nullable<IEdgesRenderer>;
  112584. /** @hidden */
  112585. _masterMesh: Nullable<AbstractMesh>;
  112586. /** @hidden */
  112587. _boundingInfo: Nullable<BoundingInfo>;
  112588. /** @hidden */
  112589. _renderId: number;
  112590. /**
  112591. * Gets or sets the list of subMeshes
  112592. * @see https://doc.babylonjs.com/how_to/multi_materials
  112593. */
  112594. subMeshes: SubMesh[];
  112595. /** @hidden */
  112596. _intersectionsInProgress: AbstractMesh[];
  112597. /** @hidden */
  112598. _unIndexed: boolean;
  112599. /** @hidden */
  112600. _lightSources: Light[];
  112601. /** Gets the list of lights affecting that mesh */
  112602. get lightSources(): Light[];
  112603. /** @hidden */
  112604. get _positions(): Nullable<Vector3[]>;
  112605. /** @hidden */
  112606. _waitingData: {
  112607. lods: Nullable<any>;
  112608. actions: Nullable<any>;
  112609. freezeWorldMatrix: Nullable<boolean>;
  112610. };
  112611. /** @hidden */
  112612. _bonesTransformMatrices: Nullable<Float32Array>;
  112613. /** @hidden */
  112614. _transformMatrixTexture: Nullable<RawTexture>;
  112615. /**
  112616. * Gets or sets a skeleton to apply skining transformations
  112617. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112618. */
  112619. set skeleton(value: Nullable<Skeleton>);
  112620. get skeleton(): Nullable<Skeleton>;
  112621. /**
  112622. * An event triggered when the mesh is rebuilt.
  112623. */
  112624. onRebuildObservable: Observable<AbstractMesh>;
  112625. /**
  112626. * Creates a new AbstractMesh
  112627. * @param name defines the name of the mesh
  112628. * @param scene defines the hosting scene
  112629. */
  112630. constructor(name: string, scene?: Nullable<Scene>);
  112631. /**
  112632. * Returns the string "AbstractMesh"
  112633. * @returns "AbstractMesh"
  112634. */
  112635. getClassName(): string;
  112636. /**
  112637. * Gets a string representation of the current mesh
  112638. * @param fullDetails defines a boolean indicating if full details must be included
  112639. * @returns a string representation of the current mesh
  112640. */
  112641. toString(fullDetails?: boolean): string;
  112642. /**
  112643. * @hidden
  112644. */
  112645. protected _getEffectiveParent(): Nullable<Node>;
  112646. /** @hidden */
  112647. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112648. /** @hidden */
  112649. _rebuild(): void;
  112650. /** @hidden */
  112651. _resyncLightSources(): void;
  112652. /** @hidden */
  112653. _resyncLightSource(light: Light): void;
  112654. /** @hidden */
  112655. _unBindEffect(): void;
  112656. /** @hidden */
  112657. _removeLightSource(light: Light, dispose: boolean): void;
  112658. private _markSubMeshesAsDirty;
  112659. /** @hidden */
  112660. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  112661. /** @hidden */
  112662. _markSubMeshesAsAttributesDirty(): void;
  112663. /** @hidden */
  112664. _markSubMeshesAsMiscDirty(): void;
  112665. /**
  112666. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  112667. */
  112668. get scaling(): Vector3;
  112669. set scaling(newScaling: Vector3);
  112670. /**
  112671. * Returns true if the mesh is blocked. Implemented by child classes
  112672. */
  112673. get isBlocked(): boolean;
  112674. /**
  112675. * Returns the mesh itself by default. Implemented by child classes
  112676. * @param camera defines the camera to use to pick the right LOD level
  112677. * @returns the currentAbstractMesh
  112678. */
  112679. getLOD(camera: Camera): Nullable<AbstractMesh>;
  112680. /**
  112681. * Returns 0 by default. Implemented by child classes
  112682. * @returns an integer
  112683. */
  112684. getTotalVertices(): number;
  112685. /**
  112686. * Returns a positive integer : the total number of indices in this mesh geometry.
  112687. * @returns the numner of indices or zero if the mesh has no geometry.
  112688. */
  112689. getTotalIndices(): number;
  112690. /**
  112691. * Returns null by default. Implemented by child classes
  112692. * @returns null
  112693. */
  112694. getIndices(): Nullable<IndicesArray>;
  112695. /**
  112696. * Returns the array of the requested vertex data kind. Implemented by child classes
  112697. * @param kind defines the vertex data kind to use
  112698. * @returns null
  112699. */
  112700. getVerticesData(kind: string): Nullable<FloatArray>;
  112701. /**
  112702. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112703. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112704. * Note that a new underlying VertexBuffer object is created each call.
  112705. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112706. * @param kind defines vertex data kind:
  112707. * * VertexBuffer.PositionKind
  112708. * * VertexBuffer.UVKind
  112709. * * VertexBuffer.UV2Kind
  112710. * * VertexBuffer.UV3Kind
  112711. * * VertexBuffer.UV4Kind
  112712. * * VertexBuffer.UV5Kind
  112713. * * VertexBuffer.UV6Kind
  112714. * * VertexBuffer.ColorKind
  112715. * * VertexBuffer.MatricesIndicesKind
  112716. * * VertexBuffer.MatricesIndicesExtraKind
  112717. * * VertexBuffer.MatricesWeightsKind
  112718. * * VertexBuffer.MatricesWeightsExtraKind
  112719. * @param data defines the data source
  112720. * @param updatable defines if the data must be flagged as updatable (or static)
  112721. * @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
  112722. * @returns the current mesh
  112723. */
  112724. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112725. /**
  112726. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112727. * If the mesh has no geometry, it is simply returned as it is.
  112728. * @param kind defines vertex data kind:
  112729. * * VertexBuffer.PositionKind
  112730. * * VertexBuffer.UVKind
  112731. * * VertexBuffer.UV2Kind
  112732. * * VertexBuffer.UV3Kind
  112733. * * VertexBuffer.UV4Kind
  112734. * * VertexBuffer.UV5Kind
  112735. * * VertexBuffer.UV6Kind
  112736. * * VertexBuffer.ColorKind
  112737. * * VertexBuffer.MatricesIndicesKind
  112738. * * VertexBuffer.MatricesIndicesExtraKind
  112739. * * VertexBuffer.MatricesWeightsKind
  112740. * * VertexBuffer.MatricesWeightsExtraKind
  112741. * @param data defines the data source
  112742. * @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
  112743. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112744. * @returns the current mesh
  112745. */
  112746. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112747. /**
  112748. * Sets the mesh indices,
  112749. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112750. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112751. * @param totalVertices Defines the total number of vertices
  112752. * @returns the current mesh
  112753. */
  112754. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112755. /**
  112756. * Gets a boolean indicating if specific vertex data is present
  112757. * @param kind defines the vertex data kind to use
  112758. * @returns true is data kind is present
  112759. */
  112760. isVerticesDataPresent(kind: string): boolean;
  112761. /**
  112762. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112763. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112764. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112765. * @returns a BoundingInfo
  112766. */
  112767. getBoundingInfo(): BoundingInfo;
  112768. /**
  112769. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112770. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112771. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112772. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112773. * @returns the current mesh
  112774. */
  112775. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112776. /**
  112777. * Overwrite the current bounding info
  112778. * @param boundingInfo defines the new bounding info
  112779. * @returns the current mesh
  112780. */
  112781. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112782. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112783. get useBones(): boolean;
  112784. /** @hidden */
  112785. _preActivate(): void;
  112786. /** @hidden */
  112787. _preActivateForIntermediateRendering(renderId: number): void;
  112788. /** @hidden */
  112789. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112790. /** @hidden */
  112791. _postActivate(): void;
  112792. /** @hidden */
  112793. _freeze(): void;
  112794. /** @hidden */
  112795. _unFreeze(): void;
  112796. /**
  112797. * Gets the current world matrix
  112798. * @returns a Matrix
  112799. */
  112800. getWorldMatrix(): Matrix;
  112801. /** @hidden */
  112802. _getWorldMatrixDeterminant(): number;
  112803. /**
  112804. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112805. */
  112806. get isAnInstance(): boolean;
  112807. /**
  112808. * Gets a boolean indicating if this mesh has instances
  112809. */
  112810. get hasInstances(): boolean;
  112811. /**
  112812. * Gets a boolean indicating if this mesh has thin instances
  112813. */
  112814. get hasThinInstances(): boolean;
  112815. /**
  112816. * Perform relative position change from the point of view of behind the front of the mesh.
  112817. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112818. * Supports definition of mesh facing forward or backward
  112819. * @param amountRight defines the distance on the right axis
  112820. * @param amountUp defines the distance on the up axis
  112821. * @param amountForward defines the distance on the forward axis
  112822. * @returns the current mesh
  112823. */
  112824. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112825. /**
  112826. * Calculate relative position change from the point of view of behind the front of the mesh.
  112827. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112828. * Supports definition of mesh facing forward or backward
  112829. * @param amountRight defines the distance on the right axis
  112830. * @param amountUp defines the distance on the up axis
  112831. * @param amountForward defines the distance on the forward axis
  112832. * @returns the new displacement vector
  112833. */
  112834. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112835. /**
  112836. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112837. * Supports definition of mesh facing forward or backward
  112838. * @param flipBack defines the flip
  112839. * @param twirlClockwise defines the twirl
  112840. * @param tiltRight defines the tilt
  112841. * @returns the current mesh
  112842. */
  112843. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112844. /**
  112845. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112846. * Supports definition of mesh facing forward or backward.
  112847. * @param flipBack defines the flip
  112848. * @param twirlClockwise defines the twirl
  112849. * @param tiltRight defines the tilt
  112850. * @returns the new rotation vector
  112851. */
  112852. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112853. /**
  112854. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112855. * This means the mesh underlying bounding box and sphere are recomputed.
  112856. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112857. * @returns the current mesh
  112858. */
  112859. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112860. /** @hidden */
  112861. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112862. /** @hidden */
  112863. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112864. /** @hidden */
  112865. _updateBoundingInfo(): AbstractMesh;
  112866. /** @hidden */
  112867. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112868. /** @hidden */
  112869. protected _afterComputeWorldMatrix(): void;
  112870. /** @hidden */
  112871. get _effectiveMesh(): AbstractMesh;
  112872. /**
  112873. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112874. * A mesh is in the frustum if its bounding box intersects the frustum
  112875. * @param frustumPlanes defines the frustum to test
  112876. * @returns true if the mesh is in the frustum planes
  112877. */
  112878. isInFrustum(frustumPlanes: Plane[]): boolean;
  112879. /**
  112880. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112881. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112882. * @param frustumPlanes defines the frustum to test
  112883. * @returns true if the mesh is completely in the frustum planes
  112884. */
  112885. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112886. /**
  112887. * True if the mesh intersects another mesh or a SolidParticle object
  112888. * @param mesh defines a target mesh or SolidParticle to test
  112889. * @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)
  112890. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112891. * @returns true if there is an intersection
  112892. */
  112893. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112894. /**
  112895. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112896. * @param point defines the point to test
  112897. * @returns true if there is an intersection
  112898. */
  112899. intersectsPoint(point: Vector3): boolean;
  112900. /**
  112901. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112902. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112903. */
  112904. get checkCollisions(): boolean;
  112905. set checkCollisions(collisionEnabled: boolean);
  112906. /**
  112907. * Gets Collider object used to compute collisions (not physics)
  112908. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112909. */
  112910. get collider(): Nullable<Collider>;
  112911. /**
  112912. * Move the mesh using collision engine
  112913. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112914. * @param displacement defines the requested displacement vector
  112915. * @returns the current mesh
  112916. */
  112917. moveWithCollisions(displacement: Vector3): AbstractMesh;
  112918. private _onCollisionPositionChange;
  112919. /** @hidden */
  112920. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  112921. /** @hidden */
  112922. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  112923. /** @hidden */
  112924. _checkCollision(collider: Collider): AbstractMesh;
  112925. /** @hidden */
  112926. _generatePointsArray(): boolean;
  112927. /**
  112928. * Checks if the passed Ray intersects with the mesh
  112929. * @param ray defines the ray to use
  112930. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  112931. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112932. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  112933. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  112934. * @returns the picking info
  112935. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  112936. */
  112937. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  112938. /**
  112939. * Clones the current mesh
  112940. * @param name defines the mesh name
  112941. * @param newParent defines the new mesh parent
  112942. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  112943. * @returns the new mesh
  112944. */
  112945. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  112946. /**
  112947. * Disposes all the submeshes of the current meshnp
  112948. * @returns the current mesh
  112949. */
  112950. releaseSubMeshes(): AbstractMesh;
  112951. /**
  112952. * Releases resources associated with this abstract mesh.
  112953. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112954. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112955. */
  112956. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112957. /**
  112958. * Adds the passed mesh as a child to the current mesh
  112959. * @param mesh defines the child mesh
  112960. * @returns the current mesh
  112961. */
  112962. addChild(mesh: AbstractMesh): AbstractMesh;
  112963. /**
  112964. * Removes the passed mesh from the current mesh children list
  112965. * @param mesh defines the child mesh
  112966. * @returns the current mesh
  112967. */
  112968. removeChild(mesh: AbstractMesh): AbstractMesh;
  112969. /** @hidden */
  112970. private _initFacetData;
  112971. /**
  112972. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  112973. * This method can be called within the render loop.
  112974. * 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
  112975. * @returns the current mesh
  112976. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112977. */
  112978. updateFacetData(): AbstractMesh;
  112979. /**
  112980. * Returns the facetLocalNormals array.
  112981. * The normals are expressed in the mesh local spac
  112982. * @returns an array of Vector3
  112983. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112984. */
  112985. getFacetLocalNormals(): Vector3[];
  112986. /**
  112987. * Returns the facetLocalPositions array.
  112988. * The facet positions are expressed in the mesh local space
  112989. * @returns an array of Vector3
  112990. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112991. */
  112992. getFacetLocalPositions(): Vector3[];
  112993. /**
  112994. * Returns the facetLocalPartioning array
  112995. * @returns an array of array of numbers
  112996. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112997. */
  112998. getFacetLocalPartitioning(): number[][];
  112999. /**
  113000. * Returns the i-th facet position in the world system.
  113001. * This method allocates a new Vector3 per call
  113002. * @param i defines the facet index
  113003. * @returns a new Vector3
  113004. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113005. */
  113006. getFacetPosition(i: number): Vector3;
  113007. /**
  113008. * Sets the reference Vector3 with the i-th facet position in the world system
  113009. * @param i defines the facet index
  113010. * @param ref defines the target vector
  113011. * @returns the current mesh
  113012. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113013. */
  113014. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  113015. /**
  113016. * Returns the i-th facet normal in the world system.
  113017. * This method allocates a new Vector3 per call
  113018. * @param i defines the facet index
  113019. * @returns a new Vector3
  113020. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113021. */
  113022. getFacetNormal(i: number): Vector3;
  113023. /**
  113024. * Sets the reference Vector3 with the i-th facet normal in the world system
  113025. * @param i defines the facet index
  113026. * @param ref defines the target vector
  113027. * @returns the current mesh
  113028. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113029. */
  113030. getFacetNormalToRef(i: number, ref: Vector3): this;
  113031. /**
  113032. * 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)
  113033. * @param x defines x coordinate
  113034. * @param y defines y coordinate
  113035. * @param z defines z coordinate
  113036. * @returns the array of facet indexes
  113037. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113038. */
  113039. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  113040. /**
  113041. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  113042. * @param projected sets as the (x,y,z) world projection on the facet
  113043. * @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
  113044. * @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
  113045. * @param x defines x coordinate
  113046. * @param y defines y coordinate
  113047. * @param z defines z coordinate
  113048. * @returns the face index if found (or null instead)
  113049. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113050. */
  113051. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113052. /**
  113053. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  113054. * @param projected sets as the (x,y,z) local projection on the facet
  113055. * @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
  113056. * @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
  113057. * @param x defines x coordinate
  113058. * @param y defines y coordinate
  113059. * @param z defines z coordinate
  113060. * @returns the face index if found (or null instead)
  113061. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113062. */
  113063. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113064. /**
  113065. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  113066. * @returns the parameters
  113067. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113068. */
  113069. getFacetDataParameters(): any;
  113070. /**
  113071. * Disables the feature FacetData and frees the related memory
  113072. * @returns the current mesh
  113073. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113074. */
  113075. disableFacetData(): AbstractMesh;
  113076. /**
  113077. * Updates the AbstractMesh indices array
  113078. * @param indices defines the data source
  113079. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113080. * @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)
  113081. * @returns the current mesh
  113082. */
  113083. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113084. /**
  113085. * Creates new normals data for the mesh
  113086. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  113087. * @returns the current mesh
  113088. */
  113089. createNormals(updatable: boolean): AbstractMesh;
  113090. /**
  113091. * Align the mesh with a normal
  113092. * @param normal defines the normal to use
  113093. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  113094. * @returns the current mesh
  113095. */
  113096. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  113097. /** @hidden */
  113098. _checkOcclusionQuery(): boolean;
  113099. /**
  113100. * Disables the mesh edge rendering mode
  113101. * @returns the currentAbstractMesh
  113102. */
  113103. disableEdgesRendering(): AbstractMesh;
  113104. /**
  113105. * Enables the edge rendering mode on the mesh.
  113106. * This mode makes the mesh edges visible
  113107. * @param epsilon defines the maximal distance between two angles to detect a face
  113108. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113109. * @returns the currentAbstractMesh
  113110. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113111. */
  113112. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  113113. /**
  113114. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  113115. * @returns an array of particle systems in the scene that use the mesh as an emitter
  113116. */
  113117. getConnectedParticleSystems(): IParticleSystem[];
  113118. }
  113119. }
  113120. declare module BABYLON {
  113121. /**
  113122. * Interface used to define ActionEvent
  113123. */
  113124. export interface IActionEvent {
  113125. /** The mesh or sprite that triggered the action */
  113126. source: any;
  113127. /** The X mouse cursor position at the time of the event */
  113128. pointerX: number;
  113129. /** The Y mouse cursor position at the time of the event */
  113130. pointerY: number;
  113131. /** The mesh that is currently pointed at (can be null) */
  113132. meshUnderPointer: Nullable<AbstractMesh>;
  113133. /** the original (browser) event that triggered the ActionEvent */
  113134. sourceEvent?: any;
  113135. /** additional data for the event */
  113136. additionalData?: any;
  113137. }
  113138. /**
  113139. * ActionEvent is the event being sent when an action is triggered.
  113140. */
  113141. export class ActionEvent implements IActionEvent {
  113142. /** The mesh or sprite that triggered the action */
  113143. source: any;
  113144. /** The X mouse cursor position at the time of the event */
  113145. pointerX: number;
  113146. /** The Y mouse cursor position at the time of the event */
  113147. pointerY: number;
  113148. /** The mesh that is currently pointed at (can be null) */
  113149. meshUnderPointer: Nullable<AbstractMesh>;
  113150. /** the original (browser) event that triggered the ActionEvent */
  113151. sourceEvent?: any;
  113152. /** additional data for the event */
  113153. additionalData?: any;
  113154. /**
  113155. * Creates a new ActionEvent
  113156. * @param source The mesh or sprite that triggered the action
  113157. * @param pointerX The X mouse cursor position at the time of the event
  113158. * @param pointerY The Y mouse cursor position at the time of the event
  113159. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  113160. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  113161. * @param additionalData additional data for the event
  113162. */
  113163. constructor(
  113164. /** The mesh or sprite that triggered the action */
  113165. source: any,
  113166. /** The X mouse cursor position at the time of the event */
  113167. pointerX: number,
  113168. /** The Y mouse cursor position at the time of the event */
  113169. pointerY: number,
  113170. /** The mesh that is currently pointed at (can be null) */
  113171. meshUnderPointer: Nullable<AbstractMesh>,
  113172. /** the original (browser) event that triggered the ActionEvent */
  113173. sourceEvent?: any,
  113174. /** additional data for the event */
  113175. additionalData?: any);
  113176. /**
  113177. * Helper function to auto-create an ActionEvent from a source mesh.
  113178. * @param source The source mesh that triggered the event
  113179. * @param evt The original (browser) event
  113180. * @param additionalData additional data for the event
  113181. * @returns the new ActionEvent
  113182. */
  113183. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  113184. /**
  113185. * Helper function to auto-create an ActionEvent from a source sprite
  113186. * @param source The source sprite that triggered the event
  113187. * @param scene Scene associated with the sprite
  113188. * @param evt The original (browser) event
  113189. * @param additionalData additional data for the event
  113190. * @returns the new ActionEvent
  113191. */
  113192. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  113193. /**
  113194. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  113195. * @param scene the scene where the event occurred
  113196. * @param evt The original (browser) event
  113197. * @returns the new ActionEvent
  113198. */
  113199. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  113200. /**
  113201. * Helper function to auto-create an ActionEvent from a primitive
  113202. * @param prim defines the target primitive
  113203. * @param pointerPos defines the pointer position
  113204. * @param evt The original (browser) event
  113205. * @param additionalData additional data for the event
  113206. * @returns the new ActionEvent
  113207. */
  113208. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  113209. }
  113210. }
  113211. declare module BABYLON {
  113212. /**
  113213. * Abstract class used to decouple action Manager from scene and meshes.
  113214. * Do not instantiate.
  113215. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  113216. */
  113217. export abstract class AbstractActionManager implements IDisposable {
  113218. /** Gets the list of active triggers */
  113219. static Triggers: {
  113220. [key: string]: number;
  113221. };
  113222. /** Gets the cursor to use when hovering items */
  113223. hoverCursor: string;
  113224. /** Gets the list of actions */
  113225. actions: IAction[];
  113226. /**
  113227. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  113228. */
  113229. isRecursive: boolean;
  113230. /**
  113231. * Releases all associated resources
  113232. */
  113233. abstract dispose(): void;
  113234. /**
  113235. * Does this action manager has pointer triggers
  113236. */
  113237. abstract get hasPointerTriggers(): boolean;
  113238. /**
  113239. * Does this action manager has pick triggers
  113240. */
  113241. abstract get hasPickTriggers(): boolean;
  113242. /**
  113243. * Process a specific trigger
  113244. * @param trigger defines the trigger to process
  113245. * @param evt defines the event details to be processed
  113246. */
  113247. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  113248. /**
  113249. * Does this action manager handles actions of any of the given triggers
  113250. * @param triggers defines the triggers to be tested
  113251. * @return a boolean indicating whether one (or more) of the triggers is handled
  113252. */
  113253. abstract hasSpecificTriggers(triggers: number[]): boolean;
  113254. /**
  113255. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  113256. * speed.
  113257. * @param triggerA defines the trigger to be tested
  113258. * @param triggerB defines the trigger to be tested
  113259. * @return a boolean indicating whether one (or more) of the triggers is handled
  113260. */
  113261. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  113262. /**
  113263. * Does this action manager handles actions of a given trigger
  113264. * @param trigger defines the trigger to be tested
  113265. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  113266. * @return whether the trigger is handled
  113267. */
  113268. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  113269. /**
  113270. * Serialize this manager to a JSON object
  113271. * @param name defines the property name to store this manager
  113272. * @returns a JSON representation of this manager
  113273. */
  113274. abstract serialize(name: string): any;
  113275. /**
  113276. * Registers an action to this action manager
  113277. * @param action defines the action to be registered
  113278. * @return the action amended (prepared) after registration
  113279. */
  113280. abstract registerAction(action: IAction): Nullable<IAction>;
  113281. /**
  113282. * Unregisters an action to this action manager
  113283. * @param action defines the action to be unregistered
  113284. * @return a boolean indicating whether the action has been unregistered
  113285. */
  113286. abstract unregisterAction(action: IAction): Boolean;
  113287. /**
  113288. * Does exist one action manager with at least one trigger
  113289. **/
  113290. static get HasTriggers(): boolean;
  113291. /**
  113292. * Does exist one action manager with at least one pick trigger
  113293. **/
  113294. static get HasPickTriggers(): boolean;
  113295. /**
  113296. * Does exist one action manager that handles actions of a given trigger
  113297. * @param trigger defines the trigger to be tested
  113298. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  113299. **/
  113300. static HasSpecificTrigger(trigger: number): boolean;
  113301. }
  113302. }
  113303. declare module BABYLON {
  113304. /**
  113305. * Defines how a node can be built from a string name.
  113306. */
  113307. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  113308. /**
  113309. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  113310. */
  113311. export class Node implements IBehaviorAware<Node> {
  113312. /** @hidden */
  113313. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  113314. private static _NodeConstructors;
  113315. /**
  113316. * Add a new node constructor
  113317. * @param type defines the type name of the node to construct
  113318. * @param constructorFunc defines the constructor function
  113319. */
  113320. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  113321. /**
  113322. * Returns a node constructor based on type name
  113323. * @param type defines the type name
  113324. * @param name defines the new node name
  113325. * @param scene defines the hosting scene
  113326. * @param options defines optional options to transmit to constructors
  113327. * @returns the new constructor or null
  113328. */
  113329. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  113330. /**
  113331. * Gets or sets the name of the node
  113332. */
  113333. name: string;
  113334. /**
  113335. * Gets or sets the id of the node
  113336. */
  113337. id: string;
  113338. /**
  113339. * Gets or sets the unique id of the node
  113340. */
  113341. uniqueId: number;
  113342. /**
  113343. * Gets or sets a string used to store user defined state for the node
  113344. */
  113345. state: string;
  113346. /**
  113347. * Gets or sets an object used to store user defined information for the node
  113348. */
  113349. metadata: any;
  113350. /**
  113351. * For internal use only. Please do not use.
  113352. */
  113353. reservedDataStore: any;
  113354. /**
  113355. * List of inspectable custom properties (used by the Inspector)
  113356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113357. */
  113358. inspectableCustomProperties: IInspectable[];
  113359. private _doNotSerialize;
  113360. /**
  113361. * Gets or sets a boolean used to define if the node must be serialized
  113362. */
  113363. get doNotSerialize(): boolean;
  113364. set doNotSerialize(value: boolean);
  113365. /** @hidden */
  113366. _isDisposed: boolean;
  113367. /**
  113368. * Gets a list of Animations associated with the node
  113369. */
  113370. animations: Animation[];
  113371. protected _ranges: {
  113372. [name: string]: Nullable<AnimationRange>;
  113373. };
  113374. /**
  113375. * Callback raised when the node is ready to be used
  113376. */
  113377. onReady: Nullable<(node: Node) => void>;
  113378. private _isEnabled;
  113379. private _isParentEnabled;
  113380. private _isReady;
  113381. /** @hidden */
  113382. _currentRenderId: number;
  113383. private _parentUpdateId;
  113384. /** @hidden */
  113385. _childUpdateId: number;
  113386. /** @hidden */
  113387. _waitingParentId: Nullable<string>;
  113388. /** @hidden */
  113389. _scene: Scene;
  113390. /** @hidden */
  113391. _cache: any;
  113392. private _parentNode;
  113393. private _children;
  113394. /** @hidden */
  113395. _worldMatrix: Matrix;
  113396. /** @hidden */
  113397. _worldMatrixDeterminant: number;
  113398. /** @hidden */
  113399. _worldMatrixDeterminantIsDirty: boolean;
  113400. /** @hidden */
  113401. private _sceneRootNodesIndex;
  113402. /**
  113403. * Gets a boolean indicating if the node has been disposed
  113404. * @returns true if the node was disposed
  113405. */
  113406. isDisposed(): boolean;
  113407. /**
  113408. * Gets or sets the parent of the node (without keeping the current position in the scene)
  113409. * @see https://doc.babylonjs.com/how_to/parenting
  113410. */
  113411. set parent(parent: Nullable<Node>);
  113412. get parent(): Nullable<Node>;
  113413. /** @hidden */
  113414. _addToSceneRootNodes(): void;
  113415. /** @hidden */
  113416. _removeFromSceneRootNodes(): void;
  113417. private _animationPropertiesOverride;
  113418. /**
  113419. * Gets or sets the animation properties override
  113420. */
  113421. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  113422. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  113423. /**
  113424. * Gets a string identifying the name of the class
  113425. * @returns "Node" string
  113426. */
  113427. getClassName(): string;
  113428. /** @hidden */
  113429. readonly _isNode: boolean;
  113430. /**
  113431. * An event triggered when the mesh is disposed
  113432. */
  113433. onDisposeObservable: Observable<Node>;
  113434. private _onDisposeObserver;
  113435. /**
  113436. * Sets a callback that will be raised when the node will be disposed
  113437. */
  113438. set onDispose(callback: () => void);
  113439. /**
  113440. * Creates a new Node
  113441. * @param name the name and id to be given to this node
  113442. * @param scene the scene this node will be added to
  113443. */
  113444. constructor(name: string, scene?: Nullable<Scene>);
  113445. /**
  113446. * Gets the scene of the node
  113447. * @returns a scene
  113448. */
  113449. getScene(): Scene;
  113450. /**
  113451. * Gets the engine of the node
  113452. * @returns a Engine
  113453. */
  113454. getEngine(): Engine;
  113455. private _behaviors;
  113456. /**
  113457. * Attach a behavior to the node
  113458. * @see https://doc.babylonjs.com/features/behaviour
  113459. * @param behavior defines the behavior to attach
  113460. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  113461. * @returns the current Node
  113462. */
  113463. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  113464. /**
  113465. * Remove an attached behavior
  113466. * @see https://doc.babylonjs.com/features/behaviour
  113467. * @param behavior defines the behavior to attach
  113468. * @returns the current Node
  113469. */
  113470. removeBehavior(behavior: Behavior<Node>): Node;
  113471. /**
  113472. * Gets the list of attached behaviors
  113473. * @see https://doc.babylonjs.com/features/behaviour
  113474. */
  113475. get behaviors(): Behavior<Node>[];
  113476. /**
  113477. * Gets an attached behavior by name
  113478. * @param name defines the name of the behavior to look for
  113479. * @see https://doc.babylonjs.com/features/behaviour
  113480. * @returns null if behavior was not found else the requested behavior
  113481. */
  113482. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  113483. /**
  113484. * Returns the latest update of the World matrix
  113485. * @returns a Matrix
  113486. */
  113487. getWorldMatrix(): Matrix;
  113488. /** @hidden */
  113489. _getWorldMatrixDeterminant(): number;
  113490. /**
  113491. * Returns directly the latest state of the mesh World matrix.
  113492. * A Matrix is returned.
  113493. */
  113494. get worldMatrixFromCache(): Matrix;
  113495. /** @hidden */
  113496. _initCache(): void;
  113497. /** @hidden */
  113498. updateCache(force?: boolean): void;
  113499. /** @hidden */
  113500. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113501. /** @hidden */
  113502. _updateCache(ignoreParentClass?: boolean): void;
  113503. /** @hidden */
  113504. _isSynchronized(): boolean;
  113505. /** @hidden */
  113506. _markSyncedWithParent(): void;
  113507. /** @hidden */
  113508. isSynchronizedWithParent(): boolean;
  113509. /** @hidden */
  113510. isSynchronized(): boolean;
  113511. /**
  113512. * Is this node ready to be used/rendered
  113513. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113514. * @return true if the node is ready
  113515. */
  113516. isReady(completeCheck?: boolean): boolean;
  113517. /**
  113518. * Is this node enabled?
  113519. * 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
  113520. * @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
  113521. * @return whether this node (and its parent) is enabled
  113522. */
  113523. isEnabled(checkAncestors?: boolean): boolean;
  113524. /** @hidden */
  113525. protected _syncParentEnabledState(): void;
  113526. /**
  113527. * Set the enabled state of this node
  113528. * @param value defines the new enabled state
  113529. */
  113530. setEnabled(value: boolean): void;
  113531. /**
  113532. * Is this node a descendant of the given node?
  113533. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  113534. * @param ancestor defines the parent node to inspect
  113535. * @returns a boolean indicating if this node is a descendant of the given node
  113536. */
  113537. isDescendantOf(ancestor: Node): boolean;
  113538. /** @hidden */
  113539. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113540. /**
  113541. * Will return all nodes that have this node as ascendant
  113542. * @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
  113543. * @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
  113544. * @return all children nodes of all types
  113545. */
  113546. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113547. /**
  113548. * Get all child-meshes of this node
  113549. * @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)
  113550. * @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
  113551. * @returns an array of AbstractMesh
  113552. */
  113553. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113554. /**
  113555. * Get all direct children of this node
  113556. * @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
  113557. * @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)
  113558. * @returns an array of Node
  113559. */
  113560. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113561. /** @hidden */
  113562. _setReady(state: boolean): void;
  113563. /**
  113564. * Get an animation by name
  113565. * @param name defines the name of the animation to look for
  113566. * @returns null if not found else the requested animation
  113567. */
  113568. getAnimationByName(name: string): Nullable<Animation>;
  113569. /**
  113570. * Creates an animation range for this node
  113571. * @param name defines the name of the range
  113572. * @param from defines the starting key
  113573. * @param to defines the end key
  113574. */
  113575. createAnimationRange(name: string, from: number, to: number): void;
  113576. /**
  113577. * Delete a specific animation range
  113578. * @param name defines the name of the range to delete
  113579. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113580. */
  113581. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113582. /**
  113583. * Get an animation range by name
  113584. * @param name defines the name of the animation range to look for
  113585. * @returns null if not found else the requested animation range
  113586. */
  113587. getAnimationRange(name: string): Nullable<AnimationRange>;
  113588. /**
  113589. * Gets the list of all animation ranges defined on this node
  113590. * @returns an array
  113591. */
  113592. getAnimationRanges(): Nullable<AnimationRange>[];
  113593. /**
  113594. * Will start the animation sequence
  113595. * @param name defines the range frames for animation sequence
  113596. * @param loop defines if the animation should loop (false by default)
  113597. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113598. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113599. * @returns the object created for this animation. If range does not exist, it will return null
  113600. */
  113601. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113602. /**
  113603. * Serialize animation ranges into a JSON compatible object
  113604. * @returns serialization object
  113605. */
  113606. serializeAnimationRanges(): any;
  113607. /**
  113608. * Computes the world matrix of the node
  113609. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113610. * @returns the world matrix
  113611. */
  113612. computeWorldMatrix(force?: boolean): Matrix;
  113613. /**
  113614. * Releases resources associated with this node.
  113615. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113616. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113617. */
  113618. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113619. /**
  113620. * Parse animation range data from a serialization object and store them into a given node
  113621. * @param node defines where to store the animation ranges
  113622. * @param parsedNode defines the serialization object to read data from
  113623. * @param scene defines the hosting scene
  113624. */
  113625. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113626. /**
  113627. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113628. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113629. * @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
  113630. * @returns the new bounding vectors
  113631. */
  113632. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113633. min: Vector3;
  113634. max: Vector3;
  113635. };
  113636. }
  113637. }
  113638. declare module BABYLON {
  113639. /**
  113640. * @hidden
  113641. */
  113642. export class _IAnimationState {
  113643. key: number;
  113644. repeatCount: number;
  113645. workValue?: any;
  113646. loopMode?: number;
  113647. offsetValue?: any;
  113648. highLimitValue?: any;
  113649. }
  113650. /**
  113651. * Class used to store any kind of animation
  113652. */
  113653. export class Animation {
  113654. /**Name of the animation */
  113655. name: string;
  113656. /**Property to animate */
  113657. targetProperty: string;
  113658. /**The frames per second of the animation */
  113659. framePerSecond: number;
  113660. /**The data type of the animation */
  113661. dataType: number;
  113662. /**The loop mode of the animation */
  113663. loopMode?: number | undefined;
  113664. /**Specifies if blending should be enabled */
  113665. enableBlending?: boolean | undefined;
  113666. /**
  113667. * Use matrix interpolation instead of using direct key value when animating matrices
  113668. */
  113669. static AllowMatricesInterpolation: boolean;
  113670. /**
  113671. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  113672. */
  113673. static AllowMatrixDecomposeForInterpolation: boolean;
  113674. /** Define the Url to load snippets */
  113675. static SnippetUrl: string;
  113676. /** Snippet ID if the animation was created from the snippet server */
  113677. snippetId: string;
  113678. /**
  113679. * Stores the key frames of the animation
  113680. */
  113681. private _keys;
  113682. /**
  113683. * Stores the easing function of the animation
  113684. */
  113685. private _easingFunction;
  113686. /**
  113687. * @hidden Internal use only
  113688. */
  113689. _runtimeAnimations: RuntimeAnimation[];
  113690. /**
  113691. * The set of event that will be linked to this animation
  113692. */
  113693. private _events;
  113694. /**
  113695. * Stores an array of target property paths
  113696. */
  113697. targetPropertyPath: string[];
  113698. /**
  113699. * Stores the blending speed of the animation
  113700. */
  113701. blendingSpeed: number;
  113702. /**
  113703. * Stores the animation ranges for the animation
  113704. */
  113705. private _ranges;
  113706. /**
  113707. * @hidden Internal use
  113708. */
  113709. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  113710. /**
  113711. * Sets up an animation
  113712. * @param property The property to animate
  113713. * @param animationType The animation type to apply
  113714. * @param framePerSecond The frames per second of the animation
  113715. * @param easingFunction The easing function used in the animation
  113716. * @returns The created animation
  113717. */
  113718. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  113719. /**
  113720. * Create and start an animation on a node
  113721. * @param name defines the name of the global animation that will be run on all nodes
  113722. * @param node defines the root node where the animation will take place
  113723. * @param targetProperty defines property to animate
  113724. * @param framePerSecond defines the number of frame per second yo use
  113725. * @param totalFrame defines the number of frames in total
  113726. * @param from defines the initial value
  113727. * @param to defines the final value
  113728. * @param loopMode defines which loop mode you want to use (off by default)
  113729. * @param easingFunction defines the easing function to use (linear by default)
  113730. * @param onAnimationEnd defines the callback to call when animation end
  113731. * @returns the animatable created for this animation
  113732. */
  113733. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113734. /**
  113735. * Create and start an animation on a node and its descendants
  113736. * @param name defines the name of the global animation that will be run on all nodes
  113737. * @param node defines the root node where the animation will take place
  113738. * @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
  113739. * @param targetProperty defines property to animate
  113740. * @param framePerSecond defines the number of frame per second to use
  113741. * @param totalFrame defines the number of frames in total
  113742. * @param from defines the initial value
  113743. * @param to defines the final value
  113744. * @param loopMode defines which loop mode you want to use (off by default)
  113745. * @param easingFunction defines the easing function to use (linear by default)
  113746. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113747. * @returns the list of animatables created for all nodes
  113748. * @example https://www.babylonjs-playground.com/#MH0VLI
  113749. */
  113750. 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[]>;
  113751. /**
  113752. * Creates a new animation, merges it with the existing animations and starts it
  113753. * @param name Name of the animation
  113754. * @param node Node which contains the scene that begins the animations
  113755. * @param targetProperty Specifies which property to animate
  113756. * @param framePerSecond The frames per second of the animation
  113757. * @param totalFrame The total number of frames
  113758. * @param from The frame at the beginning of the animation
  113759. * @param to The frame at the end of the animation
  113760. * @param loopMode Specifies the loop mode of the animation
  113761. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113762. * @param onAnimationEnd Callback to run once the animation is complete
  113763. * @returns Nullable animation
  113764. */
  113765. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113766. /**
  113767. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113768. * @param sourceAnimation defines the Animation containing keyframes to convert
  113769. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113770. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113771. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113772. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113773. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113774. */
  113775. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113776. /**
  113777. * Transition property of an host to the target Value
  113778. * @param property The property to transition
  113779. * @param targetValue The target Value of the property
  113780. * @param host The object where the property to animate belongs
  113781. * @param scene Scene used to run the animation
  113782. * @param frameRate Framerate (in frame/s) to use
  113783. * @param transition The transition type we want to use
  113784. * @param duration The duration of the animation, in milliseconds
  113785. * @param onAnimationEnd Callback trigger at the end of the animation
  113786. * @returns Nullable animation
  113787. */
  113788. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113789. /**
  113790. * Return the array of runtime animations currently using this animation
  113791. */
  113792. get runtimeAnimations(): RuntimeAnimation[];
  113793. /**
  113794. * Specifies if any of the runtime animations are currently running
  113795. */
  113796. get hasRunningRuntimeAnimations(): boolean;
  113797. /**
  113798. * Initializes the animation
  113799. * @param name Name of the animation
  113800. * @param targetProperty Property to animate
  113801. * @param framePerSecond The frames per second of the animation
  113802. * @param dataType The data type of the animation
  113803. * @param loopMode The loop mode of the animation
  113804. * @param enableBlending Specifies if blending should be enabled
  113805. */
  113806. constructor(
  113807. /**Name of the animation */
  113808. name: string,
  113809. /**Property to animate */
  113810. targetProperty: string,
  113811. /**The frames per second of the animation */
  113812. framePerSecond: number,
  113813. /**The data type of the animation */
  113814. dataType: number,
  113815. /**The loop mode of the animation */
  113816. loopMode?: number | undefined,
  113817. /**Specifies if blending should be enabled */
  113818. enableBlending?: boolean | undefined);
  113819. /**
  113820. * Converts the animation to a string
  113821. * @param fullDetails support for multiple levels of logging within scene loading
  113822. * @returns String form of the animation
  113823. */
  113824. toString(fullDetails?: boolean): string;
  113825. /**
  113826. * Add an event to this animation
  113827. * @param event Event to add
  113828. */
  113829. addEvent(event: AnimationEvent): void;
  113830. /**
  113831. * Remove all events found at the given frame
  113832. * @param frame The frame to remove events from
  113833. */
  113834. removeEvents(frame: number): void;
  113835. /**
  113836. * Retrieves all the events from the animation
  113837. * @returns Events from the animation
  113838. */
  113839. getEvents(): AnimationEvent[];
  113840. /**
  113841. * Creates an animation range
  113842. * @param name Name of the animation range
  113843. * @param from Starting frame of the animation range
  113844. * @param to Ending frame of the animation
  113845. */
  113846. createRange(name: string, from: number, to: number): void;
  113847. /**
  113848. * Deletes an animation range by name
  113849. * @param name Name of the animation range to delete
  113850. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113851. */
  113852. deleteRange(name: string, deleteFrames?: boolean): void;
  113853. /**
  113854. * Gets the animation range by name, or null if not defined
  113855. * @param name Name of the animation range
  113856. * @returns Nullable animation range
  113857. */
  113858. getRange(name: string): Nullable<AnimationRange>;
  113859. /**
  113860. * Gets the key frames from the animation
  113861. * @returns The key frames of the animation
  113862. */
  113863. getKeys(): Array<IAnimationKey>;
  113864. /**
  113865. * Gets the highest frame rate of the animation
  113866. * @returns Highest frame rate of the animation
  113867. */
  113868. getHighestFrame(): number;
  113869. /**
  113870. * Gets the easing function of the animation
  113871. * @returns Easing function of the animation
  113872. */
  113873. getEasingFunction(): IEasingFunction;
  113874. /**
  113875. * Sets the easing function of the animation
  113876. * @param easingFunction A custom mathematical formula for animation
  113877. */
  113878. setEasingFunction(easingFunction: EasingFunction): void;
  113879. /**
  113880. * Interpolates a scalar linearly
  113881. * @param startValue Start value of the animation curve
  113882. * @param endValue End value of the animation curve
  113883. * @param gradient Scalar amount to interpolate
  113884. * @returns Interpolated scalar value
  113885. */
  113886. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113887. /**
  113888. * Interpolates a scalar cubically
  113889. * @param startValue Start value of the animation curve
  113890. * @param outTangent End tangent of the animation
  113891. * @param endValue End value of the animation curve
  113892. * @param inTangent Start tangent of the animation curve
  113893. * @param gradient Scalar amount to interpolate
  113894. * @returns Interpolated scalar value
  113895. */
  113896. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113897. /**
  113898. * Interpolates a quaternion using a spherical linear interpolation
  113899. * @param startValue Start value of the animation curve
  113900. * @param endValue End value of the animation curve
  113901. * @param gradient Scalar amount to interpolate
  113902. * @returns Interpolated quaternion value
  113903. */
  113904. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113905. /**
  113906. * Interpolates a quaternion cubically
  113907. * @param startValue Start value of the animation curve
  113908. * @param outTangent End tangent of the animation curve
  113909. * @param endValue End value of the animation curve
  113910. * @param inTangent Start tangent of the animation curve
  113911. * @param gradient Scalar amount to interpolate
  113912. * @returns Interpolated quaternion value
  113913. */
  113914. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  113915. /**
  113916. * Interpolates a Vector3 linearl
  113917. * @param startValue Start value of the animation curve
  113918. * @param endValue End value of the animation curve
  113919. * @param gradient Scalar amount to interpolate
  113920. * @returns Interpolated scalar value
  113921. */
  113922. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  113923. /**
  113924. * Interpolates a Vector3 cubically
  113925. * @param startValue Start value of the animation curve
  113926. * @param outTangent End tangent of the animation
  113927. * @param endValue End value of the animation curve
  113928. * @param inTangent Start tangent of the animation curve
  113929. * @param gradient Scalar amount to interpolate
  113930. * @returns InterpolatedVector3 value
  113931. */
  113932. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  113933. /**
  113934. * Interpolates a Vector2 linearly
  113935. * @param startValue Start value of the animation curve
  113936. * @param endValue End value of the animation curve
  113937. * @param gradient Scalar amount to interpolate
  113938. * @returns Interpolated Vector2 value
  113939. */
  113940. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  113941. /**
  113942. * Interpolates a Vector2 cubically
  113943. * @param startValue Start value of the animation curve
  113944. * @param outTangent End tangent of the animation
  113945. * @param endValue End value of the animation curve
  113946. * @param inTangent Start tangent of the animation curve
  113947. * @param gradient Scalar amount to interpolate
  113948. * @returns Interpolated Vector2 value
  113949. */
  113950. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  113951. /**
  113952. * Interpolates a size linearly
  113953. * @param startValue Start value of the animation curve
  113954. * @param endValue End value of the animation curve
  113955. * @param gradient Scalar amount to interpolate
  113956. * @returns Interpolated Size value
  113957. */
  113958. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  113959. /**
  113960. * Interpolates a Color3 linearly
  113961. * @param startValue Start value of the animation curve
  113962. * @param endValue End value of the animation curve
  113963. * @param gradient Scalar amount to interpolate
  113964. * @returns Interpolated Color3 value
  113965. */
  113966. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  113967. /**
  113968. * Interpolates a Color4 linearly
  113969. * @param startValue Start value of the animation curve
  113970. * @param endValue End value of the animation curve
  113971. * @param gradient Scalar amount to interpolate
  113972. * @returns Interpolated Color3 value
  113973. */
  113974. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  113975. /**
  113976. * @hidden Internal use only
  113977. */
  113978. _getKeyValue(value: any): any;
  113979. /**
  113980. * @hidden Internal use only
  113981. */
  113982. _interpolate(currentFrame: number, state: _IAnimationState): any;
  113983. /**
  113984. * Defines the function to use to interpolate matrices
  113985. * @param startValue defines the start matrix
  113986. * @param endValue defines the end matrix
  113987. * @param gradient defines the gradient between both matrices
  113988. * @param result defines an optional target matrix where to store the interpolation
  113989. * @returns the interpolated matrix
  113990. */
  113991. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  113992. /**
  113993. * Makes a copy of the animation
  113994. * @returns Cloned animation
  113995. */
  113996. clone(): Animation;
  113997. /**
  113998. * Sets the key frames of the animation
  113999. * @param values The animation key frames to set
  114000. */
  114001. setKeys(values: Array<IAnimationKey>): void;
  114002. /**
  114003. * Serializes the animation to an object
  114004. * @returns Serialized object
  114005. */
  114006. serialize(): any;
  114007. /**
  114008. * Float animation type
  114009. */
  114010. static readonly ANIMATIONTYPE_FLOAT: number;
  114011. /**
  114012. * Vector3 animation type
  114013. */
  114014. static readonly ANIMATIONTYPE_VECTOR3: number;
  114015. /**
  114016. * Quaternion animation type
  114017. */
  114018. static readonly ANIMATIONTYPE_QUATERNION: number;
  114019. /**
  114020. * Matrix animation type
  114021. */
  114022. static readonly ANIMATIONTYPE_MATRIX: number;
  114023. /**
  114024. * Color3 animation type
  114025. */
  114026. static readonly ANIMATIONTYPE_COLOR3: number;
  114027. /**
  114028. * Color3 animation type
  114029. */
  114030. static readonly ANIMATIONTYPE_COLOR4: number;
  114031. /**
  114032. * Vector2 animation type
  114033. */
  114034. static readonly ANIMATIONTYPE_VECTOR2: number;
  114035. /**
  114036. * Size animation type
  114037. */
  114038. static readonly ANIMATIONTYPE_SIZE: number;
  114039. /**
  114040. * Relative Loop Mode
  114041. */
  114042. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  114043. /**
  114044. * Cycle Loop Mode
  114045. */
  114046. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  114047. /**
  114048. * Constant Loop Mode
  114049. */
  114050. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  114051. /** @hidden */
  114052. static _UniversalLerp(left: any, right: any, amount: number): any;
  114053. /**
  114054. * Parses an animation object and creates an animation
  114055. * @param parsedAnimation Parsed animation object
  114056. * @returns Animation object
  114057. */
  114058. static Parse(parsedAnimation: any): Animation;
  114059. /**
  114060. * Appends the serialized animations from the source animations
  114061. * @param source Source containing the animations
  114062. * @param destination Target to store the animations
  114063. */
  114064. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114065. /**
  114066. * Creates a new animation or an array of animations from a snippet saved in a remote file
  114067. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  114068. * @param url defines the url to load from
  114069. * @returns a promise that will resolve to the new animation or an array of animations
  114070. */
  114071. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  114072. /**
  114073. * Creates an animation or an array of animations from a snippet saved by the Inspector
  114074. * @param snippetId defines the snippet to load
  114075. * @returns a promise that will resolve to the new animation or a new array of animations
  114076. */
  114077. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  114078. }
  114079. }
  114080. declare module BABYLON {
  114081. /**
  114082. * Interface containing an array of animations
  114083. */
  114084. export interface IAnimatable {
  114085. /**
  114086. * Array of animations
  114087. */
  114088. animations: Nullable<Array<Animation>>;
  114089. }
  114090. }
  114091. declare module BABYLON {
  114092. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  114093. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114094. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114095. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114096. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114097. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114098. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114099. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114100. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114101. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114102. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114103. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114104. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114105. /**
  114106. * Decorator used to define property that can be serialized as reference to a camera
  114107. * @param sourceName defines the name of the property to decorate
  114108. */
  114109. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114110. /**
  114111. * Class used to help serialization objects
  114112. */
  114113. export class SerializationHelper {
  114114. /** @hidden */
  114115. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  114116. /** @hidden */
  114117. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  114118. /** @hidden */
  114119. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  114120. /** @hidden */
  114121. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  114122. /**
  114123. * Appends the serialized animations from the source animations
  114124. * @param source Source containing the animations
  114125. * @param destination Target to store the animations
  114126. */
  114127. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114128. /**
  114129. * Static function used to serialized a specific entity
  114130. * @param entity defines the entity to serialize
  114131. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  114132. * @returns a JSON compatible object representing the serialization of the entity
  114133. */
  114134. static Serialize<T>(entity: T, serializationObject?: any): any;
  114135. /**
  114136. * Creates a new entity from a serialization data object
  114137. * @param creationFunction defines a function used to instanciated the new entity
  114138. * @param source defines the source serialization data
  114139. * @param scene defines the hosting scene
  114140. * @param rootUrl defines the root url for resources
  114141. * @returns a new entity
  114142. */
  114143. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  114144. /**
  114145. * Clones an object
  114146. * @param creationFunction defines the function used to instanciate the new object
  114147. * @param source defines the source object
  114148. * @returns the cloned object
  114149. */
  114150. static Clone<T>(creationFunction: () => T, source: T): T;
  114151. /**
  114152. * Instanciates a new object based on a source one (some data will be shared between both object)
  114153. * @param creationFunction defines the function used to instanciate the new object
  114154. * @param source defines the source object
  114155. * @returns the new object
  114156. */
  114157. static Instanciate<T>(creationFunction: () => T, source: T): T;
  114158. }
  114159. }
  114160. declare module BABYLON {
  114161. /**
  114162. * Base class of all the textures in babylon.
  114163. * It groups all the common properties the materials, post process, lights... might need
  114164. * in order to make a correct use of the texture.
  114165. */
  114166. export class BaseTexture implements IAnimatable {
  114167. /**
  114168. * Default anisotropic filtering level for the application.
  114169. * It is set to 4 as a good tradeoff between perf and quality.
  114170. */
  114171. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  114172. /**
  114173. * Gets or sets the unique id of the texture
  114174. */
  114175. uniqueId: number;
  114176. /**
  114177. * Define the name of the texture.
  114178. */
  114179. name: string;
  114180. /**
  114181. * Gets or sets an object used to store user defined information.
  114182. */
  114183. metadata: any;
  114184. /**
  114185. * For internal use only. Please do not use.
  114186. */
  114187. reservedDataStore: any;
  114188. private _hasAlpha;
  114189. /**
  114190. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  114191. */
  114192. set hasAlpha(value: boolean);
  114193. get hasAlpha(): boolean;
  114194. /**
  114195. * Defines if the alpha value should be determined via the rgb values.
  114196. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  114197. */
  114198. getAlphaFromRGB: boolean;
  114199. /**
  114200. * Intensity or strength of the texture.
  114201. * It is commonly used by materials to fine tune the intensity of the texture
  114202. */
  114203. level: number;
  114204. /**
  114205. * Define the UV chanel to use starting from 0 and defaulting to 0.
  114206. * This is part of the texture as textures usually maps to one uv set.
  114207. */
  114208. coordinatesIndex: number;
  114209. protected _coordinatesMode: number;
  114210. /**
  114211. * How a texture is mapped.
  114212. *
  114213. * | Value | Type | Description |
  114214. * | ----- | ----------------------------------- | ----------- |
  114215. * | 0 | EXPLICIT_MODE | |
  114216. * | 1 | SPHERICAL_MODE | |
  114217. * | 2 | PLANAR_MODE | |
  114218. * | 3 | CUBIC_MODE | |
  114219. * | 4 | PROJECTION_MODE | |
  114220. * | 5 | SKYBOX_MODE | |
  114221. * | 6 | INVCUBIC_MODE | |
  114222. * | 7 | EQUIRECTANGULAR_MODE | |
  114223. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  114224. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  114225. */
  114226. set coordinatesMode(value: number);
  114227. get coordinatesMode(): number;
  114228. private _wrapU;
  114229. /**
  114230. * | Value | Type | Description |
  114231. * | ----- | ------------------ | ----------- |
  114232. * | 0 | CLAMP_ADDRESSMODE | |
  114233. * | 1 | WRAP_ADDRESSMODE | |
  114234. * | 2 | MIRROR_ADDRESSMODE | |
  114235. */
  114236. get wrapU(): number;
  114237. set wrapU(value: number);
  114238. private _wrapV;
  114239. /**
  114240. * | Value | Type | Description |
  114241. * | ----- | ------------------ | ----------- |
  114242. * | 0 | CLAMP_ADDRESSMODE | |
  114243. * | 1 | WRAP_ADDRESSMODE | |
  114244. * | 2 | MIRROR_ADDRESSMODE | |
  114245. */
  114246. get wrapV(): number;
  114247. set wrapV(value: number);
  114248. /**
  114249. * | Value | Type | Description |
  114250. * | ----- | ------------------ | ----------- |
  114251. * | 0 | CLAMP_ADDRESSMODE | |
  114252. * | 1 | WRAP_ADDRESSMODE | |
  114253. * | 2 | MIRROR_ADDRESSMODE | |
  114254. */
  114255. wrapR: number;
  114256. /**
  114257. * With compliant hardware and browser (supporting anisotropic filtering)
  114258. * this defines the level of anisotropic filtering in the texture.
  114259. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  114260. */
  114261. anisotropicFilteringLevel: number;
  114262. /**
  114263. * Define if the texture is a cube texture or if false a 2d texture.
  114264. */
  114265. get isCube(): boolean;
  114266. set isCube(value: boolean);
  114267. /**
  114268. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  114269. */
  114270. get is3D(): boolean;
  114271. set is3D(value: boolean);
  114272. /**
  114273. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  114274. */
  114275. get is2DArray(): boolean;
  114276. set is2DArray(value: boolean);
  114277. private _gammaSpace;
  114278. /**
  114279. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  114280. * HDR texture are usually stored in linear space.
  114281. * This only impacts the PBR and Background materials
  114282. */
  114283. get gammaSpace(): boolean;
  114284. set gammaSpace(gamma: boolean);
  114285. /**
  114286. * Gets or sets whether or not the texture contains RGBD data.
  114287. */
  114288. get isRGBD(): boolean;
  114289. set isRGBD(value: boolean);
  114290. /**
  114291. * Is Z inverted in the texture (useful in a cube texture).
  114292. */
  114293. invertZ: boolean;
  114294. /**
  114295. * Are mip maps generated for this texture or not.
  114296. */
  114297. get noMipmap(): boolean;
  114298. /**
  114299. * @hidden
  114300. */
  114301. lodLevelInAlpha: boolean;
  114302. /**
  114303. * With prefiltered texture, defined the offset used during the prefiltering steps.
  114304. */
  114305. get lodGenerationOffset(): number;
  114306. set lodGenerationOffset(value: number);
  114307. /**
  114308. * With prefiltered texture, defined the scale used during the prefiltering steps.
  114309. */
  114310. get lodGenerationScale(): number;
  114311. set lodGenerationScale(value: number);
  114312. /**
  114313. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  114314. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  114315. * average roughness values.
  114316. */
  114317. get linearSpecularLOD(): boolean;
  114318. set linearSpecularLOD(value: boolean);
  114319. /**
  114320. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  114321. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  114322. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  114323. */
  114324. get irradianceTexture(): Nullable<BaseTexture>;
  114325. set irradianceTexture(value: Nullable<BaseTexture>);
  114326. /**
  114327. * Define if the texture is a render target.
  114328. */
  114329. isRenderTarget: boolean;
  114330. /**
  114331. * Define the unique id of the texture in the scene.
  114332. */
  114333. get uid(): string;
  114334. /** @hidden */
  114335. _prefiltered: boolean;
  114336. /**
  114337. * Return a string representation of the texture.
  114338. * @returns the texture as a string
  114339. */
  114340. toString(): string;
  114341. /**
  114342. * Get the class name of the texture.
  114343. * @returns "BaseTexture"
  114344. */
  114345. getClassName(): string;
  114346. /**
  114347. * Define the list of animation attached to the texture.
  114348. */
  114349. animations: Animation[];
  114350. /**
  114351. * An event triggered when the texture is disposed.
  114352. */
  114353. onDisposeObservable: Observable<BaseTexture>;
  114354. private _onDisposeObserver;
  114355. /**
  114356. * Callback triggered when the texture has been disposed.
  114357. * Kept for back compatibility, you can use the onDisposeObservable instead.
  114358. */
  114359. set onDispose(callback: () => void);
  114360. /**
  114361. * Define the current state of the loading sequence when in delayed load mode.
  114362. */
  114363. delayLoadState: number;
  114364. protected _scene: Nullable<Scene>;
  114365. protected _engine: Nullable<ThinEngine>;
  114366. /** @hidden */
  114367. _texture: Nullable<InternalTexture>;
  114368. private _uid;
  114369. /**
  114370. * Define if the texture is preventinga material to render or not.
  114371. * If not and the texture is not ready, the engine will use a default black texture instead.
  114372. */
  114373. get isBlocking(): boolean;
  114374. /**
  114375. * Instantiates a new BaseTexture.
  114376. * Base class of all the textures in babylon.
  114377. * It groups all the common properties the materials, post process, lights... might need
  114378. * in order to make a correct use of the texture.
  114379. * @param sceneOrEngine Define the scene or engine the texture blongs to
  114380. */
  114381. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  114382. /**
  114383. * Get the scene the texture belongs to.
  114384. * @returns the scene or null if undefined
  114385. */
  114386. getScene(): Nullable<Scene>;
  114387. /** @hidden */
  114388. protected _getEngine(): Nullable<ThinEngine>;
  114389. /**
  114390. * Get the texture transform matrix used to offset tile the texture for istance.
  114391. * @returns the transformation matrix
  114392. */
  114393. getTextureMatrix(): Matrix;
  114394. /**
  114395. * Get the texture reflection matrix used to rotate/transform the reflection.
  114396. * @returns the reflection matrix
  114397. */
  114398. getReflectionTextureMatrix(): Matrix;
  114399. /**
  114400. * Get the underlying lower level texture from Babylon.
  114401. * @returns the insternal texture
  114402. */
  114403. getInternalTexture(): Nullable<InternalTexture>;
  114404. /**
  114405. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  114406. * @returns true if ready or not blocking
  114407. */
  114408. isReadyOrNotBlocking(): boolean;
  114409. /**
  114410. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  114411. * @returns true if fully ready
  114412. */
  114413. isReady(): boolean;
  114414. private _cachedSize;
  114415. /**
  114416. * Get the size of the texture.
  114417. * @returns the texture size.
  114418. */
  114419. getSize(): ISize;
  114420. /**
  114421. * Get the base size of the texture.
  114422. * It can be different from the size if the texture has been resized for POT for instance
  114423. * @returns the base size
  114424. */
  114425. getBaseSize(): ISize;
  114426. /**
  114427. * Update the sampling mode of the texture.
  114428. * Default is Trilinear mode.
  114429. *
  114430. * | Value | Type | Description |
  114431. * | ----- | ------------------ | ----------- |
  114432. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  114433. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  114434. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  114435. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  114436. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  114437. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  114438. * | 7 | NEAREST_LINEAR | |
  114439. * | 8 | NEAREST_NEAREST | |
  114440. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  114441. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  114442. * | 11 | LINEAR_LINEAR | |
  114443. * | 12 | LINEAR_NEAREST | |
  114444. *
  114445. * > _mag_: magnification filter (close to the viewer)
  114446. * > _min_: minification filter (far from the viewer)
  114447. * > _mip_: filter used between mip map levels
  114448. *@param samplingMode Define the new sampling mode of the texture
  114449. */
  114450. updateSamplingMode(samplingMode: number): void;
  114451. /**
  114452. * Scales the texture if is `canRescale()`
  114453. * @param ratio the resize factor we want to use to rescale
  114454. */
  114455. scale(ratio: number): void;
  114456. /**
  114457. * Get if the texture can rescale.
  114458. */
  114459. get canRescale(): boolean;
  114460. /** @hidden */
  114461. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  114462. /** @hidden */
  114463. _rebuild(): void;
  114464. /**
  114465. * Triggers the load sequence in delayed load mode.
  114466. */
  114467. delayLoad(): void;
  114468. /**
  114469. * Clones the texture.
  114470. * @returns the cloned texture
  114471. */
  114472. clone(): Nullable<BaseTexture>;
  114473. /**
  114474. * Get the texture underlying type (INT, FLOAT...)
  114475. */
  114476. get textureType(): number;
  114477. /**
  114478. * Get the texture underlying format (RGB, RGBA...)
  114479. */
  114480. get textureFormat(): number;
  114481. /**
  114482. * Indicates that textures need to be re-calculated for all materials
  114483. */
  114484. protected _markAllSubMeshesAsTexturesDirty(): void;
  114485. /**
  114486. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  114487. * This will returns an RGBA array buffer containing either in values (0-255) or
  114488. * float values (0-1) depending of the underlying buffer type.
  114489. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  114490. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  114491. * @param buffer defines a user defined buffer to fill with data (can be null)
  114492. * @returns The Array buffer containing the pixels data.
  114493. */
  114494. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  114495. /**
  114496. * Release and destroy the underlying lower level texture aka internalTexture.
  114497. */
  114498. releaseInternalTexture(): void;
  114499. /** @hidden */
  114500. get _lodTextureHigh(): Nullable<BaseTexture>;
  114501. /** @hidden */
  114502. get _lodTextureMid(): Nullable<BaseTexture>;
  114503. /** @hidden */
  114504. get _lodTextureLow(): Nullable<BaseTexture>;
  114505. /**
  114506. * Dispose the texture and release its associated resources.
  114507. */
  114508. dispose(): void;
  114509. /**
  114510. * Serialize the texture into a JSON representation that can be parsed later on.
  114511. * @returns the JSON representation of the texture
  114512. */
  114513. serialize(): any;
  114514. /**
  114515. * Helper function to be called back once a list of texture contains only ready textures.
  114516. * @param textures Define the list of textures to wait for
  114517. * @param callback Define the callback triggered once the entire list will be ready
  114518. */
  114519. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  114520. private static _isScene;
  114521. }
  114522. }
  114523. declare module BABYLON {
  114524. /**
  114525. * Options to be used when creating an effect.
  114526. */
  114527. export interface IEffectCreationOptions {
  114528. /**
  114529. * Atrributes that will be used in the shader.
  114530. */
  114531. attributes: string[];
  114532. /**
  114533. * Uniform varible names that will be set in the shader.
  114534. */
  114535. uniformsNames: string[];
  114536. /**
  114537. * Uniform buffer variable names that will be set in the shader.
  114538. */
  114539. uniformBuffersNames: string[];
  114540. /**
  114541. * Sampler texture variable names that will be set in the shader.
  114542. */
  114543. samplers: string[];
  114544. /**
  114545. * Define statements that will be set in the shader.
  114546. */
  114547. defines: any;
  114548. /**
  114549. * Possible fallbacks for this effect to improve performance when needed.
  114550. */
  114551. fallbacks: Nullable<IEffectFallbacks>;
  114552. /**
  114553. * Callback that will be called when the shader is compiled.
  114554. */
  114555. onCompiled: Nullable<(effect: Effect) => void>;
  114556. /**
  114557. * Callback that will be called if an error occurs during shader compilation.
  114558. */
  114559. onError: Nullable<(effect: Effect, errors: string) => void>;
  114560. /**
  114561. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114562. */
  114563. indexParameters?: any;
  114564. /**
  114565. * Max number of lights that can be used in the shader.
  114566. */
  114567. maxSimultaneousLights?: number;
  114568. /**
  114569. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114570. */
  114571. transformFeedbackVaryings?: Nullable<string[]>;
  114572. /**
  114573. * 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
  114574. */
  114575. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114576. /**
  114577. * Is this effect rendering to several color attachments ?
  114578. */
  114579. multiTarget?: boolean;
  114580. }
  114581. /**
  114582. * Effect containing vertex and fragment shader that can be executed on an object.
  114583. */
  114584. export class Effect implements IDisposable {
  114585. /**
  114586. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114587. */
  114588. static ShadersRepository: string;
  114589. /**
  114590. * Enable logging of the shader code when a compilation error occurs
  114591. */
  114592. static LogShaderCodeOnCompilationError: boolean;
  114593. /**
  114594. * Name of the effect.
  114595. */
  114596. name: any;
  114597. /**
  114598. * String container all the define statements that should be set on the shader.
  114599. */
  114600. defines: string;
  114601. /**
  114602. * Callback that will be called when the shader is compiled.
  114603. */
  114604. onCompiled: Nullable<(effect: Effect) => void>;
  114605. /**
  114606. * Callback that will be called if an error occurs during shader compilation.
  114607. */
  114608. onError: Nullable<(effect: Effect, errors: string) => void>;
  114609. /**
  114610. * Callback that will be called when effect is bound.
  114611. */
  114612. onBind: Nullable<(effect: Effect) => void>;
  114613. /**
  114614. * Unique ID of the effect.
  114615. */
  114616. uniqueId: number;
  114617. /**
  114618. * Observable that will be called when the shader is compiled.
  114619. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114620. */
  114621. onCompileObservable: Observable<Effect>;
  114622. /**
  114623. * Observable that will be called if an error occurs during shader compilation.
  114624. */
  114625. onErrorObservable: Observable<Effect>;
  114626. /** @hidden */
  114627. _onBindObservable: Nullable<Observable<Effect>>;
  114628. /**
  114629. * @hidden
  114630. * Specifies if the effect was previously ready
  114631. */
  114632. _wasPreviouslyReady: boolean;
  114633. /**
  114634. * Observable that will be called when effect is bound.
  114635. */
  114636. get onBindObservable(): Observable<Effect>;
  114637. /** @hidden */
  114638. _bonesComputationForcedToCPU: boolean;
  114639. /** @hidden */
  114640. _multiTarget: boolean;
  114641. private static _uniqueIdSeed;
  114642. private _engine;
  114643. private _uniformBuffersNames;
  114644. private _uniformBuffersNamesList;
  114645. private _uniformsNames;
  114646. private _samplerList;
  114647. private _samplers;
  114648. private _isReady;
  114649. private _compilationError;
  114650. private _allFallbacksProcessed;
  114651. private _attributesNames;
  114652. private _attributes;
  114653. private _attributeLocationByName;
  114654. private _uniforms;
  114655. /**
  114656. * Key for the effect.
  114657. * @hidden
  114658. */
  114659. _key: string;
  114660. private _indexParameters;
  114661. private _fallbacks;
  114662. private _vertexSourceCode;
  114663. private _fragmentSourceCode;
  114664. private _vertexSourceCodeOverride;
  114665. private _fragmentSourceCodeOverride;
  114666. private _transformFeedbackVaryings;
  114667. /**
  114668. * Compiled shader to webGL program.
  114669. * @hidden
  114670. */
  114671. _pipelineContext: Nullable<IPipelineContext>;
  114672. private _valueCache;
  114673. private static _baseCache;
  114674. /**
  114675. * Instantiates an effect.
  114676. * An effect can be used to create/manage/execute vertex and fragment shaders.
  114677. * @param baseName Name of the effect.
  114678. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  114679. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  114680. * @param samplers List of sampler variables that will be passed to the shader.
  114681. * @param engine Engine to be used to render the effect
  114682. * @param defines Define statements to be added to the shader.
  114683. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  114684. * @param onCompiled Callback that will be called when the shader is compiled.
  114685. * @param onError Callback that will be called if an error occurs during shader compilation.
  114686. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114687. */
  114688. 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);
  114689. private _useFinalCode;
  114690. /**
  114691. * Unique key for this effect
  114692. */
  114693. get key(): string;
  114694. /**
  114695. * If the effect has been compiled and prepared.
  114696. * @returns if the effect is compiled and prepared.
  114697. */
  114698. isReady(): boolean;
  114699. private _isReadyInternal;
  114700. /**
  114701. * The engine the effect was initialized with.
  114702. * @returns the engine.
  114703. */
  114704. getEngine(): Engine;
  114705. /**
  114706. * The pipeline context for this effect
  114707. * @returns the associated pipeline context
  114708. */
  114709. getPipelineContext(): Nullable<IPipelineContext>;
  114710. /**
  114711. * The set of names of attribute variables for the shader.
  114712. * @returns An array of attribute names.
  114713. */
  114714. getAttributesNames(): string[];
  114715. /**
  114716. * Returns the attribute at the given index.
  114717. * @param index The index of the attribute.
  114718. * @returns The location of the attribute.
  114719. */
  114720. getAttributeLocation(index: number): number;
  114721. /**
  114722. * Returns the attribute based on the name of the variable.
  114723. * @param name of the attribute to look up.
  114724. * @returns the attribute location.
  114725. */
  114726. getAttributeLocationByName(name: string): number;
  114727. /**
  114728. * The number of attributes.
  114729. * @returns the numnber of attributes.
  114730. */
  114731. getAttributesCount(): number;
  114732. /**
  114733. * Gets the index of a uniform variable.
  114734. * @param uniformName of the uniform to look up.
  114735. * @returns the index.
  114736. */
  114737. getUniformIndex(uniformName: string): number;
  114738. /**
  114739. * Returns the attribute based on the name of the variable.
  114740. * @param uniformName of the uniform to look up.
  114741. * @returns the location of the uniform.
  114742. */
  114743. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114744. /**
  114745. * Returns an array of sampler variable names
  114746. * @returns The array of sampler variable names.
  114747. */
  114748. getSamplers(): string[];
  114749. /**
  114750. * Returns an array of uniform variable names
  114751. * @returns The array of uniform variable names.
  114752. */
  114753. getUniformNames(): string[];
  114754. /**
  114755. * Returns an array of uniform buffer variable names
  114756. * @returns The array of uniform buffer variable names.
  114757. */
  114758. getUniformBuffersNames(): string[];
  114759. /**
  114760. * Returns the index parameters used to create the effect
  114761. * @returns The index parameters object
  114762. */
  114763. getIndexParameters(): any;
  114764. /**
  114765. * The error from the last compilation.
  114766. * @returns the error string.
  114767. */
  114768. getCompilationError(): string;
  114769. /**
  114770. * Gets a boolean indicating that all fallbacks were used during compilation
  114771. * @returns true if all fallbacks were used
  114772. */
  114773. allFallbacksProcessed(): boolean;
  114774. /**
  114775. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114776. * @param func The callback to be used.
  114777. */
  114778. executeWhenCompiled(func: (effect: Effect) => void): void;
  114779. private _checkIsReady;
  114780. private _loadShader;
  114781. /**
  114782. * Gets the vertex shader source code of this effect
  114783. */
  114784. get vertexSourceCode(): string;
  114785. /**
  114786. * Gets the fragment shader source code of this effect
  114787. */
  114788. get fragmentSourceCode(): string;
  114789. /**
  114790. * Recompiles the webGL program
  114791. * @param vertexSourceCode The source code for the vertex shader.
  114792. * @param fragmentSourceCode The source code for the fragment shader.
  114793. * @param onCompiled Callback called when completed.
  114794. * @param onError Callback called on error.
  114795. * @hidden
  114796. */
  114797. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114798. /**
  114799. * Prepares the effect
  114800. * @hidden
  114801. */
  114802. _prepareEffect(): void;
  114803. private _getShaderCodeAndErrorLine;
  114804. private _processCompilationErrors;
  114805. /**
  114806. * Checks if the effect is supported. (Must be called after compilation)
  114807. */
  114808. get isSupported(): boolean;
  114809. /**
  114810. * Binds a texture to the engine to be used as output of the shader.
  114811. * @param channel Name of the output variable.
  114812. * @param texture Texture to bind.
  114813. * @hidden
  114814. */
  114815. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114816. /**
  114817. * Sets a texture on the engine to be used in the shader.
  114818. * @param channel Name of the sampler variable.
  114819. * @param texture Texture to set.
  114820. */
  114821. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114822. /**
  114823. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114824. * @param channel Name of the sampler variable.
  114825. * @param texture Texture to set.
  114826. */
  114827. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114828. /**
  114829. * Sets an array of textures on the engine to be used in the shader.
  114830. * @param channel Name of the variable.
  114831. * @param textures Textures to set.
  114832. */
  114833. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114834. /**
  114835. * 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)
  114836. * @param channel Name of the sampler variable.
  114837. * @param postProcess Post process to get the input texture from.
  114838. */
  114839. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114840. /**
  114841. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114842. * 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)
  114843. * @param channel Name of the sampler variable.
  114844. * @param postProcess Post process to get the output texture from.
  114845. */
  114846. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114847. /** @hidden */
  114848. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114849. /** @hidden */
  114850. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114851. /** @hidden */
  114852. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114853. /** @hidden */
  114854. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114855. /**
  114856. * Binds a buffer to a uniform.
  114857. * @param buffer Buffer to bind.
  114858. * @param name Name of the uniform variable to bind to.
  114859. */
  114860. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114861. /**
  114862. * Binds block to a uniform.
  114863. * @param blockName Name of the block to bind.
  114864. * @param index Index to bind.
  114865. */
  114866. bindUniformBlock(blockName: string, index: number): void;
  114867. /**
  114868. * Sets an interger value on a uniform variable.
  114869. * @param uniformName Name of the variable.
  114870. * @param value Value to be set.
  114871. * @returns this effect.
  114872. */
  114873. setInt(uniformName: string, value: number): Effect;
  114874. /**
  114875. * Sets an int array on a uniform variable.
  114876. * @param uniformName Name of the variable.
  114877. * @param array array to be set.
  114878. * @returns this effect.
  114879. */
  114880. setIntArray(uniformName: string, array: Int32Array): Effect;
  114881. /**
  114882. * 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)
  114883. * @param uniformName Name of the variable.
  114884. * @param array array to be set.
  114885. * @returns this effect.
  114886. */
  114887. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114888. /**
  114889. * 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)
  114890. * @param uniformName Name of the variable.
  114891. * @param array array to be set.
  114892. * @returns this effect.
  114893. */
  114894. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114895. /**
  114896. * 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)
  114897. * @param uniformName Name of the variable.
  114898. * @param array array to be set.
  114899. * @returns this effect.
  114900. */
  114901. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114902. /**
  114903. * Sets an float array on a uniform variable.
  114904. * @param uniformName Name of the variable.
  114905. * @param array array to be set.
  114906. * @returns this effect.
  114907. */
  114908. setFloatArray(uniformName: string, array: Float32Array): Effect;
  114909. /**
  114910. * 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)
  114911. * @param uniformName Name of the variable.
  114912. * @param array array to be set.
  114913. * @returns this effect.
  114914. */
  114915. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  114916. /**
  114917. * 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)
  114918. * @param uniformName Name of the variable.
  114919. * @param array array to be set.
  114920. * @returns this effect.
  114921. */
  114922. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  114923. /**
  114924. * 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)
  114925. * @param uniformName Name of the variable.
  114926. * @param array array to be set.
  114927. * @returns this effect.
  114928. */
  114929. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  114930. /**
  114931. * Sets an array on a uniform variable.
  114932. * @param uniformName Name of the variable.
  114933. * @param array array to be set.
  114934. * @returns this effect.
  114935. */
  114936. setArray(uniformName: string, array: number[]): Effect;
  114937. /**
  114938. * 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)
  114939. * @param uniformName Name of the variable.
  114940. * @param array array to be set.
  114941. * @returns this effect.
  114942. */
  114943. setArray2(uniformName: string, array: number[]): Effect;
  114944. /**
  114945. * 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)
  114946. * @param uniformName Name of the variable.
  114947. * @param array array to be set.
  114948. * @returns this effect.
  114949. */
  114950. setArray3(uniformName: string, array: number[]): Effect;
  114951. /**
  114952. * 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)
  114953. * @param uniformName Name of the variable.
  114954. * @param array array to be set.
  114955. * @returns this effect.
  114956. */
  114957. setArray4(uniformName: string, array: number[]): Effect;
  114958. /**
  114959. * Sets matrices on a uniform variable.
  114960. * @param uniformName Name of the variable.
  114961. * @param matrices matrices to be set.
  114962. * @returns this effect.
  114963. */
  114964. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  114965. /**
  114966. * Sets matrix on a uniform variable.
  114967. * @param uniformName Name of the variable.
  114968. * @param matrix matrix to be set.
  114969. * @returns this effect.
  114970. */
  114971. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  114972. /**
  114973. * 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)
  114974. * @param uniformName Name of the variable.
  114975. * @param matrix matrix to be set.
  114976. * @returns this effect.
  114977. */
  114978. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114979. /**
  114980. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  114981. * @param uniformName Name of the variable.
  114982. * @param matrix matrix to be set.
  114983. * @returns this effect.
  114984. */
  114985. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114986. /**
  114987. * Sets a float on a uniform variable.
  114988. * @param uniformName Name of the variable.
  114989. * @param value value to be set.
  114990. * @returns this effect.
  114991. */
  114992. setFloat(uniformName: string, value: number): Effect;
  114993. /**
  114994. * Sets a boolean on a uniform variable.
  114995. * @param uniformName Name of the variable.
  114996. * @param bool value to be set.
  114997. * @returns this effect.
  114998. */
  114999. setBool(uniformName: string, bool: boolean): Effect;
  115000. /**
  115001. * Sets a Vector2 on a uniform variable.
  115002. * @param uniformName Name of the variable.
  115003. * @param vector2 vector2 to be set.
  115004. * @returns this effect.
  115005. */
  115006. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  115007. /**
  115008. * Sets a float2 on a uniform variable.
  115009. * @param uniformName Name of the variable.
  115010. * @param x First float in float2.
  115011. * @param y Second float in float2.
  115012. * @returns this effect.
  115013. */
  115014. setFloat2(uniformName: string, x: number, y: number): Effect;
  115015. /**
  115016. * Sets a Vector3 on a uniform variable.
  115017. * @param uniformName Name of the variable.
  115018. * @param vector3 Value to be set.
  115019. * @returns this effect.
  115020. */
  115021. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  115022. /**
  115023. * Sets a float3 on a uniform variable.
  115024. * @param uniformName Name of the variable.
  115025. * @param x First float in float3.
  115026. * @param y Second float in float3.
  115027. * @param z Third float in float3.
  115028. * @returns this effect.
  115029. */
  115030. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  115031. /**
  115032. * Sets a Vector4 on a uniform variable.
  115033. * @param uniformName Name of the variable.
  115034. * @param vector4 Value to be set.
  115035. * @returns this effect.
  115036. */
  115037. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  115038. /**
  115039. * Sets a float4 on a uniform variable.
  115040. * @param uniformName Name of the variable.
  115041. * @param x First float in float4.
  115042. * @param y Second float in float4.
  115043. * @param z Third float in float4.
  115044. * @param w Fourth float in float4.
  115045. * @returns this effect.
  115046. */
  115047. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  115048. /**
  115049. * Sets a Color3 on a uniform variable.
  115050. * @param uniformName Name of the variable.
  115051. * @param color3 Value to be set.
  115052. * @returns this effect.
  115053. */
  115054. setColor3(uniformName: string, color3: IColor3Like): Effect;
  115055. /**
  115056. * Sets a Color4 on a uniform variable.
  115057. * @param uniformName Name of the variable.
  115058. * @param color3 Value to be set.
  115059. * @param alpha Alpha value to be set.
  115060. * @returns this effect.
  115061. */
  115062. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  115063. /**
  115064. * Sets a Color4 on a uniform variable
  115065. * @param uniformName defines the name of the variable
  115066. * @param color4 defines the value to be set
  115067. * @returns this effect.
  115068. */
  115069. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  115070. /** Release all associated resources */
  115071. dispose(): void;
  115072. /**
  115073. * This function will add a new shader to the shader store
  115074. * @param name the name of the shader
  115075. * @param pixelShader optional pixel shader content
  115076. * @param vertexShader optional vertex shader content
  115077. */
  115078. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  115079. /**
  115080. * Store of each shader (The can be looked up using effect.key)
  115081. */
  115082. static ShadersStore: {
  115083. [key: string]: string;
  115084. };
  115085. /**
  115086. * Store of each included file for a shader (The can be looked up using effect.key)
  115087. */
  115088. static IncludesShadersStore: {
  115089. [key: string]: string;
  115090. };
  115091. /**
  115092. * Resets the cache of effects.
  115093. */
  115094. static ResetCache(): void;
  115095. }
  115096. }
  115097. declare module BABYLON {
  115098. /**
  115099. * Interface used to describe the capabilities of the engine relatively to the current browser
  115100. */
  115101. export interface EngineCapabilities {
  115102. /** Maximum textures units per fragment shader */
  115103. maxTexturesImageUnits: number;
  115104. /** Maximum texture units per vertex shader */
  115105. maxVertexTextureImageUnits: number;
  115106. /** Maximum textures units in the entire pipeline */
  115107. maxCombinedTexturesImageUnits: number;
  115108. /** Maximum texture size */
  115109. maxTextureSize: number;
  115110. /** Maximum texture samples */
  115111. maxSamples?: number;
  115112. /** Maximum cube texture size */
  115113. maxCubemapTextureSize: number;
  115114. /** Maximum render texture size */
  115115. maxRenderTextureSize: number;
  115116. /** Maximum number of vertex attributes */
  115117. maxVertexAttribs: number;
  115118. /** Maximum number of varyings */
  115119. maxVaryingVectors: number;
  115120. /** Maximum number of uniforms per vertex shader */
  115121. maxVertexUniformVectors: number;
  115122. /** Maximum number of uniforms per fragment shader */
  115123. maxFragmentUniformVectors: number;
  115124. /** Defines if standard derivates (dx/dy) are supported */
  115125. standardDerivatives: boolean;
  115126. /** Defines if s3tc texture compression is supported */
  115127. s3tc?: WEBGL_compressed_texture_s3tc;
  115128. /** Defines if pvrtc texture compression is supported */
  115129. pvrtc: any;
  115130. /** Defines if etc1 texture compression is supported */
  115131. etc1: any;
  115132. /** Defines if etc2 texture compression is supported */
  115133. etc2: any;
  115134. /** Defines if astc texture compression is supported */
  115135. astc: any;
  115136. /** Defines if bptc texture compression is supported */
  115137. bptc: any;
  115138. /** Defines if float textures are supported */
  115139. textureFloat: boolean;
  115140. /** Defines if vertex array objects are supported */
  115141. vertexArrayObject: boolean;
  115142. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  115143. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  115144. /** Gets the maximum level of anisotropy supported */
  115145. maxAnisotropy: number;
  115146. /** Defines if instancing is supported */
  115147. instancedArrays: boolean;
  115148. /** Defines if 32 bits indices are supported */
  115149. uintIndices: boolean;
  115150. /** Defines if high precision shaders are supported */
  115151. highPrecisionShaderSupported: boolean;
  115152. /** Defines if depth reading in the fragment shader is supported */
  115153. fragmentDepthSupported: boolean;
  115154. /** Defines if float texture linear filtering is supported*/
  115155. textureFloatLinearFiltering: boolean;
  115156. /** Defines if rendering to float textures is supported */
  115157. textureFloatRender: boolean;
  115158. /** Defines if half float textures are supported*/
  115159. textureHalfFloat: boolean;
  115160. /** Defines if half float texture linear filtering is supported*/
  115161. textureHalfFloatLinearFiltering: boolean;
  115162. /** Defines if rendering to half float textures is supported */
  115163. textureHalfFloatRender: boolean;
  115164. /** Defines if textureLOD shader command is supported */
  115165. textureLOD: boolean;
  115166. /** Defines if draw buffers extension is supported */
  115167. drawBuffersExtension: boolean;
  115168. /** Defines if depth textures are supported */
  115169. depthTextureExtension: boolean;
  115170. /** Defines if float color buffer are supported */
  115171. colorBufferFloat: boolean;
  115172. /** Gets disjoint timer query extension (null if not supported) */
  115173. timerQuery?: EXT_disjoint_timer_query;
  115174. /** Defines if timestamp can be used with timer query */
  115175. canUseTimestampForTimerQuery: boolean;
  115176. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  115177. multiview?: any;
  115178. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  115179. oculusMultiview?: any;
  115180. /** Function used to let the system compiles shaders in background */
  115181. parallelShaderCompile?: {
  115182. COMPLETION_STATUS_KHR: number;
  115183. };
  115184. /** Max number of texture samples for MSAA */
  115185. maxMSAASamples: number;
  115186. /** Defines if the blend min max extension is supported */
  115187. blendMinMax: boolean;
  115188. }
  115189. }
  115190. declare module BABYLON {
  115191. /**
  115192. * @hidden
  115193. **/
  115194. export class DepthCullingState {
  115195. private _isDepthTestDirty;
  115196. private _isDepthMaskDirty;
  115197. private _isDepthFuncDirty;
  115198. private _isCullFaceDirty;
  115199. private _isCullDirty;
  115200. private _isZOffsetDirty;
  115201. private _isFrontFaceDirty;
  115202. private _depthTest;
  115203. private _depthMask;
  115204. private _depthFunc;
  115205. private _cull;
  115206. private _cullFace;
  115207. private _zOffset;
  115208. private _frontFace;
  115209. /**
  115210. * Initializes the state.
  115211. */
  115212. constructor();
  115213. get isDirty(): boolean;
  115214. get zOffset(): number;
  115215. set zOffset(value: number);
  115216. get cullFace(): Nullable<number>;
  115217. set cullFace(value: Nullable<number>);
  115218. get cull(): Nullable<boolean>;
  115219. set cull(value: Nullable<boolean>);
  115220. get depthFunc(): Nullable<number>;
  115221. set depthFunc(value: Nullable<number>);
  115222. get depthMask(): boolean;
  115223. set depthMask(value: boolean);
  115224. get depthTest(): boolean;
  115225. set depthTest(value: boolean);
  115226. get frontFace(): Nullable<number>;
  115227. set frontFace(value: Nullable<number>);
  115228. reset(): void;
  115229. apply(gl: WebGLRenderingContext): void;
  115230. }
  115231. }
  115232. declare module BABYLON {
  115233. /**
  115234. * @hidden
  115235. **/
  115236. export class StencilState {
  115237. /** 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 */
  115238. static readonly ALWAYS: number;
  115239. /** Passed to stencilOperation to specify that stencil value must be kept */
  115240. static readonly KEEP: number;
  115241. /** Passed to stencilOperation to specify that stencil value must be replaced */
  115242. static readonly REPLACE: number;
  115243. private _isStencilTestDirty;
  115244. private _isStencilMaskDirty;
  115245. private _isStencilFuncDirty;
  115246. private _isStencilOpDirty;
  115247. private _stencilTest;
  115248. private _stencilMask;
  115249. private _stencilFunc;
  115250. private _stencilFuncRef;
  115251. private _stencilFuncMask;
  115252. private _stencilOpStencilFail;
  115253. private _stencilOpDepthFail;
  115254. private _stencilOpStencilDepthPass;
  115255. get isDirty(): boolean;
  115256. get stencilFunc(): number;
  115257. set stencilFunc(value: number);
  115258. get stencilFuncRef(): number;
  115259. set stencilFuncRef(value: number);
  115260. get stencilFuncMask(): number;
  115261. set stencilFuncMask(value: number);
  115262. get stencilOpStencilFail(): number;
  115263. set stencilOpStencilFail(value: number);
  115264. get stencilOpDepthFail(): number;
  115265. set stencilOpDepthFail(value: number);
  115266. get stencilOpStencilDepthPass(): number;
  115267. set stencilOpStencilDepthPass(value: number);
  115268. get stencilMask(): number;
  115269. set stencilMask(value: number);
  115270. get stencilTest(): boolean;
  115271. set stencilTest(value: boolean);
  115272. constructor();
  115273. reset(): void;
  115274. apply(gl: WebGLRenderingContext): void;
  115275. }
  115276. }
  115277. declare module BABYLON {
  115278. /**
  115279. * @hidden
  115280. **/
  115281. export class AlphaState {
  115282. private _isAlphaBlendDirty;
  115283. private _isBlendFunctionParametersDirty;
  115284. private _isBlendEquationParametersDirty;
  115285. private _isBlendConstantsDirty;
  115286. private _alphaBlend;
  115287. private _blendFunctionParameters;
  115288. private _blendEquationParameters;
  115289. private _blendConstants;
  115290. /**
  115291. * Initializes the state.
  115292. */
  115293. constructor();
  115294. get isDirty(): boolean;
  115295. get alphaBlend(): boolean;
  115296. set alphaBlend(value: boolean);
  115297. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  115298. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  115299. setAlphaEquationParameters(rgb: number, alpha: number): void;
  115300. reset(): void;
  115301. apply(gl: WebGLRenderingContext): void;
  115302. }
  115303. }
  115304. declare module BABYLON {
  115305. /** @hidden */
  115306. export class WebGL2ShaderProcessor implements IShaderProcessor {
  115307. attributeProcessor(attribute: string): string;
  115308. varyingProcessor(varying: string, isFragment: boolean): string;
  115309. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115310. }
  115311. }
  115312. declare module BABYLON {
  115313. /**
  115314. * Interface for attribute information associated with buffer instanciation
  115315. */
  115316. export interface InstancingAttributeInfo {
  115317. /**
  115318. * Name of the GLSL attribute
  115319. * if attribute index is not specified, this is used to retrieve the index from the effect
  115320. */
  115321. attributeName: string;
  115322. /**
  115323. * Index/offset of the attribute in the vertex shader
  115324. * if not specified, this will be computes from the name.
  115325. */
  115326. index?: number;
  115327. /**
  115328. * size of the attribute, 1, 2, 3 or 4
  115329. */
  115330. attributeSize: number;
  115331. /**
  115332. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  115333. */
  115334. offset: number;
  115335. /**
  115336. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  115337. * default to 1
  115338. */
  115339. divisor?: number;
  115340. /**
  115341. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  115342. * default is FLOAT
  115343. */
  115344. attributeType?: number;
  115345. /**
  115346. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  115347. */
  115348. normalized?: boolean;
  115349. }
  115350. }
  115351. declare module BABYLON {
  115352. interface ThinEngine {
  115353. /**
  115354. * Update a video texture
  115355. * @param texture defines the texture to update
  115356. * @param video defines the video element to use
  115357. * @param invertY defines if data must be stored with Y axis inverted
  115358. */
  115359. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  115360. }
  115361. }
  115362. declare module BABYLON {
  115363. interface ThinEngine {
  115364. /**
  115365. * Creates a dynamic texture
  115366. * @param width defines the width of the texture
  115367. * @param height defines the height of the texture
  115368. * @param generateMipMaps defines if the engine should generate the mip levels
  115369. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  115370. * @returns the dynamic texture inside an InternalTexture
  115371. */
  115372. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  115373. /**
  115374. * Update the content of a dynamic texture
  115375. * @param texture defines the texture to update
  115376. * @param canvas defines the canvas containing the source
  115377. * @param invertY defines if data must be stored with Y axis inverted
  115378. * @param premulAlpha defines if alpha is stored as premultiplied
  115379. * @param format defines the format of the data
  115380. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  115381. */
  115382. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  115383. }
  115384. }
  115385. declare module BABYLON {
  115386. /**
  115387. * Settings for finer control over video usage
  115388. */
  115389. export interface VideoTextureSettings {
  115390. /**
  115391. * Applies `autoplay` to video, if specified
  115392. */
  115393. autoPlay?: boolean;
  115394. /**
  115395. * Applies `loop` to video, if specified
  115396. */
  115397. loop?: boolean;
  115398. /**
  115399. * Automatically updates internal texture from video at every frame in the render loop
  115400. */
  115401. autoUpdateTexture: boolean;
  115402. /**
  115403. * Image src displayed during the video loading or until the user interacts with the video.
  115404. */
  115405. poster?: string;
  115406. }
  115407. /**
  115408. * If you want to display a video in your scene, this is the special texture for that.
  115409. * This special texture works similar to other textures, with the exception of a few parameters.
  115410. * @see https://doc.babylonjs.com/how_to/video_texture
  115411. */
  115412. export class VideoTexture extends Texture {
  115413. /**
  115414. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  115415. */
  115416. readonly autoUpdateTexture: boolean;
  115417. /**
  115418. * The video instance used by the texture internally
  115419. */
  115420. readonly video: HTMLVideoElement;
  115421. private _onUserActionRequestedObservable;
  115422. /**
  115423. * Event triggerd when a dom action is required by the user to play the video.
  115424. * This happens due to recent changes in browser policies preventing video to auto start.
  115425. */
  115426. get onUserActionRequestedObservable(): Observable<Texture>;
  115427. private _generateMipMaps;
  115428. private _stillImageCaptured;
  115429. private _displayingPosterTexture;
  115430. private _settings;
  115431. private _createInternalTextureOnEvent;
  115432. private _frameId;
  115433. private _currentSrc;
  115434. /**
  115435. * Creates a video texture.
  115436. * If you want to display a video in your scene, this is the special texture for that.
  115437. * This special texture works similar to other textures, with the exception of a few parameters.
  115438. * @see https://doc.babylonjs.com/how_to/video_texture
  115439. * @param name optional name, will detect from video source, if not defined
  115440. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  115441. * @param scene is obviously the current scene.
  115442. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  115443. * @param invertY is false by default but can be used to invert video on Y axis
  115444. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  115445. * @param settings allows finer control over video usage
  115446. */
  115447. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  115448. private _getName;
  115449. private _getVideo;
  115450. private _createInternalTexture;
  115451. private reset;
  115452. /**
  115453. * @hidden Internal method to initiate `update`.
  115454. */
  115455. _rebuild(): void;
  115456. /**
  115457. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  115458. */
  115459. update(): void;
  115460. /**
  115461. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  115462. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  115463. */
  115464. updateTexture(isVisible: boolean): void;
  115465. protected _updateInternalTexture: () => void;
  115466. /**
  115467. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  115468. * @param url New url.
  115469. */
  115470. updateURL(url: string): void;
  115471. /**
  115472. * Clones the texture.
  115473. * @returns the cloned texture
  115474. */
  115475. clone(): VideoTexture;
  115476. /**
  115477. * Dispose the texture and release its associated resources.
  115478. */
  115479. dispose(): void;
  115480. /**
  115481. * Creates a video texture straight from a stream.
  115482. * @param scene Define the scene the texture should be created in
  115483. * @param stream Define the stream the texture should be created from
  115484. * @returns The created video texture as a promise
  115485. */
  115486. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  115487. /**
  115488. * Creates a video texture straight from your WebCam video feed.
  115489. * @param scene Define the scene the texture should be created in
  115490. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115491. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115492. * @returns The created video texture as a promise
  115493. */
  115494. static CreateFromWebCamAsync(scene: Scene, constraints: {
  115495. minWidth: number;
  115496. maxWidth: number;
  115497. minHeight: number;
  115498. maxHeight: number;
  115499. deviceId: string;
  115500. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  115501. /**
  115502. * Creates a video texture straight from your WebCam video feed.
  115503. * @param scene Define the scene the texture should be created in
  115504. * @param onReady Define a callback to triggered once the texture will be ready
  115505. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115506. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115507. */
  115508. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  115509. minWidth: number;
  115510. maxWidth: number;
  115511. minHeight: number;
  115512. maxHeight: number;
  115513. deviceId: string;
  115514. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  115515. }
  115516. }
  115517. declare module BABYLON {
  115518. /**
  115519. * Defines the interface used by objects working like Scene
  115520. * @hidden
  115521. */
  115522. export interface ISceneLike {
  115523. _addPendingData(data: any): void;
  115524. _removePendingData(data: any): void;
  115525. offlineProvider: IOfflineProvider;
  115526. }
  115527. /**
  115528. * Information about the current host
  115529. */
  115530. export interface HostInformation {
  115531. /**
  115532. * Defines if the current host is a mobile
  115533. */
  115534. isMobile: boolean;
  115535. }
  115536. /** Interface defining initialization parameters for Engine class */
  115537. export interface EngineOptions extends WebGLContextAttributes {
  115538. /**
  115539. * Defines if the engine should no exceed a specified device ratio
  115540. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115541. */
  115542. limitDeviceRatio?: number;
  115543. /**
  115544. * Defines if webvr should be enabled automatically
  115545. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115546. */
  115547. autoEnableWebVR?: boolean;
  115548. /**
  115549. * Defines if webgl2 should be turned off even if supported
  115550. * @see https://doc.babylonjs.com/features/webgl2
  115551. */
  115552. disableWebGL2Support?: boolean;
  115553. /**
  115554. * Defines if webaudio should be initialized as well
  115555. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115556. */
  115557. audioEngine?: boolean;
  115558. /**
  115559. * Defines if animations should run using a deterministic lock step
  115560. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115561. */
  115562. deterministicLockstep?: boolean;
  115563. /** Defines the maximum steps to use with deterministic lock step mode */
  115564. lockstepMaxSteps?: number;
  115565. /** Defines the seconds between each deterministic lock step */
  115566. timeStep?: number;
  115567. /**
  115568. * Defines that engine should ignore context lost events
  115569. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115570. */
  115571. doNotHandleContextLost?: boolean;
  115572. /**
  115573. * Defines that engine should ignore modifying touch action attribute and style
  115574. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115575. */
  115576. doNotHandleTouchAction?: boolean;
  115577. /**
  115578. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115579. */
  115580. useHighPrecisionFloats?: boolean;
  115581. /**
  115582. * Make the canvas XR Compatible for XR sessions
  115583. */
  115584. xrCompatible?: boolean;
  115585. /**
  115586. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115587. */
  115588. useHighPrecisionMatrix?: boolean;
  115589. }
  115590. /**
  115591. * The base engine class (root of all engines)
  115592. */
  115593. export class ThinEngine {
  115594. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115595. static ExceptionList: ({
  115596. key: string;
  115597. capture: string;
  115598. captureConstraint: number;
  115599. targets: string[];
  115600. } | {
  115601. key: string;
  115602. capture: null;
  115603. captureConstraint: null;
  115604. targets: string[];
  115605. })[];
  115606. /** @hidden */
  115607. static _TextureLoaders: IInternalTextureLoader[];
  115608. /**
  115609. * Returns the current npm package of the sdk
  115610. */
  115611. static get NpmPackage(): string;
  115612. /**
  115613. * Returns the current version of the framework
  115614. */
  115615. static get Version(): string;
  115616. /**
  115617. * Returns a string describing the current engine
  115618. */
  115619. get description(): string;
  115620. /**
  115621. * Gets or sets the epsilon value used by collision engine
  115622. */
  115623. static CollisionsEpsilon: number;
  115624. /**
  115625. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115626. */
  115627. static get ShadersRepository(): string;
  115628. static set ShadersRepository(value: string);
  115629. /** @hidden */
  115630. _shaderProcessor: IShaderProcessor;
  115631. /**
  115632. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115633. */
  115634. forcePOTTextures: boolean;
  115635. /**
  115636. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115637. */
  115638. isFullscreen: boolean;
  115639. /**
  115640. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115641. */
  115642. cullBackFaces: boolean;
  115643. /**
  115644. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115645. */
  115646. renderEvenInBackground: boolean;
  115647. /**
  115648. * Gets or sets a boolean indicating that cache can be kept between frames
  115649. */
  115650. preventCacheWipeBetweenFrames: boolean;
  115651. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  115652. validateShaderPrograms: boolean;
  115653. /**
  115654. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  115655. * This can provide greater z depth for distant objects.
  115656. */
  115657. useReverseDepthBuffer: boolean;
  115658. /**
  115659. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  115660. */
  115661. disableUniformBuffers: boolean;
  115662. /** @hidden */
  115663. _uniformBuffers: UniformBuffer[];
  115664. /**
  115665. * Gets a boolean indicating that the engine supports uniform buffers
  115666. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  115667. */
  115668. get supportsUniformBuffers(): boolean;
  115669. /** @hidden */
  115670. _gl: WebGLRenderingContext;
  115671. /** @hidden */
  115672. _webGLVersion: number;
  115673. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  115674. protected _windowIsBackground: boolean;
  115675. protected _creationOptions: EngineOptions;
  115676. protected _highPrecisionShadersAllowed: boolean;
  115677. /** @hidden */
  115678. get _shouldUseHighPrecisionShader(): boolean;
  115679. /**
  115680. * Gets a boolean indicating that only power of 2 textures are supported
  115681. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  115682. */
  115683. get needPOTTextures(): boolean;
  115684. /** @hidden */
  115685. _badOS: boolean;
  115686. /** @hidden */
  115687. _badDesktopOS: boolean;
  115688. private _hardwareScalingLevel;
  115689. /** @hidden */
  115690. _caps: EngineCapabilities;
  115691. private _isStencilEnable;
  115692. private _glVersion;
  115693. private _glRenderer;
  115694. private _glVendor;
  115695. /** @hidden */
  115696. _videoTextureSupported: boolean;
  115697. protected _renderingQueueLaunched: boolean;
  115698. protected _activeRenderLoops: (() => void)[];
  115699. /**
  115700. * Observable signaled when a context lost event is raised
  115701. */
  115702. onContextLostObservable: Observable<ThinEngine>;
  115703. /**
  115704. * Observable signaled when a context restored event is raised
  115705. */
  115706. onContextRestoredObservable: Observable<ThinEngine>;
  115707. private _onContextLost;
  115708. private _onContextRestored;
  115709. protected _contextWasLost: boolean;
  115710. /** @hidden */
  115711. _doNotHandleContextLost: boolean;
  115712. /**
  115713. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  115714. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  115715. */
  115716. get doNotHandleContextLost(): boolean;
  115717. set doNotHandleContextLost(value: boolean);
  115718. /**
  115719. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  115720. */
  115721. disableVertexArrayObjects: boolean;
  115722. /** @hidden */
  115723. protected _colorWrite: boolean;
  115724. /** @hidden */
  115725. protected _colorWriteChanged: boolean;
  115726. /** @hidden */
  115727. protected _depthCullingState: DepthCullingState;
  115728. /** @hidden */
  115729. protected _stencilState: StencilState;
  115730. /** @hidden */
  115731. _alphaState: AlphaState;
  115732. /** @hidden */
  115733. _alphaMode: number;
  115734. /** @hidden */
  115735. _alphaEquation: number;
  115736. /** @hidden */
  115737. _internalTexturesCache: InternalTexture[];
  115738. /** @hidden */
  115739. protected _activeChannel: number;
  115740. private _currentTextureChannel;
  115741. /** @hidden */
  115742. protected _boundTexturesCache: {
  115743. [key: string]: Nullable<InternalTexture>;
  115744. };
  115745. /** @hidden */
  115746. protected _currentEffect: Nullable<Effect>;
  115747. /** @hidden */
  115748. protected _currentProgram: Nullable<WebGLProgram>;
  115749. private _compiledEffects;
  115750. private _vertexAttribArraysEnabled;
  115751. /** @hidden */
  115752. protected _cachedViewport: Nullable<IViewportLike>;
  115753. private _cachedVertexArrayObject;
  115754. /** @hidden */
  115755. protected _cachedVertexBuffers: any;
  115756. /** @hidden */
  115757. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115758. /** @hidden */
  115759. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115760. /** @hidden */
  115761. _currentRenderTarget: Nullable<InternalTexture>;
  115762. private _uintIndicesCurrentlySet;
  115763. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115764. /** @hidden */
  115765. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115766. /** @hidden */
  115767. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115768. private _currentBufferPointers;
  115769. private _currentInstanceLocations;
  115770. private _currentInstanceBuffers;
  115771. private _textureUnits;
  115772. /** @hidden */
  115773. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115774. /** @hidden */
  115775. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115776. /** @hidden */
  115777. _boundRenderFunction: any;
  115778. private _vaoRecordInProgress;
  115779. private _mustWipeVertexAttributes;
  115780. private _emptyTexture;
  115781. private _emptyCubeTexture;
  115782. private _emptyTexture3D;
  115783. private _emptyTexture2DArray;
  115784. /** @hidden */
  115785. _frameHandler: number;
  115786. private _nextFreeTextureSlots;
  115787. private _maxSimultaneousTextures;
  115788. private _activeRequests;
  115789. /** @hidden */
  115790. _transformTextureUrl: Nullable<(url: string) => string>;
  115791. /**
  115792. * Gets information about the current host
  115793. */
  115794. hostInformation: HostInformation;
  115795. protected get _supportsHardwareTextureRescaling(): boolean;
  115796. private _framebufferDimensionsObject;
  115797. /**
  115798. * sets the object from which width and height will be taken from when getting render width and height
  115799. * Will fallback to the gl object
  115800. * @param dimensions the framebuffer width and height that will be used.
  115801. */
  115802. set framebufferDimensionsObject(dimensions: Nullable<{
  115803. framebufferWidth: number;
  115804. framebufferHeight: number;
  115805. }>);
  115806. /**
  115807. * Gets the current viewport
  115808. */
  115809. get currentViewport(): Nullable<IViewportLike>;
  115810. /**
  115811. * Gets the default empty texture
  115812. */
  115813. get emptyTexture(): InternalTexture;
  115814. /**
  115815. * Gets the default empty 3D texture
  115816. */
  115817. get emptyTexture3D(): InternalTexture;
  115818. /**
  115819. * Gets the default empty 2D array texture
  115820. */
  115821. get emptyTexture2DArray(): InternalTexture;
  115822. /**
  115823. * Gets the default empty cube texture
  115824. */
  115825. get emptyCubeTexture(): InternalTexture;
  115826. /**
  115827. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115828. */
  115829. readonly premultipliedAlpha: boolean;
  115830. /**
  115831. * Observable event triggered before each texture is initialized
  115832. */
  115833. onBeforeTextureInitObservable: Observable<Texture>;
  115834. /**
  115835. * Creates a new engine
  115836. * @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
  115837. * @param antialias defines enable antialiasing (default: false)
  115838. * @param options defines further options to be sent to the getContext() function
  115839. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115840. */
  115841. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115842. private _rebuildInternalTextures;
  115843. private _rebuildEffects;
  115844. /**
  115845. * Gets a boolean indicating if all created effects are ready
  115846. * @returns true if all effects are ready
  115847. */
  115848. areAllEffectsReady(): boolean;
  115849. protected _rebuildBuffers(): void;
  115850. protected _initGLContext(): void;
  115851. /**
  115852. * Gets version of the current webGL context
  115853. */
  115854. get webGLVersion(): number;
  115855. /**
  115856. * Gets a string identifying the name of the class
  115857. * @returns "Engine" string
  115858. */
  115859. getClassName(): string;
  115860. /**
  115861. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115862. */
  115863. get isStencilEnable(): boolean;
  115864. /** @hidden */
  115865. _prepareWorkingCanvas(): void;
  115866. /**
  115867. * Reset the texture cache to empty state
  115868. */
  115869. resetTextureCache(): void;
  115870. /**
  115871. * Gets an object containing information about the current webGL context
  115872. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115873. */
  115874. getGlInfo(): {
  115875. vendor: string;
  115876. renderer: string;
  115877. version: string;
  115878. };
  115879. /**
  115880. * Defines the hardware scaling level.
  115881. * By default the hardware scaling level is computed from the window device ratio.
  115882. * 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.
  115883. * @param level defines the level to use
  115884. */
  115885. setHardwareScalingLevel(level: number): void;
  115886. /**
  115887. * Gets the current hardware scaling level.
  115888. * By default the hardware scaling level is computed from the window device ratio.
  115889. * 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.
  115890. * @returns a number indicating the current hardware scaling level
  115891. */
  115892. getHardwareScalingLevel(): number;
  115893. /**
  115894. * Gets the list of loaded textures
  115895. * @returns an array containing all loaded textures
  115896. */
  115897. getLoadedTexturesCache(): InternalTexture[];
  115898. /**
  115899. * Gets the object containing all engine capabilities
  115900. * @returns the EngineCapabilities object
  115901. */
  115902. getCaps(): EngineCapabilities;
  115903. /**
  115904. * stop executing a render loop function and remove it from the execution array
  115905. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  115906. */
  115907. stopRenderLoop(renderFunction?: () => void): void;
  115908. /** @hidden */
  115909. _renderLoop(): void;
  115910. /**
  115911. * Gets the HTML canvas attached with the current webGL context
  115912. * @returns a HTML canvas
  115913. */
  115914. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  115915. /**
  115916. * Gets host window
  115917. * @returns the host window object
  115918. */
  115919. getHostWindow(): Nullable<Window>;
  115920. /**
  115921. * Gets the current render width
  115922. * @param useScreen defines if screen size must be used (or the current render target if any)
  115923. * @returns a number defining the current render width
  115924. */
  115925. getRenderWidth(useScreen?: boolean): number;
  115926. /**
  115927. * Gets the current render height
  115928. * @param useScreen defines if screen size must be used (or the current render target if any)
  115929. * @returns a number defining the current render height
  115930. */
  115931. getRenderHeight(useScreen?: boolean): number;
  115932. /**
  115933. * Can be used to override the current requestAnimationFrame requester.
  115934. * @hidden
  115935. */
  115936. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115937. /**
  115938. * Register and execute a render loop. The engine can have more than one render function
  115939. * @param renderFunction defines the function to continuously execute
  115940. */
  115941. runRenderLoop(renderFunction: () => void): void;
  115942. /**
  115943. * Clear the current render buffer or the current render target (if any is set up)
  115944. * @param color defines the color to use
  115945. * @param backBuffer defines if the back buffer must be cleared
  115946. * @param depth defines if the depth buffer must be cleared
  115947. * @param stencil defines if the stencil buffer must be cleared
  115948. */
  115949. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115950. private _viewportCached;
  115951. /** @hidden */
  115952. _viewport(x: number, y: number, width: number, height: number): void;
  115953. /**
  115954. * Set the WebGL's viewport
  115955. * @param viewport defines the viewport element to be used
  115956. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  115957. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  115958. */
  115959. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  115960. /**
  115961. * Begin a new frame
  115962. */
  115963. beginFrame(): void;
  115964. /**
  115965. * Enf the current frame
  115966. */
  115967. endFrame(): void;
  115968. /**
  115969. * Resize the view according to the canvas' size
  115970. */
  115971. resize(): void;
  115972. /**
  115973. * Force a specific size of the canvas
  115974. * @param width defines the new canvas' width
  115975. * @param height defines the new canvas' height
  115976. * @returns true if the size was changed
  115977. */
  115978. setSize(width: number, height: number): boolean;
  115979. /**
  115980. * Binds the frame buffer to the specified texture.
  115981. * @param texture The texture to render to or null for the default canvas
  115982. * @param faceIndex The face of the texture to render to in case of cube texture
  115983. * @param requiredWidth The width of the target to render to
  115984. * @param requiredHeight The height of the target to render to
  115985. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  115986. * @param lodLevel defines the lod level to bind to the frame buffer
  115987. * @param layer defines the 2d array index to bind to frame buffer to
  115988. */
  115989. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  115990. /** @hidden */
  115991. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  115992. /**
  115993. * Unbind the current render target texture from the webGL context
  115994. * @param texture defines the render target texture to unbind
  115995. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  115996. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  115997. */
  115998. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  115999. /**
  116000. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  116001. */
  116002. flushFramebuffer(): void;
  116003. /**
  116004. * Unbind the current render target and bind the default framebuffer
  116005. */
  116006. restoreDefaultFramebuffer(): void;
  116007. /** @hidden */
  116008. protected _resetVertexBufferBinding(): void;
  116009. /**
  116010. * Creates a vertex buffer
  116011. * @param data the data for the vertex buffer
  116012. * @returns the new WebGL static buffer
  116013. */
  116014. createVertexBuffer(data: DataArray): DataBuffer;
  116015. private _createVertexBuffer;
  116016. /**
  116017. * Creates a dynamic vertex buffer
  116018. * @param data the data for the dynamic vertex buffer
  116019. * @returns the new WebGL dynamic buffer
  116020. */
  116021. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  116022. protected _resetIndexBufferBinding(): void;
  116023. /**
  116024. * Creates a new index buffer
  116025. * @param indices defines the content of the index buffer
  116026. * @param updatable defines if the index buffer must be updatable
  116027. * @returns a new webGL buffer
  116028. */
  116029. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  116030. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  116031. /**
  116032. * Bind a webGL buffer to the webGL context
  116033. * @param buffer defines the buffer to bind
  116034. */
  116035. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  116036. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  116037. private bindBuffer;
  116038. /**
  116039. * update the bound buffer with the given data
  116040. * @param data defines the data to update
  116041. */
  116042. updateArrayBuffer(data: Float32Array): void;
  116043. private _vertexAttribPointer;
  116044. /** @hidden */
  116045. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  116046. private _bindVertexBuffersAttributes;
  116047. /**
  116048. * Records a vertex array object
  116049. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116050. * @param vertexBuffers defines the list of vertex buffers to store
  116051. * @param indexBuffer defines the index buffer to store
  116052. * @param effect defines the effect to store
  116053. * @returns the new vertex array object
  116054. */
  116055. recordVertexArrayObject(vertexBuffers: {
  116056. [key: string]: VertexBuffer;
  116057. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  116058. /**
  116059. * Bind a specific vertex array object
  116060. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116061. * @param vertexArrayObject defines the vertex array object to bind
  116062. * @param indexBuffer defines the index buffer to bind
  116063. */
  116064. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  116065. /**
  116066. * Bind webGl buffers directly to the webGL context
  116067. * @param vertexBuffer defines the vertex buffer to bind
  116068. * @param indexBuffer defines the index buffer to bind
  116069. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116070. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116071. * @param effect defines the effect associated with the vertex buffer
  116072. */
  116073. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  116074. private _unbindVertexArrayObject;
  116075. /**
  116076. * Bind a list of vertex buffers to the webGL context
  116077. * @param vertexBuffers defines the list of vertex buffers to bind
  116078. * @param indexBuffer defines the index buffer to bind
  116079. * @param effect defines the effect associated with the vertex buffers
  116080. */
  116081. bindBuffers(vertexBuffers: {
  116082. [key: string]: Nullable<VertexBuffer>;
  116083. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  116084. /**
  116085. * Unbind all instance attributes
  116086. */
  116087. unbindInstanceAttributes(): void;
  116088. /**
  116089. * Release and free the memory of a vertex array object
  116090. * @param vao defines the vertex array object to delete
  116091. */
  116092. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  116093. /** @hidden */
  116094. _releaseBuffer(buffer: DataBuffer): boolean;
  116095. protected _deleteBuffer(buffer: DataBuffer): void;
  116096. /**
  116097. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  116098. * @param instancesBuffer defines the webGL buffer to update and bind
  116099. * @param data defines the data to store in the buffer
  116100. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  116101. */
  116102. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  116103. /**
  116104. * Bind the content of a webGL buffer used with instantiation
  116105. * @param instancesBuffer defines the webGL buffer to bind
  116106. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  116107. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  116108. */
  116109. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  116110. /**
  116111. * Disable the instance attribute corresponding to the name in parameter
  116112. * @param name defines the name of the attribute to disable
  116113. */
  116114. disableInstanceAttributeByName(name: string): void;
  116115. /**
  116116. * Disable the instance attribute corresponding to the location in parameter
  116117. * @param attributeLocation defines the attribute location of the attribute to disable
  116118. */
  116119. disableInstanceAttribute(attributeLocation: number): void;
  116120. /**
  116121. * Disable the attribute corresponding to the location in parameter
  116122. * @param attributeLocation defines the attribute location of the attribute to disable
  116123. */
  116124. disableAttributeByIndex(attributeLocation: number): void;
  116125. /**
  116126. * Send a draw order
  116127. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116128. * @param indexStart defines the starting index
  116129. * @param indexCount defines the number of index to draw
  116130. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116131. */
  116132. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116133. /**
  116134. * Draw a list of points
  116135. * @param verticesStart defines the index of first vertex to draw
  116136. * @param verticesCount defines the count of vertices to draw
  116137. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116138. */
  116139. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116140. /**
  116141. * Draw a list of unindexed primitives
  116142. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116143. * @param verticesStart defines the index of first vertex to draw
  116144. * @param verticesCount defines the count of vertices to draw
  116145. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116146. */
  116147. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116148. /**
  116149. * Draw a list of indexed primitives
  116150. * @param fillMode defines the primitive to use
  116151. * @param indexStart defines the starting index
  116152. * @param indexCount defines the number of index to draw
  116153. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116154. */
  116155. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116156. /**
  116157. * Draw a list of unindexed primitives
  116158. * @param fillMode defines the primitive to use
  116159. * @param verticesStart defines the index of first vertex to draw
  116160. * @param verticesCount defines the count of vertices to draw
  116161. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116162. */
  116163. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116164. private _drawMode;
  116165. /** @hidden */
  116166. protected _reportDrawCall(): void;
  116167. /** @hidden */
  116168. _releaseEffect(effect: Effect): void;
  116169. /** @hidden */
  116170. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116171. /**
  116172. * Create a new effect (used to store vertex/fragment shaders)
  116173. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  116174. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  116175. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  116176. * @param samplers defines an array of string used to represent textures
  116177. * @param defines defines the string containing the defines to use to compile the shaders
  116178. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116179. * @param onCompiled defines a function to call when the effect creation is successful
  116180. * @param onError defines a function to call when the effect creation has failed
  116181. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  116182. * @returns the new Effect
  116183. */
  116184. 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;
  116185. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  116186. private _compileShader;
  116187. private _compileRawShader;
  116188. /** @hidden */
  116189. _getShaderSource(shader: WebGLShader): Nullable<string>;
  116190. /**
  116191. * Directly creates a webGL program
  116192. * @param pipelineContext defines the pipeline context to attach to
  116193. * @param vertexCode defines the vertex shader code to use
  116194. * @param fragmentCode defines the fragment shader code to use
  116195. * @param context defines the webGL context to use (if not set, the current one will be used)
  116196. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116197. * @returns the new webGL program
  116198. */
  116199. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116200. /**
  116201. * Creates a webGL program
  116202. * @param pipelineContext defines the pipeline context to attach to
  116203. * @param vertexCode defines the vertex shader code to use
  116204. * @param fragmentCode defines the fragment shader code to use
  116205. * @param defines defines the string containing the defines to use to compile the shaders
  116206. * @param context defines the webGL context to use (if not set, the current one will be used)
  116207. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116208. * @returns the new webGL program
  116209. */
  116210. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116211. /**
  116212. * Creates a new pipeline context
  116213. * @returns the new pipeline
  116214. */
  116215. createPipelineContext(): IPipelineContext;
  116216. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116217. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  116218. /** @hidden */
  116219. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  116220. /** @hidden */
  116221. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  116222. /** @hidden */
  116223. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  116224. /**
  116225. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116226. * @param pipelineContext defines the pipeline context to use
  116227. * @param uniformsNames defines the list of uniform names
  116228. * @returns an array of webGL uniform locations
  116229. */
  116230. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116231. /**
  116232. * Gets the lsit of active attributes for a given webGL program
  116233. * @param pipelineContext defines the pipeline context to use
  116234. * @param attributesNames defines the list of attribute names to get
  116235. * @returns an array of indices indicating the offset of each attribute
  116236. */
  116237. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116238. /**
  116239. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116240. * @param effect defines the effect to activate
  116241. */
  116242. enableEffect(effect: Nullable<Effect>): void;
  116243. /**
  116244. * Set the value of an uniform to a number (int)
  116245. * @param uniform defines the webGL uniform location where to store the value
  116246. * @param value defines the int number to store
  116247. * @returns true if the value was set
  116248. */
  116249. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116250. /**
  116251. * Set the value of an uniform to an array of int32
  116252. * @param uniform defines the webGL uniform location where to store the value
  116253. * @param array defines the array of int32 to store
  116254. * @returns true if the value was set
  116255. */
  116256. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116257. /**
  116258. * Set the value of an uniform to an array of int32 (stored as vec2)
  116259. * @param uniform defines the webGL uniform location where to store the value
  116260. * @param array defines the array of int32 to store
  116261. * @returns true if the value was set
  116262. */
  116263. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116264. /**
  116265. * Set the value of an uniform to an array of int32 (stored as vec3)
  116266. * @param uniform defines the webGL uniform location where to store the value
  116267. * @param array defines the array of int32 to store
  116268. * @returns true if the value was set
  116269. */
  116270. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116271. /**
  116272. * Set the value of an uniform to an array of int32 (stored as vec4)
  116273. * @param uniform defines the webGL uniform location where to store the value
  116274. * @param array defines the array of int32 to store
  116275. * @returns true if the value was set
  116276. */
  116277. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116278. /**
  116279. * Set the value of an uniform to an array of number
  116280. * @param uniform defines the webGL uniform location where to store the value
  116281. * @param array defines the array of number to store
  116282. * @returns true if the value was set
  116283. */
  116284. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116285. /**
  116286. * Set the value of an uniform to an array of number (stored as vec2)
  116287. * @param uniform defines the webGL uniform location where to store the value
  116288. * @param array defines the array of number to store
  116289. * @returns true if the value was set
  116290. */
  116291. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116292. /**
  116293. * Set the value of an uniform to an array of number (stored as vec3)
  116294. * @param uniform defines the webGL uniform location where to store the value
  116295. * @param array defines the array of number to store
  116296. * @returns true if the value was set
  116297. */
  116298. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116299. /**
  116300. * Set the value of an uniform to an array of number (stored as vec4)
  116301. * @param uniform defines the webGL uniform location where to store the value
  116302. * @param array defines the array of number to store
  116303. * @returns true if the value was set
  116304. */
  116305. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116306. /**
  116307. * Set the value of an uniform to an array of float32 (stored as matrices)
  116308. * @param uniform defines the webGL uniform location where to store the value
  116309. * @param matrices defines the array of float32 to store
  116310. * @returns true if the value was set
  116311. */
  116312. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  116313. /**
  116314. * Set the value of an uniform to a matrix (3x3)
  116315. * @param uniform defines the webGL uniform location where to store the value
  116316. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116317. * @returns true if the value was set
  116318. */
  116319. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116320. /**
  116321. * Set the value of an uniform to a matrix (2x2)
  116322. * @param uniform defines the webGL uniform location where to store the value
  116323. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116324. * @returns true if the value was set
  116325. */
  116326. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116327. /**
  116328. * Set the value of an uniform to a number (float)
  116329. * @param uniform defines the webGL uniform location where to store the value
  116330. * @param value defines the float number to store
  116331. * @returns true if the value was transfered
  116332. */
  116333. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116334. /**
  116335. * Set the value of an uniform to a vec2
  116336. * @param uniform defines the webGL uniform location where to store the value
  116337. * @param x defines the 1st component of the value
  116338. * @param y defines the 2nd component of the value
  116339. * @returns true if the value was set
  116340. */
  116341. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  116342. /**
  116343. * Set the value of an uniform to a vec3
  116344. * @param uniform defines the webGL uniform location where to store the value
  116345. * @param x defines the 1st component of the value
  116346. * @param y defines the 2nd component of the value
  116347. * @param z defines the 3rd component of the value
  116348. * @returns true if the value was set
  116349. */
  116350. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  116351. /**
  116352. * Set the value of an uniform to a vec4
  116353. * @param uniform defines the webGL uniform location where to store the value
  116354. * @param x defines the 1st component of the value
  116355. * @param y defines the 2nd component of the value
  116356. * @param z defines the 3rd component of the value
  116357. * @param w defines the 4th component of the value
  116358. * @returns true if the value was set
  116359. */
  116360. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  116361. /**
  116362. * Apply all cached states (depth, culling, stencil and alpha)
  116363. */
  116364. applyStates(): void;
  116365. /**
  116366. * Enable or disable color writing
  116367. * @param enable defines the state to set
  116368. */
  116369. setColorWrite(enable: boolean): void;
  116370. /**
  116371. * Gets a boolean indicating if color writing is enabled
  116372. * @returns the current color writing state
  116373. */
  116374. getColorWrite(): boolean;
  116375. /**
  116376. * Gets the depth culling state manager
  116377. */
  116378. get depthCullingState(): DepthCullingState;
  116379. /**
  116380. * Gets the alpha state manager
  116381. */
  116382. get alphaState(): AlphaState;
  116383. /**
  116384. * Gets the stencil state manager
  116385. */
  116386. get stencilState(): StencilState;
  116387. /**
  116388. * Clears the list of texture accessible through engine.
  116389. * This can help preventing texture load conflict due to name collision.
  116390. */
  116391. clearInternalTexturesCache(): void;
  116392. /**
  116393. * Force the entire cache to be cleared
  116394. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116395. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116396. */
  116397. wipeCaches(bruteForce?: boolean): void;
  116398. /** @hidden */
  116399. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  116400. min: number;
  116401. mag: number;
  116402. };
  116403. /** @hidden */
  116404. _createTexture(): WebGLTexture;
  116405. /**
  116406. * Usually called from Texture.ts.
  116407. * Passed information to create a WebGLTexture
  116408. * @param url defines a value which contains one of the following:
  116409. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116410. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116411. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116412. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116413. * @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)
  116414. * @param scene needed for loading to the correct scene
  116415. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116416. * @param onLoad optional callback to be called upon successful completion
  116417. * @param onError optional callback to be called upon failure
  116418. * @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
  116419. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116420. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116421. * @param forcedExtension defines the extension to use to pick the right loader
  116422. * @param mimeType defines an optional mime type
  116423. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116424. */
  116425. 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;
  116426. /**
  116427. * Loads an image as an HTMLImageElement.
  116428. * @param input url string, ArrayBuffer, or Blob to load
  116429. * @param onLoad callback called when the image successfully loads
  116430. * @param onError callback called when the image fails to load
  116431. * @param offlineProvider offline provider for caching
  116432. * @param mimeType optional mime type
  116433. * @returns the HTMLImageElement of the loaded image
  116434. * @hidden
  116435. */
  116436. 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>;
  116437. /**
  116438. * @hidden
  116439. */
  116440. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116441. private _unpackFlipYCached;
  116442. /**
  116443. * In case you are sharing the context with other applications, it might
  116444. * be interested to not cache the unpack flip y state to ensure a consistent
  116445. * value would be set.
  116446. */
  116447. enableUnpackFlipYCached: boolean;
  116448. /** @hidden */
  116449. _unpackFlipY(value: boolean): void;
  116450. /** @hidden */
  116451. _getUnpackAlignement(): number;
  116452. private _getTextureTarget;
  116453. /**
  116454. * Update the sampling mode of a given texture
  116455. * @param samplingMode defines the required sampling mode
  116456. * @param texture defines the texture to update
  116457. * @param generateMipMaps defines whether to generate mipmaps for the texture
  116458. */
  116459. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  116460. /**
  116461. * Update the sampling mode of a given texture
  116462. * @param texture defines the texture to update
  116463. * @param wrapU defines the texture wrap mode of the u coordinates
  116464. * @param wrapV defines the texture wrap mode of the v coordinates
  116465. * @param wrapR defines the texture wrap mode of the r coordinates
  116466. */
  116467. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  116468. /** @hidden */
  116469. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  116470. width: number;
  116471. height: number;
  116472. layers?: number;
  116473. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  116474. /** @hidden */
  116475. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116476. /** @hidden */
  116477. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  116478. /**
  116479. * Update a portion of an internal texture
  116480. * @param texture defines the texture to update
  116481. * @param imageData defines the data to store into the texture
  116482. * @param xOffset defines the x coordinates of the update rectangle
  116483. * @param yOffset defines the y coordinates of the update rectangle
  116484. * @param width defines the width of the update rectangle
  116485. * @param height defines the height of the update rectangle
  116486. * @param faceIndex defines the face index if texture is a cube (0 by default)
  116487. * @param lod defines the lod level to update (0 by default)
  116488. */
  116489. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  116490. /** @hidden */
  116491. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116492. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  116493. private _prepareWebGLTexture;
  116494. /** @hidden */
  116495. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  116496. private _getDepthStencilBuffer;
  116497. /** @hidden */
  116498. _releaseFramebufferObjects(texture: InternalTexture): void;
  116499. /** @hidden */
  116500. _releaseTexture(texture: InternalTexture): void;
  116501. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116502. protected _setProgram(program: WebGLProgram): void;
  116503. protected _boundUniforms: {
  116504. [key: number]: WebGLUniformLocation;
  116505. };
  116506. /**
  116507. * Binds an effect to the webGL context
  116508. * @param effect defines the effect to bind
  116509. */
  116510. bindSamplers(effect: Effect): void;
  116511. private _activateCurrentTexture;
  116512. /** @hidden */
  116513. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  116514. /** @hidden */
  116515. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  116516. /**
  116517. * Unbind all textures from the webGL context
  116518. */
  116519. unbindAllTextures(): void;
  116520. /**
  116521. * Sets a texture to the according uniform.
  116522. * @param channel The texture channel
  116523. * @param uniform The uniform to set
  116524. * @param texture The texture to apply
  116525. */
  116526. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  116527. private _bindSamplerUniformToChannel;
  116528. private _getTextureWrapMode;
  116529. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116530. /**
  116531. * Sets an array of texture to the webGL context
  116532. * @param channel defines the channel where the texture array must be set
  116533. * @param uniform defines the associated uniform location
  116534. * @param textures defines the array of textures to bind
  116535. */
  116536. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  116537. /** @hidden */
  116538. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  116539. private _setTextureParameterFloat;
  116540. private _setTextureParameterInteger;
  116541. /**
  116542. * Unbind all vertex attributes from the webGL context
  116543. */
  116544. unbindAllAttributes(): void;
  116545. /**
  116546. * 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
  116547. */
  116548. releaseEffects(): void;
  116549. /**
  116550. * Dispose and release all associated resources
  116551. */
  116552. dispose(): void;
  116553. /**
  116554. * Attach a new callback raised when context lost event is fired
  116555. * @param callback defines the callback to call
  116556. */
  116557. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116558. /**
  116559. * Attach a new callback raised when context restored event is fired
  116560. * @param callback defines the callback to call
  116561. */
  116562. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116563. /**
  116564. * Get the current error code of the webGL context
  116565. * @returns the error code
  116566. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116567. */
  116568. getError(): number;
  116569. private _canRenderToFloatFramebuffer;
  116570. private _canRenderToHalfFloatFramebuffer;
  116571. private _canRenderToFramebuffer;
  116572. /** @hidden */
  116573. _getWebGLTextureType(type: number): number;
  116574. /** @hidden */
  116575. _getInternalFormat(format: number): number;
  116576. /** @hidden */
  116577. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116578. /** @hidden */
  116579. _getRGBAMultiSampleBufferFormat(type: number): number;
  116580. /** @hidden */
  116581. _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;
  116582. /**
  116583. * Loads a file from a url
  116584. * @param url url to load
  116585. * @param onSuccess callback called when the file successfully loads
  116586. * @param onProgress callback called while file is loading (if the server supports this mode)
  116587. * @param offlineProvider defines the offline provider for caching
  116588. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116589. * @param onError callback called when the file fails to load
  116590. * @returns a file request object
  116591. * @hidden
  116592. */
  116593. 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;
  116594. /**
  116595. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116596. * @param x defines the x coordinate of the rectangle where pixels must be read
  116597. * @param y defines the y coordinate of the rectangle where pixels must be read
  116598. * @param width defines the width of the rectangle where pixels must be read
  116599. * @param height defines the height of the rectangle where pixels must be read
  116600. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116601. * @returns a Uint8Array containing RGBA colors
  116602. */
  116603. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116604. private static _isSupported;
  116605. /**
  116606. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116607. * @returns true if the engine can be created
  116608. * @ignorenaming
  116609. */
  116610. static isSupported(): boolean;
  116611. /**
  116612. * Find the next highest power of two.
  116613. * @param x Number to start search from.
  116614. * @return Next highest power of two.
  116615. */
  116616. static CeilingPOT(x: number): number;
  116617. /**
  116618. * Find the next lowest power of two.
  116619. * @param x Number to start search from.
  116620. * @return Next lowest power of two.
  116621. */
  116622. static FloorPOT(x: number): number;
  116623. /**
  116624. * Find the nearest power of two.
  116625. * @param x Number to start search from.
  116626. * @return Next nearest power of two.
  116627. */
  116628. static NearestPOT(x: number): number;
  116629. /**
  116630. * Get the closest exponent of two
  116631. * @param value defines the value to approximate
  116632. * @param max defines the maximum value to return
  116633. * @param mode defines how to define the closest value
  116634. * @returns closest exponent of two of the given value
  116635. */
  116636. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116637. /**
  116638. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  116639. * @param func - the function to be called
  116640. * @param requester - the object that will request the next frame. Falls back to window.
  116641. * @returns frame number
  116642. */
  116643. static QueueNewFrame(func: () => void, requester?: any): number;
  116644. /**
  116645. * Gets host document
  116646. * @returns the host document object
  116647. */
  116648. getHostDocument(): Nullable<Document>;
  116649. }
  116650. }
  116651. declare module BABYLON {
  116652. /**
  116653. * Class representing spherical harmonics coefficients to the 3rd degree
  116654. */
  116655. export class SphericalHarmonics {
  116656. /**
  116657. * Defines whether or not the harmonics have been prescaled for rendering.
  116658. */
  116659. preScaled: boolean;
  116660. /**
  116661. * The l0,0 coefficients of the spherical harmonics
  116662. */
  116663. l00: Vector3;
  116664. /**
  116665. * The l1,-1 coefficients of the spherical harmonics
  116666. */
  116667. l1_1: Vector3;
  116668. /**
  116669. * The l1,0 coefficients of the spherical harmonics
  116670. */
  116671. l10: Vector3;
  116672. /**
  116673. * The l1,1 coefficients of the spherical harmonics
  116674. */
  116675. l11: Vector3;
  116676. /**
  116677. * The l2,-2 coefficients of the spherical harmonics
  116678. */
  116679. l2_2: Vector3;
  116680. /**
  116681. * The l2,-1 coefficients of the spherical harmonics
  116682. */
  116683. l2_1: Vector3;
  116684. /**
  116685. * The l2,0 coefficients of the spherical harmonics
  116686. */
  116687. l20: Vector3;
  116688. /**
  116689. * The l2,1 coefficients of the spherical harmonics
  116690. */
  116691. l21: Vector3;
  116692. /**
  116693. * The l2,2 coefficients of the spherical harmonics
  116694. */
  116695. l22: Vector3;
  116696. /**
  116697. * Adds a light to the spherical harmonics
  116698. * @param direction the direction of the light
  116699. * @param color the color of the light
  116700. * @param deltaSolidAngle the delta solid angle of the light
  116701. */
  116702. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  116703. /**
  116704. * Scales the spherical harmonics by the given amount
  116705. * @param scale the amount to scale
  116706. */
  116707. scaleInPlace(scale: number): void;
  116708. /**
  116709. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  116710. *
  116711. * ```
  116712. * E_lm = A_l * L_lm
  116713. * ```
  116714. *
  116715. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  116716. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  116717. * the scaling factors are given in equation 9.
  116718. */
  116719. convertIncidentRadianceToIrradiance(): void;
  116720. /**
  116721. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  116722. *
  116723. * ```
  116724. * L = (1/pi) * E * rho
  116725. * ```
  116726. *
  116727. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  116728. */
  116729. convertIrradianceToLambertianRadiance(): void;
  116730. /**
  116731. * Integrates the reconstruction coefficients directly in to the SH preventing further
  116732. * required operations at run time.
  116733. *
  116734. * This is simply done by scaling back the SH with Ylm constants parameter.
  116735. * The trigonometric part being applied by the shader at run time.
  116736. */
  116737. preScaleForRendering(): void;
  116738. /**
  116739. * Constructs a spherical harmonics from an array.
  116740. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  116741. * @returns the spherical harmonics
  116742. */
  116743. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  116744. /**
  116745. * Gets the spherical harmonics from polynomial
  116746. * @param polynomial the spherical polynomial
  116747. * @returns the spherical harmonics
  116748. */
  116749. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  116750. }
  116751. /**
  116752. * Class representing spherical polynomial coefficients to the 3rd degree
  116753. */
  116754. export class SphericalPolynomial {
  116755. private _harmonics;
  116756. /**
  116757. * The spherical harmonics used to create the polynomials.
  116758. */
  116759. get preScaledHarmonics(): SphericalHarmonics;
  116760. /**
  116761. * The x coefficients of the spherical polynomial
  116762. */
  116763. x: Vector3;
  116764. /**
  116765. * The y coefficients of the spherical polynomial
  116766. */
  116767. y: Vector3;
  116768. /**
  116769. * The z coefficients of the spherical polynomial
  116770. */
  116771. z: Vector3;
  116772. /**
  116773. * The xx coefficients of the spherical polynomial
  116774. */
  116775. xx: Vector3;
  116776. /**
  116777. * The yy coefficients of the spherical polynomial
  116778. */
  116779. yy: Vector3;
  116780. /**
  116781. * The zz coefficients of the spherical polynomial
  116782. */
  116783. zz: Vector3;
  116784. /**
  116785. * The xy coefficients of the spherical polynomial
  116786. */
  116787. xy: Vector3;
  116788. /**
  116789. * The yz coefficients of the spherical polynomial
  116790. */
  116791. yz: Vector3;
  116792. /**
  116793. * The zx coefficients of the spherical polynomial
  116794. */
  116795. zx: Vector3;
  116796. /**
  116797. * Adds an ambient color to the spherical polynomial
  116798. * @param color the color to add
  116799. */
  116800. addAmbient(color: Color3): void;
  116801. /**
  116802. * Scales the spherical polynomial by the given amount
  116803. * @param scale the amount to scale
  116804. */
  116805. scaleInPlace(scale: number): void;
  116806. /**
  116807. * Gets the spherical polynomial from harmonics
  116808. * @param harmonics the spherical harmonics
  116809. * @returns the spherical polynomial
  116810. */
  116811. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116812. /**
  116813. * Constructs a spherical polynomial from an array.
  116814. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116815. * @returns the spherical polynomial
  116816. */
  116817. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116818. }
  116819. }
  116820. declare module BABYLON {
  116821. /**
  116822. * Defines the source of the internal texture
  116823. */
  116824. export enum InternalTextureSource {
  116825. /**
  116826. * The source of the texture data is unknown
  116827. */
  116828. Unknown = 0,
  116829. /**
  116830. * Texture data comes from an URL
  116831. */
  116832. Url = 1,
  116833. /**
  116834. * Texture data is only used for temporary storage
  116835. */
  116836. Temp = 2,
  116837. /**
  116838. * Texture data comes from raw data (ArrayBuffer)
  116839. */
  116840. Raw = 3,
  116841. /**
  116842. * Texture content is dynamic (video or dynamic texture)
  116843. */
  116844. Dynamic = 4,
  116845. /**
  116846. * Texture content is generated by rendering to it
  116847. */
  116848. RenderTarget = 5,
  116849. /**
  116850. * Texture content is part of a multi render target process
  116851. */
  116852. MultiRenderTarget = 6,
  116853. /**
  116854. * Texture data comes from a cube data file
  116855. */
  116856. Cube = 7,
  116857. /**
  116858. * Texture data comes from a raw cube data
  116859. */
  116860. CubeRaw = 8,
  116861. /**
  116862. * Texture data come from a prefiltered cube data file
  116863. */
  116864. CubePrefiltered = 9,
  116865. /**
  116866. * Texture content is raw 3D data
  116867. */
  116868. Raw3D = 10,
  116869. /**
  116870. * Texture content is raw 2D array data
  116871. */
  116872. Raw2DArray = 11,
  116873. /**
  116874. * Texture content is a depth texture
  116875. */
  116876. Depth = 12,
  116877. /**
  116878. * Texture data comes from a raw cube data encoded with RGBD
  116879. */
  116880. CubeRawRGBD = 13
  116881. }
  116882. /**
  116883. * Class used to store data associated with WebGL texture data for the engine
  116884. * This class should not be used directly
  116885. */
  116886. export class InternalTexture {
  116887. /** @hidden */
  116888. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116889. /**
  116890. * Defines if the texture is ready
  116891. */
  116892. isReady: boolean;
  116893. /**
  116894. * Defines if the texture is a cube texture
  116895. */
  116896. isCube: boolean;
  116897. /**
  116898. * Defines if the texture contains 3D data
  116899. */
  116900. is3D: boolean;
  116901. /**
  116902. * Defines if the texture contains 2D array data
  116903. */
  116904. is2DArray: boolean;
  116905. /**
  116906. * Defines if the texture contains multiview data
  116907. */
  116908. isMultiview: boolean;
  116909. /**
  116910. * Gets the URL used to load this texture
  116911. */
  116912. url: string;
  116913. /**
  116914. * Gets the sampling mode of the texture
  116915. */
  116916. samplingMode: number;
  116917. /**
  116918. * Gets a boolean indicating if the texture needs mipmaps generation
  116919. */
  116920. generateMipMaps: boolean;
  116921. /**
  116922. * Gets the number of samples used by the texture (WebGL2+ only)
  116923. */
  116924. samples: number;
  116925. /**
  116926. * Gets the type of the texture (int, float...)
  116927. */
  116928. type: number;
  116929. /**
  116930. * Gets the format of the texture (RGB, RGBA...)
  116931. */
  116932. format: number;
  116933. /**
  116934. * Observable called when the texture is loaded
  116935. */
  116936. onLoadedObservable: Observable<InternalTexture>;
  116937. /**
  116938. * Gets the width of the texture
  116939. */
  116940. width: number;
  116941. /**
  116942. * Gets the height of the texture
  116943. */
  116944. height: number;
  116945. /**
  116946. * Gets the depth of the texture
  116947. */
  116948. depth: number;
  116949. /**
  116950. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  116951. */
  116952. baseWidth: number;
  116953. /**
  116954. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  116955. */
  116956. baseHeight: number;
  116957. /**
  116958. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  116959. */
  116960. baseDepth: number;
  116961. /**
  116962. * Gets a boolean indicating if the texture is inverted on Y axis
  116963. */
  116964. invertY: boolean;
  116965. /** @hidden */
  116966. _invertVScale: boolean;
  116967. /** @hidden */
  116968. _associatedChannel: number;
  116969. /** @hidden */
  116970. _source: InternalTextureSource;
  116971. /** @hidden */
  116972. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  116973. /** @hidden */
  116974. _bufferView: Nullable<ArrayBufferView>;
  116975. /** @hidden */
  116976. _bufferViewArray: Nullable<ArrayBufferView[]>;
  116977. /** @hidden */
  116978. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  116979. /** @hidden */
  116980. _size: number;
  116981. /** @hidden */
  116982. _extension: string;
  116983. /** @hidden */
  116984. _files: Nullable<string[]>;
  116985. /** @hidden */
  116986. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  116987. /** @hidden */
  116988. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  116989. /** @hidden */
  116990. _framebuffer: Nullable<WebGLFramebuffer>;
  116991. /** @hidden */
  116992. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  116993. /** @hidden */
  116994. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  116995. /** @hidden */
  116996. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  116997. /** @hidden */
  116998. _attachments: Nullable<number[]>;
  116999. /** @hidden */
  117000. _textureArray: Nullable<InternalTexture[]>;
  117001. /** @hidden */
  117002. _cachedCoordinatesMode: Nullable<number>;
  117003. /** @hidden */
  117004. _cachedWrapU: Nullable<number>;
  117005. /** @hidden */
  117006. _cachedWrapV: Nullable<number>;
  117007. /** @hidden */
  117008. _cachedWrapR: Nullable<number>;
  117009. /** @hidden */
  117010. _cachedAnisotropicFilteringLevel: Nullable<number>;
  117011. /** @hidden */
  117012. _isDisabled: boolean;
  117013. /** @hidden */
  117014. _compression: Nullable<string>;
  117015. /** @hidden */
  117016. _generateStencilBuffer: boolean;
  117017. /** @hidden */
  117018. _generateDepthBuffer: boolean;
  117019. /** @hidden */
  117020. _comparisonFunction: number;
  117021. /** @hidden */
  117022. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  117023. /** @hidden */
  117024. _lodGenerationScale: number;
  117025. /** @hidden */
  117026. _lodGenerationOffset: number;
  117027. /** @hidden */
  117028. _depthStencilTexture: Nullable<InternalTexture>;
  117029. /** @hidden */
  117030. _colorTextureArray: Nullable<WebGLTexture>;
  117031. /** @hidden */
  117032. _depthStencilTextureArray: Nullable<WebGLTexture>;
  117033. /** @hidden */
  117034. _lodTextureHigh: Nullable<BaseTexture>;
  117035. /** @hidden */
  117036. _lodTextureMid: Nullable<BaseTexture>;
  117037. /** @hidden */
  117038. _lodTextureLow: Nullable<BaseTexture>;
  117039. /** @hidden */
  117040. _isRGBD: boolean;
  117041. /** @hidden */
  117042. _linearSpecularLOD: boolean;
  117043. /** @hidden */
  117044. _irradianceTexture: Nullable<BaseTexture>;
  117045. /** @hidden */
  117046. _webGLTexture: Nullable<WebGLTexture>;
  117047. /** @hidden */
  117048. _references: number;
  117049. /** @hidden */
  117050. _gammaSpace: Nullable<boolean>;
  117051. private _engine;
  117052. /**
  117053. * Gets the Engine the texture belongs to.
  117054. * @returns The babylon engine
  117055. */
  117056. getEngine(): ThinEngine;
  117057. /**
  117058. * Gets the data source type of the texture
  117059. */
  117060. get source(): InternalTextureSource;
  117061. /**
  117062. * Creates a new InternalTexture
  117063. * @param engine defines the engine to use
  117064. * @param source defines the type of data that will be used
  117065. * @param delayAllocation if the texture allocation should be delayed (default: false)
  117066. */
  117067. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  117068. /**
  117069. * Increments the number of references (ie. the number of Texture that point to it)
  117070. */
  117071. incrementReferences(): void;
  117072. /**
  117073. * Change the size of the texture (not the size of the content)
  117074. * @param width defines the new width
  117075. * @param height defines the new height
  117076. * @param depth defines the new depth (1 by default)
  117077. */
  117078. updateSize(width: int, height: int, depth?: int): void;
  117079. /** @hidden */
  117080. _rebuild(): void;
  117081. /** @hidden */
  117082. _swapAndDie(target: InternalTexture): void;
  117083. /**
  117084. * Dispose the current allocated resources
  117085. */
  117086. dispose(): void;
  117087. }
  117088. }
  117089. declare module BABYLON {
  117090. /**
  117091. * Class used to work with sound analyzer using fast fourier transform (FFT)
  117092. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117093. */
  117094. export class Analyser {
  117095. /**
  117096. * Gets or sets the smoothing
  117097. * @ignorenaming
  117098. */
  117099. SMOOTHING: number;
  117100. /**
  117101. * Gets or sets the FFT table size
  117102. * @ignorenaming
  117103. */
  117104. FFT_SIZE: number;
  117105. /**
  117106. * Gets or sets the bar graph amplitude
  117107. * @ignorenaming
  117108. */
  117109. BARGRAPHAMPLITUDE: number;
  117110. /**
  117111. * Gets or sets the position of the debug canvas
  117112. * @ignorenaming
  117113. */
  117114. DEBUGCANVASPOS: {
  117115. x: number;
  117116. y: number;
  117117. };
  117118. /**
  117119. * Gets or sets the debug canvas size
  117120. * @ignorenaming
  117121. */
  117122. DEBUGCANVASSIZE: {
  117123. width: number;
  117124. height: number;
  117125. };
  117126. private _byteFreqs;
  117127. private _byteTime;
  117128. private _floatFreqs;
  117129. private _webAudioAnalyser;
  117130. private _debugCanvas;
  117131. private _debugCanvasContext;
  117132. private _scene;
  117133. private _registerFunc;
  117134. private _audioEngine;
  117135. /**
  117136. * Creates a new analyser
  117137. * @param scene defines hosting scene
  117138. */
  117139. constructor(scene: Scene);
  117140. /**
  117141. * Get the number of data values you will have to play with for the visualization
  117142. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  117143. * @returns a number
  117144. */
  117145. getFrequencyBinCount(): number;
  117146. /**
  117147. * Gets the current frequency data as a byte array
  117148. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117149. * @returns a Uint8Array
  117150. */
  117151. getByteFrequencyData(): Uint8Array;
  117152. /**
  117153. * Gets the current waveform as a byte array
  117154. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  117155. * @returns a Uint8Array
  117156. */
  117157. getByteTimeDomainData(): Uint8Array;
  117158. /**
  117159. * Gets the current frequency data as a float array
  117160. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117161. * @returns a Float32Array
  117162. */
  117163. getFloatFrequencyData(): Float32Array;
  117164. /**
  117165. * Renders the debug canvas
  117166. */
  117167. drawDebugCanvas(): void;
  117168. /**
  117169. * Stops rendering the debug canvas and removes it
  117170. */
  117171. stopDebugCanvas(): void;
  117172. /**
  117173. * Connects two audio nodes
  117174. * @param inputAudioNode defines first node to connect
  117175. * @param outputAudioNode defines second node to connect
  117176. */
  117177. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  117178. /**
  117179. * Releases all associated resources
  117180. */
  117181. dispose(): void;
  117182. }
  117183. }
  117184. declare module BABYLON {
  117185. /**
  117186. * This represents an audio engine and it is responsible
  117187. * to play, synchronize and analyse sounds throughout the application.
  117188. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117189. */
  117190. export interface IAudioEngine extends IDisposable {
  117191. /**
  117192. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117193. */
  117194. readonly canUseWebAudio: boolean;
  117195. /**
  117196. * Gets the current AudioContext if available.
  117197. */
  117198. readonly audioContext: Nullable<AudioContext>;
  117199. /**
  117200. * The master gain node defines the global audio volume of your audio engine.
  117201. */
  117202. readonly masterGain: GainNode;
  117203. /**
  117204. * Gets whether or not mp3 are supported by your browser.
  117205. */
  117206. readonly isMP3supported: boolean;
  117207. /**
  117208. * Gets whether or not ogg are supported by your browser.
  117209. */
  117210. readonly isOGGsupported: boolean;
  117211. /**
  117212. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117213. * @ignoreNaming
  117214. */
  117215. WarnedWebAudioUnsupported: boolean;
  117216. /**
  117217. * Defines if the audio engine relies on a custom unlocked button.
  117218. * In this case, the embedded button will not be displayed.
  117219. */
  117220. useCustomUnlockedButton: boolean;
  117221. /**
  117222. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  117223. */
  117224. readonly unlocked: boolean;
  117225. /**
  117226. * Event raised when audio has been unlocked on the browser.
  117227. */
  117228. onAudioUnlockedObservable: Observable<AudioEngine>;
  117229. /**
  117230. * Event raised when audio has been locked on the browser.
  117231. */
  117232. onAudioLockedObservable: Observable<AudioEngine>;
  117233. /**
  117234. * Flags the audio engine in Locked state.
  117235. * This happens due to new browser policies preventing audio to autoplay.
  117236. */
  117237. lock(): void;
  117238. /**
  117239. * Unlocks the audio engine once a user action has been done on the dom.
  117240. * This is helpful to resume play once browser policies have been satisfied.
  117241. */
  117242. unlock(): void;
  117243. /**
  117244. * Gets the global volume sets on the master gain.
  117245. * @returns the global volume if set or -1 otherwise
  117246. */
  117247. getGlobalVolume(): number;
  117248. /**
  117249. * Sets the global volume of your experience (sets on the master gain).
  117250. * @param newVolume Defines the new global volume of the application
  117251. */
  117252. setGlobalVolume(newVolume: number): void;
  117253. /**
  117254. * Connect the audio engine to an audio analyser allowing some amazing
  117255. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117256. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117257. * @param analyser The analyser to connect to the engine
  117258. */
  117259. connectToAnalyser(analyser: Analyser): void;
  117260. }
  117261. /**
  117262. * This represents the default audio engine used in babylon.
  117263. * It is responsible to play, synchronize and analyse sounds throughout the application.
  117264. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117265. */
  117266. export class AudioEngine implements IAudioEngine {
  117267. private _audioContext;
  117268. private _audioContextInitialized;
  117269. private _muteButton;
  117270. private _hostElement;
  117271. /**
  117272. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117273. */
  117274. canUseWebAudio: boolean;
  117275. /**
  117276. * The master gain node defines the global audio volume of your audio engine.
  117277. */
  117278. masterGain: GainNode;
  117279. /**
  117280. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117281. * @ignoreNaming
  117282. */
  117283. WarnedWebAudioUnsupported: boolean;
  117284. /**
  117285. * Gets whether or not mp3 are supported by your browser.
  117286. */
  117287. isMP3supported: boolean;
  117288. /**
  117289. * Gets whether or not ogg are supported by your browser.
  117290. */
  117291. isOGGsupported: boolean;
  117292. /**
  117293. * Gets whether audio has been unlocked on the device.
  117294. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  117295. * a user interaction has happened.
  117296. */
  117297. unlocked: boolean;
  117298. /**
  117299. * Defines if the audio engine relies on a custom unlocked button.
  117300. * In this case, the embedded button will not be displayed.
  117301. */
  117302. useCustomUnlockedButton: boolean;
  117303. /**
  117304. * Event raised when audio has been unlocked on the browser.
  117305. */
  117306. onAudioUnlockedObservable: Observable<AudioEngine>;
  117307. /**
  117308. * Event raised when audio has been locked on the browser.
  117309. */
  117310. onAudioLockedObservable: Observable<AudioEngine>;
  117311. /**
  117312. * Gets the current AudioContext if available.
  117313. */
  117314. get audioContext(): Nullable<AudioContext>;
  117315. private _connectedAnalyser;
  117316. /**
  117317. * Instantiates a new audio engine.
  117318. *
  117319. * There should be only one per page as some browsers restrict the number
  117320. * of audio contexts you can create.
  117321. * @param hostElement defines the host element where to display the mute icon if necessary
  117322. */
  117323. constructor(hostElement?: Nullable<HTMLElement>);
  117324. /**
  117325. * Flags the audio engine in Locked state.
  117326. * This happens due to new browser policies preventing audio to autoplay.
  117327. */
  117328. lock(): void;
  117329. /**
  117330. * Unlocks the audio engine once a user action has been done on the dom.
  117331. * This is helpful to resume play once browser policies have been satisfied.
  117332. */
  117333. unlock(): void;
  117334. private _resumeAudioContext;
  117335. private _initializeAudioContext;
  117336. private _tryToRun;
  117337. private _triggerRunningState;
  117338. private _triggerSuspendedState;
  117339. private _displayMuteButton;
  117340. private _moveButtonToTopLeft;
  117341. private _onResize;
  117342. private _hideMuteButton;
  117343. /**
  117344. * Destroy and release the resources associated with the audio ccontext.
  117345. */
  117346. dispose(): void;
  117347. /**
  117348. * Gets the global volume sets on the master gain.
  117349. * @returns the global volume if set or -1 otherwise
  117350. */
  117351. getGlobalVolume(): number;
  117352. /**
  117353. * Sets the global volume of your experience (sets on the master gain).
  117354. * @param newVolume Defines the new global volume of the application
  117355. */
  117356. setGlobalVolume(newVolume: number): void;
  117357. /**
  117358. * Connect the audio engine to an audio analyser allowing some amazing
  117359. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117360. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117361. * @param analyser The analyser to connect to the engine
  117362. */
  117363. connectToAnalyser(analyser: Analyser): void;
  117364. }
  117365. }
  117366. declare module BABYLON {
  117367. /**
  117368. * Interface used to present a loading screen while loading a scene
  117369. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117370. */
  117371. export interface ILoadingScreen {
  117372. /**
  117373. * Function called to display the loading screen
  117374. */
  117375. displayLoadingUI: () => void;
  117376. /**
  117377. * Function called to hide the loading screen
  117378. */
  117379. hideLoadingUI: () => void;
  117380. /**
  117381. * Gets or sets the color to use for the background
  117382. */
  117383. loadingUIBackgroundColor: string;
  117384. /**
  117385. * Gets or sets the text to display while loading
  117386. */
  117387. loadingUIText: string;
  117388. }
  117389. /**
  117390. * Class used for the default loading screen
  117391. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117392. */
  117393. export class DefaultLoadingScreen implements ILoadingScreen {
  117394. private _renderingCanvas;
  117395. private _loadingText;
  117396. private _loadingDivBackgroundColor;
  117397. private _loadingDiv;
  117398. private _loadingTextDiv;
  117399. /** Gets or sets the logo url to use for the default loading screen */
  117400. static DefaultLogoUrl: string;
  117401. /** Gets or sets the spinner url to use for the default loading screen */
  117402. static DefaultSpinnerUrl: string;
  117403. /**
  117404. * Creates a new default loading screen
  117405. * @param _renderingCanvas defines the canvas used to render the scene
  117406. * @param _loadingText defines the default text to display
  117407. * @param _loadingDivBackgroundColor defines the default background color
  117408. */
  117409. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  117410. /**
  117411. * Function called to display the loading screen
  117412. */
  117413. displayLoadingUI(): void;
  117414. /**
  117415. * Function called to hide the loading screen
  117416. */
  117417. hideLoadingUI(): void;
  117418. /**
  117419. * Gets or sets the text to display while loading
  117420. */
  117421. set loadingUIText(text: string);
  117422. get loadingUIText(): string;
  117423. /**
  117424. * Gets or sets the color to use for the background
  117425. */
  117426. get loadingUIBackgroundColor(): string;
  117427. set loadingUIBackgroundColor(color: string);
  117428. private _resizeLoadingUI;
  117429. }
  117430. }
  117431. declare module BABYLON {
  117432. /**
  117433. * Interface for any object that can request an animation frame
  117434. */
  117435. export interface ICustomAnimationFrameRequester {
  117436. /**
  117437. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  117438. */
  117439. renderFunction?: Function;
  117440. /**
  117441. * Called to request the next frame to render to
  117442. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  117443. */
  117444. requestAnimationFrame: Function;
  117445. /**
  117446. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  117447. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  117448. */
  117449. requestID?: number;
  117450. }
  117451. }
  117452. declare module BABYLON {
  117453. /**
  117454. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  117455. */
  117456. export class PerformanceMonitor {
  117457. private _enabled;
  117458. private _rollingFrameTime;
  117459. private _lastFrameTimeMs;
  117460. /**
  117461. * constructor
  117462. * @param frameSampleSize The number of samples required to saturate the sliding window
  117463. */
  117464. constructor(frameSampleSize?: number);
  117465. /**
  117466. * Samples current frame
  117467. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  117468. */
  117469. sampleFrame(timeMs?: number): void;
  117470. /**
  117471. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117472. */
  117473. get averageFrameTime(): number;
  117474. /**
  117475. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117476. */
  117477. get averageFrameTimeVariance(): number;
  117478. /**
  117479. * Returns the frame time of the most recent frame
  117480. */
  117481. get instantaneousFrameTime(): number;
  117482. /**
  117483. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  117484. */
  117485. get averageFPS(): number;
  117486. /**
  117487. * Returns the average framerate in frames per second using the most recent frame time
  117488. */
  117489. get instantaneousFPS(): number;
  117490. /**
  117491. * Returns true if enough samples have been taken to completely fill the sliding window
  117492. */
  117493. get isSaturated(): boolean;
  117494. /**
  117495. * Enables contributions to the sliding window sample set
  117496. */
  117497. enable(): void;
  117498. /**
  117499. * Disables contributions to the sliding window sample set
  117500. * Samples will not be interpolated over the disabled period
  117501. */
  117502. disable(): void;
  117503. /**
  117504. * Returns true if sampling is enabled
  117505. */
  117506. get isEnabled(): boolean;
  117507. /**
  117508. * Resets performance monitor
  117509. */
  117510. reset(): void;
  117511. }
  117512. /**
  117513. * RollingAverage
  117514. *
  117515. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  117516. */
  117517. export class RollingAverage {
  117518. /**
  117519. * Current average
  117520. */
  117521. average: number;
  117522. /**
  117523. * Current variance
  117524. */
  117525. variance: number;
  117526. protected _samples: Array<number>;
  117527. protected _sampleCount: number;
  117528. protected _pos: number;
  117529. protected _m2: number;
  117530. /**
  117531. * constructor
  117532. * @param length The number of samples required to saturate the sliding window
  117533. */
  117534. constructor(length: number);
  117535. /**
  117536. * Adds a sample to the sample set
  117537. * @param v The sample value
  117538. */
  117539. add(v: number): void;
  117540. /**
  117541. * Returns previously added values or null if outside of history or outside the sliding window domain
  117542. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  117543. * @return Value previously recorded with add() or null if outside of range
  117544. */
  117545. history(i: number): number;
  117546. /**
  117547. * Returns true if enough samples have been taken to completely fill the sliding window
  117548. * @return true if sample-set saturated
  117549. */
  117550. isSaturated(): boolean;
  117551. /**
  117552. * Resets the rolling average (equivalent to 0 samples taken so far)
  117553. */
  117554. reset(): void;
  117555. /**
  117556. * Wraps a value around the sample range boundaries
  117557. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117558. * @return Wrapped position in sample range
  117559. */
  117560. protected _wrapPosition(i: number): number;
  117561. }
  117562. }
  117563. declare module BABYLON {
  117564. /**
  117565. * This class is used to track a performance counter which is number based.
  117566. * The user has access to many properties which give statistics of different nature.
  117567. *
  117568. * The implementer can track two kinds of Performance Counter: time and count.
  117569. * 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.
  117570. * 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.
  117571. */
  117572. export class PerfCounter {
  117573. /**
  117574. * Gets or sets a global boolean to turn on and off all the counters
  117575. */
  117576. static Enabled: boolean;
  117577. /**
  117578. * Returns the smallest value ever
  117579. */
  117580. get min(): number;
  117581. /**
  117582. * Returns the biggest value ever
  117583. */
  117584. get max(): number;
  117585. /**
  117586. * Returns the average value since the performance counter is running
  117587. */
  117588. get average(): number;
  117589. /**
  117590. * Returns the average value of the last second the counter was monitored
  117591. */
  117592. get lastSecAverage(): number;
  117593. /**
  117594. * Returns the current value
  117595. */
  117596. get current(): number;
  117597. /**
  117598. * Gets the accumulated total
  117599. */
  117600. get total(): number;
  117601. /**
  117602. * Gets the total value count
  117603. */
  117604. get count(): number;
  117605. /**
  117606. * Creates a new counter
  117607. */
  117608. constructor();
  117609. /**
  117610. * Call this method to start monitoring a new frame.
  117611. * 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.
  117612. */
  117613. fetchNewFrame(): void;
  117614. /**
  117615. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117616. * @param newCount the count value to add to the monitored count
  117617. * @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.
  117618. */
  117619. addCount(newCount: number, fetchResult: boolean): void;
  117620. /**
  117621. * Start monitoring this performance counter
  117622. */
  117623. beginMonitoring(): void;
  117624. /**
  117625. * Compute the time lapsed since the previous beginMonitoring() call.
  117626. * @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
  117627. */
  117628. endMonitoring(newFrame?: boolean): void;
  117629. private _fetchResult;
  117630. private _startMonitoringTime;
  117631. private _min;
  117632. private _max;
  117633. private _average;
  117634. private _current;
  117635. private _totalValueCount;
  117636. private _totalAccumulated;
  117637. private _lastSecAverage;
  117638. private _lastSecAccumulated;
  117639. private _lastSecTime;
  117640. private _lastSecValueCount;
  117641. }
  117642. }
  117643. declare module BABYLON {
  117644. interface ThinEngine {
  117645. /** @hidden */
  117646. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  117647. }
  117648. }
  117649. declare module BABYLON {
  117650. /**
  117651. * Defines the interface used by display changed events
  117652. */
  117653. export interface IDisplayChangedEventArgs {
  117654. /** Gets the vrDisplay object (if any) */
  117655. vrDisplay: Nullable<any>;
  117656. /** Gets a boolean indicating if webVR is supported */
  117657. vrSupported: boolean;
  117658. }
  117659. /**
  117660. * Defines the interface used by objects containing a viewport (like a camera)
  117661. */
  117662. interface IViewportOwnerLike {
  117663. /**
  117664. * Gets or sets the viewport
  117665. */
  117666. viewport: IViewportLike;
  117667. }
  117668. /**
  117669. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  117670. */
  117671. export class Engine extends ThinEngine {
  117672. /** Defines that alpha blending is disabled */
  117673. static readonly ALPHA_DISABLE: number;
  117674. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  117675. static readonly ALPHA_ADD: number;
  117676. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  117677. static readonly ALPHA_COMBINE: number;
  117678. /** Defines that alpha blending to DEST - SRC * DEST */
  117679. static readonly ALPHA_SUBTRACT: number;
  117680. /** Defines that alpha blending to SRC * DEST */
  117681. static readonly ALPHA_MULTIPLY: number;
  117682. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  117683. static readonly ALPHA_MAXIMIZED: number;
  117684. /** Defines that alpha blending to SRC + DEST */
  117685. static readonly ALPHA_ONEONE: number;
  117686. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  117687. static readonly ALPHA_PREMULTIPLIED: number;
  117688. /**
  117689. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  117690. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  117691. */
  117692. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  117693. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  117694. static readonly ALPHA_INTERPOLATE: number;
  117695. /**
  117696. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  117697. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  117698. */
  117699. static readonly ALPHA_SCREENMODE: number;
  117700. /** Defines that the ressource is not delayed*/
  117701. static readonly DELAYLOADSTATE_NONE: number;
  117702. /** Defines that the ressource was successfully delay loaded */
  117703. static readonly DELAYLOADSTATE_LOADED: number;
  117704. /** Defines that the ressource is currently delay loading */
  117705. static readonly DELAYLOADSTATE_LOADING: number;
  117706. /** Defines that the ressource is delayed and has not started loading */
  117707. static readonly DELAYLOADSTATE_NOTLOADED: number;
  117708. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  117709. static readonly NEVER: number;
  117710. /** 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 */
  117711. static readonly ALWAYS: number;
  117712. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  117713. static readonly LESS: number;
  117714. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  117715. static readonly EQUAL: number;
  117716. /** 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 */
  117717. static readonly LEQUAL: number;
  117718. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  117719. static readonly GREATER: number;
  117720. /** 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 */
  117721. static readonly GEQUAL: number;
  117722. /** 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 */
  117723. static readonly NOTEQUAL: number;
  117724. /** Passed to stencilOperation to specify that stencil value must be kept */
  117725. static readonly KEEP: number;
  117726. /** Passed to stencilOperation to specify that stencil value must be replaced */
  117727. static readonly REPLACE: number;
  117728. /** Passed to stencilOperation to specify that stencil value must be incremented */
  117729. static readonly INCR: number;
  117730. /** Passed to stencilOperation to specify that stencil value must be decremented */
  117731. static readonly DECR: number;
  117732. /** Passed to stencilOperation to specify that stencil value must be inverted */
  117733. static readonly INVERT: number;
  117734. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  117735. static readonly INCR_WRAP: number;
  117736. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  117737. static readonly DECR_WRAP: number;
  117738. /** Texture is not repeating outside of 0..1 UVs */
  117739. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  117740. /** Texture is repeating outside of 0..1 UVs */
  117741. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  117742. /** Texture is repeating and mirrored */
  117743. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  117744. /** ALPHA */
  117745. static readonly TEXTUREFORMAT_ALPHA: number;
  117746. /** LUMINANCE */
  117747. static readonly TEXTUREFORMAT_LUMINANCE: number;
  117748. /** LUMINANCE_ALPHA */
  117749. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  117750. /** RGB */
  117751. static readonly TEXTUREFORMAT_RGB: number;
  117752. /** RGBA */
  117753. static readonly TEXTUREFORMAT_RGBA: number;
  117754. /** RED */
  117755. static readonly TEXTUREFORMAT_RED: number;
  117756. /** RED (2nd reference) */
  117757. static readonly TEXTUREFORMAT_R: number;
  117758. /** RG */
  117759. static readonly TEXTUREFORMAT_RG: number;
  117760. /** RED_INTEGER */
  117761. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117762. /** RED_INTEGER (2nd reference) */
  117763. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117764. /** RG_INTEGER */
  117765. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117766. /** RGB_INTEGER */
  117767. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117768. /** RGBA_INTEGER */
  117769. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117770. /** UNSIGNED_BYTE */
  117771. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117772. /** UNSIGNED_BYTE (2nd reference) */
  117773. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117774. /** FLOAT */
  117775. static readonly TEXTURETYPE_FLOAT: number;
  117776. /** HALF_FLOAT */
  117777. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117778. /** BYTE */
  117779. static readonly TEXTURETYPE_BYTE: number;
  117780. /** SHORT */
  117781. static readonly TEXTURETYPE_SHORT: number;
  117782. /** UNSIGNED_SHORT */
  117783. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117784. /** INT */
  117785. static readonly TEXTURETYPE_INT: number;
  117786. /** UNSIGNED_INT */
  117787. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117788. /** UNSIGNED_SHORT_4_4_4_4 */
  117789. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117790. /** UNSIGNED_SHORT_5_5_5_1 */
  117791. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117792. /** UNSIGNED_SHORT_5_6_5 */
  117793. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117794. /** UNSIGNED_INT_2_10_10_10_REV */
  117795. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117796. /** UNSIGNED_INT_24_8 */
  117797. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117798. /** UNSIGNED_INT_10F_11F_11F_REV */
  117799. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117800. /** UNSIGNED_INT_5_9_9_9_REV */
  117801. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117802. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117803. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117804. /** nearest is mag = nearest and min = nearest and mip = linear */
  117805. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117806. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117807. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117808. /** Trilinear is mag = linear and min = linear and mip = linear */
  117809. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117810. /** nearest is mag = nearest and min = nearest and mip = linear */
  117811. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117812. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117813. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117814. /** Trilinear is mag = linear and min = linear and mip = linear */
  117815. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117816. /** mag = nearest and min = nearest and mip = nearest */
  117817. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117818. /** mag = nearest and min = linear and mip = nearest */
  117819. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117820. /** mag = nearest and min = linear and mip = linear */
  117821. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117822. /** mag = nearest and min = linear and mip = none */
  117823. static readonly TEXTURE_NEAREST_LINEAR: number;
  117824. /** mag = nearest and min = nearest and mip = none */
  117825. static readonly TEXTURE_NEAREST_NEAREST: number;
  117826. /** mag = linear and min = nearest and mip = nearest */
  117827. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117828. /** mag = linear and min = nearest and mip = linear */
  117829. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117830. /** mag = linear and min = linear and mip = none */
  117831. static readonly TEXTURE_LINEAR_LINEAR: number;
  117832. /** mag = linear and min = nearest and mip = none */
  117833. static readonly TEXTURE_LINEAR_NEAREST: number;
  117834. /** Explicit coordinates mode */
  117835. static readonly TEXTURE_EXPLICIT_MODE: number;
  117836. /** Spherical coordinates mode */
  117837. static readonly TEXTURE_SPHERICAL_MODE: number;
  117838. /** Planar coordinates mode */
  117839. static readonly TEXTURE_PLANAR_MODE: number;
  117840. /** Cubic coordinates mode */
  117841. static readonly TEXTURE_CUBIC_MODE: number;
  117842. /** Projection coordinates mode */
  117843. static readonly TEXTURE_PROJECTION_MODE: number;
  117844. /** Skybox coordinates mode */
  117845. static readonly TEXTURE_SKYBOX_MODE: number;
  117846. /** Inverse Cubic coordinates mode */
  117847. static readonly TEXTURE_INVCUBIC_MODE: number;
  117848. /** Equirectangular coordinates mode */
  117849. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117850. /** Equirectangular Fixed coordinates mode */
  117851. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117852. /** Equirectangular Fixed Mirrored coordinates mode */
  117853. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117854. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117855. static readonly SCALEMODE_FLOOR: number;
  117856. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117857. static readonly SCALEMODE_NEAREST: number;
  117858. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117859. static readonly SCALEMODE_CEILING: number;
  117860. /**
  117861. * Returns the current npm package of the sdk
  117862. */
  117863. static get NpmPackage(): string;
  117864. /**
  117865. * Returns the current version of the framework
  117866. */
  117867. static get Version(): string;
  117868. /** Gets the list of created engines */
  117869. static get Instances(): Engine[];
  117870. /**
  117871. * Gets the latest created engine
  117872. */
  117873. static get LastCreatedEngine(): Nullable<Engine>;
  117874. /**
  117875. * Gets the latest created scene
  117876. */
  117877. static get LastCreatedScene(): Nullable<Scene>;
  117878. /**
  117879. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117880. * @param flag defines which part of the materials must be marked as dirty
  117881. * @param predicate defines a predicate used to filter which materials should be affected
  117882. */
  117883. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117884. /**
  117885. * Method called to create the default loading screen.
  117886. * This can be overriden in your own app.
  117887. * @param canvas The rendering canvas element
  117888. * @returns The loading screen
  117889. */
  117890. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117891. /**
  117892. * Method called to create the default rescale post process on each engine.
  117893. */
  117894. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  117895. /**
  117896. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  117897. **/
  117898. enableOfflineSupport: boolean;
  117899. /**
  117900. * 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)
  117901. **/
  117902. disableManifestCheck: boolean;
  117903. /**
  117904. * Gets the list of created scenes
  117905. */
  117906. scenes: Scene[];
  117907. /**
  117908. * Event raised when a new scene is created
  117909. */
  117910. onNewSceneAddedObservable: Observable<Scene>;
  117911. /**
  117912. * Gets the list of created postprocesses
  117913. */
  117914. postProcesses: PostProcess[];
  117915. /**
  117916. * Gets a boolean indicating if the pointer is currently locked
  117917. */
  117918. isPointerLock: boolean;
  117919. /**
  117920. * Observable event triggered each time the rendering canvas is resized
  117921. */
  117922. onResizeObservable: Observable<Engine>;
  117923. /**
  117924. * Observable event triggered each time the canvas loses focus
  117925. */
  117926. onCanvasBlurObservable: Observable<Engine>;
  117927. /**
  117928. * Observable event triggered each time the canvas gains focus
  117929. */
  117930. onCanvasFocusObservable: Observable<Engine>;
  117931. /**
  117932. * Observable event triggered each time the canvas receives pointerout event
  117933. */
  117934. onCanvasPointerOutObservable: Observable<PointerEvent>;
  117935. /**
  117936. * Observable raised when the engine begins a new frame
  117937. */
  117938. onBeginFrameObservable: Observable<Engine>;
  117939. /**
  117940. * If set, will be used to request the next animation frame for the render loop
  117941. */
  117942. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  117943. /**
  117944. * Observable raised when the engine ends the current frame
  117945. */
  117946. onEndFrameObservable: Observable<Engine>;
  117947. /**
  117948. * Observable raised when the engine is about to compile a shader
  117949. */
  117950. onBeforeShaderCompilationObservable: Observable<Engine>;
  117951. /**
  117952. * Observable raised when the engine has jsut compiled a shader
  117953. */
  117954. onAfterShaderCompilationObservable: Observable<Engine>;
  117955. /**
  117956. * Gets the audio engine
  117957. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117958. * @ignorenaming
  117959. */
  117960. static audioEngine: IAudioEngine;
  117961. /**
  117962. * Default AudioEngine factory responsible of creating the Audio Engine.
  117963. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  117964. */
  117965. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  117966. /**
  117967. * Default offline support factory responsible of creating a tool used to store data locally.
  117968. * By default, this will create a Database object if the workload has been embedded.
  117969. */
  117970. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  117971. private _loadingScreen;
  117972. private _pointerLockRequested;
  117973. private _rescalePostProcess;
  117974. private _deterministicLockstep;
  117975. private _lockstepMaxSteps;
  117976. private _timeStep;
  117977. protected get _supportsHardwareTextureRescaling(): boolean;
  117978. private _fps;
  117979. private _deltaTime;
  117980. /** @hidden */
  117981. _drawCalls: PerfCounter;
  117982. /** 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 */
  117983. canvasTabIndex: number;
  117984. /**
  117985. * Turn this value on if you want to pause FPS computation when in background
  117986. */
  117987. disablePerformanceMonitorInBackground: boolean;
  117988. private _performanceMonitor;
  117989. /**
  117990. * Gets the performance monitor attached to this engine
  117991. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117992. */
  117993. get performanceMonitor(): PerformanceMonitor;
  117994. private _onFocus;
  117995. private _onBlur;
  117996. private _onCanvasPointerOut;
  117997. private _onCanvasBlur;
  117998. private _onCanvasFocus;
  117999. private _onFullscreenChange;
  118000. private _onPointerLockChange;
  118001. /**
  118002. * Gets the HTML element used to attach event listeners
  118003. * @returns a HTML element
  118004. */
  118005. getInputElement(): Nullable<HTMLElement>;
  118006. /**
  118007. * Creates a new engine
  118008. * @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
  118009. * @param antialias defines enable antialiasing (default: false)
  118010. * @param options defines further options to be sent to the getContext() function
  118011. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  118012. */
  118013. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  118014. /**
  118015. * Gets current aspect ratio
  118016. * @param viewportOwner defines the camera to use to get the aspect ratio
  118017. * @param useScreen defines if screen size must be used (or the current render target if any)
  118018. * @returns a number defining the aspect ratio
  118019. */
  118020. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  118021. /**
  118022. * Gets current screen aspect ratio
  118023. * @returns a number defining the aspect ratio
  118024. */
  118025. getScreenAspectRatio(): number;
  118026. /**
  118027. * Gets the client rect of the HTML canvas attached with the current webGL context
  118028. * @returns a client rectanglee
  118029. */
  118030. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  118031. /**
  118032. * Gets the client rect of the HTML element used for events
  118033. * @returns a client rectanglee
  118034. */
  118035. getInputElementClientRect(): Nullable<ClientRect>;
  118036. /**
  118037. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  118038. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118039. * @returns true if engine is in deterministic lock step mode
  118040. */
  118041. isDeterministicLockStep(): boolean;
  118042. /**
  118043. * Gets the max steps when engine is running in deterministic lock step
  118044. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118045. * @returns the max steps
  118046. */
  118047. getLockstepMaxSteps(): number;
  118048. /**
  118049. * Returns the time in ms between steps when using deterministic lock step.
  118050. * @returns time step in (ms)
  118051. */
  118052. getTimeStep(): number;
  118053. /**
  118054. * Force the mipmap generation for the given render target texture
  118055. * @param texture defines the render target texture to use
  118056. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  118057. */
  118058. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  118059. /** States */
  118060. /**
  118061. * Set various states to the webGL context
  118062. * @param culling defines backface culling state
  118063. * @param zOffset defines the value to apply to zOffset (0 by default)
  118064. * @param force defines if states must be applied even if cache is up to date
  118065. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  118066. */
  118067. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  118068. /**
  118069. * Set the z offset to apply to current rendering
  118070. * @param value defines the offset to apply
  118071. */
  118072. setZOffset(value: number): void;
  118073. /**
  118074. * Gets the current value of the zOffset
  118075. * @returns the current zOffset state
  118076. */
  118077. getZOffset(): number;
  118078. /**
  118079. * Enable or disable depth buffering
  118080. * @param enable defines the state to set
  118081. */
  118082. setDepthBuffer(enable: boolean): void;
  118083. /**
  118084. * Gets a boolean indicating if depth writing is enabled
  118085. * @returns the current depth writing state
  118086. */
  118087. getDepthWrite(): boolean;
  118088. /**
  118089. * Enable or disable depth writing
  118090. * @param enable defines the state to set
  118091. */
  118092. setDepthWrite(enable: boolean): void;
  118093. /**
  118094. * Gets a boolean indicating if stencil buffer is enabled
  118095. * @returns the current stencil buffer state
  118096. */
  118097. getStencilBuffer(): boolean;
  118098. /**
  118099. * Enable or disable the stencil buffer
  118100. * @param enable defines if the stencil buffer must be enabled or disabled
  118101. */
  118102. setStencilBuffer(enable: boolean): void;
  118103. /**
  118104. * Gets the current stencil mask
  118105. * @returns a number defining the new stencil mask to use
  118106. */
  118107. getStencilMask(): number;
  118108. /**
  118109. * Sets the current stencil mask
  118110. * @param mask defines the new stencil mask to use
  118111. */
  118112. setStencilMask(mask: number): void;
  118113. /**
  118114. * Gets the current stencil function
  118115. * @returns a number defining the stencil function to use
  118116. */
  118117. getStencilFunction(): number;
  118118. /**
  118119. * Gets the current stencil reference value
  118120. * @returns a number defining the stencil reference value to use
  118121. */
  118122. getStencilFunctionReference(): number;
  118123. /**
  118124. * Gets the current stencil mask
  118125. * @returns a number defining the stencil mask to use
  118126. */
  118127. getStencilFunctionMask(): number;
  118128. /**
  118129. * Sets the current stencil function
  118130. * @param stencilFunc defines the new stencil function to use
  118131. */
  118132. setStencilFunction(stencilFunc: number): void;
  118133. /**
  118134. * Sets the current stencil reference
  118135. * @param reference defines the new stencil reference to use
  118136. */
  118137. setStencilFunctionReference(reference: number): void;
  118138. /**
  118139. * Sets the current stencil mask
  118140. * @param mask defines the new stencil mask to use
  118141. */
  118142. setStencilFunctionMask(mask: number): void;
  118143. /**
  118144. * Gets the current stencil operation when stencil fails
  118145. * @returns a number defining stencil operation to use when stencil fails
  118146. */
  118147. getStencilOperationFail(): number;
  118148. /**
  118149. * Gets the current stencil operation when depth fails
  118150. * @returns a number defining stencil operation to use when depth fails
  118151. */
  118152. getStencilOperationDepthFail(): number;
  118153. /**
  118154. * Gets the current stencil operation when stencil passes
  118155. * @returns a number defining stencil operation to use when stencil passes
  118156. */
  118157. getStencilOperationPass(): number;
  118158. /**
  118159. * Sets the stencil operation to use when stencil fails
  118160. * @param operation defines the stencil operation to use when stencil fails
  118161. */
  118162. setStencilOperationFail(operation: number): void;
  118163. /**
  118164. * Sets the stencil operation to use when depth fails
  118165. * @param operation defines the stencil operation to use when depth fails
  118166. */
  118167. setStencilOperationDepthFail(operation: number): void;
  118168. /**
  118169. * Sets the stencil operation to use when stencil passes
  118170. * @param operation defines the stencil operation to use when stencil passes
  118171. */
  118172. setStencilOperationPass(operation: number): void;
  118173. /**
  118174. * Sets a boolean indicating if the dithering state is enabled or disabled
  118175. * @param value defines the dithering state
  118176. */
  118177. setDitheringState(value: boolean): void;
  118178. /**
  118179. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  118180. * @param value defines the rasterizer state
  118181. */
  118182. setRasterizerState(value: boolean): void;
  118183. /**
  118184. * Gets the current depth function
  118185. * @returns a number defining the depth function
  118186. */
  118187. getDepthFunction(): Nullable<number>;
  118188. /**
  118189. * Sets the current depth function
  118190. * @param depthFunc defines the function to use
  118191. */
  118192. setDepthFunction(depthFunc: number): void;
  118193. /**
  118194. * Sets the current depth function to GREATER
  118195. */
  118196. setDepthFunctionToGreater(): void;
  118197. /**
  118198. * Sets the current depth function to GEQUAL
  118199. */
  118200. setDepthFunctionToGreaterOrEqual(): void;
  118201. /**
  118202. * Sets the current depth function to LESS
  118203. */
  118204. setDepthFunctionToLess(): void;
  118205. /**
  118206. * Sets the current depth function to LEQUAL
  118207. */
  118208. setDepthFunctionToLessOrEqual(): void;
  118209. private _cachedStencilBuffer;
  118210. private _cachedStencilFunction;
  118211. private _cachedStencilMask;
  118212. private _cachedStencilOperationPass;
  118213. private _cachedStencilOperationFail;
  118214. private _cachedStencilOperationDepthFail;
  118215. private _cachedStencilReference;
  118216. /**
  118217. * Caches the the state of the stencil buffer
  118218. */
  118219. cacheStencilState(): void;
  118220. /**
  118221. * Restores the state of the stencil buffer
  118222. */
  118223. restoreStencilState(): void;
  118224. /**
  118225. * Directly set the WebGL Viewport
  118226. * @param x defines the x coordinate of the viewport (in screen space)
  118227. * @param y defines the y coordinate of the viewport (in screen space)
  118228. * @param width defines the width of the viewport (in screen space)
  118229. * @param height defines the height of the viewport (in screen space)
  118230. * @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
  118231. */
  118232. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  118233. /**
  118234. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  118235. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118236. * @param y defines the y-coordinate of the corner of the clear rectangle
  118237. * @param width defines the width of the clear rectangle
  118238. * @param height defines the height of the clear rectangle
  118239. * @param clearColor defines the clear color
  118240. */
  118241. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  118242. /**
  118243. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  118244. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118245. * @param y defines the y-coordinate of the corner of the clear rectangle
  118246. * @param width defines the width of the clear rectangle
  118247. * @param height defines the height of the clear rectangle
  118248. */
  118249. enableScissor(x: number, y: number, width: number, height: number): void;
  118250. /**
  118251. * Disable previously set scissor test rectangle
  118252. */
  118253. disableScissor(): void;
  118254. protected _reportDrawCall(): void;
  118255. /**
  118256. * Initializes a webVR display and starts listening to display change events
  118257. * The onVRDisplayChangedObservable will be notified upon these changes
  118258. * @returns The onVRDisplayChangedObservable
  118259. */
  118260. initWebVR(): Observable<IDisplayChangedEventArgs>;
  118261. /** @hidden */
  118262. _prepareVRComponent(): void;
  118263. /** @hidden */
  118264. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  118265. /** @hidden */
  118266. _submitVRFrame(): void;
  118267. /**
  118268. * Call this function to leave webVR mode
  118269. * Will do nothing if webVR is not supported or if there is no webVR device
  118270. * @see https://doc.babylonjs.com/how_to/webvr_camera
  118271. */
  118272. disableVR(): void;
  118273. /**
  118274. * Gets a boolean indicating that the system is in VR mode and is presenting
  118275. * @returns true if VR mode is engaged
  118276. */
  118277. isVRPresenting(): boolean;
  118278. /** @hidden */
  118279. _requestVRFrame(): void;
  118280. /** @hidden */
  118281. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118282. /**
  118283. * Gets the source code of the vertex shader associated with a specific webGL program
  118284. * @param program defines the program to use
  118285. * @returns a string containing the source code of the vertex shader associated with the program
  118286. */
  118287. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  118288. /**
  118289. * Gets the source code of the fragment shader associated with a specific webGL program
  118290. * @param program defines the program to use
  118291. * @returns a string containing the source code of the fragment shader associated with the program
  118292. */
  118293. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  118294. /**
  118295. * Sets a depth stencil texture from a render target to the according uniform.
  118296. * @param channel The texture channel
  118297. * @param uniform The uniform to set
  118298. * @param texture The render target texture containing the depth stencil texture to apply
  118299. */
  118300. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  118301. /**
  118302. * Sets a texture to the webGL context from a postprocess
  118303. * @param channel defines the channel to use
  118304. * @param postProcess defines the source postprocess
  118305. */
  118306. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  118307. /**
  118308. * Binds the output of the passed in post process to the texture channel specified
  118309. * @param channel The channel the texture should be bound to
  118310. * @param postProcess The post process which's output should be bound
  118311. */
  118312. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  118313. protected _rebuildBuffers(): void;
  118314. /** @hidden */
  118315. _renderFrame(): void;
  118316. _renderLoop(): void;
  118317. /** @hidden */
  118318. _renderViews(): boolean;
  118319. /**
  118320. * Toggle full screen mode
  118321. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118322. */
  118323. switchFullscreen(requestPointerLock: boolean): void;
  118324. /**
  118325. * Enters full screen mode
  118326. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118327. */
  118328. enterFullscreen(requestPointerLock: boolean): void;
  118329. /**
  118330. * Exits full screen mode
  118331. */
  118332. exitFullscreen(): void;
  118333. /**
  118334. * Enters Pointerlock mode
  118335. */
  118336. enterPointerlock(): void;
  118337. /**
  118338. * Exits Pointerlock mode
  118339. */
  118340. exitPointerlock(): void;
  118341. /**
  118342. * Begin a new frame
  118343. */
  118344. beginFrame(): void;
  118345. /**
  118346. * Enf the current frame
  118347. */
  118348. endFrame(): void;
  118349. resize(): void;
  118350. /**
  118351. * Force a specific size of the canvas
  118352. * @param width defines the new canvas' width
  118353. * @param height defines the new canvas' height
  118354. * @returns true if the size was changed
  118355. */
  118356. setSize(width: number, height: number): boolean;
  118357. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118358. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118359. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118360. _releaseTexture(texture: InternalTexture): void;
  118361. /**
  118362. * @hidden
  118363. * Rescales a texture
  118364. * @param source input texutre
  118365. * @param destination destination texture
  118366. * @param scene scene to use to render the resize
  118367. * @param internalFormat format to use when resizing
  118368. * @param onComplete callback to be called when resize has completed
  118369. */
  118370. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  118371. /**
  118372. * Gets the current framerate
  118373. * @returns a number representing the framerate
  118374. */
  118375. getFps(): number;
  118376. /**
  118377. * Gets the time spent between current and previous frame
  118378. * @returns a number representing the delta time in ms
  118379. */
  118380. getDeltaTime(): number;
  118381. private _measureFps;
  118382. /** @hidden */
  118383. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  118384. /**
  118385. * Updates the sample count of a render target texture
  118386. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118387. * @param texture defines the texture to update
  118388. * @param samples defines the sample count to set
  118389. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118390. */
  118391. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  118392. /**
  118393. * Updates a depth texture Comparison Mode and Function.
  118394. * If the comparison Function is equal to 0, the mode will be set to none.
  118395. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  118396. * @param texture The texture to set the comparison function for
  118397. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  118398. */
  118399. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  118400. /**
  118401. * Creates a webGL buffer to use with instanciation
  118402. * @param capacity defines the size of the buffer
  118403. * @returns the webGL buffer
  118404. */
  118405. createInstancesBuffer(capacity: number): DataBuffer;
  118406. /**
  118407. * Delete a webGL buffer used with instanciation
  118408. * @param buffer defines the webGL buffer to delete
  118409. */
  118410. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  118411. private _clientWaitAsync;
  118412. /** @hidden */
  118413. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  118414. dispose(): void;
  118415. private _disableTouchAction;
  118416. /**
  118417. * Display the loading screen
  118418. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118419. */
  118420. displayLoadingUI(): void;
  118421. /**
  118422. * Hide the loading screen
  118423. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118424. */
  118425. hideLoadingUI(): void;
  118426. /**
  118427. * Gets the current loading screen object
  118428. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118429. */
  118430. get loadingScreen(): ILoadingScreen;
  118431. /**
  118432. * Sets the current loading screen object
  118433. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118434. */
  118435. set loadingScreen(loadingScreen: ILoadingScreen);
  118436. /**
  118437. * Sets the current loading screen text
  118438. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118439. */
  118440. set loadingUIText(text: string);
  118441. /**
  118442. * Sets the current loading screen background color
  118443. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118444. */
  118445. set loadingUIBackgroundColor(color: string);
  118446. /** Pointerlock and fullscreen */
  118447. /**
  118448. * Ask the browser to promote the current element to pointerlock mode
  118449. * @param element defines the DOM element to promote
  118450. */
  118451. static _RequestPointerlock(element: HTMLElement): void;
  118452. /**
  118453. * Asks the browser to exit pointerlock mode
  118454. */
  118455. static _ExitPointerlock(): void;
  118456. /**
  118457. * Ask the browser to promote the current element to fullscreen rendering mode
  118458. * @param element defines the DOM element to promote
  118459. */
  118460. static _RequestFullscreen(element: HTMLElement): void;
  118461. /**
  118462. * Asks the browser to exit fullscreen mode
  118463. */
  118464. static _ExitFullscreen(): void;
  118465. }
  118466. }
  118467. declare module BABYLON {
  118468. /**
  118469. * The engine store class is responsible to hold all the instances of Engine and Scene created
  118470. * during the life time of the application.
  118471. */
  118472. export class EngineStore {
  118473. /** Gets the list of created engines */
  118474. static Instances: Engine[];
  118475. /** @hidden */
  118476. static _LastCreatedScene: Nullable<Scene>;
  118477. /**
  118478. * Gets the latest created engine
  118479. */
  118480. static get LastCreatedEngine(): Nullable<Engine>;
  118481. /**
  118482. * Gets the latest created scene
  118483. */
  118484. static get LastCreatedScene(): Nullable<Scene>;
  118485. /**
  118486. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118487. * @ignorenaming
  118488. */
  118489. static UseFallbackTexture: boolean;
  118490. /**
  118491. * Texture content used if a texture cannot loaded
  118492. * @ignorenaming
  118493. */
  118494. static FallbackTexture: string;
  118495. }
  118496. }
  118497. declare module BABYLON {
  118498. /**
  118499. * Helper class that provides a small promise polyfill
  118500. */
  118501. export class PromisePolyfill {
  118502. /**
  118503. * Static function used to check if the polyfill is required
  118504. * If this is the case then the function will inject the polyfill to window.Promise
  118505. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  118506. */
  118507. static Apply(force?: boolean): void;
  118508. }
  118509. }
  118510. declare module BABYLON {
  118511. /**
  118512. * Interface for screenshot methods with describe argument called `size` as object with options
  118513. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  118514. */
  118515. export interface IScreenshotSize {
  118516. /**
  118517. * number in pixels for canvas height
  118518. */
  118519. height?: number;
  118520. /**
  118521. * multiplier allowing render at a higher or lower resolution
  118522. * If value is defined then height and width will be ignored and taken from camera
  118523. */
  118524. precision?: number;
  118525. /**
  118526. * number in pixels for canvas width
  118527. */
  118528. width?: number;
  118529. }
  118530. }
  118531. declare module BABYLON {
  118532. interface IColor4Like {
  118533. r: float;
  118534. g: float;
  118535. b: float;
  118536. a: float;
  118537. }
  118538. /**
  118539. * Class containing a set of static utilities functions
  118540. */
  118541. export class Tools {
  118542. /**
  118543. * Gets or sets the base URL to use to load assets
  118544. */
  118545. static get BaseUrl(): string;
  118546. static set BaseUrl(value: string);
  118547. /**
  118548. * Enable/Disable Custom HTTP Request Headers globally.
  118549. * default = false
  118550. * @see CustomRequestHeaders
  118551. */
  118552. static UseCustomRequestHeaders: boolean;
  118553. /**
  118554. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118555. * i.e. when loading files, where the server/service expects an Authorization header
  118556. */
  118557. static CustomRequestHeaders: {
  118558. [key: string]: string;
  118559. };
  118560. /**
  118561. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118562. */
  118563. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118564. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118565. /**
  118566. * Default behaviour for cors in the application.
  118567. * It can be a string if the expected behavior is identical in the entire app.
  118568. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118569. */
  118570. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118571. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118572. /**
  118573. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118574. * @ignorenaming
  118575. */
  118576. static get UseFallbackTexture(): boolean;
  118577. static set UseFallbackTexture(value: boolean);
  118578. /**
  118579. * Use this object to register external classes like custom textures or material
  118580. * to allow the laoders to instantiate them
  118581. */
  118582. static get RegisteredExternalClasses(): {
  118583. [key: string]: Object;
  118584. };
  118585. static set RegisteredExternalClasses(classes: {
  118586. [key: string]: Object;
  118587. });
  118588. /**
  118589. * Texture content used if a texture cannot loaded
  118590. * @ignorenaming
  118591. */
  118592. static get fallbackTexture(): string;
  118593. static set fallbackTexture(value: string);
  118594. /**
  118595. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118596. * @param u defines the coordinate on X axis
  118597. * @param v defines the coordinate on Y axis
  118598. * @param width defines the width of the source data
  118599. * @param height defines the height of the source data
  118600. * @param pixels defines the source byte array
  118601. * @param color defines the output color
  118602. */
  118603. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118604. /**
  118605. * Interpolates between a and b via alpha
  118606. * @param a The lower value (returned when alpha = 0)
  118607. * @param b The upper value (returned when alpha = 1)
  118608. * @param alpha The interpolation-factor
  118609. * @return The mixed value
  118610. */
  118611. static Mix(a: number, b: number, alpha: number): number;
  118612. /**
  118613. * Tries to instantiate a new object from a given class name
  118614. * @param className defines the class name to instantiate
  118615. * @returns the new object or null if the system was not able to do the instantiation
  118616. */
  118617. static Instantiate(className: string): any;
  118618. /**
  118619. * Provides a slice function that will work even on IE
  118620. * @param data defines the array to slice
  118621. * @param start defines the start of the data (optional)
  118622. * @param end defines the end of the data (optional)
  118623. * @returns the new sliced array
  118624. */
  118625. static Slice<T>(data: T, start?: number, end?: number): T;
  118626. /**
  118627. * Polyfill for setImmediate
  118628. * @param action defines the action to execute after the current execution block
  118629. */
  118630. static SetImmediate(action: () => void): void;
  118631. /**
  118632. * Function indicating if a number is an exponent of 2
  118633. * @param value defines the value to test
  118634. * @returns true if the value is an exponent of 2
  118635. */
  118636. static IsExponentOfTwo(value: number): boolean;
  118637. private static _tmpFloatArray;
  118638. /**
  118639. * Returns the nearest 32-bit single precision float representation of a Number
  118640. * @param value A Number. If the parameter is of a different type, it will get converted
  118641. * to a number or to NaN if it cannot be converted
  118642. * @returns number
  118643. */
  118644. static FloatRound(value: number): number;
  118645. /**
  118646. * Extracts the filename from a path
  118647. * @param path defines the path to use
  118648. * @returns the filename
  118649. */
  118650. static GetFilename(path: string): string;
  118651. /**
  118652. * Extracts the "folder" part of a path (everything before the filename).
  118653. * @param uri The URI to extract the info from
  118654. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  118655. * @returns The "folder" part of the path
  118656. */
  118657. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  118658. /**
  118659. * Extracts text content from a DOM element hierarchy
  118660. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  118661. */
  118662. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  118663. /**
  118664. * Convert an angle in radians to degrees
  118665. * @param angle defines the angle to convert
  118666. * @returns the angle in degrees
  118667. */
  118668. static ToDegrees(angle: number): number;
  118669. /**
  118670. * Convert an angle in degrees to radians
  118671. * @param angle defines the angle to convert
  118672. * @returns the angle in radians
  118673. */
  118674. static ToRadians(angle: number): number;
  118675. /**
  118676. * Returns an array if obj is not an array
  118677. * @param obj defines the object to evaluate as an array
  118678. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  118679. * @returns either obj directly if obj is an array or a new array containing obj
  118680. */
  118681. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  118682. /**
  118683. * Gets the pointer prefix to use
  118684. * @param engine defines the engine we are finding the prefix for
  118685. * @returns "pointer" if touch is enabled. Else returns "mouse"
  118686. */
  118687. static GetPointerPrefix(engine: Engine): string;
  118688. /**
  118689. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  118690. * @param url define the url we are trying
  118691. * @param element define the dom element where to configure the cors policy
  118692. */
  118693. static SetCorsBehavior(url: string | string[], element: {
  118694. crossOrigin: string | null;
  118695. }): void;
  118696. /**
  118697. * Removes unwanted characters from an url
  118698. * @param url defines the url to clean
  118699. * @returns the cleaned url
  118700. */
  118701. static CleanUrl(url: string): string;
  118702. /**
  118703. * Gets or sets a function used to pre-process url before using them to load assets
  118704. */
  118705. static get PreprocessUrl(): (url: string) => string;
  118706. static set PreprocessUrl(processor: (url: string) => string);
  118707. /**
  118708. * Loads an image as an HTMLImageElement.
  118709. * @param input url string, ArrayBuffer, or Blob to load
  118710. * @param onLoad callback called when the image successfully loads
  118711. * @param onError callback called when the image fails to load
  118712. * @param offlineProvider offline provider for caching
  118713. * @param mimeType optional mime type
  118714. * @returns the HTMLImageElement of the loaded image
  118715. */
  118716. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  118717. /**
  118718. * Loads a file from a url
  118719. * @param url url string, ArrayBuffer, or Blob to load
  118720. * @param onSuccess callback called when the file successfully loads
  118721. * @param onProgress callback called while file is loading (if the server supports this mode)
  118722. * @param offlineProvider defines the offline provider for caching
  118723. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118724. * @param onError callback called when the file fails to load
  118725. * @returns a file request object
  118726. */
  118727. 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;
  118728. /**
  118729. * Loads a file from a url
  118730. * @param url the file url to load
  118731. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118732. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  118733. */
  118734. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  118735. /**
  118736. * Load a script (identified by an url). When the url returns, the
  118737. * content of this file is added into a new script element, attached to the DOM (body element)
  118738. * @param scriptUrl defines the url of the script to laod
  118739. * @param onSuccess defines the callback called when the script is loaded
  118740. * @param onError defines the callback to call if an error occurs
  118741. * @param scriptId defines the id of the script element
  118742. */
  118743. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  118744. /**
  118745. * Load an asynchronous script (identified by an url). When the url returns, the
  118746. * content of this file is added into a new script element, attached to the DOM (body element)
  118747. * @param scriptUrl defines the url of the script to laod
  118748. * @param scriptId defines the id of the script element
  118749. * @returns a promise request object
  118750. */
  118751. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  118752. /**
  118753. * Loads a file from a blob
  118754. * @param fileToLoad defines the blob to use
  118755. * @param callback defines the callback to call when data is loaded
  118756. * @param progressCallback defines the callback to call during loading process
  118757. * @returns a file request object
  118758. */
  118759. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118760. /**
  118761. * Reads a file from a File object
  118762. * @param file defines the file to load
  118763. * @param onSuccess defines the callback to call when data is loaded
  118764. * @param onProgress defines the callback to call during loading process
  118765. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118766. * @param onError defines the callback to call when an error occurs
  118767. * @returns a file request object
  118768. */
  118769. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118770. /**
  118771. * Creates a data url from a given string content
  118772. * @param content defines the content to convert
  118773. * @returns the new data url link
  118774. */
  118775. static FileAsURL(content: string): string;
  118776. /**
  118777. * Format the given number to a specific decimal format
  118778. * @param value defines the number to format
  118779. * @param decimals defines the number of decimals to use
  118780. * @returns the formatted string
  118781. */
  118782. static Format(value: number, decimals?: number): string;
  118783. /**
  118784. * Tries to copy an object by duplicating every property
  118785. * @param source defines the source object
  118786. * @param destination defines the target object
  118787. * @param doNotCopyList defines a list of properties to avoid
  118788. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118789. */
  118790. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118791. /**
  118792. * Gets a boolean indicating if the given object has no own property
  118793. * @param obj defines the object to test
  118794. * @returns true if object has no own property
  118795. */
  118796. static IsEmpty(obj: any): boolean;
  118797. /**
  118798. * Function used to register events at window level
  118799. * @param windowElement defines the Window object to use
  118800. * @param events defines the events to register
  118801. */
  118802. static RegisterTopRootEvents(windowElement: Window, events: {
  118803. name: string;
  118804. handler: Nullable<(e: FocusEvent) => any>;
  118805. }[]): void;
  118806. /**
  118807. * Function used to unregister events from window level
  118808. * @param windowElement defines the Window object to use
  118809. * @param events defines the events to unregister
  118810. */
  118811. static UnregisterTopRootEvents(windowElement: Window, events: {
  118812. name: string;
  118813. handler: Nullable<(e: FocusEvent) => any>;
  118814. }[]): void;
  118815. /**
  118816. * @ignore
  118817. */
  118818. static _ScreenshotCanvas: HTMLCanvasElement;
  118819. /**
  118820. * Dumps the current bound framebuffer
  118821. * @param width defines the rendering width
  118822. * @param height defines the rendering height
  118823. * @param engine defines the hosting engine
  118824. * @param successCallback defines the callback triggered once the data are available
  118825. * @param mimeType defines the mime type of the result
  118826. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118827. */
  118828. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118829. /**
  118830. * Converts the canvas data to blob.
  118831. * This acts as a polyfill for browsers not supporting the to blob function.
  118832. * @param canvas Defines the canvas to extract the data from
  118833. * @param successCallback Defines the callback triggered once the data are available
  118834. * @param mimeType Defines the mime type of the result
  118835. */
  118836. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118837. /**
  118838. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118839. * @param successCallback defines the callback triggered once the data are available
  118840. * @param mimeType defines the mime type of the result
  118841. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118842. */
  118843. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118844. /**
  118845. * Downloads a blob in the browser
  118846. * @param blob defines the blob to download
  118847. * @param fileName defines the name of the downloaded file
  118848. */
  118849. static Download(blob: Blob, fileName: string): void;
  118850. /**
  118851. * Captures a screenshot of the current rendering
  118852. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118853. * @param engine defines the rendering engine
  118854. * @param camera defines the source camera
  118855. * @param size This parameter can be set to a single number or to an object with the
  118856. * following (optional) properties: precision, width, height. If a single number is passed,
  118857. * it will be used for both width and height. If an object is passed, the screenshot size
  118858. * will be derived from the parameters. The precision property is a multiplier allowing
  118859. * rendering at a higher or lower resolution
  118860. * @param successCallback defines the callback receives a single parameter which contains the
  118861. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118862. * src parameter of an <img> to display it
  118863. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118864. * Check your browser for supported MIME types
  118865. */
  118866. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118867. /**
  118868. * Captures a screenshot of the current rendering
  118869. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118870. * @param engine defines the rendering engine
  118871. * @param camera defines the source camera
  118872. * @param size This parameter can be set to a single number or to an object with the
  118873. * following (optional) properties: precision, width, height. If a single number is passed,
  118874. * it will be used for both width and height. If an object is passed, the screenshot size
  118875. * will be derived from the parameters. The precision property is a multiplier allowing
  118876. * rendering at a higher or lower resolution
  118877. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118878. * Check your browser for supported MIME types
  118879. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118880. * to the src parameter of an <img> to display it
  118881. */
  118882. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118883. /**
  118884. * Generates an image screenshot from the specified camera.
  118885. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118886. * @param engine The engine to use for rendering
  118887. * @param camera The camera to use for rendering
  118888. * @param size This parameter can be set to a single number or to an object with the
  118889. * following (optional) properties: precision, width, height. If a single number is passed,
  118890. * it will be used for both width and height. If an object is passed, the screenshot size
  118891. * will be derived from the parameters. The precision property is a multiplier allowing
  118892. * rendering at a higher or lower resolution
  118893. * @param successCallback The callback receives a single parameter which contains the
  118894. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118895. * src parameter of an <img> to display it
  118896. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118897. * Check your browser for supported MIME types
  118898. * @param samples Texture samples (default: 1)
  118899. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118900. * @param fileName A name for for the downloaded file.
  118901. */
  118902. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  118903. /**
  118904. * Generates an image screenshot from the specified camera.
  118905. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118906. * @param engine The engine to use for rendering
  118907. * @param camera The camera to use for rendering
  118908. * @param size This parameter can be set to a single number or to an object with the
  118909. * following (optional) properties: precision, width, height. If a single number is passed,
  118910. * it will be used for both width and height. If an object is passed, the screenshot size
  118911. * will be derived from the parameters. The precision property is a multiplier allowing
  118912. * rendering at a higher or lower resolution
  118913. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118914. * Check your browser for supported MIME types
  118915. * @param samples Texture samples (default: 1)
  118916. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118917. * @param fileName A name for for the downloaded file.
  118918. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118919. * to the src parameter of an <img> to display it
  118920. */
  118921. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  118922. /**
  118923. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  118924. * Be aware Math.random() could cause collisions, but:
  118925. * "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"
  118926. * @returns a pseudo random id
  118927. */
  118928. static RandomId(): string;
  118929. /**
  118930. * Test if the given uri is a base64 string
  118931. * @param uri The uri to test
  118932. * @return True if the uri is a base64 string or false otherwise
  118933. */
  118934. static IsBase64(uri: string): boolean;
  118935. /**
  118936. * Decode the given base64 uri.
  118937. * @param uri The uri to decode
  118938. * @return The decoded base64 data.
  118939. */
  118940. static DecodeBase64(uri: string): ArrayBuffer;
  118941. /**
  118942. * Gets the absolute url.
  118943. * @param url the input url
  118944. * @return the absolute url
  118945. */
  118946. static GetAbsoluteUrl(url: string): string;
  118947. /**
  118948. * No log
  118949. */
  118950. static readonly NoneLogLevel: number;
  118951. /**
  118952. * Only message logs
  118953. */
  118954. static readonly MessageLogLevel: number;
  118955. /**
  118956. * Only warning logs
  118957. */
  118958. static readonly WarningLogLevel: number;
  118959. /**
  118960. * Only error logs
  118961. */
  118962. static readonly ErrorLogLevel: number;
  118963. /**
  118964. * All logs
  118965. */
  118966. static readonly AllLogLevel: number;
  118967. /**
  118968. * Gets a value indicating the number of loading errors
  118969. * @ignorenaming
  118970. */
  118971. static get errorsCount(): number;
  118972. /**
  118973. * Callback called when a new log is added
  118974. */
  118975. static OnNewCacheEntry: (entry: string) => void;
  118976. /**
  118977. * Log a message to the console
  118978. * @param message defines the message to log
  118979. */
  118980. static Log(message: string): void;
  118981. /**
  118982. * Write a warning message to the console
  118983. * @param message defines the message to log
  118984. */
  118985. static Warn(message: string): void;
  118986. /**
  118987. * Write an error message to the console
  118988. * @param message defines the message to log
  118989. */
  118990. static Error(message: string): void;
  118991. /**
  118992. * Gets current log cache (list of logs)
  118993. */
  118994. static get LogCache(): string;
  118995. /**
  118996. * Clears the log cache
  118997. */
  118998. static ClearLogCache(): void;
  118999. /**
  119000. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  119001. */
  119002. static set LogLevels(level: number);
  119003. /**
  119004. * Checks if the window object exists
  119005. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  119006. */
  119007. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  119008. /**
  119009. * No performance log
  119010. */
  119011. static readonly PerformanceNoneLogLevel: number;
  119012. /**
  119013. * Use user marks to log performance
  119014. */
  119015. static readonly PerformanceUserMarkLogLevel: number;
  119016. /**
  119017. * Log performance to the console
  119018. */
  119019. static readonly PerformanceConsoleLogLevel: number;
  119020. private static _performance;
  119021. /**
  119022. * Sets the current performance log level
  119023. */
  119024. static set PerformanceLogLevel(level: number);
  119025. private static _StartPerformanceCounterDisabled;
  119026. private static _EndPerformanceCounterDisabled;
  119027. private static _StartUserMark;
  119028. private static _EndUserMark;
  119029. private static _StartPerformanceConsole;
  119030. private static _EndPerformanceConsole;
  119031. /**
  119032. * Starts a performance counter
  119033. */
  119034. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119035. /**
  119036. * Ends a specific performance coutner
  119037. */
  119038. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119039. /**
  119040. * Gets either window.performance.now() if supported or Date.now() else
  119041. */
  119042. static get Now(): number;
  119043. /**
  119044. * This method will return the name of the class used to create the instance of the given object.
  119045. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  119046. * @param object the object to get the class name from
  119047. * @param isType defines if the object is actually a type
  119048. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  119049. */
  119050. static GetClassName(object: any, isType?: boolean): string;
  119051. /**
  119052. * Gets the first element of an array satisfying a given predicate
  119053. * @param array defines the array to browse
  119054. * @param predicate defines the predicate to use
  119055. * @returns null if not found or the element
  119056. */
  119057. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  119058. /**
  119059. * This method will return the name of the full name of the class, including its owning module (if any).
  119060. * 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).
  119061. * @param object the object to get the class name from
  119062. * @param isType defines if the object is actually a type
  119063. * @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.
  119064. * @ignorenaming
  119065. */
  119066. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  119067. /**
  119068. * Returns a promise that resolves after the given amount of time.
  119069. * @param delay Number of milliseconds to delay
  119070. * @returns Promise that resolves after the given amount of time
  119071. */
  119072. static DelayAsync(delay: number): Promise<void>;
  119073. /**
  119074. * Utility function to detect if the current user agent is Safari
  119075. * @returns whether or not the current user agent is safari
  119076. */
  119077. static IsSafari(): boolean;
  119078. }
  119079. /**
  119080. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  119081. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  119082. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  119083. * @param name The name of the class, case should be preserved
  119084. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  119085. */
  119086. export function className(name: string, module?: string): (target: Object) => void;
  119087. /**
  119088. * An implementation of a loop for asynchronous functions.
  119089. */
  119090. export class AsyncLoop {
  119091. /**
  119092. * Defines the number of iterations for the loop
  119093. */
  119094. iterations: number;
  119095. /**
  119096. * Defines the current index of the loop.
  119097. */
  119098. index: number;
  119099. private _done;
  119100. private _fn;
  119101. private _successCallback;
  119102. /**
  119103. * Constructor.
  119104. * @param iterations the number of iterations.
  119105. * @param func the function to run each iteration
  119106. * @param successCallback the callback that will be called upon succesful execution
  119107. * @param offset starting offset.
  119108. */
  119109. constructor(
  119110. /**
  119111. * Defines the number of iterations for the loop
  119112. */
  119113. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  119114. /**
  119115. * Execute the next iteration. Must be called after the last iteration was finished.
  119116. */
  119117. executeNext(): void;
  119118. /**
  119119. * Break the loop and run the success callback.
  119120. */
  119121. breakLoop(): void;
  119122. /**
  119123. * Create and run an async loop.
  119124. * @param iterations the number of iterations.
  119125. * @param fn the function to run each iteration
  119126. * @param successCallback the callback that will be called upon succesful execution
  119127. * @param offset starting offset.
  119128. * @returns the created async loop object
  119129. */
  119130. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  119131. /**
  119132. * A for-loop that will run a given number of iterations synchronous and the rest async.
  119133. * @param iterations total number of iterations
  119134. * @param syncedIterations number of synchronous iterations in each async iteration.
  119135. * @param fn the function to call each iteration.
  119136. * @param callback a success call back that will be called when iterating stops.
  119137. * @param breakFunction a break condition (optional)
  119138. * @param timeout timeout settings for the setTimeout function. default - 0.
  119139. * @returns the created async loop object
  119140. */
  119141. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  119142. }
  119143. }
  119144. declare module BABYLON {
  119145. /**
  119146. * This class implement a typical dictionary using a string as key and the generic type T as value.
  119147. * The underlying implementation relies on an associative array to ensure the best performances.
  119148. * The value can be anything including 'null' but except 'undefined'
  119149. */
  119150. export class StringDictionary<T> {
  119151. /**
  119152. * This will clear this dictionary and copy the content from the 'source' one.
  119153. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  119154. * @param source the dictionary to take the content from and copy to this dictionary
  119155. */
  119156. copyFrom(source: StringDictionary<T>): void;
  119157. /**
  119158. * Get a value based from its key
  119159. * @param key the given key to get the matching value from
  119160. * @return the value if found, otherwise undefined is returned
  119161. */
  119162. get(key: string): T | undefined;
  119163. /**
  119164. * Get a value from its key or add it if it doesn't exist.
  119165. * This method will ensure you that a given key/data will be present in the dictionary.
  119166. * @param key the given key to get the matching value from
  119167. * @param factory the factory that will create the value if the key is not present in the dictionary.
  119168. * The factory will only be invoked if there's no data for the given key.
  119169. * @return the value corresponding to the key.
  119170. */
  119171. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  119172. /**
  119173. * Get a value from its key if present in the dictionary otherwise add it
  119174. * @param key the key to get the value from
  119175. * @param val if there's no such key/value pair in the dictionary add it with this value
  119176. * @return the value corresponding to the key
  119177. */
  119178. getOrAdd(key: string, val: T): T;
  119179. /**
  119180. * Check if there's a given key in the dictionary
  119181. * @param key the key to check for
  119182. * @return true if the key is present, false otherwise
  119183. */
  119184. contains(key: string): boolean;
  119185. /**
  119186. * Add a new key and its corresponding value
  119187. * @param key the key to add
  119188. * @param value the value corresponding to the key
  119189. * @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
  119190. */
  119191. add(key: string, value: T): boolean;
  119192. /**
  119193. * Update a specific value associated to a key
  119194. * @param key defines the key to use
  119195. * @param value defines the value to store
  119196. * @returns true if the value was updated (or false if the key was not found)
  119197. */
  119198. set(key: string, value: T): boolean;
  119199. /**
  119200. * Get the element of the given key and remove it from the dictionary
  119201. * @param key defines the key to search
  119202. * @returns the value associated with the key or null if not found
  119203. */
  119204. getAndRemove(key: string): Nullable<T>;
  119205. /**
  119206. * Remove a key/value from the dictionary.
  119207. * @param key the key to remove
  119208. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  119209. */
  119210. remove(key: string): boolean;
  119211. /**
  119212. * Clear the whole content of the dictionary
  119213. */
  119214. clear(): void;
  119215. /**
  119216. * Gets the current count
  119217. */
  119218. get count(): number;
  119219. /**
  119220. * Execute a callback on each key/val of the dictionary.
  119221. * Note that you can remove any element in this dictionary in the callback implementation
  119222. * @param callback the callback to execute on a given key/value pair
  119223. */
  119224. forEach(callback: (key: string, val: T) => void): void;
  119225. /**
  119226. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  119227. * If the callback returns null or undefined the method will iterate to the next key/value pair
  119228. * Note that you can remove any element in this dictionary in the callback implementation
  119229. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  119230. * @returns the first item
  119231. */
  119232. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  119233. private _count;
  119234. private _data;
  119235. }
  119236. }
  119237. declare module BABYLON {
  119238. /** @hidden */
  119239. export interface ICollisionCoordinator {
  119240. createCollider(): Collider;
  119241. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119242. init(scene: Scene): void;
  119243. }
  119244. /** @hidden */
  119245. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  119246. private _scene;
  119247. private _scaledPosition;
  119248. private _scaledVelocity;
  119249. private _finalPosition;
  119250. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119251. createCollider(): Collider;
  119252. init(scene: Scene): void;
  119253. private _collideWithWorld;
  119254. }
  119255. }
  119256. declare module BABYLON {
  119257. /**
  119258. * Class used to manage all inputs for the scene.
  119259. */
  119260. export class InputManager {
  119261. /** The distance in pixel that you have to move to prevent some events */
  119262. static DragMovementThreshold: number;
  119263. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  119264. static LongPressDelay: number;
  119265. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  119266. static DoubleClickDelay: number;
  119267. /** If you need to check double click without raising a single click at first click, enable this flag */
  119268. static ExclusiveDoubleClickMode: boolean;
  119269. /** 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. */
  119270. private _alreadyAttached;
  119271. private _wheelEventName;
  119272. private _onPointerMove;
  119273. private _onPointerDown;
  119274. private _onPointerUp;
  119275. private _initClickEvent;
  119276. private _initActionManager;
  119277. private _delayedSimpleClick;
  119278. private _delayedSimpleClickTimeout;
  119279. private _previousDelayedSimpleClickTimeout;
  119280. private _meshPickProceed;
  119281. private _previousButtonPressed;
  119282. private _currentPickResult;
  119283. private _previousPickResult;
  119284. private _totalPointersPressed;
  119285. private _doubleClickOccured;
  119286. private _pointerOverMesh;
  119287. private _pickedDownMesh;
  119288. private _pickedUpMesh;
  119289. private _pointerX;
  119290. private _pointerY;
  119291. private _unTranslatedPointerX;
  119292. private _unTranslatedPointerY;
  119293. private _startingPointerPosition;
  119294. private _previousStartingPointerPosition;
  119295. private _startingPointerTime;
  119296. private _previousStartingPointerTime;
  119297. private _pointerCaptures;
  119298. private _meshUnderPointerId;
  119299. private _onKeyDown;
  119300. private _onKeyUp;
  119301. private _onCanvasFocusObserver;
  119302. private _onCanvasBlurObserver;
  119303. private _scene;
  119304. /**
  119305. * Creates a new InputManager
  119306. * @param scene defines the hosting scene
  119307. */
  119308. constructor(scene: Scene);
  119309. /**
  119310. * Gets the mesh that is currently under the pointer
  119311. */
  119312. get meshUnderPointer(): Nullable<AbstractMesh>;
  119313. /**
  119314. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  119315. * @param pointerId the pointer id to use
  119316. * @returns The mesh under this pointer id or null if not found
  119317. */
  119318. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  119319. /**
  119320. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  119321. */
  119322. get unTranslatedPointer(): Vector2;
  119323. /**
  119324. * Gets or sets the current on-screen X position of the pointer
  119325. */
  119326. get pointerX(): number;
  119327. set pointerX(value: number);
  119328. /**
  119329. * Gets or sets the current on-screen Y position of the pointer
  119330. */
  119331. get pointerY(): number;
  119332. set pointerY(value: number);
  119333. private _updatePointerPosition;
  119334. private _processPointerMove;
  119335. private _setRayOnPointerInfo;
  119336. private _checkPrePointerObservable;
  119337. /**
  119338. * Use this method to simulate a pointer move on a mesh
  119339. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119340. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119341. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119342. */
  119343. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119344. /**
  119345. * Use this method to simulate a pointer down on a mesh
  119346. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119347. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119348. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119349. */
  119350. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119351. private _processPointerDown;
  119352. /** @hidden */
  119353. _isPointerSwiping(): boolean;
  119354. /**
  119355. * Use this method to simulate a pointer up on a mesh
  119356. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119357. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119358. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119359. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119360. */
  119361. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  119362. private _processPointerUp;
  119363. /**
  119364. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119365. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119366. * @returns true if the pointer was captured
  119367. */
  119368. isPointerCaptured(pointerId?: number): boolean;
  119369. /**
  119370. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119371. * @param attachUp defines if you want to attach events to pointerup
  119372. * @param attachDown defines if you want to attach events to pointerdown
  119373. * @param attachMove defines if you want to attach events to pointermove
  119374. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  119375. */
  119376. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  119377. /**
  119378. * Detaches all event handlers
  119379. */
  119380. detachControl(): void;
  119381. /**
  119382. * Force the value of meshUnderPointer
  119383. * @param mesh defines the mesh to use
  119384. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  119385. */
  119386. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  119387. /**
  119388. * Gets the mesh under the pointer
  119389. * @returns a Mesh or null if no mesh is under the pointer
  119390. */
  119391. getPointerOverMesh(): Nullable<AbstractMesh>;
  119392. }
  119393. }
  119394. declare module BABYLON {
  119395. /**
  119396. * This class defines the direct association between an animation and a target
  119397. */
  119398. export class TargetedAnimation {
  119399. /**
  119400. * Animation to perform
  119401. */
  119402. animation: Animation;
  119403. /**
  119404. * Target to animate
  119405. */
  119406. target: any;
  119407. /**
  119408. * Returns the string "TargetedAnimation"
  119409. * @returns "TargetedAnimation"
  119410. */
  119411. getClassName(): string;
  119412. /**
  119413. * Serialize the object
  119414. * @returns the JSON object representing the current entity
  119415. */
  119416. serialize(): any;
  119417. }
  119418. /**
  119419. * Use this class to create coordinated animations on multiple targets
  119420. */
  119421. export class AnimationGroup implements IDisposable {
  119422. /** The name of the animation group */
  119423. name: string;
  119424. private _scene;
  119425. private _targetedAnimations;
  119426. private _animatables;
  119427. private _from;
  119428. private _to;
  119429. private _isStarted;
  119430. private _isPaused;
  119431. private _speedRatio;
  119432. private _loopAnimation;
  119433. private _isAdditive;
  119434. /**
  119435. * Gets or sets the unique id of the node
  119436. */
  119437. uniqueId: number;
  119438. /**
  119439. * This observable will notify when one animation have ended
  119440. */
  119441. onAnimationEndObservable: Observable<TargetedAnimation>;
  119442. /**
  119443. * Observer raised when one animation loops
  119444. */
  119445. onAnimationLoopObservable: Observable<TargetedAnimation>;
  119446. /**
  119447. * Observer raised when all animations have looped
  119448. */
  119449. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  119450. /**
  119451. * This observable will notify when all animations have ended.
  119452. */
  119453. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  119454. /**
  119455. * This observable will notify when all animations have paused.
  119456. */
  119457. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  119458. /**
  119459. * This observable will notify when all animations are playing.
  119460. */
  119461. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  119462. /**
  119463. * Gets the first frame
  119464. */
  119465. get from(): number;
  119466. /**
  119467. * Gets the last frame
  119468. */
  119469. get to(): number;
  119470. /**
  119471. * Define if the animations are started
  119472. */
  119473. get isStarted(): boolean;
  119474. /**
  119475. * Gets a value indicating that the current group is playing
  119476. */
  119477. get isPlaying(): boolean;
  119478. /**
  119479. * Gets or sets the speed ratio to use for all animations
  119480. */
  119481. get speedRatio(): number;
  119482. /**
  119483. * Gets or sets the speed ratio to use for all animations
  119484. */
  119485. set speedRatio(value: number);
  119486. /**
  119487. * Gets or sets if all animations should loop or not
  119488. */
  119489. get loopAnimation(): boolean;
  119490. set loopAnimation(value: boolean);
  119491. /**
  119492. * Gets or sets if all animations should be evaluated additively
  119493. */
  119494. get isAdditive(): boolean;
  119495. set isAdditive(value: boolean);
  119496. /**
  119497. * Gets the targeted animations for this animation group
  119498. */
  119499. get targetedAnimations(): Array<TargetedAnimation>;
  119500. /**
  119501. * returning the list of animatables controlled by this animation group.
  119502. */
  119503. get animatables(): Array<Animatable>;
  119504. /**
  119505. * Gets the list of target animations
  119506. */
  119507. get children(): TargetedAnimation[];
  119508. /**
  119509. * Instantiates a new Animation Group.
  119510. * This helps managing several animations at once.
  119511. * @see https://doc.babylonjs.com/how_to/group
  119512. * @param name Defines the name of the group
  119513. * @param scene Defines the scene the group belongs to
  119514. */
  119515. constructor(
  119516. /** The name of the animation group */
  119517. name: string, scene?: Nullable<Scene>);
  119518. /**
  119519. * Add an animation (with its target) in the group
  119520. * @param animation defines the animation we want to add
  119521. * @param target defines the target of the animation
  119522. * @returns the TargetedAnimation object
  119523. */
  119524. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  119525. /**
  119526. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  119527. * It can add constant keys at begin or end
  119528. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  119529. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  119530. * @returns the animation group
  119531. */
  119532. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  119533. private _animationLoopCount;
  119534. private _animationLoopFlags;
  119535. private _processLoop;
  119536. /**
  119537. * Start all animations on given targets
  119538. * @param loop defines if animations must loop
  119539. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  119540. * @param from defines the from key (optional)
  119541. * @param to defines the to key (optional)
  119542. * @param isAdditive defines the additive state for the resulting animatables (optional)
  119543. * @returns the current animation group
  119544. */
  119545. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  119546. /**
  119547. * Pause all animations
  119548. * @returns the animation group
  119549. */
  119550. pause(): AnimationGroup;
  119551. /**
  119552. * Play all animations to initial state
  119553. * This function will start() the animations if they were not started or will restart() them if they were paused
  119554. * @param loop defines if animations must loop
  119555. * @returns the animation group
  119556. */
  119557. play(loop?: boolean): AnimationGroup;
  119558. /**
  119559. * Reset all animations to initial state
  119560. * @returns the animation group
  119561. */
  119562. reset(): AnimationGroup;
  119563. /**
  119564. * Restart animations from key 0
  119565. * @returns the animation group
  119566. */
  119567. restart(): AnimationGroup;
  119568. /**
  119569. * Stop all animations
  119570. * @returns the animation group
  119571. */
  119572. stop(): AnimationGroup;
  119573. /**
  119574. * Set animation weight for all animatables
  119575. * @param weight defines the weight to use
  119576. * @return the animationGroup
  119577. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119578. */
  119579. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119580. /**
  119581. * Synchronize and normalize all animatables with a source animatable
  119582. * @param root defines the root animatable to synchronize with
  119583. * @return the animationGroup
  119584. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119585. */
  119586. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119587. /**
  119588. * Goes to a specific frame in this animation group
  119589. * @param frame the frame number to go to
  119590. * @return the animationGroup
  119591. */
  119592. goToFrame(frame: number): AnimationGroup;
  119593. /**
  119594. * Dispose all associated resources
  119595. */
  119596. dispose(): void;
  119597. private _checkAnimationGroupEnded;
  119598. /**
  119599. * Clone the current animation group and returns a copy
  119600. * @param newName defines the name of the new group
  119601. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119602. * @returns the new aniamtion group
  119603. */
  119604. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119605. /**
  119606. * Serializes the animationGroup to an object
  119607. * @returns Serialized object
  119608. */
  119609. serialize(): any;
  119610. /**
  119611. * Returns a new AnimationGroup object parsed from the source provided.
  119612. * @param parsedAnimationGroup defines the source
  119613. * @param scene defines the scene that will receive the animationGroup
  119614. * @returns a new AnimationGroup
  119615. */
  119616. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119617. /**
  119618. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119619. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119620. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119621. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119622. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119623. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119624. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119625. */
  119626. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119627. /**
  119628. * Returns the string "AnimationGroup"
  119629. * @returns "AnimationGroup"
  119630. */
  119631. getClassName(): string;
  119632. /**
  119633. * Creates a detailled string about the object
  119634. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119635. * @returns a string representing the object
  119636. */
  119637. toString(fullDetails?: boolean): string;
  119638. }
  119639. }
  119640. declare module BABYLON {
  119641. /**
  119642. * Define an interface for all classes that will hold resources
  119643. */
  119644. export interface IDisposable {
  119645. /**
  119646. * Releases all held resources
  119647. */
  119648. dispose(): void;
  119649. }
  119650. /** Interface defining initialization parameters for Scene class */
  119651. export interface SceneOptions {
  119652. /**
  119653. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  119654. * It will improve performance when the number of geometries becomes important.
  119655. */
  119656. useGeometryUniqueIdsMap?: boolean;
  119657. /**
  119658. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  119659. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119660. */
  119661. useMaterialMeshMap?: boolean;
  119662. /**
  119663. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  119664. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119665. */
  119666. useClonedMeshMap?: boolean;
  119667. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  119668. virtual?: boolean;
  119669. }
  119670. /**
  119671. * Represents a scene to be rendered by the engine.
  119672. * @see https://doc.babylonjs.com/features/scene
  119673. */
  119674. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  119675. /** The fog is deactivated */
  119676. static readonly FOGMODE_NONE: number;
  119677. /** The fog density is following an exponential function */
  119678. static readonly FOGMODE_EXP: number;
  119679. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  119680. static readonly FOGMODE_EXP2: number;
  119681. /** The fog density is following a linear function. */
  119682. static readonly FOGMODE_LINEAR: number;
  119683. /**
  119684. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  119685. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119686. */
  119687. static MinDeltaTime: number;
  119688. /**
  119689. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  119690. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119691. */
  119692. static MaxDeltaTime: number;
  119693. /**
  119694. * Factory used to create the default material.
  119695. * @param name The name of the material to create
  119696. * @param scene The scene to create the material for
  119697. * @returns The default material
  119698. */
  119699. static DefaultMaterialFactory(scene: Scene): Material;
  119700. /**
  119701. * Factory used to create the a collision coordinator.
  119702. * @returns The collision coordinator
  119703. */
  119704. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  119705. /** @hidden */
  119706. _inputManager: InputManager;
  119707. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  119708. cameraToUseForPointers: Nullable<Camera>;
  119709. /** @hidden */
  119710. readonly _isScene: boolean;
  119711. /** @hidden */
  119712. _blockEntityCollection: boolean;
  119713. /**
  119714. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  119715. */
  119716. autoClear: boolean;
  119717. /**
  119718. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  119719. */
  119720. autoClearDepthAndStencil: boolean;
  119721. /**
  119722. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  119723. */
  119724. clearColor: Color4;
  119725. /**
  119726. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  119727. */
  119728. ambientColor: Color3;
  119729. /**
  119730. * This is use to store the default BRDF lookup for PBR materials in your scene.
  119731. * It should only be one of the following (if not the default embedded one):
  119732. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119733. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  119734. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119735. * The material properties need to be setup according to the type of texture in use.
  119736. */
  119737. environmentBRDFTexture: BaseTexture;
  119738. /**
  119739. * Texture used in all pbr material as the reflection texture.
  119740. * As in the majority of the scene they are the same (exception for multi room and so on),
  119741. * this is easier to reference from here than from all the materials.
  119742. */
  119743. get environmentTexture(): Nullable<BaseTexture>;
  119744. /**
  119745. * Texture used in all pbr material as the reflection texture.
  119746. * As in the majority of the scene they are the same (exception for multi room and so on),
  119747. * this is easier to set here than in all the materials.
  119748. */
  119749. set environmentTexture(value: Nullable<BaseTexture>);
  119750. /** @hidden */
  119751. protected _environmentIntensity: number;
  119752. /**
  119753. * Intensity of the environment in all pbr material.
  119754. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119755. * As in the majority of the scene they are the same (exception for multi room and so on),
  119756. * this is easier to reference from here than from all the materials.
  119757. */
  119758. get environmentIntensity(): number;
  119759. /**
  119760. * Intensity of the environment in all pbr material.
  119761. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119762. * As in the majority of the scene they are the same (exception for multi room and so on),
  119763. * this is easier to set here than in all the materials.
  119764. */
  119765. set environmentIntensity(value: number);
  119766. /** @hidden */
  119767. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119768. /**
  119769. * Default image processing configuration used either in the rendering
  119770. * Forward main pass or through the imageProcessingPostProcess if present.
  119771. * As in the majority of the scene they are the same (exception for multi camera),
  119772. * this is easier to reference from here than from all the materials and post process.
  119773. *
  119774. * No setter as we it is a shared configuration, you can set the values instead.
  119775. */
  119776. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119777. private _forceWireframe;
  119778. /**
  119779. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119780. */
  119781. set forceWireframe(value: boolean);
  119782. get forceWireframe(): boolean;
  119783. private _skipFrustumClipping;
  119784. /**
  119785. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119786. */
  119787. set skipFrustumClipping(value: boolean);
  119788. get skipFrustumClipping(): boolean;
  119789. private _forcePointsCloud;
  119790. /**
  119791. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119792. */
  119793. set forcePointsCloud(value: boolean);
  119794. get forcePointsCloud(): boolean;
  119795. /**
  119796. * Gets or sets the active clipplane 1
  119797. */
  119798. clipPlane: Nullable<Plane>;
  119799. /**
  119800. * Gets or sets the active clipplane 2
  119801. */
  119802. clipPlane2: Nullable<Plane>;
  119803. /**
  119804. * Gets or sets the active clipplane 3
  119805. */
  119806. clipPlane3: Nullable<Plane>;
  119807. /**
  119808. * Gets or sets the active clipplane 4
  119809. */
  119810. clipPlane4: Nullable<Plane>;
  119811. /**
  119812. * Gets or sets the active clipplane 5
  119813. */
  119814. clipPlane5: Nullable<Plane>;
  119815. /**
  119816. * Gets or sets the active clipplane 6
  119817. */
  119818. clipPlane6: Nullable<Plane>;
  119819. /**
  119820. * Gets or sets a boolean indicating if animations are enabled
  119821. */
  119822. animationsEnabled: boolean;
  119823. private _animationPropertiesOverride;
  119824. /**
  119825. * Gets or sets the animation properties override
  119826. */
  119827. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119828. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119829. /**
  119830. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119831. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119832. */
  119833. useConstantAnimationDeltaTime: boolean;
  119834. /**
  119835. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119836. * Please note that it requires to run a ray cast through the scene on every frame
  119837. */
  119838. constantlyUpdateMeshUnderPointer: boolean;
  119839. /**
  119840. * Defines the HTML cursor to use when hovering over interactive elements
  119841. */
  119842. hoverCursor: string;
  119843. /**
  119844. * Defines the HTML default cursor to use (empty by default)
  119845. */
  119846. defaultCursor: string;
  119847. /**
  119848. * Defines whether cursors are handled by the scene.
  119849. */
  119850. doNotHandleCursors: boolean;
  119851. /**
  119852. * This is used to call preventDefault() on pointer down
  119853. * in order to block unwanted artifacts like system double clicks
  119854. */
  119855. preventDefaultOnPointerDown: boolean;
  119856. /**
  119857. * This is used to call preventDefault() on pointer up
  119858. * in order to block unwanted artifacts like system double clicks
  119859. */
  119860. preventDefaultOnPointerUp: boolean;
  119861. /**
  119862. * Gets or sets user defined metadata
  119863. */
  119864. metadata: any;
  119865. /**
  119866. * For internal use only. Please do not use.
  119867. */
  119868. reservedDataStore: any;
  119869. /**
  119870. * Gets the name of the plugin used to load this scene (null by default)
  119871. */
  119872. loadingPluginName: string;
  119873. /**
  119874. * Use this array to add regular expressions used to disable offline support for specific urls
  119875. */
  119876. disableOfflineSupportExceptionRules: RegExp[];
  119877. /**
  119878. * An event triggered when the scene is disposed.
  119879. */
  119880. onDisposeObservable: Observable<Scene>;
  119881. private _onDisposeObserver;
  119882. /** Sets a function to be executed when this scene is disposed. */
  119883. set onDispose(callback: () => void);
  119884. /**
  119885. * An event triggered before rendering the scene (right after animations and physics)
  119886. */
  119887. onBeforeRenderObservable: Observable<Scene>;
  119888. private _onBeforeRenderObserver;
  119889. /** Sets a function to be executed before rendering this scene */
  119890. set beforeRender(callback: Nullable<() => void>);
  119891. /**
  119892. * An event triggered after rendering the scene
  119893. */
  119894. onAfterRenderObservable: Observable<Scene>;
  119895. /**
  119896. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  119897. */
  119898. onAfterRenderCameraObservable: Observable<Camera>;
  119899. private _onAfterRenderObserver;
  119900. /** Sets a function to be executed after rendering this scene */
  119901. set afterRender(callback: Nullable<() => void>);
  119902. /**
  119903. * An event triggered before animating the scene
  119904. */
  119905. onBeforeAnimationsObservable: Observable<Scene>;
  119906. /**
  119907. * An event triggered after animations processing
  119908. */
  119909. onAfterAnimationsObservable: Observable<Scene>;
  119910. /**
  119911. * An event triggered before draw calls are ready to be sent
  119912. */
  119913. onBeforeDrawPhaseObservable: Observable<Scene>;
  119914. /**
  119915. * An event triggered after draw calls have been sent
  119916. */
  119917. onAfterDrawPhaseObservable: Observable<Scene>;
  119918. /**
  119919. * An event triggered when the scene is ready
  119920. */
  119921. onReadyObservable: Observable<Scene>;
  119922. /**
  119923. * An event triggered before rendering a camera
  119924. */
  119925. onBeforeCameraRenderObservable: Observable<Camera>;
  119926. private _onBeforeCameraRenderObserver;
  119927. /** Sets a function to be executed before rendering a camera*/
  119928. set beforeCameraRender(callback: () => void);
  119929. /**
  119930. * An event triggered after rendering a camera
  119931. */
  119932. onAfterCameraRenderObservable: Observable<Camera>;
  119933. private _onAfterCameraRenderObserver;
  119934. /** Sets a function to be executed after rendering a camera*/
  119935. set afterCameraRender(callback: () => void);
  119936. /**
  119937. * An event triggered when active meshes evaluation is about to start
  119938. */
  119939. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  119940. /**
  119941. * An event triggered when active meshes evaluation is done
  119942. */
  119943. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  119944. /**
  119945. * An event triggered when particles rendering is about to start
  119946. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119947. */
  119948. onBeforeParticlesRenderingObservable: Observable<Scene>;
  119949. /**
  119950. * An event triggered when particles rendering is done
  119951. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119952. */
  119953. onAfterParticlesRenderingObservable: Observable<Scene>;
  119954. /**
  119955. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  119956. */
  119957. onDataLoadedObservable: Observable<Scene>;
  119958. /**
  119959. * An event triggered when a camera is created
  119960. */
  119961. onNewCameraAddedObservable: Observable<Camera>;
  119962. /**
  119963. * An event triggered when a camera is removed
  119964. */
  119965. onCameraRemovedObservable: Observable<Camera>;
  119966. /**
  119967. * An event triggered when a light is created
  119968. */
  119969. onNewLightAddedObservable: Observable<Light>;
  119970. /**
  119971. * An event triggered when a light is removed
  119972. */
  119973. onLightRemovedObservable: Observable<Light>;
  119974. /**
  119975. * An event triggered when a geometry is created
  119976. */
  119977. onNewGeometryAddedObservable: Observable<Geometry>;
  119978. /**
  119979. * An event triggered when a geometry is removed
  119980. */
  119981. onGeometryRemovedObservable: Observable<Geometry>;
  119982. /**
  119983. * An event triggered when a transform node is created
  119984. */
  119985. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  119986. /**
  119987. * An event triggered when a transform node is removed
  119988. */
  119989. onTransformNodeRemovedObservable: Observable<TransformNode>;
  119990. /**
  119991. * An event triggered when a mesh is created
  119992. */
  119993. onNewMeshAddedObservable: Observable<AbstractMesh>;
  119994. /**
  119995. * An event triggered when a mesh is removed
  119996. */
  119997. onMeshRemovedObservable: Observable<AbstractMesh>;
  119998. /**
  119999. * An event triggered when a skeleton is created
  120000. */
  120001. onNewSkeletonAddedObservable: Observable<Skeleton>;
  120002. /**
  120003. * An event triggered when a skeleton is removed
  120004. */
  120005. onSkeletonRemovedObservable: Observable<Skeleton>;
  120006. /**
  120007. * An event triggered when a material is created
  120008. */
  120009. onNewMaterialAddedObservable: Observable<Material>;
  120010. /**
  120011. * An event triggered when a material is removed
  120012. */
  120013. onMaterialRemovedObservable: Observable<Material>;
  120014. /**
  120015. * An event triggered when a texture is created
  120016. */
  120017. onNewTextureAddedObservable: Observable<BaseTexture>;
  120018. /**
  120019. * An event triggered when a texture is removed
  120020. */
  120021. onTextureRemovedObservable: Observable<BaseTexture>;
  120022. /**
  120023. * An event triggered when render targets are about to be rendered
  120024. * Can happen multiple times per frame.
  120025. */
  120026. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  120027. /**
  120028. * An event triggered when render targets were rendered.
  120029. * Can happen multiple times per frame.
  120030. */
  120031. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  120032. /**
  120033. * An event triggered before calculating deterministic simulation step
  120034. */
  120035. onBeforeStepObservable: Observable<Scene>;
  120036. /**
  120037. * An event triggered after calculating deterministic simulation step
  120038. */
  120039. onAfterStepObservable: Observable<Scene>;
  120040. /**
  120041. * An event triggered when the activeCamera property is updated
  120042. */
  120043. onActiveCameraChanged: Observable<Scene>;
  120044. /**
  120045. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  120046. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120047. * 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)
  120048. */
  120049. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120050. /**
  120051. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  120052. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120053. * 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)
  120054. */
  120055. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120056. /**
  120057. * This Observable will when a mesh has been imported into the scene.
  120058. */
  120059. onMeshImportedObservable: Observable<AbstractMesh>;
  120060. /**
  120061. * This Observable will when an animation file has been imported into the scene.
  120062. */
  120063. onAnimationFileImportedObservable: Observable<Scene>;
  120064. /**
  120065. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  120066. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  120067. */
  120068. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  120069. /** @hidden */
  120070. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  120071. /**
  120072. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  120073. */
  120074. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  120075. /**
  120076. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  120077. */
  120078. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  120079. /**
  120080. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  120081. */
  120082. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  120083. /** Callback called when a pointer move is detected */
  120084. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120085. /** Callback called when a pointer down is detected */
  120086. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120087. /** Callback called when a pointer up is detected */
  120088. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  120089. /** Callback called when a pointer pick is detected */
  120090. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  120091. /**
  120092. * 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).
  120093. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  120094. */
  120095. onPrePointerObservable: Observable<PointerInfoPre>;
  120096. /**
  120097. * Observable event triggered each time an input event is received from the rendering canvas
  120098. */
  120099. onPointerObservable: Observable<PointerInfo>;
  120100. /**
  120101. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  120102. */
  120103. get unTranslatedPointer(): Vector2;
  120104. /**
  120105. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  120106. */
  120107. static get DragMovementThreshold(): number;
  120108. static set DragMovementThreshold(value: number);
  120109. /**
  120110. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  120111. */
  120112. static get LongPressDelay(): number;
  120113. static set LongPressDelay(value: number);
  120114. /**
  120115. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  120116. */
  120117. static get DoubleClickDelay(): number;
  120118. static set DoubleClickDelay(value: number);
  120119. /** If you need to check double click without raising a single click at first click, enable this flag */
  120120. static get ExclusiveDoubleClickMode(): boolean;
  120121. static set ExclusiveDoubleClickMode(value: boolean);
  120122. /** @hidden */
  120123. _mirroredCameraPosition: Nullable<Vector3>;
  120124. /**
  120125. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  120126. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  120127. */
  120128. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  120129. /**
  120130. * Observable event triggered each time an keyboard event is received from the hosting window
  120131. */
  120132. onKeyboardObservable: Observable<KeyboardInfo>;
  120133. private _useRightHandedSystem;
  120134. /**
  120135. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  120136. */
  120137. set useRightHandedSystem(value: boolean);
  120138. get useRightHandedSystem(): boolean;
  120139. private _timeAccumulator;
  120140. private _currentStepId;
  120141. private _currentInternalStep;
  120142. /**
  120143. * Sets the step Id used by deterministic lock step
  120144. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120145. * @param newStepId defines the step Id
  120146. */
  120147. setStepId(newStepId: number): void;
  120148. /**
  120149. * Gets the step Id used by deterministic lock step
  120150. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120151. * @returns the step Id
  120152. */
  120153. getStepId(): number;
  120154. /**
  120155. * Gets the internal step used by deterministic lock step
  120156. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120157. * @returns the internal step
  120158. */
  120159. getInternalStep(): number;
  120160. private _fogEnabled;
  120161. /**
  120162. * Gets or sets a boolean indicating if fog is enabled on this scene
  120163. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120164. * (Default is true)
  120165. */
  120166. set fogEnabled(value: boolean);
  120167. get fogEnabled(): boolean;
  120168. private _fogMode;
  120169. /**
  120170. * Gets or sets the fog mode to use
  120171. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120172. * | mode | value |
  120173. * | --- | --- |
  120174. * | FOGMODE_NONE | 0 |
  120175. * | FOGMODE_EXP | 1 |
  120176. * | FOGMODE_EXP2 | 2 |
  120177. * | FOGMODE_LINEAR | 3 |
  120178. */
  120179. set fogMode(value: number);
  120180. get fogMode(): number;
  120181. /**
  120182. * Gets or sets the fog color to use
  120183. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120184. * (Default is Color3(0.2, 0.2, 0.3))
  120185. */
  120186. fogColor: Color3;
  120187. /**
  120188. * Gets or sets the fog density to use
  120189. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120190. * (Default is 0.1)
  120191. */
  120192. fogDensity: number;
  120193. /**
  120194. * Gets or sets the fog start distance to use
  120195. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120196. * (Default is 0)
  120197. */
  120198. fogStart: number;
  120199. /**
  120200. * Gets or sets the fog end distance to use
  120201. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120202. * (Default is 1000)
  120203. */
  120204. fogEnd: number;
  120205. /**
  120206. * Flag indicating that the frame buffer binding is handled by another component
  120207. */
  120208. prePass: boolean;
  120209. private _shadowsEnabled;
  120210. /**
  120211. * Gets or sets a boolean indicating if shadows are enabled on this scene
  120212. */
  120213. set shadowsEnabled(value: boolean);
  120214. get shadowsEnabled(): boolean;
  120215. private _lightsEnabled;
  120216. /**
  120217. * Gets or sets a boolean indicating if lights are enabled on this scene
  120218. */
  120219. set lightsEnabled(value: boolean);
  120220. get lightsEnabled(): boolean;
  120221. /** All of the active cameras added to this scene. */
  120222. activeCameras: Camera[];
  120223. /** @hidden */
  120224. _activeCamera: Nullable<Camera>;
  120225. /** Gets or sets the current active camera */
  120226. get activeCamera(): Nullable<Camera>;
  120227. set activeCamera(value: Nullable<Camera>);
  120228. private _defaultMaterial;
  120229. /** The default material used on meshes when no material is affected */
  120230. get defaultMaterial(): Material;
  120231. /** The default material used on meshes when no material is affected */
  120232. set defaultMaterial(value: Material);
  120233. private _texturesEnabled;
  120234. /**
  120235. * Gets or sets a boolean indicating if textures are enabled on this scene
  120236. */
  120237. set texturesEnabled(value: boolean);
  120238. get texturesEnabled(): boolean;
  120239. /**
  120240. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  120241. */
  120242. physicsEnabled: boolean;
  120243. /**
  120244. * Gets or sets a boolean indicating if particles are enabled on this scene
  120245. */
  120246. particlesEnabled: boolean;
  120247. /**
  120248. * Gets or sets a boolean indicating if sprites are enabled on this scene
  120249. */
  120250. spritesEnabled: boolean;
  120251. private _skeletonsEnabled;
  120252. /**
  120253. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  120254. */
  120255. set skeletonsEnabled(value: boolean);
  120256. get skeletonsEnabled(): boolean;
  120257. /**
  120258. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  120259. */
  120260. lensFlaresEnabled: boolean;
  120261. /**
  120262. * Gets or sets a boolean indicating if collisions are enabled on this scene
  120263. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120264. */
  120265. collisionsEnabled: boolean;
  120266. private _collisionCoordinator;
  120267. /** @hidden */
  120268. get collisionCoordinator(): ICollisionCoordinator;
  120269. /**
  120270. * Defines the gravity applied to this scene (used only for collisions)
  120271. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120272. */
  120273. gravity: Vector3;
  120274. /**
  120275. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  120276. */
  120277. postProcessesEnabled: boolean;
  120278. /**
  120279. * Gets the current postprocess manager
  120280. */
  120281. postProcessManager: PostProcessManager;
  120282. /**
  120283. * Gets or sets a boolean indicating if render targets are enabled on this scene
  120284. */
  120285. renderTargetsEnabled: boolean;
  120286. /**
  120287. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  120288. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  120289. */
  120290. dumpNextRenderTargets: boolean;
  120291. /**
  120292. * The list of user defined render targets added to the scene
  120293. */
  120294. customRenderTargets: RenderTargetTexture[];
  120295. /**
  120296. * Defines if texture loading must be delayed
  120297. * If true, textures will only be loaded when they need to be rendered
  120298. */
  120299. useDelayedTextureLoading: boolean;
  120300. /**
  120301. * Gets the list of meshes imported to the scene through SceneLoader
  120302. */
  120303. importedMeshesFiles: String[];
  120304. /**
  120305. * Gets or sets a boolean indicating if probes are enabled on this scene
  120306. */
  120307. probesEnabled: boolean;
  120308. /**
  120309. * Gets or sets the current offline provider to use to store scene data
  120310. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120311. */
  120312. offlineProvider: IOfflineProvider;
  120313. /**
  120314. * Gets or sets the action manager associated with the scene
  120315. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120316. */
  120317. actionManager: AbstractActionManager;
  120318. private _meshesForIntersections;
  120319. /**
  120320. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  120321. */
  120322. proceduralTexturesEnabled: boolean;
  120323. private _engine;
  120324. private _totalVertices;
  120325. /** @hidden */
  120326. _activeIndices: PerfCounter;
  120327. /** @hidden */
  120328. _activeParticles: PerfCounter;
  120329. /** @hidden */
  120330. _activeBones: PerfCounter;
  120331. private _animationRatio;
  120332. /** @hidden */
  120333. _animationTimeLast: number;
  120334. /** @hidden */
  120335. _animationTime: number;
  120336. /**
  120337. * Gets or sets a general scale for animation speed
  120338. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  120339. */
  120340. animationTimeScale: number;
  120341. /** @hidden */
  120342. _cachedMaterial: Nullable<Material>;
  120343. /** @hidden */
  120344. _cachedEffect: Nullable<Effect>;
  120345. /** @hidden */
  120346. _cachedVisibility: Nullable<number>;
  120347. private _renderId;
  120348. private _frameId;
  120349. private _executeWhenReadyTimeoutId;
  120350. private _intermediateRendering;
  120351. private _viewUpdateFlag;
  120352. private _projectionUpdateFlag;
  120353. /** @hidden */
  120354. _toBeDisposed: Nullable<IDisposable>[];
  120355. private _activeRequests;
  120356. /** @hidden */
  120357. _pendingData: any[];
  120358. private _isDisposed;
  120359. /**
  120360. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  120361. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  120362. */
  120363. dispatchAllSubMeshesOfActiveMeshes: boolean;
  120364. private _activeMeshes;
  120365. private _processedMaterials;
  120366. private _renderTargets;
  120367. /** @hidden */
  120368. _activeParticleSystems: SmartArray<IParticleSystem>;
  120369. private _activeSkeletons;
  120370. private _softwareSkinnedMeshes;
  120371. private _renderingManager;
  120372. /** @hidden */
  120373. _activeAnimatables: Animatable[];
  120374. private _transformMatrix;
  120375. private _sceneUbo;
  120376. /** @hidden */
  120377. _viewMatrix: Matrix;
  120378. private _projectionMatrix;
  120379. /** @hidden */
  120380. _forcedViewPosition: Nullable<Vector3>;
  120381. /** @hidden */
  120382. _frustumPlanes: Plane[];
  120383. /**
  120384. * Gets the list of frustum planes (built from the active camera)
  120385. */
  120386. get frustumPlanes(): Plane[];
  120387. /**
  120388. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  120389. * This is useful if there are more lights that the maximum simulteanous authorized
  120390. */
  120391. requireLightSorting: boolean;
  120392. /** @hidden */
  120393. readonly useMaterialMeshMap: boolean;
  120394. /** @hidden */
  120395. readonly useClonedMeshMap: boolean;
  120396. private _externalData;
  120397. private _uid;
  120398. /**
  120399. * @hidden
  120400. * Backing store of defined scene components.
  120401. */
  120402. _components: ISceneComponent[];
  120403. /**
  120404. * @hidden
  120405. * Backing store of defined scene components.
  120406. */
  120407. _serializableComponents: ISceneSerializableComponent[];
  120408. /**
  120409. * List of components to register on the next registration step.
  120410. */
  120411. private _transientComponents;
  120412. /**
  120413. * Registers the transient components if needed.
  120414. */
  120415. private _registerTransientComponents;
  120416. /**
  120417. * @hidden
  120418. * Add a component to the scene.
  120419. * Note that the ccomponent could be registered on th next frame if this is called after
  120420. * the register component stage.
  120421. * @param component Defines the component to add to the scene
  120422. */
  120423. _addComponent(component: ISceneComponent): void;
  120424. /**
  120425. * @hidden
  120426. * Gets a component from the scene.
  120427. * @param name defines the name of the component to retrieve
  120428. * @returns the component or null if not present
  120429. */
  120430. _getComponent(name: string): Nullable<ISceneComponent>;
  120431. /**
  120432. * @hidden
  120433. * Defines the actions happening before camera updates.
  120434. */
  120435. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  120436. /**
  120437. * @hidden
  120438. * Defines the actions happening before clear the canvas.
  120439. */
  120440. _beforeClearStage: Stage<SimpleStageAction>;
  120441. /**
  120442. * @hidden
  120443. * Defines the actions when collecting render targets for the frame.
  120444. */
  120445. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120446. /**
  120447. * @hidden
  120448. * Defines the actions happening for one camera in the frame.
  120449. */
  120450. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120451. /**
  120452. * @hidden
  120453. * Defines the actions happening during the per mesh ready checks.
  120454. */
  120455. _isReadyForMeshStage: Stage<MeshStageAction>;
  120456. /**
  120457. * @hidden
  120458. * Defines the actions happening before evaluate active mesh checks.
  120459. */
  120460. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  120461. /**
  120462. * @hidden
  120463. * Defines the actions happening during the evaluate sub mesh checks.
  120464. */
  120465. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  120466. /**
  120467. * @hidden
  120468. * Defines the actions happening during the active mesh stage.
  120469. */
  120470. _activeMeshStage: Stage<ActiveMeshStageAction>;
  120471. /**
  120472. * @hidden
  120473. * Defines the actions happening during the per camera render target step.
  120474. */
  120475. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  120476. /**
  120477. * @hidden
  120478. * Defines the actions happening just before the active camera is drawing.
  120479. */
  120480. _beforeCameraDrawStage: Stage<CameraStageAction>;
  120481. /**
  120482. * @hidden
  120483. * Defines the actions happening just before a render target is drawing.
  120484. */
  120485. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120486. /**
  120487. * @hidden
  120488. * Defines the actions happening just before a rendering group is drawing.
  120489. */
  120490. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120491. /**
  120492. * @hidden
  120493. * Defines the actions happening just before a mesh is drawing.
  120494. */
  120495. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120496. /**
  120497. * @hidden
  120498. * Defines the actions happening just after a mesh has been drawn.
  120499. */
  120500. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120501. /**
  120502. * @hidden
  120503. * Defines the actions happening just after a rendering group has been drawn.
  120504. */
  120505. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120506. /**
  120507. * @hidden
  120508. * Defines the actions happening just after the active camera has been drawn.
  120509. */
  120510. _afterCameraDrawStage: Stage<CameraStageAction>;
  120511. /**
  120512. * @hidden
  120513. * Defines the actions happening just after a render target has been drawn.
  120514. */
  120515. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120516. /**
  120517. * @hidden
  120518. * Defines the actions happening just after rendering all cameras and computing intersections.
  120519. */
  120520. _afterRenderStage: Stage<SimpleStageAction>;
  120521. /**
  120522. * @hidden
  120523. * Defines the actions happening when a pointer move event happens.
  120524. */
  120525. _pointerMoveStage: Stage<PointerMoveStageAction>;
  120526. /**
  120527. * @hidden
  120528. * Defines the actions happening when a pointer down event happens.
  120529. */
  120530. _pointerDownStage: Stage<PointerUpDownStageAction>;
  120531. /**
  120532. * @hidden
  120533. * Defines the actions happening when a pointer up event happens.
  120534. */
  120535. _pointerUpStage: Stage<PointerUpDownStageAction>;
  120536. /**
  120537. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  120538. */
  120539. private geometriesByUniqueId;
  120540. /**
  120541. * Creates a new Scene
  120542. * @param engine defines the engine to use to render this scene
  120543. * @param options defines the scene options
  120544. */
  120545. constructor(engine: Engine, options?: SceneOptions);
  120546. /**
  120547. * Gets a string identifying the name of the class
  120548. * @returns "Scene" string
  120549. */
  120550. getClassName(): string;
  120551. private _defaultMeshCandidates;
  120552. /**
  120553. * @hidden
  120554. */
  120555. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120556. private _defaultSubMeshCandidates;
  120557. /**
  120558. * @hidden
  120559. */
  120560. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120561. /**
  120562. * Sets the default candidate providers for the scene.
  120563. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120564. * and getCollidingSubMeshCandidates to their default function
  120565. */
  120566. setDefaultCandidateProviders(): void;
  120567. /**
  120568. * Gets the mesh that is currently under the pointer
  120569. */
  120570. get meshUnderPointer(): Nullable<AbstractMesh>;
  120571. /**
  120572. * Gets or sets the current on-screen X position of the pointer
  120573. */
  120574. get pointerX(): number;
  120575. set pointerX(value: number);
  120576. /**
  120577. * Gets or sets the current on-screen Y position of the pointer
  120578. */
  120579. get pointerY(): number;
  120580. set pointerY(value: number);
  120581. /**
  120582. * Gets the cached material (ie. the latest rendered one)
  120583. * @returns the cached material
  120584. */
  120585. getCachedMaterial(): Nullable<Material>;
  120586. /**
  120587. * Gets the cached effect (ie. the latest rendered one)
  120588. * @returns the cached effect
  120589. */
  120590. getCachedEffect(): Nullable<Effect>;
  120591. /**
  120592. * Gets the cached visibility state (ie. the latest rendered one)
  120593. * @returns the cached visibility state
  120594. */
  120595. getCachedVisibility(): Nullable<number>;
  120596. /**
  120597. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120598. * @param material defines the current material
  120599. * @param effect defines the current effect
  120600. * @param visibility defines the current visibility state
  120601. * @returns true if one parameter is not cached
  120602. */
  120603. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120604. /**
  120605. * Gets the engine associated with the scene
  120606. * @returns an Engine
  120607. */
  120608. getEngine(): Engine;
  120609. /**
  120610. * Gets the total number of vertices rendered per frame
  120611. * @returns the total number of vertices rendered per frame
  120612. */
  120613. getTotalVertices(): number;
  120614. /**
  120615. * Gets the performance counter for total vertices
  120616. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120617. */
  120618. get totalVerticesPerfCounter(): PerfCounter;
  120619. /**
  120620. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120621. * @returns the total number of active indices rendered per frame
  120622. */
  120623. getActiveIndices(): number;
  120624. /**
  120625. * Gets the performance counter for active indices
  120626. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120627. */
  120628. get totalActiveIndicesPerfCounter(): PerfCounter;
  120629. /**
  120630. * Gets the total number of active particles rendered per frame
  120631. * @returns the total number of active particles rendered per frame
  120632. */
  120633. getActiveParticles(): number;
  120634. /**
  120635. * Gets the performance counter for active particles
  120636. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120637. */
  120638. get activeParticlesPerfCounter(): PerfCounter;
  120639. /**
  120640. * Gets the total number of active bones rendered per frame
  120641. * @returns the total number of active bones rendered per frame
  120642. */
  120643. getActiveBones(): number;
  120644. /**
  120645. * Gets the performance counter for active bones
  120646. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120647. */
  120648. get activeBonesPerfCounter(): PerfCounter;
  120649. /**
  120650. * Gets the array of active meshes
  120651. * @returns an array of AbstractMesh
  120652. */
  120653. getActiveMeshes(): SmartArray<AbstractMesh>;
  120654. /**
  120655. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  120656. * @returns a number
  120657. */
  120658. getAnimationRatio(): number;
  120659. /**
  120660. * Gets an unique Id for the current render phase
  120661. * @returns a number
  120662. */
  120663. getRenderId(): number;
  120664. /**
  120665. * Gets an unique Id for the current frame
  120666. * @returns a number
  120667. */
  120668. getFrameId(): number;
  120669. /** Call this function if you want to manually increment the render Id*/
  120670. incrementRenderId(): void;
  120671. private _createUbo;
  120672. /**
  120673. * Use this method to simulate a pointer move on a mesh
  120674. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120675. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120676. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120677. * @returns the current scene
  120678. */
  120679. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120680. /**
  120681. * Use this method to simulate a pointer down on a mesh
  120682. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120683. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120684. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120685. * @returns the current scene
  120686. */
  120687. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120688. /**
  120689. * Use this method to simulate a pointer up on a mesh
  120690. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120691. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120692. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120693. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  120694. * @returns the current scene
  120695. */
  120696. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  120697. /**
  120698. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  120699. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  120700. * @returns true if the pointer was captured
  120701. */
  120702. isPointerCaptured(pointerId?: number): boolean;
  120703. /**
  120704. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  120705. * @param attachUp defines if you want to attach events to pointerup
  120706. * @param attachDown defines if you want to attach events to pointerdown
  120707. * @param attachMove defines if you want to attach events to pointermove
  120708. */
  120709. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  120710. /** Detaches all event handlers*/
  120711. detachControl(): void;
  120712. /**
  120713. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  120714. * Delay loaded resources are not taking in account
  120715. * @return true if all required resources are ready
  120716. */
  120717. isReady(): boolean;
  120718. /** Resets all cached information relative to material (including effect and visibility) */
  120719. resetCachedMaterial(): void;
  120720. /**
  120721. * Registers a function to be called before every frame render
  120722. * @param func defines the function to register
  120723. */
  120724. registerBeforeRender(func: () => void): void;
  120725. /**
  120726. * Unregisters a function called before every frame render
  120727. * @param func defines the function to unregister
  120728. */
  120729. unregisterBeforeRender(func: () => void): void;
  120730. /**
  120731. * Registers a function to be called after every frame render
  120732. * @param func defines the function to register
  120733. */
  120734. registerAfterRender(func: () => void): void;
  120735. /**
  120736. * Unregisters a function called after every frame render
  120737. * @param func defines the function to unregister
  120738. */
  120739. unregisterAfterRender(func: () => void): void;
  120740. private _executeOnceBeforeRender;
  120741. /**
  120742. * The provided function will run before render once and will be disposed afterwards.
  120743. * A timeout delay can be provided so that the function will be executed in N ms.
  120744. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  120745. * @param func The function to be executed.
  120746. * @param timeout optional delay in ms
  120747. */
  120748. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  120749. /** @hidden */
  120750. _addPendingData(data: any): void;
  120751. /** @hidden */
  120752. _removePendingData(data: any): void;
  120753. /**
  120754. * Returns the number of items waiting to be loaded
  120755. * @returns the number of items waiting to be loaded
  120756. */
  120757. getWaitingItemsCount(): number;
  120758. /**
  120759. * Returns a boolean indicating if the scene is still loading data
  120760. */
  120761. get isLoading(): boolean;
  120762. /**
  120763. * Registers a function to be executed when the scene is ready
  120764. * @param {Function} func - the function to be executed
  120765. */
  120766. executeWhenReady(func: () => void): void;
  120767. /**
  120768. * Returns a promise that resolves when the scene is ready
  120769. * @returns A promise that resolves when the scene is ready
  120770. */
  120771. whenReadyAsync(): Promise<void>;
  120772. /** @hidden */
  120773. _checkIsReady(): void;
  120774. /**
  120775. * Gets all animatable attached to the scene
  120776. */
  120777. get animatables(): Animatable[];
  120778. /**
  120779. * Resets the last animation time frame.
  120780. * Useful to override when animations start running when loading a scene for the first time.
  120781. */
  120782. resetLastAnimationTimeFrame(): void;
  120783. /**
  120784. * Gets the current view matrix
  120785. * @returns a Matrix
  120786. */
  120787. getViewMatrix(): Matrix;
  120788. /**
  120789. * Gets the current projection matrix
  120790. * @returns a Matrix
  120791. */
  120792. getProjectionMatrix(): Matrix;
  120793. /**
  120794. * Gets the current transform matrix
  120795. * @returns a Matrix made of View * Projection
  120796. */
  120797. getTransformMatrix(): Matrix;
  120798. /**
  120799. * Sets the current transform matrix
  120800. * @param viewL defines the View matrix to use
  120801. * @param projectionL defines the Projection matrix to use
  120802. * @param viewR defines the right View matrix to use (if provided)
  120803. * @param projectionR defines the right Projection matrix to use (if provided)
  120804. */
  120805. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120806. /**
  120807. * Gets the uniform buffer used to store scene data
  120808. * @returns a UniformBuffer
  120809. */
  120810. getSceneUniformBuffer(): UniformBuffer;
  120811. /**
  120812. * Gets an unique (relatively to the current scene) Id
  120813. * @returns an unique number for the scene
  120814. */
  120815. getUniqueId(): number;
  120816. /**
  120817. * Add a mesh to the list of scene's meshes
  120818. * @param newMesh defines the mesh to add
  120819. * @param recursive if all child meshes should also be added to the scene
  120820. */
  120821. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120822. /**
  120823. * Remove a mesh for the list of scene's meshes
  120824. * @param toRemove defines the mesh to remove
  120825. * @param recursive if all child meshes should also be removed from the scene
  120826. * @returns the index where the mesh was in the mesh list
  120827. */
  120828. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120829. /**
  120830. * Add a transform node to the list of scene's transform nodes
  120831. * @param newTransformNode defines the transform node to add
  120832. */
  120833. addTransformNode(newTransformNode: TransformNode): void;
  120834. /**
  120835. * Remove a transform node for the list of scene's transform nodes
  120836. * @param toRemove defines the transform node to remove
  120837. * @returns the index where the transform node was in the transform node list
  120838. */
  120839. removeTransformNode(toRemove: TransformNode): number;
  120840. /**
  120841. * Remove a skeleton for the list of scene's skeletons
  120842. * @param toRemove defines the skeleton to remove
  120843. * @returns the index where the skeleton was in the skeleton list
  120844. */
  120845. removeSkeleton(toRemove: Skeleton): number;
  120846. /**
  120847. * Remove a morph target for the list of scene's morph targets
  120848. * @param toRemove defines the morph target to remove
  120849. * @returns the index where the morph target was in the morph target list
  120850. */
  120851. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120852. /**
  120853. * Remove a light for the list of scene's lights
  120854. * @param toRemove defines the light to remove
  120855. * @returns the index where the light was in the light list
  120856. */
  120857. removeLight(toRemove: Light): number;
  120858. /**
  120859. * Remove a camera for the list of scene's cameras
  120860. * @param toRemove defines the camera to remove
  120861. * @returns the index where the camera was in the camera list
  120862. */
  120863. removeCamera(toRemove: Camera): number;
  120864. /**
  120865. * Remove a particle system for the list of scene's particle systems
  120866. * @param toRemove defines the particle system to remove
  120867. * @returns the index where the particle system was in the particle system list
  120868. */
  120869. removeParticleSystem(toRemove: IParticleSystem): number;
  120870. /**
  120871. * Remove a animation for the list of scene's animations
  120872. * @param toRemove defines the animation to remove
  120873. * @returns the index where the animation was in the animation list
  120874. */
  120875. removeAnimation(toRemove: Animation): number;
  120876. /**
  120877. * Will stop the animation of the given target
  120878. * @param target - the target
  120879. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120880. * @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)
  120881. */
  120882. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120883. /**
  120884. * Removes the given animation group from this scene.
  120885. * @param toRemove The animation group to remove
  120886. * @returns The index of the removed animation group
  120887. */
  120888. removeAnimationGroup(toRemove: AnimationGroup): number;
  120889. /**
  120890. * Removes the given multi-material from this scene.
  120891. * @param toRemove The multi-material to remove
  120892. * @returns The index of the removed multi-material
  120893. */
  120894. removeMultiMaterial(toRemove: MultiMaterial): number;
  120895. /**
  120896. * Removes the given material from this scene.
  120897. * @param toRemove The material to remove
  120898. * @returns The index of the removed material
  120899. */
  120900. removeMaterial(toRemove: Material): number;
  120901. /**
  120902. * Removes the given action manager from this scene.
  120903. * @param toRemove The action manager to remove
  120904. * @returns The index of the removed action manager
  120905. */
  120906. removeActionManager(toRemove: AbstractActionManager): number;
  120907. /**
  120908. * Removes the given texture from this scene.
  120909. * @param toRemove The texture to remove
  120910. * @returns The index of the removed texture
  120911. */
  120912. removeTexture(toRemove: BaseTexture): number;
  120913. /**
  120914. * Adds the given light to this scene
  120915. * @param newLight The light to add
  120916. */
  120917. addLight(newLight: Light): void;
  120918. /**
  120919. * Sorts the list list based on light priorities
  120920. */
  120921. sortLightsByPriority(): void;
  120922. /**
  120923. * Adds the given camera to this scene
  120924. * @param newCamera The camera to add
  120925. */
  120926. addCamera(newCamera: Camera): void;
  120927. /**
  120928. * Adds the given skeleton to this scene
  120929. * @param newSkeleton The skeleton to add
  120930. */
  120931. addSkeleton(newSkeleton: Skeleton): void;
  120932. /**
  120933. * Adds the given particle system to this scene
  120934. * @param newParticleSystem The particle system to add
  120935. */
  120936. addParticleSystem(newParticleSystem: IParticleSystem): void;
  120937. /**
  120938. * Adds the given animation to this scene
  120939. * @param newAnimation The animation to add
  120940. */
  120941. addAnimation(newAnimation: Animation): void;
  120942. /**
  120943. * Adds the given animation group to this scene.
  120944. * @param newAnimationGroup The animation group to add
  120945. */
  120946. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  120947. /**
  120948. * Adds the given multi-material to this scene
  120949. * @param newMultiMaterial The multi-material to add
  120950. */
  120951. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  120952. /**
  120953. * Adds the given material to this scene
  120954. * @param newMaterial The material to add
  120955. */
  120956. addMaterial(newMaterial: Material): void;
  120957. /**
  120958. * Adds the given morph target to this scene
  120959. * @param newMorphTargetManager The morph target to add
  120960. */
  120961. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  120962. /**
  120963. * Adds the given geometry to this scene
  120964. * @param newGeometry The geometry to add
  120965. */
  120966. addGeometry(newGeometry: Geometry): void;
  120967. /**
  120968. * Adds the given action manager to this scene
  120969. * @param newActionManager The action manager to add
  120970. */
  120971. addActionManager(newActionManager: AbstractActionManager): void;
  120972. /**
  120973. * Adds the given texture to this scene.
  120974. * @param newTexture The texture to add
  120975. */
  120976. addTexture(newTexture: BaseTexture): void;
  120977. /**
  120978. * Switch active camera
  120979. * @param newCamera defines the new active camera
  120980. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  120981. */
  120982. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  120983. /**
  120984. * sets the active camera of the scene using its ID
  120985. * @param id defines the camera's ID
  120986. * @return the new active camera or null if none found.
  120987. */
  120988. setActiveCameraByID(id: string): Nullable<Camera>;
  120989. /**
  120990. * sets the active camera of the scene using its name
  120991. * @param name defines the camera's name
  120992. * @returns the new active camera or null if none found.
  120993. */
  120994. setActiveCameraByName(name: string): Nullable<Camera>;
  120995. /**
  120996. * get an animation group using its name
  120997. * @param name defines the material's name
  120998. * @return the animation group or null if none found.
  120999. */
  121000. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  121001. /**
  121002. * Get a material using its unique id
  121003. * @param uniqueId defines the material's unique id
  121004. * @return the material or null if none found.
  121005. */
  121006. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  121007. /**
  121008. * get a material using its id
  121009. * @param id defines the material's ID
  121010. * @return the material or null if none found.
  121011. */
  121012. getMaterialByID(id: string): Nullable<Material>;
  121013. /**
  121014. * Gets a the last added material using a given id
  121015. * @param id defines the material's ID
  121016. * @return the last material with the given id or null if none found.
  121017. */
  121018. getLastMaterialByID(id: string): Nullable<Material>;
  121019. /**
  121020. * Gets a material using its name
  121021. * @param name defines the material's name
  121022. * @return the material or null if none found.
  121023. */
  121024. getMaterialByName(name: string): Nullable<Material>;
  121025. /**
  121026. * Get a texture using its unique id
  121027. * @param uniqueId defines the texture's unique id
  121028. * @return the texture or null if none found.
  121029. */
  121030. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  121031. /**
  121032. * Gets a camera using its id
  121033. * @param id defines the id to look for
  121034. * @returns the camera or null if not found
  121035. */
  121036. getCameraByID(id: string): Nullable<Camera>;
  121037. /**
  121038. * Gets a camera using its unique id
  121039. * @param uniqueId defines the unique id to look for
  121040. * @returns the camera or null if not found
  121041. */
  121042. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  121043. /**
  121044. * Gets a camera using its name
  121045. * @param name defines the camera's name
  121046. * @return the camera or null if none found.
  121047. */
  121048. getCameraByName(name: string): Nullable<Camera>;
  121049. /**
  121050. * Gets a bone using its id
  121051. * @param id defines the bone's id
  121052. * @return the bone or null if not found
  121053. */
  121054. getBoneByID(id: string): Nullable<Bone>;
  121055. /**
  121056. * Gets a bone using its id
  121057. * @param name defines the bone's name
  121058. * @return the bone or null if not found
  121059. */
  121060. getBoneByName(name: string): Nullable<Bone>;
  121061. /**
  121062. * Gets a light node using its name
  121063. * @param name defines the the light's name
  121064. * @return the light or null if none found.
  121065. */
  121066. getLightByName(name: string): Nullable<Light>;
  121067. /**
  121068. * Gets a light node using its id
  121069. * @param id defines the light's id
  121070. * @return the light or null if none found.
  121071. */
  121072. getLightByID(id: string): Nullable<Light>;
  121073. /**
  121074. * Gets a light node using its scene-generated unique ID
  121075. * @param uniqueId defines the light's unique id
  121076. * @return the light or null if none found.
  121077. */
  121078. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  121079. /**
  121080. * Gets a particle system by id
  121081. * @param id defines the particle system id
  121082. * @return the corresponding system or null if none found
  121083. */
  121084. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  121085. /**
  121086. * Gets a geometry using its ID
  121087. * @param id defines the geometry's id
  121088. * @return the geometry or null if none found.
  121089. */
  121090. getGeometryByID(id: string): Nullable<Geometry>;
  121091. private _getGeometryByUniqueID;
  121092. /**
  121093. * Add a new geometry to this scene
  121094. * @param geometry defines the geometry to be added to the scene.
  121095. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  121096. * @return a boolean defining if the geometry was added or not
  121097. */
  121098. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  121099. /**
  121100. * Removes an existing geometry
  121101. * @param geometry defines the geometry to be removed from the scene
  121102. * @return a boolean defining if the geometry was removed or not
  121103. */
  121104. removeGeometry(geometry: Geometry): boolean;
  121105. /**
  121106. * Gets the list of geometries attached to the scene
  121107. * @returns an array of Geometry
  121108. */
  121109. getGeometries(): Geometry[];
  121110. /**
  121111. * Gets the first added mesh found of a given ID
  121112. * @param id defines the id to search for
  121113. * @return the mesh found or null if not found at all
  121114. */
  121115. getMeshByID(id: string): Nullable<AbstractMesh>;
  121116. /**
  121117. * Gets a list of meshes using their id
  121118. * @param id defines the id to search for
  121119. * @returns a list of meshes
  121120. */
  121121. getMeshesByID(id: string): Array<AbstractMesh>;
  121122. /**
  121123. * Gets the first added transform node found of a given ID
  121124. * @param id defines the id to search for
  121125. * @return the found transform node or null if not found at all.
  121126. */
  121127. getTransformNodeByID(id: string): Nullable<TransformNode>;
  121128. /**
  121129. * Gets a transform node with its auto-generated unique id
  121130. * @param uniqueId efines the unique id to search for
  121131. * @return the found transform node or null if not found at all.
  121132. */
  121133. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  121134. /**
  121135. * Gets a list of transform nodes using their id
  121136. * @param id defines the id to search for
  121137. * @returns a list of transform nodes
  121138. */
  121139. getTransformNodesByID(id: string): Array<TransformNode>;
  121140. /**
  121141. * Gets a mesh with its auto-generated unique id
  121142. * @param uniqueId defines the unique id to search for
  121143. * @return the found mesh or null if not found at all.
  121144. */
  121145. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  121146. /**
  121147. * Gets a the last added mesh using a given id
  121148. * @param id defines the id to search for
  121149. * @return the found mesh or null if not found at all.
  121150. */
  121151. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  121152. /**
  121153. * Gets a the last added node (Mesh, Camera, Light) using a given id
  121154. * @param id defines the id to search for
  121155. * @return the found node or null if not found at all
  121156. */
  121157. getLastEntryByID(id: string): Nullable<Node>;
  121158. /**
  121159. * Gets a node (Mesh, Camera, Light) using a given id
  121160. * @param id defines the id to search for
  121161. * @return the found node or null if not found at all
  121162. */
  121163. getNodeByID(id: string): Nullable<Node>;
  121164. /**
  121165. * Gets a node (Mesh, Camera, Light) using a given name
  121166. * @param name defines the name to search for
  121167. * @return the found node or null if not found at all.
  121168. */
  121169. getNodeByName(name: string): Nullable<Node>;
  121170. /**
  121171. * Gets a mesh using a given name
  121172. * @param name defines the name to search for
  121173. * @return the found mesh or null if not found at all.
  121174. */
  121175. getMeshByName(name: string): Nullable<AbstractMesh>;
  121176. /**
  121177. * Gets a transform node using a given name
  121178. * @param name defines the name to search for
  121179. * @return the found transform node or null if not found at all.
  121180. */
  121181. getTransformNodeByName(name: string): Nullable<TransformNode>;
  121182. /**
  121183. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  121184. * @param id defines the id to search for
  121185. * @return the found skeleton or null if not found at all.
  121186. */
  121187. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  121188. /**
  121189. * Gets a skeleton using a given auto generated unique id
  121190. * @param uniqueId defines the unique id to search for
  121191. * @return the found skeleton or null if not found at all.
  121192. */
  121193. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  121194. /**
  121195. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  121196. * @param id defines the id to search for
  121197. * @return the found skeleton or null if not found at all.
  121198. */
  121199. getSkeletonById(id: string): Nullable<Skeleton>;
  121200. /**
  121201. * Gets a skeleton using a given name
  121202. * @param name defines the name to search for
  121203. * @return the found skeleton or null if not found at all.
  121204. */
  121205. getSkeletonByName(name: string): Nullable<Skeleton>;
  121206. /**
  121207. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  121208. * @param id defines the id to search for
  121209. * @return the found morph target manager or null if not found at all.
  121210. */
  121211. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  121212. /**
  121213. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  121214. * @param id defines the id to search for
  121215. * @return the found morph target or null if not found at all.
  121216. */
  121217. getMorphTargetById(id: string): Nullable<MorphTarget>;
  121218. /**
  121219. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  121220. * @param name defines the name to search for
  121221. * @return the found morph target or null if not found at all.
  121222. */
  121223. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  121224. /**
  121225. * Gets a post process using a given name (if many are found, this function will pick the first one)
  121226. * @param name defines the name to search for
  121227. * @return the found post process or null if not found at all.
  121228. */
  121229. getPostProcessByName(name: string): Nullable<PostProcess>;
  121230. /**
  121231. * Gets a boolean indicating if the given mesh is active
  121232. * @param mesh defines the mesh to look for
  121233. * @returns true if the mesh is in the active list
  121234. */
  121235. isActiveMesh(mesh: AbstractMesh): boolean;
  121236. /**
  121237. * Return a unique id as a string which can serve as an identifier for the scene
  121238. */
  121239. get uid(): string;
  121240. /**
  121241. * Add an externaly attached data from its key.
  121242. * This method call will fail and return false, if such key already exists.
  121243. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  121244. * @param key the unique key that identifies the data
  121245. * @param data the data object to associate to the key for this Engine instance
  121246. * @return true if no such key were already present and the data was added successfully, false otherwise
  121247. */
  121248. addExternalData<T>(key: string, data: T): boolean;
  121249. /**
  121250. * Get an externaly attached data from its key
  121251. * @param key the unique key that identifies the data
  121252. * @return the associated data, if present (can be null), or undefined if not present
  121253. */
  121254. getExternalData<T>(key: string): Nullable<T>;
  121255. /**
  121256. * Get an externaly attached data from its key, create it using a factory if it's not already present
  121257. * @param key the unique key that identifies the data
  121258. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  121259. * @return the associated data, can be null if the factory returned null.
  121260. */
  121261. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  121262. /**
  121263. * Remove an externaly attached data from the Engine instance
  121264. * @param key the unique key that identifies the data
  121265. * @return true if the data was successfully removed, false if it doesn't exist
  121266. */
  121267. removeExternalData(key: string): boolean;
  121268. private _evaluateSubMesh;
  121269. /**
  121270. * Clear the processed materials smart array preventing retention point in material dispose.
  121271. */
  121272. freeProcessedMaterials(): void;
  121273. private _preventFreeActiveMeshesAndRenderingGroups;
  121274. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  121275. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  121276. * when disposing several meshes in a row or a hierarchy of meshes.
  121277. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  121278. */
  121279. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  121280. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  121281. /**
  121282. * Clear the active meshes smart array preventing retention point in mesh dispose.
  121283. */
  121284. freeActiveMeshes(): void;
  121285. /**
  121286. * Clear the info related to rendering groups preventing retention points during dispose.
  121287. */
  121288. freeRenderingGroups(): void;
  121289. /** @hidden */
  121290. _isInIntermediateRendering(): boolean;
  121291. /**
  121292. * Lambda returning the list of potentially active meshes.
  121293. */
  121294. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  121295. /**
  121296. * Lambda returning the list of potentially active sub meshes.
  121297. */
  121298. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  121299. /**
  121300. * Lambda returning the list of potentially intersecting sub meshes.
  121301. */
  121302. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  121303. /**
  121304. * Lambda returning the list of potentially colliding sub meshes.
  121305. */
  121306. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  121307. private _activeMeshesFrozen;
  121308. private _skipEvaluateActiveMeshesCompletely;
  121309. /**
  121310. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  121311. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  121312. * @returns the current scene
  121313. */
  121314. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  121315. /**
  121316. * Use this function to restart evaluating active meshes on every frame
  121317. * @returns the current scene
  121318. */
  121319. unfreezeActiveMeshes(): Scene;
  121320. private _evaluateActiveMeshes;
  121321. private _activeMesh;
  121322. /**
  121323. * Update the transform matrix to update from the current active camera
  121324. * @param force defines a boolean used to force the update even if cache is up to date
  121325. */
  121326. updateTransformMatrix(force?: boolean): void;
  121327. private _bindFrameBuffer;
  121328. /** @hidden */
  121329. _allowPostProcessClearColor: boolean;
  121330. /** @hidden */
  121331. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  121332. private _processSubCameras;
  121333. private _checkIntersections;
  121334. /** @hidden */
  121335. _advancePhysicsEngineStep(step: number): void;
  121336. /**
  121337. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  121338. */
  121339. getDeterministicFrameTime: () => number;
  121340. /** @hidden */
  121341. _animate(): void;
  121342. /** Execute all animations (for a frame) */
  121343. animate(): void;
  121344. /**
  121345. * Render the scene
  121346. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  121347. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  121348. */
  121349. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  121350. /**
  121351. * Freeze all materials
  121352. * A frozen material will not be updatable but should be faster to render
  121353. */
  121354. freezeMaterials(): void;
  121355. /**
  121356. * Unfreeze all materials
  121357. * A frozen material will not be updatable but should be faster to render
  121358. */
  121359. unfreezeMaterials(): void;
  121360. /**
  121361. * Releases all held ressources
  121362. */
  121363. dispose(): void;
  121364. /**
  121365. * Gets if the scene is already disposed
  121366. */
  121367. get isDisposed(): boolean;
  121368. /**
  121369. * Call this function to reduce memory footprint of the scene.
  121370. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  121371. */
  121372. clearCachedVertexData(): void;
  121373. /**
  121374. * This function will remove the local cached buffer data from texture.
  121375. * It will save memory but will prevent the texture from being rebuilt
  121376. */
  121377. cleanCachedTextureBuffer(): void;
  121378. /**
  121379. * Get the world extend vectors with an optional filter
  121380. *
  121381. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  121382. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  121383. */
  121384. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  121385. min: Vector3;
  121386. max: Vector3;
  121387. };
  121388. /**
  121389. * Creates a ray that can be used to pick in the scene
  121390. * @param x defines the x coordinate of the origin (on-screen)
  121391. * @param y defines the y coordinate of the origin (on-screen)
  121392. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121393. * @param camera defines the camera to use for the picking
  121394. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121395. * @returns a Ray
  121396. */
  121397. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  121398. /**
  121399. * Creates a ray that can be used to pick in the scene
  121400. * @param x defines the x coordinate of the origin (on-screen)
  121401. * @param y defines the y coordinate of the origin (on-screen)
  121402. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121403. * @param result defines the ray where to store the picking ray
  121404. * @param camera defines the camera to use for the picking
  121405. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121406. * @returns the current scene
  121407. */
  121408. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  121409. /**
  121410. * Creates a ray that can be used to pick in the scene
  121411. * @param x defines the x coordinate of the origin (on-screen)
  121412. * @param y defines the y coordinate of the origin (on-screen)
  121413. * @param camera defines the camera to use for the picking
  121414. * @returns a Ray
  121415. */
  121416. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  121417. /**
  121418. * Creates a ray that can be used to pick in the scene
  121419. * @param x defines the x coordinate of the origin (on-screen)
  121420. * @param y defines the y coordinate of the origin (on-screen)
  121421. * @param result defines the ray where to store the picking ray
  121422. * @param camera defines the camera to use for the picking
  121423. * @returns the current scene
  121424. */
  121425. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  121426. /** Launch a ray to try to pick a mesh in the scene
  121427. * @param x position on screen
  121428. * @param y position on screen
  121429. * @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
  121430. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121431. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121432. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121433. * @returns a PickingInfo
  121434. */
  121435. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121436. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  121437. * @param x position on screen
  121438. * @param y position on screen
  121439. * @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
  121440. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121441. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121442. * @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)
  121443. */
  121444. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  121445. /** Use the given ray to pick a mesh in the scene
  121446. * @param ray The ray to use to pick meshes
  121447. * @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
  121448. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121449. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121450. * @returns a PickingInfo
  121451. */
  121452. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121453. /**
  121454. * Launch a ray to try to pick a mesh in the scene
  121455. * @param x X position on screen
  121456. * @param y Y position on screen
  121457. * @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
  121458. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121459. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121460. * @returns an array of PickingInfo
  121461. */
  121462. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121463. /**
  121464. * Launch a ray to try to pick a mesh in the scene
  121465. * @param ray Ray to use
  121466. * @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
  121467. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121468. * @returns an array of PickingInfo
  121469. */
  121470. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121471. /**
  121472. * Force the value of meshUnderPointer
  121473. * @param mesh defines the mesh to use
  121474. * @param pointerId optional pointer id when using more than one pointer
  121475. */
  121476. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  121477. /**
  121478. * Gets the mesh under the pointer
  121479. * @returns a Mesh or null if no mesh is under the pointer
  121480. */
  121481. getPointerOverMesh(): Nullable<AbstractMesh>;
  121482. /** @hidden */
  121483. _rebuildGeometries(): void;
  121484. /** @hidden */
  121485. _rebuildTextures(): void;
  121486. private _getByTags;
  121487. /**
  121488. * Get a list of meshes by tags
  121489. * @param tagsQuery defines the tags query to use
  121490. * @param forEach defines a predicate used to filter results
  121491. * @returns an array of Mesh
  121492. */
  121493. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  121494. /**
  121495. * Get a list of cameras by tags
  121496. * @param tagsQuery defines the tags query to use
  121497. * @param forEach defines a predicate used to filter results
  121498. * @returns an array of Camera
  121499. */
  121500. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  121501. /**
  121502. * Get a list of lights by tags
  121503. * @param tagsQuery defines the tags query to use
  121504. * @param forEach defines a predicate used to filter results
  121505. * @returns an array of Light
  121506. */
  121507. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  121508. /**
  121509. * Get a list of materials by tags
  121510. * @param tagsQuery defines the tags query to use
  121511. * @param forEach defines a predicate used to filter results
  121512. * @returns an array of Material
  121513. */
  121514. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  121515. /**
  121516. * Get a list of transform nodes by tags
  121517. * @param tagsQuery defines the tags query to use
  121518. * @param forEach defines a predicate used to filter results
  121519. * @returns an array of TransformNode
  121520. */
  121521. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  121522. /**
  121523. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121524. * This allowed control for front to back rendering or reversly depending of the special needs.
  121525. *
  121526. * @param renderingGroupId The rendering group id corresponding to its index
  121527. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121528. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121529. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121530. */
  121531. 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;
  121532. /**
  121533. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121534. *
  121535. * @param renderingGroupId The rendering group id corresponding to its index
  121536. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121537. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121538. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121539. */
  121540. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  121541. /**
  121542. * Gets the current auto clear configuration for one rendering group of the rendering
  121543. * manager.
  121544. * @param index the rendering group index to get the information for
  121545. * @returns The auto clear setup for the requested rendering group
  121546. */
  121547. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  121548. private _blockMaterialDirtyMechanism;
  121549. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  121550. get blockMaterialDirtyMechanism(): boolean;
  121551. set blockMaterialDirtyMechanism(value: boolean);
  121552. /**
  121553. * Will flag all materials as dirty to trigger new shader compilation
  121554. * @param flag defines the flag used to specify which material part must be marked as dirty
  121555. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121556. */
  121557. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121558. /** @hidden */
  121559. _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;
  121560. /** @hidden */
  121561. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121562. /** @hidden */
  121563. _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;
  121564. /** @hidden */
  121565. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121566. /** @hidden */
  121567. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121568. /** @hidden */
  121569. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121570. }
  121571. }
  121572. declare module BABYLON {
  121573. /**
  121574. * Set of assets to keep when moving a scene into an asset container.
  121575. */
  121576. export class KeepAssets extends AbstractScene {
  121577. }
  121578. /**
  121579. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121580. */
  121581. export class InstantiatedEntries {
  121582. /**
  121583. * List of new root nodes (eg. nodes with no parent)
  121584. */
  121585. rootNodes: TransformNode[];
  121586. /**
  121587. * List of new skeletons
  121588. */
  121589. skeletons: Skeleton[];
  121590. /**
  121591. * List of new animation groups
  121592. */
  121593. animationGroups: AnimationGroup[];
  121594. }
  121595. /**
  121596. * Container with a set of assets that can be added or removed from a scene.
  121597. */
  121598. export class AssetContainer extends AbstractScene {
  121599. private _wasAddedToScene;
  121600. /**
  121601. * The scene the AssetContainer belongs to.
  121602. */
  121603. scene: Scene;
  121604. /**
  121605. * Instantiates an AssetContainer.
  121606. * @param scene The scene the AssetContainer belongs to.
  121607. */
  121608. constructor(scene: Scene);
  121609. /**
  121610. * Instantiate or clone all meshes and add the new ones to the scene.
  121611. * Skeletons and animation groups will all be cloned
  121612. * @param nameFunction defines an optional function used to get new names for clones
  121613. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121614. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121615. */
  121616. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121617. /**
  121618. * Adds all the assets from the container to the scene.
  121619. */
  121620. addAllToScene(): void;
  121621. /**
  121622. * Removes all the assets in the container from the scene
  121623. */
  121624. removeAllFromScene(): void;
  121625. /**
  121626. * Disposes all the assets in the container
  121627. */
  121628. dispose(): void;
  121629. private _moveAssets;
  121630. /**
  121631. * Removes all the assets contained in the scene and adds them to the container.
  121632. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121633. */
  121634. moveAllFromScene(keepAssets?: KeepAssets): void;
  121635. /**
  121636. * 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.
  121637. * @returns the root mesh
  121638. */
  121639. createRootMesh(): Mesh;
  121640. /**
  121641. * Merge animations (direct and animation groups) from this asset container into a scene
  121642. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  121643. * @param animatables set of animatables to retarget to a node from the scene
  121644. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  121645. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  121646. */
  121647. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  121648. }
  121649. }
  121650. declare module BABYLON {
  121651. /**
  121652. * Defines how the parser contract is defined.
  121653. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  121654. */
  121655. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  121656. /**
  121657. * Defines how the individual parser contract is defined.
  121658. * These parser can parse an individual asset
  121659. */
  121660. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  121661. /**
  121662. * Base class of the scene acting as a container for the different elements composing a scene.
  121663. * This class is dynamically extended by the different components of the scene increasing
  121664. * flexibility and reducing coupling
  121665. */
  121666. export abstract class AbstractScene {
  121667. /**
  121668. * Stores the list of available parsers in the application.
  121669. */
  121670. private static _BabylonFileParsers;
  121671. /**
  121672. * Stores the list of available individual parsers in the application.
  121673. */
  121674. private static _IndividualBabylonFileParsers;
  121675. /**
  121676. * Adds a parser in the list of available ones
  121677. * @param name Defines the name of the parser
  121678. * @param parser Defines the parser to add
  121679. */
  121680. static AddParser(name: string, parser: BabylonFileParser): void;
  121681. /**
  121682. * Gets a general parser from the list of avaialble ones
  121683. * @param name Defines the name of the parser
  121684. * @returns the requested parser or null
  121685. */
  121686. static GetParser(name: string): Nullable<BabylonFileParser>;
  121687. /**
  121688. * Adds n individual parser in the list of available ones
  121689. * @param name Defines the name of the parser
  121690. * @param parser Defines the parser to add
  121691. */
  121692. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  121693. /**
  121694. * Gets an individual parser from the list of avaialble ones
  121695. * @param name Defines the name of the parser
  121696. * @returns the requested parser or null
  121697. */
  121698. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  121699. /**
  121700. * Parser json data and populate both a scene and its associated container object
  121701. * @param jsonData Defines the data to parse
  121702. * @param scene Defines the scene to parse the data for
  121703. * @param container Defines the container attached to the parsing sequence
  121704. * @param rootUrl Defines the root url of the data
  121705. */
  121706. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  121707. /**
  121708. * Gets the list of root nodes (ie. nodes with no parent)
  121709. */
  121710. rootNodes: Node[];
  121711. /** All of the cameras added to this scene
  121712. * @see https://doc.babylonjs.com/babylon101/cameras
  121713. */
  121714. cameras: Camera[];
  121715. /**
  121716. * All of the lights added to this scene
  121717. * @see https://doc.babylonjs.com/babylon101/lights
  121718. */
  121719. lights: Light[];
  121720. /**
  121721. * All of the (abstract) meshes added to this scene
  121722. */
  121723. meshes: AbstractMesh[];
  121724. /**
  121725. * The list of skeletons added to the scene
  121726. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121727. */
  121728. skeletons: Skeleton[];
  121729. /**
  121730. * All of the particle systems added to this scene
  121731. * @see https://doc.babylonjs.com/babylon101/particles
  121732. */
  121733. particleSystems: IParticleSystem[];
  121734. /**
  121735. * Gets a list of Animations associated with the scene
  121736. */
  121737. animations: Animation[];
  121738. /**
  121739. * All of the animation groups added to this scene
  121740. * @see https://doc.babylonjs.com/how_to/group
  121741. */
  121742. animationGroups: AnimationGroup[];
  121743. /**
  121744. * All of the multi-materials added to this scene
  121745. * @see https://doc.babylonjs.com/how_to/multi_materials
  121746. */
  121747. multiMaterials: MultiMaterial[];
  121748. /**
  121749. * All of the materials added to this scene
  121750. * In the context of a Scene, it is not supposed to be modified manually.
  121751. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  121752. * Note also that the order of the Material within the array is not significant and might change.
  121753. * @see https://doc.babylonjs.com/babylon101/materials
  121754. */
  121755. materials: Material[];
  121756. /**
  121757. * The list of morph target managers added to the scene
  121758. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  121759. */
  121760. morphTargetManagers: MorphTargetManager[];
  121761. /**
  121762. * The list of geometries used in the scene.
  121763. */
  121764. geometries: Geometry[];
  121765. /**
  121766. * All of the tranform nodes added to this scene
  121767. * In the context of a Scene, it is not supposed to be modified manually.
  121768. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  121769. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121770. * @see https://doc.babylonjs.com/how_to/transformnode
  121771. */
  121772. transformNodes: TransformNode[];
  121773. /**
  121774. * ActionManagers available on the scene.
  121775. */
  121776. actionManagers: AbstractActionManager[];
  121777. /**
  121778. * Textures to keep.
  121779. */
  121780. textures: BaseTexture[];
  121781. /** @hidden */
  121782. protected _environmentTexture: Nullable<BaseTexture>;
  121783. /**
  121784. * Texture used in all pbr material as the reflection texture.
  121785. * As in the majority of the scene they are the same (exception for multi room and so on),
  121786. * this is easier to reference from here than from all the materials.
  121787. */
  121788. get environmentTexture(): Nullable<BaseTexture>;
  121789. set environmentTexture(value: Nullable<BaseTexture>);
  121790. /**
  121791. * The list of postprocesses added to the scene
  121792. */
  121793. postProcesses: PostProcess[];
  121794. /**
  121795. * @returns all meshes, lights, cameras, transformNodes and bones
  121796. */
  121797. getNodes(): Array<Node>;
  121798. }
  121799. }
  121800. declare module BABYLON {
  121801. /**
  121802. * Interface used to define options for Sound class
  121803. */
  121804. export interface ISoundOptions {
  121805. /**
  121806. * Does the sound autoplay once loaded.
  121807. */
  121808. autoplay?: boolean;
  121809. /**
  121810. * Does the sound loop after it finishes playing once.
  121811. */
  121812. loop?: boolean;
  121813. /**
  121814. * Sound's volume
  121815. */
  121816. volume?: number;
  121817. /**
  121818. * Is it a spatial sound?
  121819. */
  121820. spatialSound?: boolean;
  121821. /**
  121822. * Maximum distance to hear that sound
  121823. */
  121824. maxDistance?: number;
  121825. /**
  121826. * Uses user defined attenuation function
  121827. */
  121828. useCustomAttenuation?: boolean;
  121829. /**
  121830. * Define the roll off factor of spatial sounds.
  121831. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121832. */
  121833. rolloffFactor?: number;
  121834. /**
  121835. * Define the reference distance the sound should be heard perfectly.
  121836. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121837. */
  121838. refDistance?: number;
  121839. /**
  121840. * Define the distance attenuation model the sound will follow.
  121841. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121842. */
  121843. distanceModel?: string;
  121844. /**
  121845. * Defines the playback speed (1 by default)
  121846. */
  121847. playbackRate?: number;
  121848. /**
  121849. * Defines if the sound is from a streaming source
  121850. */
  121851. streaming?: boolean;
  121852. /**
  121853. * Defines an optional length (in seconds) inside the sound file
  121854. */
  121855. length?: number;
  121856. /**
  121857. * Defines an optional offset (in seconds) inside the sound file
  121858. */
  121859. offset?: number;
  121860. /**
  121861. * If true, URLs will not be required to state the audio file codec to use.
  121862. */
  121863. skipCodecCheck?: boolean;
  121864. }
  121865. /**
  121866. * Defines a sound that can be played in the application.
  121867. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121868. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121869. */
  121870. export class Sound {
  121871. /**
  121872. * The name of the sound in the scene.
  121873. */
  121874. name: string;
  121875. /**
  121876. * Does the sound autoplay once loaded.
  121877. */
  121878. autoplay: boolean;
  121879. /**
  121880. * Does the sound loop after it finishes playing once.
  121881. */
  121882. loop: boolean;
  121883. /**
  121884. * Does the sound use a custom attenuation curve to simulate the falloff
  121885. * happening when the source gets further away from the camera.
  121886. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121887. */
  121888. useCustomAttenuation: boolean;
  121889. /**
  121890. * The sound track id this sound belongs to.
  121891. */
  121892. soundTrackId: number;
  121893. /**
  121894. * Is this sound currently played.
  121895. */
  121896. isPlaying: boolean;
  121897. /**
  121898. * Is this sound currently paused.
  121899. */
  121900. isPaused: boolean;
  121901. /**
  121902. * Does this sound enables spatial sound.
  121903. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121904. */
  121905. spatialSound: boolean;
  121906. /**
  121907. * Define the reference distance the sound should be heard perfectly.
  121908. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121909. */
  121910. refDistance: number;
  121911. /**
  121912. * Define the roll off factor of spatial sounds.
  121913. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121914. */
  121915. rolloffFactor: number;
  121916. /**
  121917. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  121918. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121919. */
  121920. maxDistance: number;
  121921. /**
  121922. * Define the distance attenuation model the sound will follow.
  121923. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121924. */
  121925. distanceModel: string;
  121926. /**
  121927. * @hidden
  121928. * Back Compat
  121929. **/
  121930. onended: () => any;
  121931. /**
  121932. * Gets or sets an object used to store user defined information for the sound.
  121933. */
  121934. metadata: any;
  121935. /**
  121936. * Observable event when the current playing sound finishes.
  121937. */
  121938. onEndedObservable: Observable<Sound>;
  121939. private _panningModel;
  121940. private _playbackRate;
  121941. private _streaming;
  121942. private _startTime;
  121943. private _startOffset;
  121944. private _position;
  121945. /** @hidden */
  121946. _positionInEmitterSpace: boolean;
  121947. private _localDirection;
  121948. private _volume;
  121949. private _isReadyToPlay;
  121950. private _isDirectional;
  121951. private _readyToPlayCallback;
  121952. private _audioBuffer;
  121953. private _soundSource;
  121954. private _streamingSource;
  121955. private _soundPanner;
  121956. private _soundGain;
  121957. private _inputAudioNode;
  121958. private _outputAudioNode;
  121959. private _coneInnerAngle;
  121960. private _coneOuterAngle;
  121961. private _coneOuterGain;
  121962. private _scene;
  121963. private _connectedTransformNode;
  121964. private _customAttenuationFunction;
  121965. private _registerFunc;
  121966. private _isOutputConnected;
  121967. private _htmlAudioElement;
  121968. private _urlType;
  121969. private _length?;
  121970. private _offset?;
  121971. /** @hidden */
  121972. static _SceneComponentInitialization: (scene: Scene) => void;
  121973. /**
  121974. * Create a sound and attach it to a scene
  121975. * @param name Name of your sound
  121976. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  121977. * @param scene defines the scene the sound belongs to
  121978. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  121979. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  121980. */
  121981. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  121982. /**
  121983. * Release the sound and its associated resources
  121984. */
  121985. dispose(): void;
  121986. /**
  121987. * Gets if the sounds is ready to be played or not.
  121988. * @returns true if ready, otherwise false
  121989. */
  121990. isReady(): boolean;
  121991. private _soundLoaded;
  121992. /**
  121993. * Sets the data of the sound from an audiobuffer
  121994. * @param audioBuffer The audioBuffer containing the data
  121995. */
  121996. setAudioBuffer(audioBuffer: AudioBuffer): void;
  121997. /**
  121998. * Updates the current sounds options such as maxdistance, loop...
  121999. * @param options A JSON object containing values named as the object properties
  122000. */
  122001. updateOptions(options: ISoundOptions): void;
  122002. private _createSpatialParameters;
  122003. private _updateSpatialParameters;
  122004. /**
  122005. * Switch the panning model to HRTF:
  122006. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122007. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122008. */
  122009. switchPanningModelToHRTF(): void;
  122010. /**
  122011. * Switch the panning model to Equal Power:
  122012. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122013. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122014. */
  122015. switchPanningModelToEqualPower(): void;
  122016. private _switchPanningModel;
  122017. /**
  122018. * Connect this sound to a sound track audio node like gain...
  122019. * @param soundTrackAudioNode the sound track audio node to connect to
  122020. */
  122021. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  122022. /**
  122023. * Transform this sound into a directional source
  122024. * @param coneInnerAngle Size of the inner cone in degree
  122025. * @param coneOuterAngle Size of the outer cone in degree
  122026. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  122027. */
  122028. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  122029. /**
  122030. * Gets or sets the inner angle for the directional cone.
  122031. */
  122032. get directionalConeInnerAngle(): number;
  122033. /**
  122034. * Gets or sets the inner angle for the directional cone.
  122035. */
  122036. set directionalConeInnerAngle(value: number);
  122037. /**
  122038. * Gets or sets the outer angle for the directional cone.
  122039. */
  122040. get directionalConeOuterAngle(): number;
  122041. /**
  122042. * Gets or sets the outer angle for the directional cone.
  122043. */
  122044. set directionalConeOuterAngle(value: number);
  122045. /**
  122046. * Sets the position of the emitter if spatial sound is enabled
  122047. * @param newPosition Defines the new posisiton
  122048. */
  122049. setPosition(newPosition: Vector3): void;
  122050. /**
  122051. * Sets the local direction of the emitter if spatial sound is enabled
  122052. * @param newLocalDirection Defines the new local direction
  122053. */
  122054. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  122055. private _updateDirection;
  122056. /** @hidden */
  122057. updateDistanceFromListener(): void;
  122058. /**
  122059. * Sets a new custom attenuation function for the sound.
  122060. * @param callback Defines the function used for the attenuation
  122061. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  122062. */
  122063. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  122064. /**
  122065. * Play the sound
  122066. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  122067. * @param offset (optional) Start the sound at a specific time in seconds
  122068. * @param length (optional) Sound duration (in seconds)
  122069. */
  122070. play(time?: number, offset?: number, length?: number): void;
  122071. private _onended;
  122072. /**
  122073. * Stop the sound
  122074. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  122075. */
  122076. stop(time?: number): void;
  122077. /**
  122078. * Put the sound in pause
  122079. */
  122080. pause(): void;
  122081. /**
  122082. * Sets a dedicated volume for this sounds
  122083. * @param newVolume Define the new volume of the sound
  122084. * @param time Define time for gradual change to new volume
  122085. */
  122086. setVolume(newVolume: number, time?: number): void;
  122087. /**
  122088. * Set the sound play back rate
  122089. * @param newPlaybackRate Define the playback rate the sound should be played at
  122090. */
  122091. setPlaybackRate(newPlaybackRate: number): void;
  122092. /**
  122093. * Gets the volume of the sound.
  122094. * @returns the volume of the sound
  122095. */
  122096. getVolume(): number;
  122097. /**
  122098. * Attach the sound to a dedicated mesh
  122099. * @param transformNode The transform node to connect the sound with
  122100. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122101. */
  122102. attachToMesh(transformNode: TransformNode): void;
  122103. /**
  122104. * Detach the sound from the previously attached mesh
  122105. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122106. */
  122107. detachFromMesh(): void;
  122108. private _onRegisterAfterWorldMatrixUpdate;
  122109. /**
  122110. * Clone the current sound in the scene.
  122111. * @returns the new sound clone
  122112. */
  122113. clone(): Nullable<Sound>;
  122114. /**
  122115. * Gets the current underlying audio buffer containing the data
  122116. * @returns the audio buffer
  122117. */
  122118. getAudioBuffer(): Nullable<AudioBuffer>;
  122119. /**
  122120. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  122121. * @returns the source node
  122122. */
  122123. getSoundSource(): Nullable<AudioBufferSourceNode>;
  122124. /**
  122125. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  122126. * @returns the gain node
  122127. */
  122128. getSoundGain(): Nullable<GainNode>;
  122129. /**
  122130. * Serializes the Sound in a JSON representation
  122131. * @returns the JSON representation of the sound
  122132. */
  122133. serialize(): any;
  122134. /**
  122135. * Parse a JSON representation of a sound to innstantiate in a given scene
  122136. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  122137. * @param scene Define the scene the new parsed sound should be created in
  122138. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  122139. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  122140. * @returns the newly parsed sound
  122141. */
  122142. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  122143. }
  122144. }
  122145. declare module BABYLON {
  122146. /**
  122147. * This defines an action helpful to play a defined sound on a triggered action.
  122148. */
  122149. export class PlaySoundAction extends Action {
  122150. private _sound;
  122151. /**
  122152. * Instantiate the action
  122153. * @param triggerOptions defines the trigger options
  122154. * @param sound defines the sound to play
  122155. * @param condition defines the trigger related conditions
  122156. */
  122157. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122158. /** @hidden */
  122159. _prepare(): void;
  122160. /**
  122161. * Execute the action and play the sound.
  122162. */
  122163. execute(): void;
  122164. /**
  122165. * Serializes the actions and its related information.
  122166. * @param parent defines the object to serialize in
  122167. * @returns the serialized object
  122168. */
  122169. serialize(parent: any): any;
  122170. }
  122171. /**
  122172. * This defines an action helpful to stop a defined sound on a triggered action.
  122173. */
  122174. export class StopSoundAction extends Action {
  122175. private _sound;
  122176. /**
  122177. * Instantiate the action
  122178. * @param triggerOptions defines the trigger options
  122179. * @param sound defines the sound to stop
  122180. * @param condition defines the trigger related conditions
  122181. */
  122182. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122183. /** @hidden */
  122184. _prepare(): void;
  122185. /**
  122186. * Execute the action and stop the sound.
  122187. */
  122188. execute(): void;
  122189. /**
  122190. * Serializes the actions and its related information.
  122191. * @param parent defines the object to serialize in
  122192. * @returns the serialized object
  122193. */
  122194. serialize(parent: any): any;
  122195. }
  122196. }
  122197. declare module BABYLON {
  122198. /**
  122199. * This defines an action responsible to change the value of a property
  122200. * by interpolating between its current value and the newly set one once triggered.
  122201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  122202. */
  122203. export class InterpolateValueAction extends Action {
  122204. /**
  122205. * Defines the path of the property where the value should be interpolated
  122206. */
  122207. propertyPath: string;
  122208. /**
  122209. * Defines the target value at the end of the interpolation.
  122210. */
  122211. value: any;
  122212. /**
  122213. * Defines the time it will take for the property to interpolate to the value.
  122214. */
  122215. duration: number;
  122216. /**
  122217. * Defines if the other scene animations should be stopped when the action has been triggered
  122218. */
  122219. stopOtherAnimations?: boolean;
  122220. /**
  122221. * Defines a callback raised once the interpolation animation has been done.
  122222. */
  122223. onInterpolationDone?: () => void;
  122224. /**
  122225. * Observable triggered once the interpolation animation has been done.
  122226. */
  122227. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  122228. private _target;
  122229. private _effectiveTarget;
  122230. private _property;
  122231. /**
  122232. * Instantiate the action
  122233. * @param triggerOptions defines the trigger options
  122234. * @param target defines the object containing the value to interpolate
  122235. * @param propertyPath defines the path to the property in the target object
  122236. * @param value defines the target value at the end of the interpolation
  122237. * @param duration deines the time it will take for the property to interpolate to the value.
  122238. * @param condition defines the trigger related conditions
  122239. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  122240. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  122241. */
  122242. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  122243. /** @hidden */
  122244. _prepare(): void;
  122245. /**
  122246. * Execute the action starts the value interpolation.
  122247. */
  122248. execute(): void;
  122249. /**
  122250. * Serializes the actions and its related information.
  122251. * @param parent defines the object to serialize in
  122252. * @returns the serialized object
  122253. */
  122254. serialize(parent: any): any;
  122255. }
  122256. }
  122257. declare module BABYLON {
  122258. /**
  122259. * Options allowed during the creation of a sound track.
  122260. */
  122261. export interface ISoundTrackOptions {
  122262. /**
  122263. * The volume the sound track should take during creation
  122264. */
  122265. volume?: number;
  122266. /**
  122267. * Define if the sound track is the main sound track of the scene
  122268. */
  122269. mainTrack?: boolean;
  122270. }
  122271. /**
  122272. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  122273. * It will be also used in a future release to apply effects on a specific track.
  122274. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122275. */
  122276. export class SoundTrack {
  122277. /**
  122278. * The unique identifier of the sound track in the scene.
  122279. */
  122280. id: number;
  122281. /**
  122282. * The list of sounds included in the sound track.
  122283. */
  122284. soundCollection: Array<Sound>;
  122285. private _outputAudioNode;
  122286. private _scene;
  122287. private _connectedAnalyser;
  122288. private _options;
  122289. private _isInitialized;
  122290. /**
  122291. * Creates a new sound track.
  122292. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122293. * @param scene Define the scene the sound track belongs to
  122294. * @param options
  122295. */
  122296. constructor(scene: Scene, options?: ISoundTrackOptions);
  122297. private _initializeSoundTrackAudioGraph;
  122298. /**
  122299. * Release the sound track and its associated resources
  122300. */
  122301. dispose(): void;
  122302. /**
  122303. * Adds a sound to this sound track
  122304. * @param sound define the cound to add
  122305. * @ignoreNaming
  122306. */
  122307. AddSound(sound: Sound): void;
  122308. /**
  122309. * Removes a sound to this sound track
  122310. * @param sound define the cound to remove
  122311. * @ignoreNaming
  122312. */
  122313. RemoveSound(sound: Sound): void;
  122314. /**
  122315. * Set a global volume for the full sound track.
  122316. * @param newVolume Define the new volume of the sound track
  122317. */
  122318. setVolume(newVolume: number): void;
  122319. /**
  122320. * Switch the panning model to HRTF:
  122321. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122322. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122323. */
  122324. switchPanningModelToHRTF(): void;
  122325. /**
  122326. * Switch the panning model to Equal Power:
  122327. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122328. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122329. */
  122330. switchPanningModelToEqualPower(): void;
  122331. /**
  122332. * Connect the sound track to an audio analyser allowing some amazing
  122333. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122334. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122335. * @param analyser The analyser to connect to the engine
  122336. */
  122337. connectToAnalyser(analyser: Analyser): void;
  122338. }
  122339. }
  122340. declare module BABYLON {
  122341. interface AbstractScene {
  122342. /**
  122343. * The list of sounds used in the scene.
  122344. */
  122345. sounds: Nullable<Array<Sound>>;
  122346. }
  122347. interface Scene {
  122348. /**
  122349. * @hidden
  122350. * Backing field
  122351. */
  122352. _mainSoundTrack: SoundTrack;
  122353. /**
  122354. * The main sound track played by the scene.
  122355. * It cotains your primary collection of sounds.
  122356. */
  122357. mainSoundTrack: SoundTrack;
  122358. /**
  122359. * The list of sound tracks added to the scene
  122360. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122361. */
  122362. soundTracks: Nullable<Array<SoundTrack>>;
  122363. /**
  122364. * Gets a sound using a given name
  122365. * @param name defines the name to search for
  122366. * @return the found sound or null if not found at all.
  122367. */
  122368. getSoundByName(name: string): Nullable<Sound>;
  122369. /**
  122370. * Gets or sets if audio support is enabled
  122371. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122372. */
  122373. audioEnabled: boolean;
  122374. /**
  122375. * Gets or sets if audio will be output to headphones
  122376. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122377. */
  122378. headphone: boolean;
  122379. /**
  122380. * Gets or sets custom audio listener position provider
  122381. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122382. */
  122383. audioListenerPositionProvider: Nullable<() => Vector3>;
  122384. /**
  122385. * Gets or sets a refresh rate when using 3D audio positioning
  122386. */
  122387. audioPositioningRefreshRate: number;
  122388. }
  122389. /**
  122390. * Defines the sound scene component responsible to manage any sounds
  122391. * in a given scene.
  122392. */
  122393. export class AudioSceneComponent implements ISceneSerializableComponent {
  122394. private static _CameraDirectionLH;
  122395. private static _CameraDirectionRH;
  122396. /**
  122397. * The component name helpfull to identify the component in the list of scene components.
  122398. */
  122399. readonly name: string;
  122400. /**
  122401. * The scene the component belongs to.
  122402. */
  122403. scene: Scene;
  122404. private _audioEnabled;
  122405. /**
  122406. * Gets whether audio is enabled or not.
  122407. * Please use related enable/disable method to switch state.
  122408. */
  122409. get audioEnabled(): boolean;
  122410. private _headphone;
  122411. /**
  122412. * Gets whether audio is outputing to headphone or not.
  122413. * Please use the according Switch methods to change output.
  122414. */
  122415. get headphone(): boolean;
  122416. /**
  122417. * Gets or sets a refresh rate when using 3D audio positioning
  122418. */
  122419. audioPositioningRefreshRate: number;
  122420. private _audioListenerPositionProvider;
  122421. /**
  122422. * Gets the current audio listener position provider
  122423. */
  122424. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  122425. /**
  122426. * Sets a custom listener position for all sounds in the scene
  122427. * By default, this is the position of the first active camera
  122428. */
  122429. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  122430. /**
  122431. * Creates a new instance of the component for the given scene
  122432. * @param scene Defines the scene to register the component in
  122433. */
  122434. constructor(scene: Scene);
  122435. /**
  122436. * Registers the component in a given scene
  122437. */
  122438. register(): void;
  122439. /**
  122440. * Rebuilds the elements related to this component in case of
  122441. * context lost for instance.
  122442. */
  122443. rebuild(): void;
  122444. /**
  122445. * Serializes the component data to the specified json object
  122446. * @param serializationObject The object to serialize to
  122447. */
  122448. serialize(serializationObject: any): void;
  122449. /**
  122450. * Adds all the elements from the container to the scene
  122451. * @param container the container holding the elements
  122452. */
  122453. addFromContainer(container: AbstractScene): void;
  122454. /**
  122455. * Removes all the elements in the container from the scene
  122456. * @param container contains the elements to remove
  122457. * @param dispose if the removed element should be disposed (default: false)
  122458. */
  122459. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122460. /**
  122461. * Disposes the component and the associated ressources.
  122462. */
  122463. dispose(): void;
  122464. /**
  122465. * Disables audio in the associated scene.
  122466. */
  122467. disableAudio(): void;
  122468. /**
  122469. * Enables audio in the associated scene.
  122470. */
  122471. enableAudio(): void;
  122472. /**
  122473. * Switch audio to headphone output.
  122474. */
  122475. switchAudioModeForHeadphones(): void;
  122476. /**
  122477. * Switch audio to normal speakers.
  122478. */
  122479. switchAudioModeForNormalSpeakers(): void;
  122480. private _cachedCameraDirection;
  122481. private _cachedCameraPosition;
  122482. private _lastCheck;
  122483. private _afterRender;
  122484. }
  122485. }
  122486. declare module BABYLON {
  122487. /**
  122488. * Wraps one or more Sound objects and selects one with random weight for playback.
  122489. */
  122490. export class WeightedSound {
  122491. /** When true a Sound will be selected and played when the current playing Sound completes. */
  122492. loop: boolean;
  122493. private _coneInnerAngle;
  122494. private _coneOuterAngle;
  122495. private _volume;
  122496. /** A Sound is currently playing. */
  122497. isPlaying: boolean;
  122498. /** A Sound is currently paused. */
  122499. isPaused: boolean;
  122500. private _sounds;
  122501. private _weights;
  122502. private _currentIndex?;
  122503. /**
  122504. * Creates a new WeightedSound from the list of sounds given.
  122505. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  122506. * @param sounds Array of Sounds that will be selected from.
  122507. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  122508. */
  122509. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  122510. /**
  122511. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  122512. */
  122513. get directionalConeInnerAngle(): number;
  122514. /**
  122515. * The size of cone in degress for a directional sound in which there will be no attenuation.
  122516. */
  122517. set directionalConeInnerAngle(value: number);
  122518. /**
  122519. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122520. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122521. */
  122522. get directionalConeOuterAngle(): number;
  122523. /**
  122524. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122525. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122526. */
  122527. set directionalConeOuterAngle(value: number);
  122528. /**
  122529. * Playback volume.
  122530. */
  122531. get volume(): number;
  122532. /**
  122533. * Playback volume.
  122534. */
  122535. set volume(value: number);
  122536. private _onended;
  122537. /**
  122538. * Suspend playback
  122539. */
  122540. pause(): void;
  122541. /**
  122542. * Stop playback
  122543. */
  122544. stop(): void;
  122545. /**
  122546. * Start playback.
  122547. * @param startOffset Position the clip head at a specific time in seconds.
  122548. */
  122549. play(startOffset?: number): void;
  122550. }
  122551. }
  122552. declare module BABYLON {
  122553. /**
  122554. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122555. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122556. */
  122557. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122558. /**
  122559. * Gets the name of the behavior.
  122560. */
  122561. get name(): string;
  122562. /**
  122563. * The easing function used by animations
  122564. */
  122565. static EasingFunction: BackEase;
  122566. /**
  122567. * The easing mode used by animations
  122568. */
  122569. static EasingMode: number;
  122570. /**
  122571. * The duration of the animation, in milliseconds
  122572. */
  122573. transitionDuration: number;
  122574. /**
  122575. * Length of the distance animated by the transition when lower radius is reached
  122576. */
  122577. lowerRadiusTransitionRange: number;
  122578. /**
  122579. * Length of the distance animated by the transition when upper radius is reached
  122580. */
  122581. upperRadiusTransitionRange: number;
  122582. private _autoTransitionRange;
  122583. /**
  122584. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122585. */
  122586. get autoTransitionRange(): boolean;
  122587. /**
  122588. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122589. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122590. */
  122591. set autoTransitionRange(value: boolean);
  122592. private _attachedCamera;
  122593. private _onAfterCheckInputsObserver;
  122594. private _onMeshTargetChangedObserver;
  122595. /**
  122596. * Initializes the behavior.
  122597. */
  122598. init(): void;
  122599. /**
  122600. * Attaches the behavior to its arc rotate camera.
  122601. * @param camera Defines the camera to attach the behavior to
  122602. */
  122603. attach(camera: ArcRotateCamera): void;
  122604. /**
  122605. * Detaches the behavior from its current arc rotate camera.
  122606. */
  122607. detach(): void;
  122608. private _radiusIsAnimating;
  122609. private _radiusBounceTransition;
  122610. private _animatables;
  122611. private _cachedWheelPrecision;
  122612. /**
  122613. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122614. * @param radiusLimit The limit to check against.
  122615. * @return Bool to indicate if at limit.
  122616. */
  122617. private _isRadiusAtLimit;
  122618. /**
  122619. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122620. * @param radiusDelta The delta by which to animate to. Can be negative.
  122621. */
  122622. private _applyBoundRadiusAnimation;
  122623. /**
  122624. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122625. */
  122626. protected _clearAnimationLocks(): void;
  122627. /**
  122628. * Stops and removes all animations that have been applied to the camera
  122629. */
  122630. stopAllAnimations(): void;
  122631. }
  122632. }
  122633. declare module BABYLON {
  122634. /**
  122635. * 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.
  122636. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122637. */
  122638. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  122639. /**
  122640. * Gets the name of the behavior.
  122641. */
  122642. get name(): string;
  122643. private _mode;
  122644. private _radiusScale;
  122645. private _positionScale;
  122646. private _defaultElevation;
  122647. private _elevationReturnTime;
  122648. private _elevationReturnWaitTime;
  122649. private _zoomStopsAnimation;
  122650. private _framingTime;
  122651. /**
  122652. * The easing function used by animations
  122653. */
  122654. static EasingFunction: ExponentialEase;
  122655. /**
  122656. * The easing mode used by animations
  122657. */
  122658. static EasingMode: number;
  122659. /**
  122660. * Sets the current mode used by the behavior
  122661. */
  122662. set mode(mode: number);
  122663. /**
  122664. * Gets current mode used by the behavior.
  122665. */
  122666. get mode(): number;
  122667. /**
  122668. * Sets the scale applied to the radius (1 by default)
  122669. */
  122670. set radiusScale(radius: number);
  122671. /**
  122672. * Gets the scale applied to the radius
  122673. */
  122674. get radiusScale(): number;
  122675. /**
  122676. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122677. */
  122678. set positionScale(scale: number);
  122679. /**
  122680. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122681. */
  122682. get positionScale(): number;
  122683. /**
  122684. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122685. * behaviour is triggered, in radians.
  122686. */
  122687. set defaultElevation(elevation: number);
  122688. /**
  122689. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122690. * behaviour is triggered, in radians.
  122691. */
  122692. get defaultElevation(): number;
  122693. /**
  122694. * Sets the time (in milliseconds) taken to return to the default beta position.
  122695. * Negative value indicates camera should not return to default.
  122696. */
  122697. set elevationReturnTime(speed: number);
  122698. /**
  122699. * Gets the time (in milliseconds) taken to return to the default beta position.
  122700. * Negative value indicates camera should not return to default.
  122701. */
  122702. get elevationReturnTime(): number;
  122703. /**
  122704. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122705. */
  122706. set elevationReturnWaitTime(time: number);
  122707. /**
  122708. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122709. */
  122710. get elevationReturnWaitTime(): number;
  122711. /**
  122712. * Sets the flag that indicates if user zooming should stop animation.
  122713. */
  122714. set zoomStopsAnimation(flag: boolean);
  122715. /**
  122716. * Gets the flag that indicates if user zooming should stop animation.
  122717. */
  122718. get zoomStopsAnimation(): boolean;
  122719. /**
  122720. * Sets the transition time when framing the mesh, in milliseconds
  122721. */
  122722. set framingTime(time: number);
  122723. /**
  122724. * Gets the transition time when framing the mesh, in milliseconds
  122725. */
  122726. get framingTime(): number;
  122727. /**
  122728. * Define if the behavior should automatically change the configured
  122729. * camera limits and sensibilities.
  122730. */
  122731. autoCorrectCameraLimitsAndSensibility: boolean;
  122732. private _onPrePointerObservableObserver;
  122733. private _onAfterCheckInputsObserver;
  122734. private _onMeshTargetChangedObserver;
  122735. private _attachedCamera;
  122736. private _isPointerDown;
  122737. private _lastInteractionTime;
  122738. /**
  122739. * Initializes the behavior.
  122740. */
  122741. init(): void;
  122742. /**
  122743. * Attaches the behavior to its arc rotate camera.
  122744. * @param camera Defines the camera to attach the behavior to
  122745. */
  122746. attach(camera: ArcRotateCamera): void;
  122747. /**
  122748. * Detaches the behavior from its current arc rotate camera.
  122749. */
  122750. detach(): void;
  122751. private _animatables;
  122752. private _betaIsAnimating;
  122753. private _betaTransition;
  122754. private _radiusTransition;
  122755. private _vectorTransition;
  122756. /**
  122757. * Targets the given mesh and updates zoom level accordingly.
  122758. * @param mesh The mesh to target.
  122759. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122760. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122761. */
  122762. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122763. /**
  122764. * Targets the given mesh with its children and updates zoom level accordingly.
  122765. * @param mesh The mesh to target.
  122766. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122767. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122768. */
  122769. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122770. /**
  122771. * Targets the given meshes with their children and updates zoom level accordingly.
  122772. * @param meshes The mesh to target.
  122773. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122774. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122775. */
  122776. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122777. /**
  122778. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122779. * @param minimumWorld Determines the smaller position of the bounding box extend
  122780. * @param maximumWorld Determines the bigger position of the bounding box extend
  122781. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122782. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122783. */
  122784. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122785. /**
  122786. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122787. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122788. * frustum width.
  122789. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122790. * to fully enclose the mesh in the viewing frustum.
  122791. */
  122792. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122793. /**
  122794. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122795. * is automatically returned to its default position (expected to be above ground plane).
  122796. */
  122797. private _maintainCameraAboveGround;
  122798. /**
  122799. * Returns the frustum slope based on the canvas ratio and camera FOV
  122800. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122801. */
  122802. private _getFrustumSlope;
  122803. /**
  122804. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122805. */
  122806. private _clearAnimationLocks;
  122807. /**
  122808. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122809. */
  122810. private _applyUserInteraction;
  122811. /**
  122812. * Stops and removes all animations that have been applied to the camera
  122813. */
  122814. stopAllAnimations(): void;
  122815. /**
  122816. * Gets a value indicating if the user is moving the camera
  122817. */
  122818. get isUserIsMoving(): boolean;
  122819. /**
  122820. * The camera can move all the way towards the mesh.
  122821. */
  122822. static IgnoreBoundsSizeMode: number;
  122823. /**
  122824. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122825. */
  122826. static FitFrustumSidesMode: number;
  122827. }
  122828. }
  122829. declare module BABYLON {
  122830. /**
  122831. * Base class for Camera Pointer Inputs.
  122832. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122833. * for example usage.
  122834. */
  122835. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122836. /**
  122837. * Defines the camera the input is attached to.
  122838. */
  122839. abstract camera: Camera;
  122840. /**
  122841. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122842. */
  122843. protected _altKey: boolean;
  122844. protected _ctrlKey: boolean;
  122845. protected _metaKey: boolean;
  122846. protected _shiftKey: boolean;
  122847. /**
  122848. * Which mouse buttons were pressed at time of last mouse event.
  122849. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122850. */
  122851. protected _buttonsPressed: number;
  122852. /**
  122853. * Defines the buttons associated with the input to handle camera move.
  122854. */
  122855. buttons: number[];
  122856. /**
  122857. * Attach the input controls to a specific dom element to get the input from.
  122858. * @param element Defines the element the controls should be listened from
  122859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122860. */
  122861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122862. /**
  122863. * Detach the current controls from the specified dom element.
  122864. * @param element Defines the element to stop listening the inputs from
  122865. */
  122866. detachControl(element: Nullable<HTMLElement>): void;
  122867. /**
  122868. * Gets the class name of the current input.
  122869. * @returns the class name
  122870. */
  122871. getClassName(): string;
  122872. /**
  122873. * Get the friendly name associated with the input class.
  122874. * @returns the input friendly name
  122875. */
  122876. getSimpleName(): string;
  122877. /**
  122878. * Called on pointer POINTERDOUBLETAP event.
  122879. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122880. */
  122881. protected onDoubleTap(type: string): void;
  122882. /**
  122883. * Called on pointer POINTERMOVE event if only a single touch is active.
  122884. * Override this method to provide functionality.
  122885. */
  122886. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122887. /**
  122888. * Called on pointer POINTERMOVE event if multiple touches are active.
  122889. * Override this method to provide functionality.
  122890. */
  122891. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122892. /**
  122893. * Called on JS contextmenu event.
  122894. * Override this method to provide functionality.
  122895. */
  122896. protected onContextMenu(evt: PointerEvent): void;
  122897. /**
  122898. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122899. * press.
  122900. * Override this method to provide functionality.
  122901. */
  122902. protected onButtonDown(evt: PointerEvent): void;
  122903. /**
  122904. * Called each time a new POINTERUP event occurs. Ie, for each button
  122905. * release.
  122906. * Override this method to provide functionality.
  122907. */
  122908. protected onButtonUp(evt: PointerEvent): void;
  122909. /**
  122910. * Called when window becomes inactive.
  122911. * Override this method to provide functionality.
  122912. */
  122913. protected onLostFocus(): void;
  122914. private _pointerInput;
  122915. private _observer;
  122916. private _onLostFocus;
  122917. private pointA;
  122918. private pointB;
  122919. }
  122920. }
  122921. declare module BABYLON {
  122922. /**
  122923. * Manage the pointers inputs to control an arc rotate camera.
  122924. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122925. */
  122926. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  122927. /**
  122928. * Defines the camera the input is attached to.
  122929. */
  122930. camera: ArcRotateCamera;
  122931. /**
  122932. * Gets the class name of the current input.
  122933. * @returns the class name
  122934. */
  122935. getClassName(): string;
  122936. /**
  122937. * Defines the buttons associated with the input to handle camera move.
  122938. */
  122939. buttons: number[];
  122940. /**
  122941. * Defines the pointer angular sensibility along the X axis or how fast is
  122942. * the camera rotating.
  122943. */
  122944. angularSensibilityX: number;
  122945. /**
  122946. * Defines the pointer angular sensibility along the Y axis or how fast is
  122947. * the camera rotating.
  122948. */
  122949. angularSensibilityY: number;
  122950. /**
  122951. * Defines the pointer pinch precision or how fast is the camera zooming.
  122952. */
  122953. pinchPrecision: number;
  122954. /**
  122955. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  122956. * from 0.
  122957. * It defines the percentage of current camera.radius to use as delta when
  122958. * pinch zoom is used.
  122959. */
  122960. pinchDeltaPercentage: number;
  122961. /**
  122962. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122963. * that any object in the plane at the camera's target point will scale
  122964. * perfectly with finger motion.
  122965. * Overrides pinchDeltaPercentage and pinchPrecision.
  122966. */
  122967. useNaturalPinchZoom: boolean;
  122968. /**
  122969. * Defines the pointer panning sensibility or how fast is the camera moving.
  122970. */
  122971. panningSensibility: number;
  122972. /**
  122973. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  122974. */
  122975. multiTouchPanning: boolean;
  122976. /**
  122977. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  122978. * zoom (pinch) through multitouch.
  122979. */
  122980. multiTouchPanAndZoom: boolean;
  122981. /**
  122982. * Revers pinch action direction.
  122983. */
  122984. pinchInwards: boolean;
  122985. private _isPanClick;
  122986. private _twoFingerActivityCount;
  122987. private _isPinching;
  122988. /**
  122989. * Called on pointer POINTERMOVE event if only a single touch is active.
  122990. */
  122991. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122992. /**
  122993. * Called on pointer POINTERDOUBLETAP event.
  122994. */
  122995. protected onDoubleTap(type: string): void;
  122996. /**
  122997. * Called on pointer POINTERMOVE event if multiple touches are active.
  122998. */
  122999. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123000. /**
  123001. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123002. * press.
  123003. */
  123004. protected onButtonDown(evt: PointerEvent): void;
  123005. /**
  123006. * Called each time a new POINTERUP event occurs. Ie, for each button
  123007. * release.
  123008. */
  123009. protected onButtonUp(evt: PointerEvent): void;
  123010. /**
  123011. * Called when window becomes inactive.
  123012. */
  123013. protected onLostFocus(): void;
  123014. }
  123015. }
  123016. declare module BABYLON {
  123017. /**
  123018. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  123019. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123020. */
  123021. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  123022. /**
  123023. * Defines the camera the input is attached to.
  123024. */
  123025. camera: ArcRotateCamera;
  123026. /**
  123027. * Defines the list of key codes associated with the up action (increase alpha)
  123028. */
  123029. keysUp: number[];
  123030. /**
  123031. * Defines the list of key codes associated with the down action (decrease alpha)
  123032. */
  123033. keysDown: number[];
  123034. /**
  123035. * Defines the list of key codes associated with the left action (increase beta)
  123036. */
  123037. keysLeft: number[];
  123038. /**
  123039. * Defines the list of key codes associated with the right action (decrease beta)
  123040. */
  123041. keysRight: number[];
  123042. /**
  123043. * Defines the list of key codes associated with the reset action.
  123044. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  123045. */
  123046. keysReset: number[];
  123047. /**
  123048. * Defines the panning sensibility of the inputs.
  123049. * (How fast is the camera panning)
  123050. */
  123051. panningSensibility: number;
  123052. /**
  123053. * Defines the zooming sensibility of the inputs.
  123054. * (How fast is the camera zooming)
  123055. */
  123056. zoomingSensibility: number;
  123057. /**
  123058. * Defines whether maintaining the alt key down switch the movement mode from
  123059. * orientation to zoom.
  123060. */
  123061. useAltToZoom: boolean;
  123062. /**
  123063. * Rotation speed of the camera
  123064. */
  123065. angularSpeed: number;
  123066. private _keys;
  123067. private _ctrlPressed;
  123068. private _altPressed;
  123069. private _onCanvasBlurObserver;
  123070. private _onKeyboardObserver;
  123071. private _engine;
  123072. private _scene;
  123073. /**
  123074. * Attach the input controls to a specific dom element to get the input from.
  123075. * @param element Defines the element the controls should be listened from
  123076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123077. */
  123078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123079. /**
  123080. * Detach the current controls from the specified dom element.
  123081. * @param element Defines the element to stop listening the inputs from
  123082. */
  123083. detachControl(element: Nullable<HTMLElement>): void;
  123084. /**
  123085. * Update the current camera state depending on the inputs that have been used this frame.
  123086. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123087. */
  123088. checkInputs(): void;
  123089. /**
  123090. * Gets the class name of the current intput.
  123091. * @returns the class name
  123092. */
  123093. getClassName(): string;
  123094. /**
  123095. * Get the friendly name associated with the input class.
  123096. * @returns the input friendly name
  123097. */
  123098. getSimpleName(): string;
  123099. }
  123100. }
  123101. declare module BABYLON {
  123102. /**
  123103. * Manage the mouse wheel inputs to control an arc rotate camera.
  123104. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123105. */
  123106. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  123107. /**
  123108. * Defines the camera the input is attached to.
  123109. */
  123110. camera: ArcRotateCamera;
  123111. /**
  123112. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123113. */
  123114. wheelPrecision: number;
  123115. /**
  123116. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123117. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123118. */
  123119. wheelDeltaPercentage: number;
  123120. private _wheel;
  123121. private _observer;
  123122. private computeDeltaFromMouseWheelLegacyEvent;
  123123. /**
  123124. * Attach the input controls to a specific dom element to get the input from.
  123125. * @param element Defines the element the controls should be listened from
  123126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123127. */
  123128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123129. /**
  123130. * Detach the current controls from the specified dom element.
  123131. * @param element Defines the element to stop listening the inputs from
  123132. */
  123133. detachControl(element: Nullable<HTMLElement>): void;
  123134. /**
  123135. * Gets the class name of the current intput.
  123136. * @returns the class name
  123137. */
  123138. getClassName(): string;
  123139. /**
  123140. * Get the friendly name associated with the input class.
  123141. * @returns the input friendly name
  123142. */
  123143. getSimpleName(): string;
  123144. }
  123145. }
  123146. declare module BABYLON {
  123147. /**
  123148. * Default Inputs manager for the ArcRotateCamera.
  123149. * It groups all the default supported inputs for ease of use.
  123150. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123151. */
  123152. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  123153. /**
  123154. * Instantiates a new ArcRotateCameraInputsManager.
  123155. * @param camera Defines the camera the inputs belong to
  123156. */
  123157. constructor(camera: ArcRotateCamera);
  123158. /**
  123159. * Add mouse wheel input support to the input manager.
  123160. * @returns the current input manager
  123161. */
  123162. addMouseWheel(): ArcRotateCameraInputsManager;
  123163. /**
  123164. * Add pointers input support to the input manager.
  123165. * @returns the current input manager
  123166. */
  123167. addPointers(): ArcRotateCameraInputsManager;
  123168. /**
  123169. * Add keyboard input support to the input manager.
  123170. * @returns the current input manager
  123171. */
  123172. addKeyboard(): ArcRotateCameraInputsManager;
  123173. }
  123174. }
  123175. declare module BABYLON {
  123176. /**
  123177. * This represents an orbital type of camera.
  123178. *
  123179. * 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.
  123180. * 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.
  123181. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  123182. */
  123183. export class ArcRotateCamera extends TargetCamera {
  123184. /**
  123185. * Defines the rotation angle of the camera along the longitudinal axis.
  123186. */
  123187. alpha: number;
  123188. /**
  123189. * Defines the rotation angle of the camera along the latitudinal axis.
  123190. */
  123191. beta: number;
  123192. /**
  123193. * Defines the radius of the camera from it s target point.
  123194. */
  123195. radius: number;
  123196. protected _target: Vector3;
  123197. protected _targetHost: Nullable<AbstractMesh>;
  123198. /**
  123199. * Defines the target point of the camera.
  123200. * The camera looks towards it form the radius distance.
  123201. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  123202. */
  123203. get target(): Vector3;
  123204. set target(value: Vector3);
  123205. /**
  123206. * Define the current local position of the camera in the scene
  123207. */
  123208. get position(): Vector3;
  123209. set position(newPosition: Vector3);
  123210. protected _upToYMatrix: Matrix;
  123211. protected _YToUpMatrix: Matrix;
  123212. /**
  123213. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  123214. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  123215. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  123216. */
  123217. set upVector(vec: Vector3);
  123218. get upVector(): Vector3;
  123219. /**
  123220. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  123221. */
  123222. setMatUp(): void;
  123223. /**
  123224. * Current inertia value on the longitudinal axis.
  123225. * The bigger this number the longer it will take for the camera to stop.
  123226. */
  123227. inertialAlphaOffset: number;
  123228. /**
  123229. * Current inertia value on the latitudinal axis.
  123230. * The bigger this number the longer it will take for the camera to stop.
  123231. */
  123232. inertialBetaOffset: number;
  123233. /**
  123234. * Current inertia value on the radius axis.
  123235. * The bigger this number the longer it will take for the camera to stop.
  123236. */
  123237. inertialRadiusOffset: number;
  123238. /**
  123239. * Minimum allowed angle on the longitudinal axis.
  123240. * This can help limiting how the Camera is able to move in the scene.
  123241. */
  123242. lowerAlphaLimit: Nullable<number>;
  123243. /**
  123244. * Maximum allowed angle on the longitudinal axis.
  123245. * This can help limiting how the Camera is able to move in the scene.
  123246. */
  123247. upperAlphaLimit: Nullable<number>;
  123248. /**
  123249. * Minimum allowed angle on the latitudinal axis.
  123250. * This can help limiting how the Camera is able to move in the scene.
  123251. */
  123252. lowerBetaLimit: number;
  123253. /**
  123254. * Maximum allowed angle on the latitudinal axis.
  123255. * This can help limiting how the Camera is able to move in the scene.
  123256. */
  123257. upperBetaLimit: number;
  123258. /**
  123259. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  123260. * This can help limiting how the Camera is able to move in the scene.
  123261. */
  123262. lowerRadiusLimit: Nullable<number>;
  123263. /**
  123264. * Maximum allowed distance of the camera to the target (The camera can not get further).
  123265. * This can help limiting how the Camera is able to move in the scene.
  123266. */
  123267. upperRadiusLimit: Nullable<number>;
  123268. /**
  123269. * Defines the current inertia value used during panning of the camera along the X axis.
  123270. */
  123271. inertialPanningX: number;
  123272. /**
  123273. * Defines the current inertia value used during panning of the camera along the Y axis.
  123274. */
  123275. inertialPanningY: number;
  123276. /**
  123277. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  123278. * Basically if your fingers moves away from more than this distance you will be considered
  123279. * in pinch mode.
  123280. */
  123281. pinchToPanMaxDistance: number;
  123282. /**
  123283. * Defines the maximum distance the camera can pan.
  123284. * This could help keeping the cammera always in your scene.
  123285. */
  123286. panningDistanceLimit: Nullable<number>;
  123287. /**
  123288. * Defines the target of the camera before paning.
  123289. */
  123290. panningOriginTarget: Vector3;
  123291. /**
  123292. * Defines the value of the inertia used during panning.
  123293. * 0 would mean stop inertia and one would mean no decelleration at all.
  123294. */
  123295. panningInertia: number;
  123296. /**
  123297. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  123298. */
  123299. get angularSensibilityX(): number;
  123300. set angularSensibilityX(value: number);
  123301. /**
  123302. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  123303. */
  123304. get angularSensibilityY(): number;
  123305. set angularSensibilityY(value: number);
  123306. /**
  123307. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  123308. */
  123309. get pinchPrecision(): number;
  123310. set pinchPrecision(value: number);
  123311. /**
  123312. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  123313. * It will be used instead of pinchDeltaPrecision if different from 0.
  123314. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123315. */
  123316. get pinchDeltaPercentage(): number;
  123317. set pinchDeltaPercentage(value: number);
  123318. /**
  123319. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  123320. * and pinch delta percentage.
  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. */
  123325. get useNaturalPinchZoom(): boolean;
  123326. set useNaturalPinchZoom(value: boolean);
  123327. /**
  123328. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  123329. */
  123330. get panningSensibility(): number;
  123331. set panningSensibility(value: number);
  123332. /**
  123333. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  123334. */
  123335. get keysUp(): number[];
  123336. set keysUp(value: number[]);
  123337. /**
  123338. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  123339. */
  123340. get keysDown(): number[];
  123341. set keysDown(value: number[]);
  123342. /**
  123343. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  123344. */
  123345. get keysLeft(): number[];
  123346. set keysLeft(value: number[]);
  123347. /**
  123348. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  123349. */
  123350. get keysRight(): number[];
  123351. set keysRight(value: number[]);
  123352. /**
  123353. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123354. */
  123355. get wheelPrecision(): number;
  123356. set wheelPrecision(value: number);
  123357. /**
  123358. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  123359. * It will be used instead of pinchDeltaPrecision if different from 0.
  123360. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123361. */
  123362. get wheelDeltaPercentage(): number;
  123363. set wheelDeltaPercentage(value: number);
  123364. /**
  123365. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  123366. */
  123367. zoomOnFactor: number;
  123368. /**
  123369. * Defines a screen offset for the camera position.
  123370. */
  123371. targetScreenOffset: Vector2;
  123372. /**
  123373. * Allows the camera to be completely reversed.
  123374. * If false the camera can not arrive upside down.
  123375. */
  123376. allowUpsideDown: boolean;
  123377. /**
  123378. * Define if double tap/click is used to restore the previously saved state of the camera.
  123379. */
  123380. useInputToRestoreState: boolean;
  123381. /** @hidden */
  123382. _viewMatrix: Matrix;
  123383. /** @hidden */
  123384. _useCtrlForPanning: boolean;
  123385. /** @hidden */
  123386. _panningMouseButton: number;
  123387. /**
  123388. * Defines the input associated to the camera.
  123389. */
  123390. inputs: ArcRotateCameraInputsManager;
  123391. /** @hidden */
  123392. _reset: () => void;
  123393. /**
  123394. * Defines the allowed panning axis.
  123395. */
  123396. panningAxis: Vector3;
  123397. protected _localDirection: Vector3;
  123398. protected _transformedDirection: Vector3;
  123399. private _bouncingBehavior;
  123400. /**
  123401. * Gets the bouncing behavior of the camera if it has been enabled.
  123402. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123403. */
  123404. get bouncingBehavior(): Nullable<BouncingBehavior>;
  123405. /**
  123406. * Defines if the bouncing behavior of the camera is enabled on the camera.
  123407. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123408. */
  123409. get useBouncingBehavior(): boolean;
  123410. set useBouncingBehavior(value: boolean);
  123411. private _framingBehavior;
  123412. /**
  123413. * Gets the framing behavior of the camera if it has been enabled.
  123414. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123415. */
  123416. get framingBehavior(): Nullable<FramingBehavior>;
  123417. /**
  123418. * Defines if the framing behavior of the camera is enabled on the camera.
  123419. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123420. */
  123421. get useFramingBehavior(): boolean;
  123422. set useFramingBehavior(value: boolean);
  123423. private _autoRotationBehavior;
  123424. /**
  123425. * Gets the auto rotation behavior of the camera if it has been enabled.
  123426. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123427. */
  123428. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  123429. /**
  123430. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  123431. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123432. */
  123433. get useAutoRotationBehavior(): boolean;
  123434. set useAutoRotationBehavior(value: boolean);
  123435. /**
  123436. * Observable triggered when the mesh target has been changed on the camera.
  123437. */
  123438. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  123439. /**
  123440. * Event raised when the camera is colliding with a mesh.
  123441. */
  123442. onCollide: (collidedMesh: AbstractMesh) => void;
  123443. /**
  123444. * Defines whether the camera should check collision with the objects oh the scene.
  123445. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  123446. */
  123447. checkCollisions: boolean;
  123448. /**
  123449. * Defines the collision radius of the camera.
  123450. * This simulates a sphere around the camera.
  123451. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123452. */
  123453. collisionRadius: Vector3;
  123454. protected _collider: Collider;
  123455. protected _previousPosition: Vector3;
  123456. protected _collisionVelocity: Vector3;
  123457. protected _newPosition: Vector3;
  123458. protected _previousAlpha: number;
  123459. protected _previousBeta: number;
  123460. protected _previousRadius: number;
  123461. protected _collisionTriggered: boolean;
  123462. protected _targetBoundingCenter: Nullable<Vector3>;
  123463. private _computationVector;
  123464. /**
  123465. * Instantiates a new ArcRotateCamera in a given scene
  123466. * @param name Defines the name of the camera
  123467. * @param alpha Defines the camera rotation along the logitudinal axis
  123468. * @param beta Defines the camera rotation along the latitudinal axis
  123469. * @param radius Defines the camera distance from its target
  123470. * @param target Defines the camera target
  123471. * @param scene Defines the scene the camera belongs to
  123472. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  123473. */
  123474. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123475. /** @hidden */
  123476. _initCache(): void;
  123477. /** @hidden */
  123478. _updateCache(ignoreParentClass?: boolean): void;
  123479. protected _getTargetPosition(): Vector3;
  123480. private _storedAlpha;
  123481. private _storedBeta;
  123482. private _storedRadius;
  123483. private _storedTarget;
  123484. private _storedTargetScreenOffset;
  123485. /**
  123486. * Stores the current state of the camera (alpha, beta, radius and target)
  123487. * @returns the camera itself
  123488. */
  123489. storeState(): Camera;
  123490. /**
  123491. * @hidden
  123492. * Restored camera state. You must call storeState() first
  123493. */
  123494. _restoreStateValues(): boolean;
  123495. /** @hidden */
  123496. _isSynchronizedViewMatrix(): boolean;
  123497. /**
  123498. * Attached controls to the current camera.
  123499. * @param element Defines the element the controls should be listened from
  123500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123501. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  123502. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  123503. */
  123504. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  123505. /**
  123506. * Detach the current controls from the camera.
  123507. * The camera will stop reacting to inputs.
  123508. * @param element Defines the element to stop listening the inputs from
  123509. */
  123510. detachControl(element: HTMLElement): void;
  123511. /** @hidden */
  123512. _checkInputs(): void;
  123513. protected _checkLimits(): void;
  123514. /**
  123515. * Rebuilds angles (alpha, beta) and radius from the give position and target
  123516. */
  123517. rebuildAnglesAndRadius(): void;
  123518. /**
  123519. * Use a position to define the current camera related information like alpha, beta and radius
  123520. * @param position Defines the position to set the camera at
  123521. */
  123522. setPosition(position: Vector3): void;
  123523. /**
  123524. * Defines the target the camera should look at.
  123525. * This will automatically adapt alpha beta and radius to fit within the new target.
  123526. * @param target Defines the new target as a Vector or a mesh
  123527. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  123528. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  123529. */
  123530. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  123531. /** @hidden */
  123532. _getViewMatrix(): Matrix;
  123533. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  123534. /**
  123535. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  123536. * @param meshes Defines the mesh to zoom on
  123537. * @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)
  123538. */
  123539. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  123540. /**
  123541. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  123542. * The target will be changed but the radius
  123543. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  123544. * @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)
  123545. */
  123546. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  123547. min: Vector3;
  123548. max: Vector3;
  123549. distance: number;
  123550. }, doNotUpdateMaxZ?: boolean): void;
  123551. /**
  123552. * @override
  123553. * Override Camera.createRigCamera
  123554. */
  123555. createRigCamera(name: string, cameraIndex: number): Camera;
  123556. /**
  123557. * @hidden
  123558. * @override
  123559. * Override Camera._updateRigCameras
  123560. */
  123561. _updateRigCameras(): void;
  123562. /**
  123563. * Destroy the camera and release the current resources hold by it.
  123564. */
  123565. dispose(): void;
  123566. /**
  123567. * Gets the current object class name.
  123568. * @return the class name
  123569. */
  123570. getClassName(): string;
  123571. }
  123572. }
  123573. declare module BABYLON {
  123574. /**
  123575. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123576. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123577. */
  123578. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123579. /**
  123580. * Gets the name of the behavior.
  123581. */
  123582. get name(): string;
  123583. private _zoomStopsAnimation;
  123584. private _idleRotationSpeed;
  123585. private _idleRotationWaitTime;
  123586. private _idleRotationSpinupTime;
  123587. /**
  123588. * Sets the flag that indicates if user zooming should stop animation.
  123589. */
  123590. set zoomStopsAnimation(flag: boolean);
  123591. /**
  123592. * Gets the flag that indicates if user zooming should stop animation.
  123593. */
  123594. get zoomStopsAnimation(): boolean;
  123595. /**
  123596. * Sets the default speed at which the camera rotates around the model.
  123597. */
  123598. set idleRotationSpeed(speed: number);
  123599. /**
  123600. * Gets the default speed at which the camera rotates around the model.
  123601. */
  123602. get idleRotationSpeed(): number;
  123603. /**
  123604. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123605. */
  123606. set idleRotationWaitTime(time: number);
  123607. /**
  123608. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123609. */
  123610. get idleRotationWaitTime(): number;
  123611. /**
  123612. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123613. */
  123614. set idleRotationSpinupTime(time: number);
  123615. /**
  123616. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123617. */
  123618. get idleRotationSpinupTime(): number;
  123619. /**
  123620. * Gets a value indicating if the camera is currently rotating because of this behavior
  123621. */
  123622. get rotationInProgress(): boolean;
  123623. private _onPrePointerObservableObserver;
  123624. private _onAfterCheckInputsObserver;
  123625. private _attachedCamera;
  123626. private _isPointerDown;
  123627. private _lastFrameTime;
  123628. private _lastInteractionTime;
  123629. private _cameraRotationSpeed;
  123630. /**
  123631. * Initializes the behavior.
  123632. */
  123633. init(): void;
  123634. /**
  123635. * Attaches the behavior to its arc rotate camera.
  123636. * @param camera Defines the camera to attach the behavior to
  123637. */
  123638. attach(camera: ArcRotateCamera): void;
  123639. /**
  123640. * Detaches the behavior from its current arc rotate camera.
  123641. */
  123642. detach(): void;
  123643. /**
  123644. * Returns true if user is scrolling.
  123645. * @return true if user is scrolling.
  123646. */
  123647. private _userIsZooming;
  123648. private _lastFrameRadius;
  123649. private _shouldAnimationStopForInteraction;
  123650. /**
  123651. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123652. */
  123653. private _applyUserInteraction;
  123654. private _userIsMoving;
  123655. }
  123656. }
  123657. declare module BABYLON {
  123658. /**
  123659. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  123660. */
  123661. export class AttachToBoxBehavior implements Behavior<Mesh> {
  123662. private ui;
  123663. /**
  123664. * The name of the behavior
  123665. */
  123666. name: string;
  123667. /**
  123668. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  123669. */
  123670. distanceAwayFromFace: number;
  123671. /**
  123672. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  123673. */
  123674. distanceAwayFromBottomOfFace: number;
  123675. private _faceVectors;
  123676. private _target;
  123677. private _scene;
  123678. private _onRenderObserver;
  123679. private _tmpMatrix;
  123680. private _tmpVector;
  123681. /**
  123682. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  123683. * @param ui The transform node that should be attched to the mesh
  123684. */
  123685. constructor(ui: TransformNode);
  123686. /**
  123687. * Initializes the behavior
  123688. */
  123689. init(): void;
  123690. private _closestFace;
  123691. private _zeroVector;
  123692. private _lookAtTmpMatrix;
  123693. private _lookAtToRef;
  123694. /**
  123695. * Attaches the AttachToBoxBehavior to the passed in mesh
  123696. * @param target The mesh that the specified node will be attached to
  123697. */
  123698. attach(target: Mesh): void;
  123699. /**
  123700. * Detaches the behavior from the mesh
  123701. */
  123702. detach(): void;
  123703. }
  123704. }
  123705. declare module BABYLON {
  123706. /**
  123707. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  123708. */
  123709. export class FadeInOutBehavior implements Behavior<Mesh> {
  123710. /**
  123711. * Time in milliseconds to delay before fading in (Default: 0)
  123712. */
  123713. delay: number;
  123714. /**
  123715. * Time in milliseconds for the mesh to fade in (Default: 300)
  123716. */
  123717. fadeInTime: number;
  123718. private _millisecondsPerFrame;
  123719. private _hovered;
  123720. private _hoverValue;
  123721. private _ownerNode;
  123722. /**
  123723. * Instatiates the FadeInOutBehavior
  123724. */
  123725. constructor();
  123726. /**
  123727. * The name of the behavior
  123728. */
  123729. get name(): string;
  123730. /**
  123731. * Initializes the behavior
  123732. */
  123733. init(): void;
  123734. /**
  123735. * Attaches the fade behavior on the passed in mesh
  123736. * @param ownerNode The mesh that will be faded in/out once attached
  123737. */
  123738. attach(ownerNode: Mesh): void;
  123739. /**
  123740. * Detaches the behavior from the mesh
  123741. */
  123742. detach(): void;
  123743. /**
  123744. * Triggers the mesh to begin fading in or out
  123745. * @param value if the object should fade in or out (true to fade in)
  123746. */
  123747. fadeIn(value: boolean): void;
  123748. private _update;
  123749. private _setAllVisibility;
  123750. }
  123751. }
  123752. declare module BABYLON {
  123753. /**
  123754. * Class containing a set of static utilities functions for managing Pivots
  123755. * @hidden
  123756. */
  123757. export class PivotTools {
  123758. private static _PivotCached;
  123759. private static _OldPivotPoint;
  123760. private static _PivotTranslation;
  123761. private static _PivotTmpVector;
  123762. private static _PivotPostMultiplyPivotMatrix;
  123763. /** @hidden */
  123764. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  123765. /** @hidden */
  123766. static _RestorePivotPoint(mesh: AbstractMesh): void;
  123767. }
  123768. }
  123769. declare module BABYLON {
  123770. /**
  123771. * Class containing static functions to help procedurally build meshes
  123772. */
  123773. export class PlaneBuilder {
  123774. /**
  123775. * Creates a plane mesh
  123776. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123777. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123778. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123782. * @param name defines the name of the mesh
  123783. * @param options defines the options used to create the mesh
  123784. * @param scene defines the hosting scene
  123785. * @returns the plane mesh
  123786. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123787. */
  123788. static CreatePlane(name: string, options: {
  123789. size?: number;
  123790. width?: number;
  123791. height?: number;
  123792. sideOrientation?: number;
  123793. frontUVs?: Vector4;
  123794. backUVs?: Vector4;
  123795. updatable?: boolean;
  123796. sourcePlane?: Plane;
  123797. }, scene?: Nullable<Scene>): Mesh;
  123798. }
  123799. }
  123800. declare module BABYLON {
  123801. /**
  123802. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123803. */
  123804. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123805. private static _AnyMouseID;
  123806. /**
  123807. * Abstract mesh the behavior is set on
  123808. */
  123809. attachedNode: AbstractMesh;
  123810. private _dragPlane;
  123811. private _scene;
  123812. private _pointerObserver;
  123813. private _beforeRenderObserver;
  123814. private static _planeScene;
  123815. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123816. /**
  123817. * 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)
  123818. */
  123819. maxDragAngle: number;
  123820. /**
  123821. * @hidden
  123822. */
  123823. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123824. /**
  123825. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123826. */
  123827. currentDraggingPointerID: number;
  123828. /**
  123829. * The last position where the pointer hit the drag plane in world space
  123830. */
  123831. lastDragPosition: Vector3;
  123832. /**
  123833. * If the behavior is currently in a dragging state
  123834. */
  123835. dragging: boolean;
  123836. /**
  123837. * 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)
  123838. */
  123839. dragDeltaRatio: number;
  123840. /**
  123841. * If the drag plane orientation should be updated during the dragging (Default: true)
  123842. */
  123843. updateDragPlane: boolean;
  123844. private _debugMode;
  123845. private _moving;
  123846. /**
  123847. * Fires each time the attached mesh is dragged with the pointer
  123848. * * delta between last drag position and current drag position in world space
  123849. * * dragDistance along the drag axis
  123850. * * dragPlaneNormal normal of the current drag plane used during the drag
  123851. * * dragPlanePoint in world space where the drag intersects the drag plane
  123852. */
  123853. onDragObservable: Observable<{
  123854. delta: Vector3;
  123855. dragPlanePoint: Vector3;
  123856. dragPlaneNormal: Vector3;
  123857. dragDistance: number;
  123858. pointerId: number;
  123859. }>;
  123860. /**
  123861. * Fires each time a drag begins (eg. mouse down on mesh)
  123862. */
  123863. onDragStartObservable: Observable<{
  123864. dragPlanePoint: Vector3;
  123865. pointerId: number;
  123866. }>;
  123867. /**
  123868. * Fires each time a drag ends (eg. mouse release after drag)
  123869. */
  123870. onDragEndObservable: Observable<{
  123871. dragPlanePoint: Vector3;
  123872. pointerId: number;
  123873. }>;
  123874. /**
  123875. * If the attached mesh should be moved when dragged
  123876. */
  123877. moveAttached: boolean;
  123878. /**
  123879. * If the drag behavior will react to drag events (Default: true)
  123880. */
  123881. enabled: boolean;
  123882. /**
  123883. * If pointer events should start and release the drag (Default: true)
  123884. */
  123885. startAndReleaseDragOnPointerEvents: boolean;
  123886. /**
  123887. * If camera controls should be detached during the drag
  123888. */
  123889. detachCameraControls: boolean;
  123890. /**
  123891. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123892. */
  123893. useObjectOrientationForDragging: boolean;
  123894. private _options;
  123895. /**
  123896. * Gets the options used by the behavior
  123897. */
  123898. get options(): {
  123899. dragAxis?: Vector3;
  123900. dragPlaneNormal?: Vector3;
  123901. };
  123902. /**
  123903. * Sets the options used by the behavior
  123904. */
  123905. set options(options: {
  123906. dragAxis?: Vector3;
  123907. dragPlaneNormal?: Vector3;
  123908. });
  123909. /**
  123910. * Creates a pointer drag behavior that can be attached to a mesh
  123911. * @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)
  123912. */
  123913. constructor(options?: {
  123914. dragAxis?: Vector3;
  123915. dragPlaneNormal?: Vector3;
  123916. });
  123917. /**
  123918. * Predicate to determine if it is valid to move the object to a new position when it is moved
  123919. */
  123920. validateDrag: (targetPosition: Vector3) => boolean;
  123921. /**
  123922. * The name of the behavior
  123923. */
  123924. get name(): string;
  123925. /**
  123926. * Initializes the behavior
  123927. */
  123928. init(): void;
  123929. private _tmpVector;
  123930. private _alternatePickedPoint;
  123931. private _worldDragAxis;
  123932. private _targetPosition;
  123933. private _attachedElement;
  123934. /**
  123935. * Attaches the drag behavior the passed in mesh
  123936. * @param ownerNode The mesh that will be dragged around once attached
  123937. * @param predicate Predicate to use for pick filtering
  123938. */
  123939. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  123940. /**
  123941. * Force relase the drag action by code.
  123942. */
  123943. releaseDrag(): void;
  123944. private _startDragRay;
  123945. private _lastPointerRay;
  123946. /**
  123947. * Simulates the start of a pointer drag event on the behavior
  123948. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  123949. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  123950. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  123951. */
  123952. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123953. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123954. private _dragDelta;
  123955. protected _moveDrag(ray: Ray): void;
  123956. private _pickWithRayOnDragPlane;
  123957. private _pointA;
  123958. private _pointC;
  123959. private _localAxis;
  123960. private _lookAt;
  123961. private _updateDragPlanePosition;
  123962. /**
  123963. * Detaches the behavior from the mesh
  123964. */
  123965. detach(): void;
  123966. }
  123967. }
  123968. declare module BABYLON {
  123969. /**
  123970. * A behavior that when attached to a mesh will allow the mesh to be scaled
  123971. */
  123972. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  123973. private _dragBehaviorA;
  123974. private _dragBehaviorB;
  123975. private _startDistance;
  123976. private _initialScale;
  123977. private _targetScale;
  123978. private _ownerNode;
  123979. private _sceneRenderObserver;
  123980. /**
  123981. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  123982. */
  123983. constructor();
  123984. /**
  123985. * The name of the behavior
  123986. */
  123987. get name(): string;
  123988. /**
  123989. * Initializes the behavior
  123990. */
  123991. init(): void;
  123992. private _getCurrentDistance;
  123993. /**
  123994. * Attaches the scale behavior the passed in mesh
  123995. * @param ownerNode The mesh that will be scaled around once attached
  123996. */
  123997. attach(ownerNode: Mesh): void;
  123998. /**
  123999. * Detaches the behavior from the mesh
  124000. */
  124001. detach(): void;
  124002. }
  124003. }
  124004. declare module BABYLON {
  124005. /**
  124006. * 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
  124007. */
  124008. export class SixDofDragBehavior implements Behavior<Mesh> {
  124009. private static _virtualScene;
  124010. private _ownerNode;
  124011. private _sceneRenderObserver;
  124012. private _scene;
  124013. private _targetPosition;
  124014. private _virtualOriginMesh;
  124015. private _virtualDragMesh;
  124016. private _pointerObserver;
  124017. private _moving;
  124018. private _startingOrientation;
  124019. private _attachedElement;
  124020. /**
  124021. * 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)
  124022. */
  124023. private zDragFactor;
  124024. /**
  124025. * If the object should rotate to face the drag origin
  124026. */
  124027. rotateDraggedObject: boolean;
  124028. /**
  124029. * If the behavior is currently in a dragging state
  124030. */
  124031. dragging: boolean;
  124032. /**
  124033. * 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)
  124034. */
  124035. dragDeltaRatio: number;
  124036. /**
  124037. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  124038. */
  124039. currentDraggingPointerID: number;
  124040. /**
  124041. * If camera controls should be detached during the drag
  124042. */
  124043. detachCameraControls: boolean;
  124044. /**
  124045. * Fires each time a drag starts
  124046. */
  124047. onDragStartObservable: Observable<{}>;
  124048. /**
  124049. * Fires each time a drag ends (eg. mouse release after drag)
  124050. */
  124051. onDragEndObservable: Observable<{}>;
  124052. /**
  124053. * 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
  124054. */
  124055. constructor();
  124056. /**
  124057. * The name of the behavior
  124058. */
  124059. get name(): string;
  124060. /**
  124061. * Initializes the behavior
  124062. */
  124063. init(): void;
  124064. /**
  124065. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  124066. */
  124067. private get _pointerCamera();
  124068. /**
  124069. * Attaches the scale behavior the passed in mesh
  124070. * @param ownerNode The mesh that will be scaled around once attached
  124071. */
  124072. attach(ownerNode: Mesh): void;
  124073. /**
  124074. * Detaches the behavior from the mesh
  124075. */
  124076. detach(): void;
  124077. }
  124078. }
  124079. declare module BABYLON {
  124080. /**
  124081. * Class used to apply inverse kinematics to bones
  124082. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  124083. */
  124084. export class BoneIKController {
  124085. private static _tmpVecs;
  124086. private static _tmpQuat;
  124087. private static _tmpMats;
  124088. /**
  124089. * Gets or sets the target mesh
  124090. */
  124091. targetMesh: AbstractMesh;
  124092. /** Gets or sets the mesh used as pole */
  124093. poleTargetMesh: AbstractMesh;
  124094. /**
  124095. * Gets or sets the bone used as pole
  124096. */
  124097. poleTargetBone: Nullable<Bone>;
  124098. /**
  124099. * Gets or sets the target position
  124100. */
  124101. targetPosition: Vector3;
  124102. /**
  124103. * Gets or sets the pole target position
  124104. */
  124105. poleTargetPosition: Vector3;
  124106. /**
  124107. * Gets or sets the pole target local offset
  124108. */
  124109. poleTargetLocalOffset: Vector3;
  124110. /**
  124111. * Gets or sets the pole angle
  124112. */
  124113. poleAngle: number;
  124114. /**
  124115. * Gets or sets the mesh associated with the controller
  124116. */
  124117. mesh: AbstractMesh;
  124118. /**
  124119. * 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)
  124120. */
  124121. slerpAmount: number;
  124122. private _bone1Quat;
  124123. private _bone1Mat;
  124124. private _bone2Ang;
  124125. private _bone1;
  124126. private _bone2;
  124127. private _bone1Length;
  124128. private _bone2Length;
  124129. private _maxAngle;
  124130. private _maxReach;
  124131. private _rightHandedSystem;
  124132. private _bendAxis;
  124133. private _slerping;
  124134. private _adjustRoll;
  124135. /**
  124136. * Gets or sets maximum allowed angle
  124137. */
  124138. get maxAngle(): number;
  124139. set maxAngle(value: number);
  124140. /**
  124141. * Creates a new BoneIKController
  124142. * @param mesh defines the mesh to control
  124143. * @param bone defines the bone to control
  124144. * @param options defines options to set up the controller
  124145. */
  124146. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  124147. targetMesh?: AbstractMesh;
  124148. poleTargetMesh?: AbstractMesh;
  124149. poleTargetBone?: Bone;
  124150. poleTargetLocalOffset?: Vector3;
  124151. poleAngle?: number;
  124152. bendAxis?: Vector3;
  124153. maxAngle?: number;
  124154. slerpAmount?: number;
  124155. });
  124156. private _setMaxAngle;
  124157. /**
  124158. * Force the controller to update the bones
  124159. */
  124160. update(): void;
  124161. }
  124162. }
  124163. declare module BABYLON {
  124164. /**
  124165. * Class used to make a bone look toward a point in space
  124166. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  124167. */
  124168. export class BoneLookController {
  124169. private static _tmpVecs;
  124170. private static _tmpQuat;
  124171. private static _tmpMats;
  124172. /**
  124173. * The target Vector3 that the bone will look at
  124174. */
  124175. target: Vector3;
  124176. /**
  124177. * The mesh that the bone is attached to
  124178. */
  124179. mesh: AbstractMesh;
  124180. /**
  124181. * The bone that will be looking to the target
  124182. */
  124183. bone: Bone;
  124184. /**
  124185. * The up axis of the coordinate system that is used when the bone is rotated
  124186. */
  124187. upAxis: Vector3;
  124188. /**
  124189. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  124190. */
  124191. upAxisSpace: Space;
  124192. /**
  124193. * Used to make an adjustment to the yaw of the bone
  124194. */
  124195. adjustYaw: number;
  124196. /**
  124197. * Used to make an adjustment to the pitch of the bone
  124198. */
  124199. adjustPitch: number;
  124200. /**
  124201. * Used to make an adjustment to the roll of the bone
  124202. */
  124203. adjustRoll: number;
  124204. /**
  124205. * 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)
  124206. */
  124207. slerpAmount: number;
  124208. private _minYaw;
  124209. private _maxYaw;
  124210. private _minPitch;
  124211. private _maxPitch;
  124212. private _minYawSin;
  124213. private _minYawCos;
  124214. private _maxYawSin;
  124215. private _maxYawCos;
  124216. private _midYawConstraint;
  124217. private _minPitchTan;
  124218. private _maxPitchTan;
  124219. private _boneQuat;
  124220. private _slerping;
  124221. private _transformYawPitch;
  124222. private _transformYawPitchInv;
  124223. private _firstFrameSkipped;
  124224. private _yawRange;
  124225. private _fowardAxis;
  124226. /**
  124227. * Gets or sets the minimum yaw angle that the bone can look to
  124228. */
  124229. get minYaw(): number;
  124230. set minYaw(value: number);
  124231. /**
  124232. * Gets or sets the maximum yaw angle that the bone can look to
  124233. */
  124234. get maxYaw(): number;
  124235. set maxYaw(value: number);
  124236. /**
  124237. * Gets or sets the minimum pitch angle that the bone can look to
  124238. */
  124239. get minPitch(): number;
  124240. set minPitch(value: number);
  124241. /**
  124242. * Gets or sets the maximum pitch angle that the bone can look to
  124243. */
  124244. get maxPitch(): number;
  124245. set maxPitch(value: number);
  124246. /**
  124247. * Create a BoneLookController
  124248. * @param mesh the mesh that the bone belongs to
  124249. * @param bone the bone that will be looking to the target
  124250. * @param target the target Vector3 to look at
  124251. * @param options optional settings:
  124252. * * maxYaw: the maximum angle the bone will yaw to
  124253. * * minYaw: the minimum angle the bone will yaw to
  124254. * * maxPitch: the maximum angle the bone will pitch to
  124255. * * minPitch: the minimum angle the bone will yaw to
  124256. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  124257. * * upAxis: the up axis of the coordinate system
  124258. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  124259. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  124260. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  124261. * * adjustYaw: used to make an adjustment to the yaw of the bone
  124262. * * adjustPitch: used to make an adjustment to the pitch of the bone
  124263. * * adjustRoll: used to make an adjustment to the roll of the bone
  124264. **/
  124265. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  124266. maxYaw?: number;
  124267. minYaw?: number;
  124268. maxPitch?: number;
  124269. minPitch?: number;
  124270. slerpAmount?: number;
  124271. upAxis?: Vector3;
  124272. upAxisSpace?: Space;
  124273. yawAxis?: Vector3;
  124274. pitchAxis?: Vector3;
  124275. adjustYaw?: number;
  124276. adjustPitch?: number;
  124277. adjustRoll?: number;
  124278. });
  124279. /**
  124280. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  124281. */
  124282. update(): void;
  124283. private _getAngleDiff;
  124284. private _getAngleBetween;
  124285. private _isAngleBetween;
  124286. }
  124287. }
  124288. declare module BABYLON {
  124289. /**
  124290. * Manage the gamepad inputs to control an arc rotate camera.
  124291. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124292. */
  124293. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  124294. /**
  124295. * Defines the camera the input is attached to.
  124296. */
  124297. camera: ArcRotateCamera;
  124298. /**
  124299. * Defines the gamepad the input is gathering event from.
  124300. */
  124301. gamepad: Nullable<Gamepad>;
  124302. /**
  124303. * Defines the gamepad rotation sensiblity.
  124304. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124305. */
  124306. gamepadRotationSensibility: number;
  124307. /**
  124308. * Defines the gamepad move sensiblity.
  124309. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124310. */
  124311. gamepadMoveSensibility: number;
  124312. private _yAxisScale;
  124313. /**
  124314. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124315. */
  124316. get invertYAxis(): boolean;
  124317. set invertYAxis(value: boolean);
  124318. private _onGamepadConnectedObserver;
  124319. private _onGamepadDisconnectedObserver;
  124320. /**
  124321. * Attach the input controls to a specific dom element to get the input from.
  124322. * @param element Defines the element the controls should be listened from
  124323. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124324. */
  124325. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124326. /**
  124327. * Detach the current controls from the specified dom element.
  124328. * @param element Defines the element to stop listening the inputs from
  124329. */
  124330. detachControl(element: Nullable<HTMLElement>): void;
  124331. /**
  124332. * Update the current camera state depending on the inputs that have been used this frame.
  124333. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124334. */
  124335. checkInputs(): void;
  124336. /**
  124337. * Gets the class name of the current intput.
  124338. * @returns the class name
  124339. */
  124340. getClassName(): string;
  124341. /**
  124342. * Get the friendly name associated with the input class.
  124343. * @returns the input friendly name
  124344. */
  124345. getSimpleName(): string;
  124346. }
  124347. }
  124348. declare module BABYLON {
  124349. interface ArcRotateCameraInputsManager {
  124350. /**
  124351. * Add orientation input support to the input manager.
  124352. * @returns the current input manager
  124353. */
  124354. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  124355. }
  124356. /**
  124357. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  124358. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124359. */
  124360. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  124361. /**
  124362. * Defines the camera the input is attached to.
  124363. */
  124364. camera: ArcRotateCamera;
  124365. /**
  124366. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  124367. */
  124368. alphaCorrection: number;
  124369. /**
  124370. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  124371. */
  124372. gammaCorrection: number;
  124373. private _alpha;
  124374. private _gamma;
  124375. private _dirty;
  124376. private _deviceOrientationHandler;
  124377. /**
  124378. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  124379. */
  124380. constructor();
  124381. /**
  124382. * Attach the input controls to a specific dom element to get the input from.
  124383. * @param element Defines the element the controls should be listened from
  124384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124385. */
  124386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124387. /** @hidden */
  124388. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  124389. /**
  124390. * Update the current camera state depending on the inputs that have been used this frame.
  124391. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124392. */
  124393. checkInputs(): void;
  124394. /**
  124395. * Detach the current controls from the specified dom element.
  124396. * @param element Defines the element to stop listening the inputs from
  124397. */
  124398. detachControl(element: Nullable<HTMLElement>): void;
  124399. /**
  124400. * Gets the class name of the current intput.
  124401. * @returns the class name
  124402. */
  124403. getClassName(): string;
  124404. /**
  124405. * Get the friendly name associated with the input class.
  124406. * @returns the input friendly name
  124407. */
  124408. getSimpleName(): string;
  124409. }
  124410. }
  124411. declare module BABYLON {
  124412. /**
  124413. * Listen to mouse events to control the camera.
  124414. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124415. */
  124416. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  124417. /**
  124418. * Defines the camera the input is attached to.
  124419. */
  124420. camera: FlyCamera;
  124421. /**
  124422. * Defines if touch is enabled. (Default is true.)
  124423. */
  124424. touchEnabled: boolean;
  124425. /**
  124426. * Defines the buttons associated with the input to handle camera rotation.
  124427. */
  124428. buttons: number[];
  124429. /**
  124430. * Assign buttons for Yaw control.
  124431. */
  124432. buttonsYaw: number[];
  124433. /**
  124434. * Assign buttons for Pitch control.
  124435. */
  124436. buttonsPitch: number[];
  124437. /**
  124438. * Assign buttons for Roll control.
  124439. */
  124440. buttonsRoll: number[];
  124441. /**
  124442. * Detect if any button is being pressed while mouse is moved.
  124443. * -1 = Mouse locked.
  124444. * 0 = Left button.
  124445. * 1 = Middle Button.
  124446. * 2 = Right Button.
  124447. */
  124448. activeButton: number;
  124449. /**
  124450. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  124451. * Higher values reduce its sensitivity.
  124452. */
  124453. angularSensibility: number;
  124454. private _mousemoveCallback;
  124455. private _observer;
  124456. private _rollObserver;
  124457. private previousPosition;
  124458. private noPreventDefault;
  124459. private element;
  124460. /**
  124461. * Listen to mouse events to control the camera.
  124462. * @param touchEnabled Define if touch is enabled. (Default is true.)
  124463. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124464. */
  124465. constructor(touchEnabled?: boolean);
  124466. /**
  124467. * Attach the mouse control to the HTML DOM element.
  124468. * @param element Defines the element that listens to the input events.
  124469. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  124470. */
  124471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124472. /**
  124473. * Detach the current controls from the specified dom element.
  124474. * @param element Defines the element to stop listening the inputs from
  124475. */
  124476. detachControl(element: Nullable<HTMLElement>): void;
  124477. /**
  124478. * Gets the class name of the current input.
  124479. * @returns the class name.
  124480. */
  124481. getClassName(): string;
  124482. /**
  124483. * Get the friendly name associated with the input class.
  124484. * @returns the input's friendly name.
  124485. */
  124486. getSimpleName(): string;
  124487. private _pointerInput;
  124488. private _onMouseMove;
  124489. /**
  124490. * Rotate camera by mouse offset.
  124491. */
  124492. private rotateCamera;
  124493. }
  124494. }
  124495. declare module BABYLON {
  124496. /**
  124497. * Default Inputs manager for the FlyCamera.
  124498. * It groups all the default supported inputs for ease of use.
  124499. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124500. */
  124501. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  124502. /**
  124503. * Instantiates a new FlyCameraInputsManager.
  124504. * @param camera Defines the camera the inputs belong to.
  124505. */
  124506. constructor(camera: FlyCamera);
  124507. /**
  124508. * Add keyboard input support to the input manager.
  124509. * @returns the new FlyCameraKeyboardMoveInput().
  124510. */
  124511. addKeyboard(): FlyCameraInputsManager;
  124512. /**
  124513. * Add mouse input support to the input manager.
  124514. * @param touchEnabled Enable touch screen support.
  124515. * @returns the new FlyCameraMouseInput().
  124516. */
  124517. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  124518. }
  124519. }
  124520. declare module BABYLON {
  124521. /**
  124522. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124523. * such as in a 3D Space Shooter or a Flight Simulator.
  124524. */
  124525. export class FlyCamera extends TargetCamera {
  124526. /**
  124527. * Define the collision ellipsoid of the camera.
  124528. * This is helpful for simulating a camera body, like a player's body.
  124529. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  124530. */
  124531. ellipsoid: Vector3;
  124532. /**
  124533. * Define an offset for the position of the ellipsoid around the camera.
  124534. * This can be helpful if the camera is attached away from the player's body center,
  124535. * such as at its head.
  124536. */
  124537. ellipsoidOffset: Vector3;
  124538. /**
  124539. * Enable or disable collisions of the camera with the rest of the scene objects.
  124540. */
  124541. checkCollisions: boolean;
  124542. /**
  124543. * Enable or disable gravity on the camera.
  124544. */
  124545. applyGravity: boolean;
  124546. /**
  124547. * Define the current direction the camera is moving to.
  124548. */
  124549. cameraDirection: Vector3;
  124550. /**
  124551. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124552. * This overrides and empties cameraRotation.
  124553. */
  124554. rotationQuaternion: Quaternion;
  124555. /**
  124556. * Track Roll to maintain the wanted Rolling when looking around.
  124557. */
  124558. _trackRoll: number;
  124559. /**
  124560. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124561. */
  124562. rollCorrect: number;
  124563. /**
  124564. * Mimic a banked turn, Rolling the camera when Yawing.
  124565. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124566. */
  124567. bankedTurn: boolean;
  124568. /**
  124569. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124570. */
  124571. bankedTurnLimit: number;
  124572. /**
  124573. * Value of 0 disables the banked Roll.
  124574. * Value of 1 is equal to the Yaw angle in radians.
  124575. */
  124576. bankedTurnMultiplier: number;
  124577. /**
  124578. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124579. */
  124580. inputs: FlyCameraInputsManager;
  124581. /**
  124582. * Gets the input sensibility for mouse input.
  124583. * Higher values reduce sensitivity.
  124584. */
  124585. get angularSensibility(): number;
  124586. /**
  124587. * Sets the input sensibility for a mouse input.
  124588. * Higher values reduce sensitivity.
  124589. */
  124590. set angularSensibility(value: number);
  124591. /**
  124592. * Get the keys for camera movement forward.
  124593. */
  124594. get keysForward(): number[];
  124595. /**
  124596. * Set the keys for camera movement forward.
  124597. */
  124598. set keysForward(value: number[]);
  124599. /**
  124600. * Get the keys for camera movement backward.
  124601. */
  124602. get keysBackward(): number[];
  124603. set keysBackward(value: number[]);
  124604. /**
  124605. * Get the keys for camera movement up.
  124606. */
  124607. get keysUp(): number[];
  124608. /**
  124609. * Set the keys for camera movement up.
  124610. */
  124611. set keysUp(value: number[]);
  124612. /**
  124613. * Get the keys for camera movement down.
  124614. */
  124615. get keysDown(): number[];
  124616. /**
  124617. * Set the keys for camera movement down.
  124618. */
  124619. set keysDown(value: number[]);
  124620. /**
  124621. * Get the keys for camera movement left.
  124622. */
  124623. get keysLeft(): number[];
  124624. /**
  124625. * Set the keys for camera movement left.
  124626. */
  124627. set keysLeft(value: number[]);
  124628. /**
  124629. * Set the keys for camera movement right.
  124630. */
  124631. get keysRight(): number[];
  124632. /**
  124633. * Set the keys for camera movement right.
  124634. */
  124635. set keysRight(value: number[]);
  124636. /**
  124637. * Event raised when the camera collides with a mesh in the scene.
  124638. */
  124639. onCollide: (collidedMesh: AbstractMesh) => void;
  124640. private _collider;
  124641. private _needMoveForGravity;
  124642. private _oldPosition;
  124643. private _diffPosition;
  124644. private _newPosition;
  124645. /** @hidden */
  124646. _localDirection: Vector3;
  124647. /** @hidden */
  124648. _transformedDirection: Vector3;
  124649. /**
  124650. * Instantiates a FlyCamera.
  124651. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124652. * such as in a 3D Space Shooter or a Flight Simulator.
  124653. * @param name Define the name of the camera in the scene.
  124654. * @param position Define the starting position of the camera in the scene.
  124655. * @param scene Define the scene the camera belongs to.
  124656. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  124657. */
  124658. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  124659. /**
  124660. * Attach a control to the HTML DOM element.
  124661. * @param element Defines the element that listens to the input events.
  124662. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  124663. */
  124664. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124665. /**
  124666. * Detach a control from the HTML DOM element.
  124667. * The camera will stop reacting to that input.
  124668. * @param element Defines the element that listens to the input events.
  124669. */
  124670. detachControl(element: HTMLElement): void;
  124671. private _collisionMask;
  124672. /**
  124673. * Get the mask that the camera ignores in collision events.
  124674. */
  124675. get collisionMask(): number;
  124676. /**
  124677. * Set the mask that the camera ignores in collision events.
  124678. */
  124679. set collisionMask(mask: number);
  124680. /** @hidden */
  124681. _collideWithWorld(displacement: Vector3): void;
  124682. /** @hidden */
  124683. private _onCollisionPositionChange;
  124684. /** @hidden */
  124685. _checkInputs(): void;
  124686. /** @hidden */
  124687. _decideIfNeedsToMove(): boolean;
  124688. /** @hidden */
  124689. _updatePosition(): void;
  124690. /**
  124691. * Restore the Roll to its target value at the rate specified.
  124692. * @param rate - Higher means slower restoring.
  124693. * @hidden
  124694. */
  124695. restoreRoll(rate: number): void;
  124696. /**
  124697. * Destroy the camera and release the current resources held by it.
  124698. */
  124699. dispose(): void;
  124700. /**
  124701. * Get the current object class name.
  124702. * @returns the class name.
  124703. */
  124704. getClassName(): string;
  124705. }
  124706. }
  124707. declare module BABYLON {
  124708. /**
  124709. * Listen to keyboard events to control the camera.
  124710. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124711. */
  124712. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  124713. /**
  124714. * Defines the camera the input is attached to.
  124715. */
  124716. camera: FlyCamera;
  124717. /**
  124718. * The list of keyboard keys used to control the forward move of the camera.
  124719. */
  124720. keysForward: number[];
  124721. /**
  124722. * The list of keyboard keys used to control the backward move of the camera.
  124723. */
  124724. keysBackward: number[];
  124725. /**
  124726. * The list of keyboard keys used to control the forward move of the camera.
  124727. */
  124728. keysUp: number[];
  124729. /**
  124730. * The list of keyboard keys used to control the backward move of the camera.
  124731. */
  124732. keysDown: number[];
  124733. /**
  124734. * The list of keyboard keys used to control the right strafe move of the camera.
  124735. */
  124736. keysRight: number[];
  124737. /**
  124738. * The list of keyboard keys used to control the left strafe move of the camera.
  124739. */
  124740. keysLeft: number[];
  124741. private _keys;
  124742. private _onCanvasBlurObserver;
  124743. private _onKeyboardObserver;
  124744. private _engine;
  124745. private _scene;
  124746. /**
  124747. * Attach the input controls to a specific dom element to get the input from.
  124748. * @param element Defines the element the controls should be listened from
  124749. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124750. */
  124751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124752. /**
  124753. * Detach the current controls from the specified dom element.
  124754. * @param element Defines the element to stop listening the inputs from
  124755. */
  124756. detachControl(element: Nullable<HTMLElement>): void;
  124757. /**
  124758. * Gets the class name of the current intput.
  124759. * @returns the class name
  124760. */
  124761. getClassName(): string;
  124762. /** @hidden */
  124763. _onLostFocus(e: FocusEvent): void;
  124764. /**
  124765. * Get the friendly name associated with the input class.
  124766. * @returns the input friendly name
  124767. */
  124768. getSimpleName(): string;
  124769. /**
  124770. * Update the current camera state depending on the inputs that have been used this frame.
  124771. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124772. */
  124773. checkInputs(): void;
  124774. }
  124775. }
  124776. declare module BABYLON {
  124777. /**
  124778. * Manage the mouse wheel inputs to control a follow camera.
  124779. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124780. */
  124781. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124782. /**
  124783. * Defines the camera the input is attached to.
  124784. */
  124785. camera: FollowCamera;
  124786. /**
  124787. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124788. */
  124789. axisControlRadius: boolean;
  124790. /**
  124791. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124792. */
  124793. axisControlHeight: boolean;
  124794. /**
  124795. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124796. */
  124797. axisControlRotation: boolean;
  124798. /**
  124799. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124800. * relation to mouseWheel events.
  124801. */
  124802. wheelPrecision: number;
  124803. /**
  124804. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124805. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124806. */
  124807. wheelDeltaPercentage: number;
  124808. private _wheel;
  124809. private _observer;
  124810. /**
  124811. * Attach the input controls to a specific dom element to get the input from.
  124812. * @param element Defines the element the controls should be listened from
  124813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124814. */
  124815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124816. /**
  124817. * Detach the current controls from the specified dom element.
  124818. * @param element Defines the element to stop listening the inputs from
  124819. */
  124820. detachControl(element: Nullable<HTMLElement>): void;
  124821. /**
  124822. * Gets the class name of the current intput.
  124823. * @returns the class name
  124824. */
  124825. getClassName(): string;
  124826. /**
  124827. * Get the friendly name associated with the input class.
  124828. * @returns the input friendly name
  124829. */
  124830. getSimpleName(): string;
  124831. }
  124832. }
  124833. declare module BABYLON {
  124834. /**
  124835. * Manage the pointers inputs to control an follow camera.
  124836. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124837. */
  124838. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124839. /**
  124840. * Defines the camera the input is attached to.
  124841. */
  124842. camera: FollowCamera;
  124843. /**
  124844. * Gets the class name of the current input.
  124845. * @returns the class name
  124846. */
  124847. getClassName(): string;
  124848. /**
  124849. * Defines the pointer angular sensibility along the X axis or how fast is
  124850. * the camera rotating.
  124851. * A negative number will reverse the axis direction.
  124852. */
  124853. angularSensibilityX: number;
  124854. /**
  124855. * Defines the pointer angular sensibility along the Y axis or how fast is
  124856. * the camera rotating.
  124857. * A negative number will reverse the axis direction.
  124858. */
  124859. angularSensibilityY: number;
  124860. /**
  124861. * Defines the pointer pinch precision or how fast is the camera zooming.
  124862. * A negative number will reverse the axis direction.
  124863. */
  124864. pinchPrecision: number;
  124865. /**
  124866. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124867. * from 0.
  124868. * It defines the percentage of current camera.radius to use as delta when
  124869. * pinch zoom is used.
  124870. */
  124871. pinchDeltaPercentage: number;
  124872. /**
  124873. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124874. */
  124875. axisXControlRadius: boolean;
  124876. /**
  124877. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124878. */
  124879. axisXControlHeight: boolean;
  124880. /**
  124881. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124882. */
  124883. axisXControlRotation: boolean;
  124884. /**
  124885. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124886. */
  124887. axisYControlRadius: boolean;
  124888. /**
  124889. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124890. */
  124891. axisYControlHeight: boolean;
  124892. /**
  124893. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  124894. */
  124895. axisYControlRotation: boolean;
  124896. /**
  124897. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  124898. */
  124899. axisPinchControlRadius: boolean;
  124900. /**
  124901. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  124902. */
  124903. axisPinchControlHeight: boolean;
  124904. /**
  124905. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  124906. */
  124907. axisPinchControlRotation: boolean;
  124908. /**
  124909. * Log error messages if basic misconfiguration has occurred.
  124910. */
  124911. warningEnable: boolean;
  124912. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  124913. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  124914. private _warningCounter;
  124915. private _warning;
  124916. }
  124917. }
  124918. declare module BABYLON {
  124919. /**
  124920. * Default Inputs manager for the FollowCamera.
  124921. * It groups all the default supported inputs for ease of use.
  124922. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124923. */
  124924. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  124925. /**
  124926. * Instantiates a new FollowCameraInputsManager.
  124927. * @param camera Defines the camera the inputs belong to
  124928. */
  124929. constructor(camera: FollowCamera);
  124930. /**
  124931. * Add keyboard input support to the input manager.
  124932. * @returns the current input manager
  124933. */
  124934. addKeyboard(): FollowCameraInputsManager;
  124935. /**
  124936. * Add mouse wheel input support to the input manager.
  124937. * @returns the current input manager
  124938. */
  124939. addMouseWheel(): FollowCameraInputsManager;
  124940. /**
  124941. * Add pointers input support to the input manager.
  124942. * @returns the current input manager
  124943. */
  124944. addPointers(): FollowCameraInputsManager;
  124945. /**
  124946. * Add orientation input support to the input manager.
  124947. * @returns the current input manager
  124948. */
  124949. addVRDeviceOrientation(): FollowCameraInputsManager;
  124950. }
  124951. }
  124952. declare module BABYLON {
  124953. /**
  124954. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  124955. * an arc rotate version arcFollowCamera are available.
  124956. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124957. */
  124958. export class FollowCamera extends TargetCamera {
  124959. /**
  124960. * Distance the follow camera should follow an object at
  124961. */
  124962. radius: number;
  124963. /**
  124964. * Minimum allowed distance of the camera to the axis of rotation
  124965. * (The camera can not get closer).
  124966. * This can help limiting how the Camera is able to move in the scene.
  124967. */
  124968. lowerRadiusLimit: Nullable<number>;
  124969. /**
  124970. * Maximum allowed distance of the camera to the axis of rotation
  124971. * (The camera can not get further).
  124972. * This can help limiting how the Camera is able to move in the scene.
  124973. */
  124974. upperRadiusLimit: Nullable<number>;
  124975. /**
  124976. * Define a rotation offset between the camera and the object it follows
  124977. */
  124978. rotationOffset: number;
  124979. /**
  124980. * Minimum allowed angle to camera position relative to target object.
  124981. * This can help limiting how the Camera is able to move in the scene.
  124982. */
  124983. lowerRotationOffsetLimit: Nullable<number>;
  124984. /**
  124985. * Maximum allowed angle to camera position relative to target object.
  124986. * This can help limiting how the Camera is able to move in the scene.
  124987. */
  124988. upperRotationOffsetLimit: Nullable<number>;
  124989. /**
  124990. * Define a height offset between the camera and the object it follows.
  124991. * It can help following an object from the top (like a car chaing a plane)
  124992. */
  124993. heightOffset: number;
  124994. /**
  124995. * Minimum allowed height of camera position relative to target object.
  124996. * This can help limiting how the Camera is able to move in the scene.
  124997. */
  124998. lowerHeightOffsetLimit: Nullable<number>;
  124999. /**
  125000. * Maximum allowed height of camera position relative to target object.
  125001. * This can help limiting how the Camera is able to move in the scene.
  125002. */
  125003. upperHeightOffsetLimit: Nullable<number>;
  125004. /**
  125005. * Define how fast the camera can accelerate to follow it s target.
  125006. */
  125007. cameraAcceleration: number;
  125008. /**
  125009. * Define the speed limit of the camera following an object.
  125010. */
  125011. maxCameraSpeed: number;
  125012. /**
  125013. * Define the target of the camera.
  125014. */
  125015. lockedTarget: Nullable<AbstractMesh>;
  125016. /**
  125017. * Defines the input associated with the camera.
  125018. */
  125019. inputs: FollowCameraInputsManager;
  125020. /**
  125021. * Instantiates the follow camera.
  125022. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125023. * @param name Define the name of the camera in the scene
  125024. * @param position Define the position of the camera
  125025. * @param scene Define the scene the camera belong to
  125026. * @param lockedTarget Define the target of the camera
  125027. */
  125028. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  125029. private _follow;
  125030. /**
  125031. * Attached controls to the current camera.
  125032. * @param element Defines the element the controls should be listened from
  125033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125034. */
  125035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125036. /**
  125037. * Detach the current controls from the camera.
  125038. * The camera will stop reacting to inputs.
  125039. * @param element Defines the element to stop listening the inputs from
  125040. */
  125041. detachControl(element: HTMLElement): void;
  125042. /** @hidden */
  125043. _checkInputs(): void;
  125044. private _checkLimits;
  125045. /**
  125046. * Gets the camera class name.
  125047. * @returns the class name
  125048. */
  125049. getClassName(): string;
  125050. }
  125051. /**
  125052. * Arc Rotate version of the follow camera.
  125053. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  125054. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125055. */
  125056. export class ArcFollowCamera extends TargetCamera {
  125057. /** The longitudinal angle of the camera */
  125058. alpha: number;
  125059. /** The latitudinal angle of the camera */
  125060. beta: number;
  125061. /** The radius of the camera from its target */
  125062. radius: number;
  125063. private _cartesianCoordinates;
  125064. /** Define the camera target (the mesh it should follow) */
  125065. private _meshTarget;
  125066. /**
  125067. * Instantiates a new ArcFollowCamera
  125068. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125069. * @param name Define the name of the camera
  125070. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  125071. * @param beta Define the rotation angle of the camera around the elevation axis
  125072. * @param radius Define the radius of the camera from its target point
  125073. * @param target Define the target of the camera
  125074. * @param scene Define the scene the camera belongs to
  125075. */
  125076. constructor(name: string,
  125077. /** The longitudinal angle of the camera */
  125078. alpha: number,
  125079. /** The latitudinal angle of the camera */
  125080. beta: number,
  125081. /** The radius of the camera from its target */
  125082. radius: number,
  125083. /** Define the camera target (the mesh it should follow) */
  125084. target: Nullable<AbstractMesh>, scene: Scene);
  125085. private _follow;
  125086. /** @hidden */
  125087. _checkInputs(): void;
  125088. /**
  125089. * Returns the class name of the object.
  125090. * It is mostly used internally for serialization purposes.
  125091. */
  125092. getClassName(): string;
  125093. }
  125094. }
  125095. declare module BABYLON {
  125096. /**
  125097. * Manage the keyboard inputs to control the movement of a follow camera.
  125098. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125099. */
  125100. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  125101. /**
  125102. * Defines the camera the input is attached to.
  125103. */
  125104. camera: FollowCamera;
  125105. /**
  125106. * Defines the list of key codes associated with the up action (increase heightOffset)
  125107. */
  125108. keysHeightOffsetIncr: number[];
  125109. /**
  125110. * Defines the list of key codes associated with the down action (decrease heightOffset)
  125111. */
  125112. keysHeightOffsetDecr: number[];
  125113. /**
  125114. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  125115. */
  125116. keysHeightOffsetModifierAlt: boolean;
  125117. /**
  125118. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  125119. */
  125120. keysHeightOffsetModifierCtrl: boolean;
  125121. /**
  125122. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  125123. */
  125124. keysHeightOffsetModifierShift: boolean;
  125125. /**
  125126. * Defines the list of key codes associated with the left action (increase rotationOffset)
  125127. */
  125128. keysRotationOffsetIncr: number[];
  125129. /**
  125130. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  125131. */
  125132. keysRotationOffsetDecr: number[];
  125133. /**
  125134. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  125135. */
  125136. keysRotationOffsetModifierAlt: boolean;
  125137. /**
  125138. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  125139. */
  125140. keysRotationOffsetModifierCtrl: boolean;
  125141. /**
  125142. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  125143. */
  125144. keysRotationOffsetModifierShift: boolean;
  125145. /**
  125146. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  125147. */
  125148. keysRadiusIncr: number[];
  125149. /**
  125150. * Defines the list of key codes associated with the zoom-out action (increase radius)
  125151. */
  125152. keysRadiusDecr: number[];
  125153. /**
  125154. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  125155. */
  125156. keysRadiusModifierAlt: boolean;
  125157. /**
  125158. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  125159. */
  125160. keysRadiusModifierCtrl: boolean;
  125161. /**
  125162. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  125163. */
  125164. keysRadiusModifierShift: boolean;
  125165. /**
  125166. * Defines the rate of change of heightOffset.
  125167. */
  125168. heightSensibility: number;
  125169. /**
  125170. * Defines the rate of change of rotationOffset.
  125171. */
  125172. rotationSensibility: number;
  125173. /**
  125174. * Defines the rate of change of radius.
  125175. */
  125176. radiusSensibility: number;
  125177. private _keys;
  125178. private _ctrlPressed;
  125179. private _altPressed;
  125180. private _shiftPressed;
  125181. private _onCanvasBlurObserver;
  125182. private _onKeyboardObserver;
  125183. private _engine;
  125184. private _scene;
  125185. /**
  125186. * Attach the input controls to a specific dom element to get the input from.
  125187. * @param element Defines the element the controls should be listened from
  125188. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125189. */
  125190. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125191. /**
  125192. * Detach the current controls from the specified dom element.
  125193. * @param element Defines the element to stop listening the inputs from
  125194. */
  125195. detachControl(element: Nullable<HTMLElement>): void;
  125196. /**
  125197. * Update the current camera state depending on the inputs that have been used this frame.
  125198. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125199. */
  125200. checkInputs(): void;
  125201. /**
  125202. * Gets the class name of the current input.
  125203. * @returns the class name
  125204. */
  125205. getClassName(): string;
  125206. /**
  125207. * Get the friendly name associated with the input class.
  125208. * @returns the input friendly name
  125209. */
  125210. getSimpleName(): string;
  125211. /**
  125212. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125213. * allow modification of the heightOffset value.
  125214. */
  125215. private _modifierHeightOffset;
  125216. /**
  125217. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125218. * allow modification of the rotationOffset value.
  125219. */
  125220. private _modifierRotationOffset;
  125221. /**
  125222. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125223. * allow modification of the radius value.
  125224. */
  125225. private _modifierRadius;
  125226. }
  125227. }
  125228. declare module BABYLON {
  125229. interface FreeCameraInputsManager {
  125230. /**
  125231. * @hidden
  125232. */
  125233. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  125234. /**
  125235. * Add orientation input support to the input manager.
  125236. * @returns the current input manager
  125237. */
  125238. addDeviceOrientation(): FreeCameraInputsManager;
  125239. }
  125240. /**
  125241. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  125242. * Screen rotation is taken into account.
  125243. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125244. */
  125245. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  125246. private _camera;
  125247. private _screenOrientationAngle;
  125248. private _constantTranform;
  125249. private _screenQuaternion;
  125250. private _alpha;
  125251. private _beta;
  125252. private _gamma;
  125253. /**
  125254. * Can be used to detect if a device orientation sensor is available on a device
  125255. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  125256. * @returns a promise that will resolve on orientation change
  125257. */
  125258. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  125259. /**
  125260. * @hidden
  125261. */
  125262. _onDeviceOrientationChangedObservable: Observable<void>;
  125263. /**
  125264. * Instantiates a new input
  125265. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125266. */
  125267. constructor();
  125268. /**
  125269. * Define the camera controlled by the input.
  125270. */
  125271. get camera(): FreeCamera;
  125272. set camera(camera: FreeCamera);
  125273. /**
  125274. * Attach the input controls to a specific dom element to get the input from.
  125275. * @param element Defines the element the controls should be listened from
  125276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125277. */
  125278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125279. private _orientationChanged;
  125280. private _deviceOrientation;
  125281. /**
  125282. * Detach the current controls from the specified dom element.
  125283. * @param element Defines the element to stop listening the inputs from
  125284. */
  125285. detachControl(element: Nullable<HTMLElement>): void;
  125286. /**
  125287. * Update the current camera state depending on the inputs that have been used this frame.
  125288. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125289. */
  125290. checkInputs(): void;
  125291. /**
  125292. * Gets the class name of the current intput.
  125293. * @returns the class name
  125294. */
  125295. getClassName(): string;
  125296. /**
  125297. * Get the friendly name associated with the input class.
  125298. * @returns the input friendly name
  125299. */
  125300. getSimpleName(): string;
  125301. }
  125302. }
  125303. declare module BABYLON {
  125304. /**
  125305. * Manage the gamepad inputs to control a free camera.
  125306. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125307. */
  125308. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  125309. /**
  125310. * Define the camera the input is attached to.
  125311. */
  125312. camera: FreeCamera;
  125313. /**
  125314. * Define the Gamepad controlling the input
  125315. */
  125316. gamepad: Nullable<Gamepad>;
  125317. /**
  125318. * Defines the gamepad rotation sensiblity.
  125319. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125320. */
  125321. gamepadAngularSensibility: number;
  125322. /**
  125323. * Defines the gamepad move sensiblity.
  125324. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125325. */
  125326. gamepadMoveSensibility: number;
  125327. private _yAxisScale;
  125328. /**
  125329. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  125330. */
  125331. get invertYAxis(): boolean;
  125332. set invertYAxis(value: boolean);
  125333. private _onGamepadConnectedObserver;
  125334. private _onGamepadDisconnectedObserver;
  125335. private _cameraTransform;
  125336. private _deltaTransform;
  125337. private _vector3;
  125338. private _vector2;
  125339. /**
  125340. * Attach the input controls to a specific dom element to get the input from.
  125341. * @param element Defines the element the controls should be listened from
  125342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125343. */
  125344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125345. /**
  125346. * Detach the current controls from the specified dom element.
  125347. * @param element Defines the element to stop listening the inputs from
  125348. */
  125349. detachControl(element: Nullable<HTMLElement>): void;
  125350. /**
  125351. * Update the current camera state depending on the inputs that have been used this frame.
  125352. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125353. */
  125354. checkInputs(): void;
  125355. /**
  125356. * Gets the class name of the current intput.
  125357. * @returns the class name
  125358. */
  125359. getClassName(): string;
  125360. /**
  125361. * Get the friendly name associated with the input class.
  125362. * @returns the input friendly name
  125363. */
  125364. getSimpleName(): string;
  125365. }
  125366. }
  125367. declare module BABYLON {
  125368. /**
  125369. * Defines the potential axis of a Joystick
  125370. */
  125371. export enum JoystickAxis {
  125372. /** X axis */
  125373. X = 0,
  125374. /** Y axis */
  125375. Y = 1,
  125376. /** Z axis */
  125377. Z = 2
  125378. }
  125379. /**
  125380. * Represents the different customization options available
  125381. * for VirtualJoystick
  125382. */
  125383. interface VirtualJoystickCustomizations {
  125384. /**
  125385. * Size of the joystick's puck
  125386. */
  125387. puckSize: number;
  125388. /**
  125389. * Size of the joystick's container
  125390. */
  125391. containerSize: number;
  125392. /**
  125393. * Color of the joystick && puck
  125394. */
  125395. color: string;
  125396. /**
  125397. * Image URL for the joystick's puck
  125398. */
  125399. puckImage?: string;
  125400. /**
  125401. * Image URL for the joystick's container
  125402. */
  125403. containerImage?: string;
  125404. /**
  125405. * Defines the unmoving position of the joystick container
  125406. */
  125407. position?: {
  125408. x: number;
  125409. y: number;
  125410. };
  125411. /**
  125412. * Defines whether or not the joystick container is always visible
  125413. */
  125414. alwaysVisible: boolean;
  125415. /**
  125416. * Defines whether or not to limit the movement of the puck to the joystick's container
  125417. */
  125418. limitToContainer: boolean;
  125419. }
  125420. /**
  125421. * Class used to define virtual joystick (used in touch mode)
  125422. */
  125423. export class VirtualJoystick {
  125424. /**
  125425. * Gets or sets a boolean indicating that left and right values must be inverted
  125426. */
  125427. reverseLeftRight: boolean;
  125428. /**
  125429. * Gets or sets a boolean indicating that up and down values must be inverted
  125430. */
  125431. reverseUpDown: boolean;
  125432. /**
  125433. * Gets the offset value for the position (ie. the change of the position value)
  125434. */
  125435. deltaPosition: Vector3;
  125436. /**
  125437. * Gets a boolean indicating if the virtual joystick was pressed
  125438. */
  125439. pressed: boolean;
  125440. /**
  125441. * Canvas the virtual joystick will render onto, default z-index of this is 5
  125442. */
  125443. static Canvas: Nullable<HTMLCanvasElement>;
  125444. /**
  125445. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  125446. */
  125447. limitToContainer: boolean;
  125448. private static _globalJoystickIndex;
  125449. private static _alwaysVisibleSticks;
  125450. private static vjCanvasContext;
  125451. private static vjCanvasWidth;
  125452. private static vjCanvasHeight;
  125453. private static halfWidth;
  125454. private static _GetDefaultOptions;
  125455. private _action;
  125456. private _axisTargetedByLeftAndRight;
  125457. private _axisTargetedByUpAndDown;
  125458. private _joystickSensibility;
  125459. private _inversedSensibility;
  125460. private _joystickPointerID;
  125461. private _joystickColor;
  125462. private _joystickPointerPos;
  125463. private _joystickPreviousPointerPos;
  125464. private _joystickPointerStartPos;
  125465. private _deltaJoystickVector;
  125466. private _leftJoystick;
  125467. private _touches;
  125468. private _joystickPosition;
  125469. private _alwaysVisible;
  125470. private _puckImage;
  125471. private _containerImage;
  125472. private _joystickPuckSize;
  125473. private _joystickContainerSize;
  125474. private _clearPuckSize;
  125475. private _clearContainerSize;
  125476. private _clearPuckSizeOffset;
  125477. private _clearContainerSizeOffset;
  125478. private _onPointerDownHandlerRef;
  125479. private _onPointerMoveHandlerRef;
  125480. private _onPointerUpHandlerRef;
  125481. private _onResize;
  125482. /**
  125483. * Creates a new virtual joystick
  125484. * @param leftJoystick defines that the joystick is for left hand (false by default)
  125485. * @param customizations Defines the options we want to customize the VirtualJoystick
  125486. */
  125487. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  125488. /**
  125489. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  125490. * @param newJoystickSensibility defines the new sensibility
  125491. */
  125492. setJoystickSensibility(newJoystickSensibility: number): void;
  125493. private _onPointerDown;
  125494. private _onPointerMove;
  125495. private _onPointerUp;
  125496. /**
  125497. * Change the color of the virtual joystick
  125498. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  125499. */
  125500. setJoystickColor(newColor: string): void;
  125501. /**
  125502. * Size of the joystick's container
  125503. */
  125504. set containerSize(newSize: number);
  125505. get containerSize(): number;
  125506. /**
  125507. * Size of the joystick's puck
  125508. */
  125509. set puckSize(newSize: number);
  125510. get puckSize(): number;
  125511. /**
  125512. * Clears the set position of the joystick
  125513. */
  125514. clearPosition(): void;
  125515. /**
  125516. * Defines whether or not the joystick container is always visible
  125517. */
  125518. set alwaysVisible(value: boolean);
  125519. get alwaysVisible(): boolean;
  125520. /**
  125521. * Sets the constant position of the Joystick container
  125522. * @param x X axis coordinate
  125523. * @param y Y axis coordinate
  125524. */
  125525. setPosition(x: number, y: number): void;
  125526. /**
  125527. * Defines a callback to call when the joystick is touched
  125528. * @param action defines the callback
  125529. */
  125530. setActionOnTouch(action: () => any): void;
  125531. /**
  125532. * Defines which axis you'd like to control for left & right
  125533. * @param axis defines the axis to use
  125534. */
  125535. setAxisForLeftRight(axis: JoystickAxis): void;
  125536. /**
  125537. * Defines which axis you'd like to control for up & down
  125538. * @param axis defines the axis to use
  125539. */
  125540. setAxisForUpDown(axis: JoystickAxis): void;
  125541. /**
  125542. * Clears the canvas from the previous puck / container draw
  125543. */
  125544. private _clearPreviousDraw;
  125545. /**
  125546. * Loads `urlPath` to be used for the container's image
  125547. * @param urlPath defines the urlPath of an image to use
  125548. */
  125549. setContainerImage(urlPath: string): void;
  125550. /**
  125551. * Loads `urlPath` to be used for the puck's image
  125552. * @param urlPath defines the urlPath of an image to use
  125553. */
  125554. setPuckImage(urlPath: string): void;
  125555. /**
  125556. * Draws the Virtual Joystick's container
  125557. */
  125558. private _drawContainer;
  125559. /**
  125560. * Draws the Virtual Joystick's puck
  125561. */
  125562. private _drawPuck;
  125563. private _drawVirtualJoystick;
  125564. /**
  125565. * Release internal HTML canvas
  125566. */
  125567. releaseCanvas(): void;
  125568. }
  125569. }
  125570. declare module BABYLON {
  125571. interface FreeCameraInputsManager {
  125572. /**
  125573. * Add virtual joystick input support to the input manager.
  125574. * @returns the current input manager
  125575. */
  125576. addVirtualJoystick(): FreeCameraInputsManager;
  125577. }
  125578. /**
  125579. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125580. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125581. */
  125582. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125583. /**
  125584. * Defines the camera the input is attached to.
  125585. */
  125586. camera: FreeCamera;
  125587. private _leftjoystick;
  125588. private _rightjoystick;
  125589. /**
  125590. * Gets the left stick of the virtual joystick.
  125591. * @returns The virtual Joystick
  125592. */
  125593. getLeftJoystick(): VirtualJoystick;
  125594. /**
  125595. * Gets the right stick of the virtual joystick.
  125596. * @returns The virtual Joystick
  125597. */
  125598. getRightJoystick(): VirtualJoystick;
  125599. /**
  125600. * Update the current camera state depending on the inputs that have been used this frame.
  125601. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125602. */
  125603. checkInputs(): void;
  125604. /**
  125605. * Attach the input controls to a specific dom element to get the input from.
  125606. * @param element Defines the element the controls should be listened from
  125607. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125608. */
  125609. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125610. /**
  125611. * Detach the current controls from the specified dom element.
  125612. * @param element Defines the element to stop listening the inputs from
  125613. */
  125614. detachControl(element: Nullable<HTMLElement>): void;
  125615. /**
  125616. * Gets the class name of the current intput.
  125617. * @returns the class name
  125618. */
  125619. getClassName(): string;
  125620. /**
  125621. * Get the friendly name associated with the input class.
  125622. * @returns the input friendly name
  125623. */
  125624. getSimpleName(): string;
  125625. }
  125626. }
  125627. declare module BABYLON {
  125628. /**
  125629. * This represents a FPS type of camera controlled by touch.
  125630. * This is like a universal camera minus the Gamepad controls.
  125631. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125632. */
  125633. export class TouchCamera extends FreeCamera {
  125634. /**
  125635. * Defines the touch sensibility for rotation.
  125636. * The higher the faster.
  125637. */
  125638. get touchAngularSensibility(): number;
  125639. set touchAngularSensibility(value: number);
  125640. /**
  125641. * Defines the touch sensibility for move.
  125642. * The higher the faster.
  125643. */
  125644. get touchMoveSensibility(): number;
  125645. set touchMoveSensibility(value: number);
  125646. /**
  125647. * Instantiates a new touch camera.
  125648. * This represents a FPS type of camera controlled by touch.
  125649. * This is like a universal camera minus the Gamepad controls.
  125650. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125651. * @param name Define the name of the camera in the scene
  125652. * @param position Define the start position of the camera in the scene
  125653. * @param scene Define the scene the camera belongs to
  125654. */
  125655. constructor(name: string, position: Vector3, scene: Scene);
  125656. /**
  125657. * Gets the current object class name.
  125658. * @return the class name
  125659. */
  125660. getClassName(): string;
  125661. /** @hidden */
  125662. _setupInputs(): void;
  125663. }
  125664. }
  125665. declare module BABYLON {
  125666. /**
  125667. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  125668. * being tilted forward or back and left or right.
  125669. */
  125670. export class DeviceOrientationCamera extends FreeCamera {
  125671. private _initialQuaternion;
  125672. private _quaternionCache;
  125673. private _tmpDragQuaternion;
  125674. private _disablePointerInputWhenUsingDeviceOrientation;
  125675. /**
  125676. * Creates a new device orientation camera
  125677. * @param name The name of the camera
  125678. * @param position The start position camera
  125679. * @param scene The scene the camera belongs to
  125680. */
  125681. constructor(name: string, position: Vector3, scene: Scene);
  125682. /**
  125683. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  125684. */
  125685. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  125686. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  125687. private _dragFactor;
  125688. /**
  125689. * Enabled turning on the y axis when the orientation sensor is active
  125690. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  125691. */
  125692. enableHorizontalDragging(dragFactor?: number): void;
  125693. /**
  125694. * Gets the current instance class name ("DeviceOrientationCamera").
  125695. * This helps avoiding instanceof at run time.
  125696. * @returns the class name
  125697. */
  125698. getClassName(): string;
  125699. /**
  125700. * @hidden
  125701. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  125702. */
  125703. _checkInputs(): void;
  125704. /**
  125705. * Reset the camera to its default orientation on the specified axis only.
  125706. * @param axis The axis to reset
  125707. */
  125708. resetToCurrentRotation(axis?: Axis): void;
  125709. }
  125710. }
  125711. declare module BABYLON {
  125712. /**
  125713. * Defines supported buttons for XBox360 compatible gamepads
  125714. */
  125715. export enum Xbox360Button {
  125716. /** A */
  125717. A = 0,
  125718. /** B */
  125719. B = 1,
  125720. /** X */
  125721. X = 2,
  125722. /** Y */
  125723. Y = 3,
  125724. /** Left button */
  125725. LB = 4,
  125726. /** Right button */
  125727. RB = 5,
  125728. /** Back */
  125729. Back = 8,
  125730. /** Start */
  125731. Start = 9,
  125732. /** Left stick */
  125733. LeftStick = 10,
  125734. /** Right stick */
  125735. RightStick = 11
  125736. }
  125737. /** Defines values for XBox360 DPad */
  125738. export enum Xbox360Dpad {
  125739. /** Up */
  125740. Up = 12,
  125741. /** Down */
  125742. Down = 13,
  125743. /** Left */
  125744. Left = 14,
  125745. /** Right */
  125746. Right = 15
  125747. }
  125748. /**
  125749. * Defines a XBox360 gamepad
  125750. */
  125751. export class Xbox360Pad extends Gamepad {
  125752. private _leftTrigger;
  125753. private _rightTrigger;
  125754. private _onlefttriggerchanged;
  125755. private _onrighttriggerchanged;
  125756. private _onbuttondown;
  125757. private _onbuttonup;
  125758. private _ondpaddown;
  125759. private _ondpadup;
  125760. /** Observable raised when a button is pressed */
  125761. onButtonDownObservable: Observable<Xbox360Button>;
  125762. /** Observable raised when a button is released */
  125763. onButtonUpObservable: Observable<Xbox360Button>;
  125764. /** Observable raised when a pad is pressed */
  125765. onPadDownObservable: Observable<Xbox360Dpad>;
  125766. /** Observable raised when a pad is released */
  125767. onPadUpObservable: Observable<Xbox360Dpad>;
  125768. private _buttonA;
  125769. private _buttonB;
  125770. private _buttonX;
  125771. private _buttonY;
  125772. private _buttonBack;
  125773. private _buttonStart;
  125774. private _buttonLB;
  125775. private _buttonRB;
  125776. private _buttonLeftStick;
  125777. private _buttonRightStick;
  125778. private _dPadUp;
  125779. private _dPadDown;
  125780. private _dPadLeft;
  125781. private _dPadRight;
  125782. private _isXboxOnePad;
  125783. /**
  125784. * Creates a new XBox360 gamepad object
  125785. * @param id defines the id of this gamepad
  125786. * @param index defines its index
  125787. * @param gamepad defines the internal HTML gamepad object
  125788. * @param xboxOne defines if it is a XBox One gamepad
  125789. */
  125790. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125791. /**
  125792. * Defines the callback to call when left trigger is pressed
  125793. * @param callback defines the callback to use
  125794. */
  125795. onlefttriggerchanged(callback: (value: number) => void): void;
  125796. /**
  125797. * Defines the callback to call when right trigger is pressed
  125798. * @param callback defines the callback to use
  125799. */
  125800. onrighttriggerchanged(callback: (value: number) => void): void;
  125801. /**
  125802. * Gets the left trigger value
  125803. */
  125804. get leftTrigger(): number;
  125805. /**
  125806. * Sets the left trigger value
  125807. */
  125808. set leftTrigger(newValue: number);
  125809. /**
  125810. * Gets the right trigger value
  125811. */
  125812. get rightTrigger(): number;
  125813. /**
  125814. * Sets the right trigger value
  125815. */
  125816. set rightTrigger(newValue: number);
  125817. /**
  125818. * Defines the callback to call when a button is pressed
  125819. * @param callback defines the callback to use
  125820. */
  125821. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125822. /**
  125823. * Defines the callback to call when a button is released
  125824. * @param callback defines the callback to use
  125825. */
  125826. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125827. /**
  125828. * Defines the callback to call when a pad is pressed
  125829. * @param callback defines the callback to use
  125830. */
  125831. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125832. /**
  125833. * Defines the callback to call when a pad is released
  125834. * @param callback defines the callback to use
  125835. */
  125836. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125837. private _setButtonValue;
  125838. private _setDPadValue;
  125839. /**
  125840. * Gets the value of the `A` button
  125841. */
  125842. get buttonA(): number;
  125843. /**
  125844. * Sets the value of the `A` button
  125845. */
  125846. set buttonA(value: number);
  125847. /**
  125848. * Gets the value of the `B` button
  125849. */
  125850. get buttonB(): number;
  125851. /**
  125852. * Sets the value of the `B` button
  125853. */
  125854. set buttonB(value: number);
  125855. /**
  125856. * Gets the value of the `X` button
  125857. */
  125858. get buttonX(): number;
  125859. /**
  125860. * Sets the value of the `X` button
  125861. */
  125862. set buttonX(value: number);
  125863. /**
  125864. * Gets the value of the `Y` button
  125865. */
  125866. get buttonY(): number;
  125867. /**
  125868. * Sets the value of the `Y` button
  125869. */
  125870. set buttonY(value: number);
  125871. /**
  125872. * Gets the value of the `Start` button
  125873. */
  125874. get buttonStart(): number;
  125875. /**
  125876. * Sets the value of the `Start` button
  125877. */
  125878. set buttonStart(value: number);
  125879. /**
  125880. * Gets the value of the `Back` button
  125881. */
  125882. get buttonBack(): number;
  125883. /**
  125884. * Sets the value of the `Back` button
  125885. */
  125886. set buttonBack(value: number);
  125887. /**
  125888. * Gets the value of the `Left` button
  125889. */
  125890. get buttonLB(): number;
  125891. /**
  125892. * Sets the value of the `Left` button
  125893. */
  125894. set buttonLB(value: number);
  125895. /**
  125896. * Gets the value of the `Right` button
  125897. */
  125898. get buttonRB(): number;
  125899. /**
  125900. * Sets the value of the `Right` button
  125901. */
  125902. set buttonRB(value: number);
  125903. /**
  125904. * Gets the value of the Left joystick
  125905. */
  125906. get buttonLeftStick(): number;
  125907. /**
  125908. * Sets the value of the Left joystick
  125909. */
  125910. set buttonLeftStick(value: number);
  125911. /**
  125912. * Gets the value of the Right joystick
  125913. */
  125914. get buttonRightStick(): number;
  125915. /**
  125916. * Sets the value of the Right joystick
  125917. */
  125918. set buttonRightStick(value: number);
  125919. /**
  125920. * Gets the value of D-pad up
  125921. */
  125922. get dPadUp(): number;
  125923. /**
  125924. * Sets the value of D-pad up
  125925. */
  125926. set dPadUp(value: number);
  125927. /**
  125928. * Gets the value of D-pad down
  125929. */
  125930. get dPadDown(): number;
  125931. /**
  125932. * Sets the value of D-pad down
  125933. */
  125934. set dPadDown(value: number);
  125935. /**
  125936. * Gets the value of D-pad left
  125937. */
  125938. get dPadLeft(): number;
  125939. /**
  125940. * Sets the value of D-pad left
  125941. */
  125942. set dPadLeft(value: number);
  125943. /**
  125944. * Gets the value of D-pad right
  125945. */
  125946. get dPadRight(): number;
  125947. /**
  125948. * Sets the value of D-pad right
  125949. */
  125950. set dPadRight(value: number);
  125951. /**
  125952. * Force the gamepad to synchronize with device values
  125953. */
  125954. update(): void;
  125955. /**
  125956. * Disposes the gamepad
  125957. */
  125958. dispose(): void;
  125959. }
  125960. }
  125961. declare module BABYLON {
  125962. /**
  125963. * Defines supported buttons for DualShock compatible gamepads
  125964. */
  125965. export enum DualShockButton {
  125966. /** Cross */
  125967. Cross = 0,
  125968. /** Circle */
  125969. Circle = 1,
  125970. /** Square */
  125971. Square = 2,
  125972. /** Triangle */
  125973. Triangle = 3,
  125974. /** L1 */
  125975. L1 = 4,
  125976. /** R1 */
  125977. R1 = 5,
  125978. /** Share */
  125979. Share = 8,
  125980. /** Options */
  125981. Options = 9,
  125982. /** Left stick */
  125983. LeftStick = 10,
  125984. /** Right stick */
  125985. RightStick = 11
  125986. }
  125987. /** Defines values for DualShock DPad */
  125988. export enum DualShockDpad {
  125989. /** Up */
  125990. Up = 12,
  125991. /** Down */
  125992. Down = 13,
  125993. /** Left */
  125994. Left = 14,
  125995. /** Right */
  125996. Right = 15
  125997. }
  125998. /**
  125999. * Defines a DualShock gamepad
  126000. */
  126001. export class DualShockPad extends Gamepad {
  126002. private _leftTrigger;
  126003. private _rightTrigger;
  126004. private _onlefttriggerchanged;
  126005. private _onrighttriggerchanged;
  126006. private _onbuttondown;
  126007. private _onbuttonup;
  126008. private _ondpaddown;
  126009. private _ondpadup;
  126010. /** Observable raised when a button is pressed */
  126011. onButtonDownObservable: Observable<DualShockButton>;
  126012. /** Observable raised when a button is released */
  126013. onButtonUpObservable: Observable<DualShockButton>;
  126014. /** Observable raised when a pad is pressed */
  126015. onPadDownObservable: Observable<DualShockDpad>;
  126016. /** Observable raised when a pad is released */
  126017. onPadUpObservable: Observable<DualShockDpad>;
  126018. private _buttonCross;
  126019. private _buttonCircle;
  126020. private _buttonSquare;
  126021. private _buttonTriangle;
  126022. private _buttonShare;
  126023. private _buttonOptions;
  126024. private _buttonL1;
  126025. private _buttonR1;
  126026. private _buttonLeftStick;
  126027. private _buttonRightStick;
  126028. private _dPadUp;
  126029. private _dPadDown;
  126030. private _dPadLeft;
  126031. private _dPadRight;
  126032. /**
  126033. * Creates a new DualShock gamepad object
  126034. * @param id defines the id of this gamepad
  126035. * @param index defines its index
  126036. * @param gamepad defines the internal HTML gamepad object
  126037. */
  126038. constructor(id: string, index: number, gamepad: any);
  126039. /**
  126040. * Defines the callback to call when left trigger is pressed
  126041. * @param callback defines the callback to use
  126042. */
  126043. onlefttriggerchanged(callback: (value: number) => void): void;
  126044. /**
  126045. * Defines the callback to call when right trigger is pressed
  126046. * @param callback defines the callback to use
  126047. */
  126048. onrighttriggerchanged(callback: (value: number) => void): void;
  126049. /**
  126050. * Gets the left trigger value
  126051. */
  126052. get leftTrigger(): number;
  126053. /**
  126054. * Sets the left trigger value
  126055. */
  126056. set leftTrigger(newValue: number);
  126057. /**
  126058. * Gets the right trigger value
  126059. */
  126060. get rightTrigger(): number;
  126061. /**
  126062. * Sets the right trigger value
  126063. */
  126064. set rightTrigger(newValue: number);
  126065. /**
  126066. * Defines the callback to call when a button is pressed
  126067. * @param callback defines the callback to use
  126068. */
  126069. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  126070. /**
  126071. * Defines the callback to call when a button is released
  126072. * @param callback defines the callback to use
  126073. */
  126074. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  126075. /**
  126076. * Defines the callback to call when a pad is pressed
  126077. * @param callback defines the callback to use
  126078. */
  126079. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  126080. /**
  126081. * Defines the callback to call when a pad is released
  126082. * @param callback defines the callback to use
  126083. */
  126084. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  126085. private _setButtonValue;
  126086. private _setDPadValue;
  126087. /**
  126088. * Gets the value of the `Cross` button
  126089. */
  126090. get buttonCross(): number;
  126091. /**
  126092. * Sets the value of the `Cross` button
  126093. */
  126094. set buttonCross(value: number);
  126095. /**
  126096. * Gets the value of the `Circle` button
  126097. */
  126098. get buttonCircle(): number;
  126099. /**
  126100. * Sets the value of the `Circle` button
  126101. */
  126102. set buttonCircle(value: number);
  126103. /**
  126104. * Gets the value of the `Square` button
  126105. */
  126106. get buttonSquare(): number;
  126107. /**
  126108. * Sets the value of the `Square` button
  126109. */
  126110. set buttonSquare(value: number);
  126111. /**
  126112. * Gets the value of the `Triangle` button
  126113. */
  126114. get buttonTriangle(): number;
  126115. /**
  126116. * Sets the value of the `Triangle` button
  126117. */
  126118. set buttonTriangle(value: number);
  126119. /**
  126120. * Gets the value of the `Options` button
  126121. */
  126122. get buttonOptions(): number;
  126123. /**
  126124. * Sets the value of the `Options` button
  126125. */
  126126. set buttonOptions(value: number);
  126127. /**
  126128. * Gets the value of the `Share` button
  126129. */
  126130. get buttonShare(): number;
  126131. /**
  126132. * Sets the value of the `Share` button
  126133. */
  126134. set buttonShare(value: number);
  126135. /**
  126136. * Gets the value of the `L1` button
  126137. */
  126138. get buttonL1(): number;
  126139. /**
  126140. * Sets the value of the `L1` button
  126141. */
  126142. set buttonL1(value: number);
  126143. /**
  126144. * Gets the value of the `R1` button
  126145. */
  126146. get buttonR1(): number;
  126147. /**
  126148. * Sets the value of the `R1` button
  126149. */
  126150. set buttonR1(value: number);
  126151. /**
  126152. * Gets the value of the Left joystick
  126153. */
  126154. get buttonLeftStick(): number;
  126155. /**
  126156. * Sets the value of the Left joystick
  126157. */
  126158. set buttonLeftStick(value: number);
  126159. /**
  126160. * Gets the value of the Right joystick
  126161. */
  126162. get buttonRightStick(): number;
  126163. /**
  126164. * Sets the value of the Right joystick
  126165. */
  126166. set buttonRightStick(value: number);
  126167. /**
  126168. * Gets the value of D-pad up
  126169. */
  126170. get dPadUp(): number;
  126171. /**
  126172. * Sets the value of D-pad up
  126173. */
  126174. set dPadUp(value: number);
  126175. /**
  126176. * Gets the value of D-pad down
  126177. */
  126178. get dPadDown(): number;
  126179. /**
  126180. * Sets the value of D-pad down
  126181. */
  126182. set dPadDown(value: number);
  126183. /**
  126184. * Gets the value of D-pad left
  126185. */
  126186. get dPadLeft(): number;
  126187. /**
  126188. * Sets the value of D-pad left
  126189. */
  126190. set dPadLeft(value: number);
  126191. /**
  126192. * Gets the value of D-pad right
  126193. */
  126194. get dPadRight(): number;
  126195. /**
  126196. * Sets the value of D-pad right
  126197. */
  126198. set dPadRight(value: number);
  126199. /**
  126200. * Force the gamepad to synchronize with device values
  126201. */
  126202. update(): void;
  126203. /**
  126204. * Disposes the gamepad
  126205. */
  126206. dispose(): void;
  126207. }
  126208. }
  126209. declare module BABYLON {
  126210. /**
  126211. * Manager for handling gamepads
  126212. */
  126213. export class GamepadManager {
  126214. private _scene?;
  126215. private _babylonGamepads;
  126216. private _oneGamepadConnected;
  126217. /** @hidden */
  126218. _isMonitoring: boolean;
  126219. private _gamepadEventSupported;
  126220. private _gamepadSupport?;
  126221. /**
  126222. * observable to be triggered when the gamepad controller has been connected
  126223. */
  126224. onGamepadConnectedObservable: Observable<Gamepad>;
  126225. /**
  126226. * observable to be triggered when the gamepad controller has been disconnected
  126227. */
  126228. onGamepadDisconnectedObservable: Observable<Gamepad>;
  126229. private _onGamepadConnectedEvent;
  126230. private _onGamepadDisconnectedEvent;
  126231. /**
  126232. * Initializes the gamepad manager
  126233. * @param _scene BabylonJS scene
  126234. */
  126235. constructor(_scene?: Scene | undefined);
  126236. /**
  126237. * The gamepads in the game pad manager
  126238. */
  126239. get gamepads(): Gamepad[];
  126240. /**
  126241. * Get the gamepad controllers based on type
  126242. * @param type The type of gamepad controller
  126243. * @returns Nullable gamepad
  126244. */
  126245. getGamepadByType(type?: number): Nullable<Gamepad>;
  126246. /**
  126247. * Disposes the gamepad manager
  126248. */
  126249. dispose(): void;
  126250. private _addNewGamepad;
  126251. private _startMonitoringGamepads;
  126252. private _stopMonitoringGamepads;
  126253. /** @hidden */
  126254. _checkGamepadsStatus(): void;
  126255. private _updateGamepadObjects;
  126256. }
  126257. }
  126258. declare module BABYLON {
  126259. interface Scene {
  126260. /** @hidden */
  126261. _gamepadManager: Nullable<GamepadManager>;
  126262. /**
  126263. * Gets the gamepad manager associated with the scene
  126264. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  126265. */
  126266. gamepadManager: GamepadManager;
  126267. }
  126268. /**
  126269. * Interface representing a free camera inputs manager
  126270. */
  126271. interface FreeCameraInputsManager {
  126272. /**
  126273. * Adds gamepad input support to the FreeCameraInputsManager.
  126274. * @returns the FreeCameraInputsManager
  126275. */
  126276. addGamepad(): FreeCameraInputsManager;
  126277. }
  126278. /**
  126279. * Interface representing an arc rotate camera inputs manager
  126280. */
  126281. interface ArcRotateCameraInputsManager {
  126282. /**
  126283. * Adds gamepad input support to the ArcRotateCamera InputManager.
  126284. * @returns the camera inputs manager
  126285. */
  126286. addGamepad(): ArcRotateCameraInputsManager;
  126287. }
  126288. /**
  126289. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  126290. */
  126291. export class GamepadSystemSceneComponent implements ISceneComponent {
  126292. /**
  126293. * The component name helpfull to identify the component in the list of scene components.
  126294. */
  126295. readonly name: string;
  126296. /**
  126297. * The scene the component belongs to.
  126298. */
  126299. scene: Scene;
  126300. /**
  126301. * Creates a new instance of the component for the given scene
  126302. * @param scene Defines the scene to register the component in
  126303. */
  126304. constructor(scene: Scene);
  126305. /**
  126306. * Registers the component in a given scene
  126307. */
  126308. register(): void;
  126309. /**
  126310. * Rebuilds the elements related to this component in case of
  126311. * context lost for instance.
  126312. */
  126313. rebuild(): void;
  126314. /**
  126315. * Disposes the component and the associated ressources
  126316. */
  126317. dispose(): void;
  126318. private _beforeCameraUpdate;
  126319. }
  126320. }
  126321. declare module BABYLON {
  126322. /**
  126323. * 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,
  126324. * which still works and will still be found in many Playgrounds.
  126325. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126326. */
  126327. export class UniversalCamera extends TouchCamera {
  126328. /**
  126329. * Defines the gamepad rotation sensiblity.
  126330. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  126331. */
  126332. get gamepadAngularSensibility(): number;
  126333. set gamepadAngularSensibility(value: number);
  126334. /**
  126335. * Defines the gamepad move sensiblity.
  126336. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  126337. */
  126338. get gamepadMoveSensibility(): number;
  126339. set gamepadMoveSensibility(value: number);
  126340. /**
  126341. * 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,
  126342. * which still works and will still be found in many Playgrounds.
  126343. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126344. * @param name Define the name of the camera in the scene
  126345. * @param position Define the start position of the camera in the scene
  126346. * @param scene Define the scene the camera belongs to
  126347. */
  126348. constructor(name: string, position: Vector3, scene: Scene);
  126349. /**
  126350. * Gets the current object class name.
  126351. * @return the class name
  126352. */
  126353. getClassName(): string;
  126354. }
  126355. }
  126356. declare module BABYLON {
  126357. /**
  126358. * This represents a FPS type of camera. This is only here for back compat purpose.
  126359. * Please use the UniversalCamera instead as both are identical.
  126360. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126361. */
  126362. export class GamepadCamera extends UniversalCamera {
  126363. /**
  126364. * Instantiates a new Gamepad Camera
  126365. * This represents a FPS type of camera. This is only here for back compat purpose.
  126366. * Please use the UniversalCamera instead as both are identical.
  126367. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126368. * @param name Define the name of the camera in the scene
  126369. * @param position Define the start position of the camera in the scene
  126370. * @param scene Define the scene the camera belongs to
  126371. */
  126372. constructor(name: string, position: Vector3, scene: Scene);
  126373. /**
  126374. * Gets the current object class name.
  126375. * @return the class name
  126376. */
  126377. getClassName(): string;
  126378. }
  126379. }
  126380. declare module BABYLON {
  126381. /** @hidden */
  126382. export var passPixelShader: {
  126383. name: string;
  126384. shader: string;
  126385. };
  126386. }
  126387. declare module BABYLON {
  126388. /** @hidden */
  126389. export var passCubePixelShader: {
  126390. name: string;
  126391. shader: string;
  126392. };
  126393. }
  126394. declare module BABYLON {
  126395. /**
  126396. * PassPostProcess which produces an output the same as it's input
  126397. */
  126398. export class PassPostProcess extends PostProcess {
  126399. /**
  126400. * Gets a string identifying the name of the class
  126401. * @returns "PassPostProcess" string
  126402. */
  126403. getClassName(): string;
  126404. /**
  126405. * Creates the PassPostProcess
  126406. * @param name The name of the effect.
  126407. * @param options The required width/height ratio to downsize to before computing the render pass.
  126408. * @param camera The camera to apply the render pass to.
  126409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126410. * @param engine The engine which the post process will be applied. (default: current engine)
  126411. * @param reusable If the post process can be reused on the same frame. (default: false)
  126412. * @param textureType The type of texture to be used when performing the post processing.
  126413. * @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)
  126414. */
  126415. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126416. /** @hidden */
  126417. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  126418. }
  126419. /**
  126420. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  126421. */
  126422. export class PassCubePostProcess extends PostProcess {
  126423. private _face;
  126424. /**
  126425. * Gets or sets the cube face to display.
  126426. * * 0 is +X
  126427. * * 1 is -X
  126428. * * 2 is +Y
  126429. * * 3 is -Y
  126430. * * 4 is +Z
  126431. * * 5 is -Z
  126432. */
  126433. get face(): number;
  126434. set face(value: number);
  126435. /**
  126436. * Gets a string identifying the name of the class
  126437. * @returns "PassCubePostProcess" string
  126438. */
  126439. getClassName(): string;
  126440. /**
  126441. * Creates the PassCubePostProcess
  126442. * @param name The name of the effect.
  126443. * @param options The required width/height ratio to downsize to before computing the render pass.
  126444. * @param camera The camera to apply the render pass to.
  126445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126446. * @param engine The engine which the post process will be applied. (default: current engine)
  126447. * @param reusable If the post process can be reused on the same frame. (default: false)
  126448. * @param textureType The type of texture to be used when performing the post processing.
  126449. * @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)
  126450. */
  126451. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126452. /** @hidden */
  126453. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  126454. }
  126455. }
  126456. declare module BABYLON {
  126457. /** @hidden */
  126458. export var anaglyphPixelShader: {
  126459. name: string;
  126460. shader: string;
  126461. };
  126462. }
  126463. declare module BABYLON {
  126464. /**
  126465. * Postprocess used to generate anaglyphic rendering
  126466. */
  126467. export class AnaglyphPostProcess extends PostProcess {
  126468. private _passedProcess;
  126469. /**
  126470. * Gets a string identifying the name of the class
  126471. * @returns "AnaglyphPostProcess" string
  126472. */
  126473. getClassName(): string;
  126474. /**
  126475. * Creates a new AnaglyphPostProcess
  126476. * @param name defines postprocess name
  126477. * @param options defines creation options or target ratio scale
  126478. * @param rigCameras defines cameras using this postprocess
  126479. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  126480. * @param engine defines hosting engine
  126481. * @param reusable defines if the postprocess will be reused multiple times per frame
  126482. */
  126483. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  126484. }
  126485. }
  126486. declare module BABYLON {
  126487. /**
  126488. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  126489. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126490. */
  126491. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  126492. /**
  126493. * Creates a new AnaglyphArcRotateCamera
  126494. * @param name defines camera name
  126495. * @param alpha defines alpha angle (in radians)
  126496. * @param beta defines beta angle (in radians)
  126497. * @param radius defines radius
  126498. * @param target defines camera target
  126499. * @param interaxialDistance defines distance between each color axis
  126500. * @param scene defines the hosting scene
  126501. */
  126502. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  126503. /**
  126504. * Gets camera class name
  126505. * @returns AnaglyphArcRotateCamera
  126506. */
  126507. getClassName(): string;
  126508. }
  126509. }
  126510. declare module BABYLON {
  126511. /**
  126512. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  126513. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126514. */
  126515. export class AnaglyphFreeCamera extends FreeCamera {
  126516. /**
  126517. * Creates a new AnaglyphFreeCamera
  126518. * @param name defines camera name
  126519. * @param position defines initial position
  126520. * @param interaxialDistance defines distance between each color axis
  126521. * @param scene defines the hosting scene
  126522. */
  126523. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126524. /**
  126525. * Gets camera class name
  126526. * @returns AnaglyphFreeCamera
  126527. */
  126528. getClassName(): string;
  126529. }
  126530. }
  126531. declare module BABYLON {
  126532. /**
  126533. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  126534. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126535. */
  126536. export class AnaglyphGamepadCamera extends GamepadCamera {
  126537. /**
  126538. * Creates a new AnaglyphGamepadCamera
  126539. * @param name defines camera name
  126540. * @param position defines initial position
  126541. * @param interaxialDistance defines distance between each color axis
  126542. * @param scene defines the hosting scene
  126543. */
  126544. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126545. /**
  126546. * Gets camera class name
  126547. * @returns AnaglyphGamepadCamera
  126548. */
  126549. getClassName(): string;
  126550. }
  126551. }
  126552. declare module BABYLON {
  126553. /**
  126554. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126555. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126556. */
  126557. export class AnaglyphUniversalCamera extends UniversalCamera {
  126558. /**
  126559. * Creates a new AnaglyphUniversalCamera
  126560. * @param name defines camera name
  126561. * @param position defines initial position
  126562. * @param interaxialDistance defines distance between each color axis
  126563. * @param scene defines the hosting scene
  126564. */
  126565. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126566. /**
  126567. * Gets camera class name
  126568. * @returns AnaglyphUniversalCamera
  126569. */
  126570. getClassName(): string;
  126571. }
  126572. }
  126573. declare module BABYLON {
  126574. /**
  126575. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126576. * @see https://doc.babylonjs.com/features/cameras
  126577. */
  126578. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126579. /**
  126580. * Creates a new StereoscopicArcRotateCamera
  126581. * @param name defines camera name
  126582. * @param alpha defines alpha angle (in radians)
  126583. * @param beta defines beta angle (in radians)
  126584. * @param radius defines radius
  126585. * @param target defines camera target
  126586. * @param interaxialDistance defines distance between each color axis
  126587. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126588. * @param scene defines the hosting scene
  126589. */
  126590. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126591. /**
  126592. * Gets camera class name
  126593. * @returns StereoscopicArcRotateCamera
  126594. */
  126595. getClassName(): string;
  126596. }
  126597. }
  126598. declare module BABYLON {
  126599. /**
  126600. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126601. * @see https://doc.babylonjs.com/features/cameras
  126602. */
  126603. export class StereoscopicFreeCamera extends FreeCamera {
  126604. /**
  126605. * Creates a new StereoscopicFreeCamera
  126606. * @param name defines camera name
  126607. * @param position defines initial position
  126608. * @param interaxialDistance defines distance between each color axis
  126609. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126610. * @param scene defines the hosting scene
  126611. */
  126612. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126613. /**
  126614. * Gets camera class name
  126615. * @returns StereoscopicFreeCamera
  126616. */
  126617. getClassName(): string;
  126618. }
  126619. }
  126620. declare module BABYLON {
  126621. /**
  126622. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126623. * @see https://doc.babylonjs.com/features/cameras
  126624. */
  126625. export class StereoscopicGamepadCamera extends GamepadCamera {
  126626. /**
  126627. * Creates a new StereoscopicGamepadCamera
  126628. * @param name defines camera name
  126629. * @param position defines initial position
  126630. * @param interaxialDistance defines distance between each color axis
  126631. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126632. * @param scene defines the hosting scene
  126633. */
  126634. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126635. /**
  126636. * Gets camera class name
  126637. * @returns StereoscopicGamepadCamera
  126638. */
  126639. getClassName(): string;
  126640. }
  126641. }
  126642. declare module BABYLON {
  126643. /**
  126644. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  126645. * @see https://doc.babylonjs.com/features/cameras
  126646. */
  126647. export class StereoscopicUniversalCamera extends UniversalCamera {
  126648. /**
  126649. * Creates a new StereoscopicUniversalCamera
  126650. * @param name defines camera name
  126651. * @param position defines initial position
  126652. * @param interaxialDistance defines distance between each color axis
  126653. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126654. * @param scene defines the hosting scene
  126655. */
  126656. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126657. /**
  126658. * Gets camera class name
  126659. * @returns StereoscopicUniversalCamera
  126660. */
  126661. getClassName(): string;
  126662. }
  126663. }
  126664. declare module BABYLON {
  126665. /**
  126666. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  126667. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126668. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126669. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126670. */
  126671. export class VirtualJoysticksCamera extends FreeCamera {
  126672. /**
  126673. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  126674. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126675. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126676. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126677. * @param name Define the name of the camera in the scene
  126678. * @param position Define the start position of the camera in the scene
  126679. * @param scene Define the scene the camera belongs to
  126680. */
  126681. constructor(name: string, position: Vector3, scene: Scene);
  126682. /**
  126683. * Gets the current object class name.
  126684. * @return the class name
  126685. */
  126686. getClassName(): string;
  126687. }
  126688. }
  126689. declare module BABYLON {
  126690. /**
  126691. * This represents all the required metrics to create a VR camera.
  126692. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  126693. */
  126694. export class VRCameraMetrics {
  126695. /**
  126696. * Define the horizontal resolution off the screen.
  126697. */
  126698. hResolution: number;
  126699. /**
  126700. * Define the vertical resolution off the screen.
  126701. */
  126702. vResolution: number;
  126703. /**
  126704. * Define the horizontal screen size.
  126705. */
  126706. hScreenSize: number;
  126707. /**
  126708. * Define the vertical screen size.
  126709. */
  126710. vScreenSize: number;
  126711. /**
  126712. * Define the vertical screen center position.
  126713. */
  126714. vScreenCenter: number;
  126715. /**
  126716. * Define the distance of the eyes to the screen.
  126717. */
  126718. eyeToScreenDistance: number;
  126719. /**
  126720. * Define the distance between both lenses
  126721. */
  126722. lensSeparationDistance: number;
  126723. /**
  126724. * Define the distance between both viewer's eyes.
  126725. */
  126726. interpupillaryDistance: number;
  126727. /**
  126728. * Define the distortion factor of the VR postprocess.
  126729. * Please, touch with care.
  126730. */
  126731. distortionK: number[];
  126732. /**
  126733. * Define the chromatic aberration correction factors for the VR post process.
  126734. */
  126735. chromaAbCorrection: number[];
  126736. /**
  126737. * Define the scale factor of the post process.
  126738. * The smaller the better but the slower.
  126739. */
  126740. postProcessScaleFactor: number;
  126741. /**
  126742. * Define an offset for the lens center.
  126743. */
  126744. lensCenterOffset: number;
  126745. /**
  126746. * Define if the current vr camera should compensate the distortion of the lense or not.
  126747. */
  126748. compensateDistortion: boolean;
  126749. /**
  126750. * Defines if multiview should be enabled when rendering (Default: false)
  126751. */
  126752. multiviewEnabled: boolean;
  126753. /**
  126754. * Gets the rendering aspect ratio based on the provided resolutions.
  126755. */
  126756. get aspectRatio(): number;
  126757. /**
  126758. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  126759. */
  126760. get aspectRatioFov(): number;
  126761. /**
  126762. * @hidden
  126763. */
  126764. get leftHMatrix(): Matrix;
  126765. /**
  126766. * @hidden
  126767. */
  126768. get rightHMatrix(): Matrix;
  126769. /**
  126770. * @hidden
  126771. */
  126772. get leftPreViewMatrix(): Matrix;
  126773. /**
  126774. * @hidden
  126775. */
  126776. get rightPreViewMatrix(): Matrix;
  126777. /**
  126778. * Get the default VRMetrics based on the most generic setup.
  126779. * @returns the default vr metrics
  126780. */
  126781. static GetDefault(): VRCameraMetrics;
  126782. }
  126783. }
  126784. declare module BABYLON {
  126785. /** @hidden */
  126786. export var vrDistortionCorrectionPixelShader: {
  126787. name: string;
  126788. shader: string;
  126789. };
  126790. }
  126791. declare module BABYLON {
  126792. /**
  126793. * VRDistortionCorrectionPostProcess used for mobile VR
  126794. */
  126795. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126796. private _isRightEye;
  126797. private _distortionFactors;
  126798. private _postProcessScaleFactor;
  126799. private _lensCenterOffset;
  126800. private _scaleIn;
  126801. private _scaleFactor;
  126802. private _lensCenter;
  126803. /**
  126804. * Gets a string identifying the name of the class
  126805. * @returns "VRDistortionCorrectionPostProcess" string
  126806. */
  126807. getClassName(): string;
  126808. /**
  126809. * Initializes the VRDistortionCorrectionPostProcess
  126810. * @param name The name of the effect.
  126811. * @param camera The camera to apply the render pass to.
  126812. * @param isRightEye If this is for the right eye distortion
  126813. * @param vrMetrics All the required metrics for the VR camera
  126814. */
  126815. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126816. }
  126817. }
  126818. declare module BABYLON {
  126819. /**
  126820. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126821. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126822. */
  126823. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126824. /**
  126825. * Creates a new VRDeviceOrientationArcRotateCamera
  126826. * @param name defines camera name
  126827. * @param alpha defines the camera rotation along the logitudinal axis
  126828. * @param beta defines the camera rotation along the latitudinal axis
  126829. * @param radius defines the camera distance from its target
  126830. * @param target defines the camera target
  126831. * @param scene defines the scene the camera belongs to
  126832. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126833. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126834. */
  126835. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126836. /**
  126837. * Gets camera class name
  126838. * @returns VRDeviceOrientationArcRotateCamera
  126839. */
  126840. getClassName(): string;
  126841. }
  126842. }
  126843. declare module BABYLON {
  126844. /**
  126845. * Camera used to simulate VR rendering (based on FreeCamera)
  126846. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126847. */
  126848. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126849. /**
  126850. * Creates a new VRDeviceOrientationFreeCamera
  126851. * @param name defines camera name
  126852. * @param position defines the start position of the camera
  126853. * @param scene defines the scene the camera belongs to
  126854. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126855. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126856. */
  126857. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126858. /**
  126859. * Gets camera class name
  126860. * @returns VRDeviceOrientationFreeCamera
  126861. */
  126862. getClassName(): string;
  126863. }
  126864. }
  126865. declare module BABYLON {
  126866. /**
  126867. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126868. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126869. */
  126870. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126871. /**
  126872. * Creates a new VRDeviceOrientationGamepadCamera
  126873. * @param name defines camera name
  126874. * @param position defines the start position of the camera
  126875. * @param scene defines the scene the camera belongs to
  126876. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126877. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126878. */
  126879. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126880. /**
  126881. * Gets camera class name
  126882. * @returns VRDeviceOrientationGamepadCamera
  126883. */
  126884. getClassName(): string;
  126885. }
  126886. }
  126887. declare module BABYLON {
  126888. /**
  126889. * A class extending Texture allowing drawing on a texture
  126890. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126891. */
  126892. export class DynamicTexture extends Texture {
  126893. private _generateMipMaps;
  126894. private _canvas;
  126895. private _context;
  126896. /**
  126897. * Creates a DynamicTexture
  126898. * @param name defines the name of the texture
  126899. * @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
  126900. * @param scene defines the scene where you want the texture
  126901. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  126902. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126903. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  126904. */
  126905. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  126906. /**
  126907. * Get the current class name of the texture useful for serialization or dynamic coding.
  126908. * @returns "DynamicTexture"
  126909. */
  126910. getClassName(): string;
  126911. /**
  126912. * Gets the current state of canRescale
  126913. */
  126914. get canRescale(): boolean;
  126915. private _recreate;
  126916. /**
  126917. * Scales the texture
  126918. * @param ratio the scale factor to apply to both width and height
  126919. */
  126920. scale(ratio: number): void;
  126921. /**
  126922. * Resizes the texture
  126923. * @param width the new width
  126924. * @param height the new height
  126925. */
  126926. scaleTo(width: number, height: number): void;
  126927. /**
  126928. * Gets the context of the canvas used by the texture
  126929. * @returns the canvas context of the dynamic texture
  126930. */
  126931. getContext(): CanvasRenderingContext2D;
  126932. /**
  126933. * Clears the texture
  126934. */
  126935. clear(): void;
  126936. /**
  126937. * Updates the texture
  126938. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126939. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  126940. */
  126941. update(invertY?: boolean, premulAlpha?: boolean): void;
  126942. /**
  126943. * Draws text onto the texture
  126944. * @param text defines the text to be drawn
  126945. * @param x defines the placement of the text from the left
  126946. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  126947. * @param font defines the font to be used with font-style, font-size, font-name
  126948. * @param color defines the color used for the text
  126949. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  126950. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126951. * @param update defines whether texture is immediately update (default is true)
  126952. */
  126953. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  126954. /**
  126955. * Clones the texture
  126956. * @returns the clone of the texture.
  126957. */
  126958. clone(): DynamicTexture;
  126959. /**
  126960. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  126961. * @returns a serialized dynamic texture object
  126962. */
  126963. serialize(): any;
  126964. private _IsCanvasElement;
  126965. /** @hidden */
  126966. _rebuild(): void;
  126967. }
  126968. }
  126969. declare module BABYLON {
  126970. /**
  126971. * Class containing static functions to help procedurally build meshes
  126972. */
  126973. export class GroundBuilder {
  126974. /**
  126975. * Creates a ground mesh
  126976. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126977. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126979. * @param name defines the name of the mesh
  126980. * @param options defines the options used to create the mesh
  126981. * @param scene defines the hosting scene
  126982. * @returns the ground mesh
  126983. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126984. */
  126985. static CreateGround(name: string, options: {
  126986. width?: number;
  126987. height?: number;
  126988. subdivisions?: number;
  126989. subdivisionsX?: number;
  126990. subdivisionsY?: number;
  126991. updatable?: boolean;
  126992. }, scene: any): Mesh;
  126993. /**
  126994. * Creates a tiled ground mesh
  126995. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  126996. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  126997. * * 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
  126998. * * 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
  126999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127000. * @param name defines the name of the mesh
  127001. * @param options defines the options used to create the mesh
  127002. * @param scene defines the hosting scene
  127003. * @returns the tiled ground mesh
  127004. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127005. */
  127006. static CreateTiledGround(name: string, options: {
  127007. xmin: number;
  127008. zmin: number;
  127009. xmax: number;
  127010. zmax: number;
  127011. subdivisions?: {
  127012. w: number;
  127013. h: number;
  127014. };
  127015. precision?: {
  127016. w: number;
  127017. h: number;
  127018. };
  127019. updatable?: boolean;
  127020. }, scene?: Nullable<Scene>): Mesh;
  127021. /**
  127022. * Creates a ground mesh from a height map
  127023. * * The parameter `url` sets the URL of the height map image resource.
  127024. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127025. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127026. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127027. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127028. * * 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.
  127029. * * 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).
  127030. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127032. * @param name defines the name of the mesh
  127033. * @param url defines the url to the height map
  127034. * @param options defines the options used to create the mesh
  127035. * @param scene defines the hosting scene
  127036. * @returns the ground mesh
  127037. * @see https://doc.babylonjs.com/babylon101/height_map
  127038. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127039. */
  127040. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127041. width?: number;
  127042. height?: number;
  127043. subdivisions?: number;
  127044. minHeight?: number;
  127045. maxHeight?: number;
  127046. colorFilter?: Color3;
  127047. alphaFilter?: number;
  127048. updatable?: boolean;
  127049. onReady?: (mesh: GroundMesh) => void;
  127050. }, scene?: Nullable<Scene>): GroundMesh;
  127051. }
  127052. }
  127053. declare module BABYLON {
  127054. /**
  127055. * Class containing static functions to help procedurally build meshes
  127056. */
  127057. export class TorusBuilder {
  127058. /**
  127059. * Creates a torus mesh
  127060. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127061. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127062. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127066. * @param name defines the name of the mesh
  127067. * @param options defines the options used to create the mesh
  127068. * @param scene defines the hosting scene
  127069. * @returns the torus mesh
  127070. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127071. */
  127072. static CreateTorus(name: string, options: {
  127073. diameter?: number;
  127074. thickness?: number;
  127075. tessellation?: number;
  127076. updatable?: boolean;
  127077. sideOrientation?: number;
  127078. frontUVs?: Vector4;
  127079. backUVs?: Vector4;
  127080. }, scene: any): Mesh;
  127081. }
  127082. }
  127083. declare module BABYLON {
  127084. /**
  127085. * Class containing static functions to help procedurally build meshes
  127086. */
  127087. export class CylinderBuilder {
  127088. /**
  127089. * Creates a cylinder or a cone mesh
  127090. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127091. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127092. * * 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.
  127093. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127094. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127095. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127096. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127097. * * 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).
  127098. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127099. * * 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).
  127100. * * 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
  127101. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127102. * * 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
  127103. * * 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.
  127104. * * If `enclose` is false, a ring surface is one element.
  127105. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127106. * * 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
  127107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127110. * @param name defines the name of the mesh
  127111. * @param options defines the options used to create the mesh
  127112. * @param scene defines the hosting scene
  127113. * @returns the cylinder mesh
  127114. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127115. */
  127116. static CreateCylinder(name: string, options: {
  127117. height?: number;
  127118. diameterTop?: number;
  127119. diameterBottom?: number;
  127120. diameter?: number;
  127121. tessellation?: number;
  127122. subdivisions?: number;
  127123. arc?: number;
  127124. faceColors?: Color4[];
  127125. faceUV?: Vector4[];
  127126. updatable?: boolean;
  127127. hasRings?: boolean;
  127128. enclose?: boolean;
  127129. cap?: number;
  127130. sideOrientation?: number;
  127131. frontUVs?: Vector4;
  127132. backUVs?: Vector4;
  127133. }, scene: any): Mesh;
  127134. }
  127135. }
  127136. declare module BABYLON {
  127137. /**
  127138. * States of the webXR experience
  127139. */
  127140. export enum WebXRState {
  127141. /**
  127142. * Transitioning to being in XR mode
  127143. */
  127144. ENTERING_XR = 0,
  127145. /**
  127146. * Transitioning to non XR mode
  127147. */
  127148. EXITING_XR = 1,
  127149. /**
  127150. * In XR mode and presenting
  127151. */
  127152. IN_XR = 2,
  127153. /**
  127154. * Not entered XR mode
  127155. */
  127156. NOT_IN_XR = 3
  127157. }
  127158. /**
  127159. * Abstraction of the XR render target
  127160. */
  127161. export interface WebXRRenderTarget extends IDisposable {
  127162. /**
  127163. * xrpresent context of the canvas which can be used to display/mirror xr content
  127164. */
  127165. canvasContext: WebGLRenderingContext;
  127166. /**
  127167. * xr layer for the canvas
  127168. */
  127169. xrLayer: Nullable<XRWebGLLayer>;
  127170. /**
  127171. * Initializes the xr layer for the session
  127172. * @param xrSession xr session
  127173. * @returns a promise that will resolve once the XR Layer has been created
  127174. */
  127175. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127176. }
  127177. }
  127178. declare module BABYLON {
  127179. /**
  127180. * COnfiguration object for WebXR output canvas
  127181. */
  127182. export class WebXRManagedOutputCanvasOptions {
  127183. /**
  127184. * An optional canvas in case you wish to create it yourself and provide it here.
  127185. * If not provided, a new canvas will be created
  127186. */
  127187. canvasElement?: HTMLCanvasElement;
  127188. /**
  127189. * Options for this XR Layer output
  127190. */
  127191. canvasOptions?: XRWebGLLayerOptions;
  127192. /**
  127193. * CSS styling for a newly created canvas (if not provided)
  127194. */
  127195. newCanvasCssStyle?: string;
  127196. /**
  127197. * Get the default values of the configuration object
  127198. * @param engine defines the engine to use (can be null)
  127199. * @returns default values of this configuration object
  127200. */
  127201. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  127202. }
  127203. /**
  127204. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  127205. */
  127206. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  127207. private _options;
  127208. private _canvas;
  127209. private _engine;
  127210. private _originalCanvasSize;
  127211. /**
  127212. * Rendering context of the canvas which can be used to display/mirror xr content
  127213. */
  127214. canvasContext: WebGLRenderingContext;
  127215. /**
  127216. * xr layer for the canvas
  127217. */
  127218. xrLayer: Nullable<XRWebGLLayer>;
  127219. /**
  127220. * Obseervers registered here will be triggered when the xr layer was initialized
  127221. */
  127222. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  127223. /**
  127224. * Initializes the canvas to be added/removed upon entering/exiting xr
  127225. * @param _xrSessionManager The XR Session manager
  127226. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  127227. */
  127228. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  127229. /**
  127230. * Disposes of the object
  127231. */
  127232. dispose(): void;
  127233. /**
  127234. * Initializes the xr layer for the session
  127235. * @param xrSession xr session
  127236. * @returns a promise that will resolve once the XR Layer has been created
  127237. */
  127238. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127239. private _addCanvas;
  127240. private _removeCanvas;
  127241. private _setCanvasSize;
  127242. private _setManagedOutputCanvas;
  127243. }
  127244. }
  127245. declare module BABYLON {
  127246. /**
  127247. * Manages an XRSession to work with Babylon's engine
  127248. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  127249. */
  127250. export class WebXRSessionManager implements IDisposable {
  127251. /** The scene which the session should be created for */
  127252. scene: Scene;
  127253. private _referenceSpace;
  127254. private _rttProvider;
  127255. private _sessionEnded;
  127256. private _xrNavigator;
  127257. private baseLayer;
  127258. /**
  127259. * The base reference space from which the session started. good if you want to reset your
  127260. * reference space
  127261. */
  127262. baseReferenceSpace: XRReferenceSpace;
  127263. /**
  127264. * Current XR frame
  127265. */
  127266. currentFrame: Nullable<XRFrame>;
  127267. /** WebXR timestamp updated every frame */
  127268. currentTimestamp: number;
  127269. /**
  127270. * Used just in case of a failure to initialize an immersive session.
  127271. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  127272. */
  127273. defaultHeightCompensation: number;
  127274. /**
  127275. * Fires every time a new xrFrame arrives which can be used to update the camera
  127276. */
  127277. onXRFrameObservable: Observable<XRFrame>;
  127278. /**
  127279. * Fires when the reference space changed
  127280. */
  127281. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  127282. /**
  127283. * Fires when the xr session is ended either by the device or manually done
  127284. */
  127285. onXRSessionEnded: Observable<any>;
  127286. /**
  127287. * Fires when the xr session is ended either by the device or manually done
  127288. */
  127289. onXRSessionInit: Observable<XRSession>;
  127290. /**
  127291. * Underlying xr session
  127292. */
  127293. session: XRSession;
  127294. /**
  127295. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  127296. * or get the offset the player is currently at.
  127297. */
  127298. viewerReferenceSpace: XRReferenceSpace;
  127299. /**
  127300. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  127301. * @param scene The scene which the session should be created for
  127302. */
  127303. constructor(
  127304. /** The scene which the session should be created for */
  127305. scene: Scene);
  127306. /**
  127307. * The current reference space used in this session. This reference space can constantly change!
  127308. * It is mainly used to offset the camera's position.
  127309. */
  127310. get referenceSpace(): XRReferenceSpace;
  127311. /**
  127312. * Set a new reference space and triggers the observable
  127313. */
  127314. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  127315. /**
  127316. * Disposes of the session manager
  127317. */
  127318. dispose(): void;
  127319. /**
  127320. * Stops the xrSession and restores the render loop
  127321. * @returns Promise which resolves after it exits XR
  127322. */
  127323. exitXRAsync(): Promise<void>;
  127324. /**
  127325. * Gets the correct render target texture to be rendered this frame for this eye
  127326. * @param eye the eye for which to get the render target
  127327. * @returns the render target for the specified eye
  127328. */
  127329. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  127330. /**
  127331. * Creates a WebXRRenderTarget object for the XR session
  127332. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  127333. * @param options optional options to provide when creating a new render target
  127334. * @returns a WebXR render target to which the session can render
  127335. */
  127336. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  127337. /**
  127338. * Initializes the manager
  127339. * After initialization enterXR can be called to start an XR session
  127340. * @returns Promise which resolves after it is initialized
  127341. */
  127342. initializeAsync(): Promise<void>;
  127343. /**
  127344. * Initializes an xr session
  127345. * @param xrSessionMode mode to initialize
  127346. * @param xrSessionInit defines optional and required values to pass to the session builder
  127347. * @returns a promise which will resolve once the session has been initialized
  127348. */
  127349. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  127350. /**
  127351. * Checks if a session would be supported for the creation options specified
  127352. * @param sessionMode session mode to check if supported eg. immersive-vr
  127353. * @returns A Promise that resolves to true if supported and false if not
  127354. */
  127355. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127356. /**
  127357. * Resets the reference space to the one started the session
  127358. */
  127359. resetReferenceSpace(): void;
  127360. /**
  127361. * Starts rendering to the xr layer
  127362. */
  127363. runXRRenderLoop(): void;
  127364. /**
  127365. * Sets the reference space on the xr session
  127366. * @param referenceSpaceType space to set
  127367. * @returns a promise that will resolve once the reference space has been set
  127368. */
  127369. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127370. /**
  127371. * Updates the render state of the session
  127372. * @param state state to set
  127373. * @returns a promise that resolves once the render state has been updated
  127374. */
  127375. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  127376. /**
  127377. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  127378. * @param sessionMode defines the session to test
  127379. * @returns a promise with boolean as final value
  127380. */
  127381. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127382. private _createRenderTargetTexture;
  127383. }
  127384. }
  127385. declare module BABYLON {
  127386. /**
  127387. * WebXR Camera which holds the views for the xrSession
  127388. * @see https://doc.babylonjs.com/how_to/webxr_camera
  127389. */
  127390. export class WebXRCamera extends FreeCamera {
  127391. private _xrSessionManager;
  127392. private _firstFrame;
  127393. private _referenceQuaternion;
  127394. private _referencedPosition;
  127395. private _xrInvPositionCache;
  127396. private _xrInvQuaternionCache;
  127397. /**
  127398. * Observable raised before camera teleportation
  127399. */
  127400. onBeforeCameraTeleport: Observable<Vector3>;
  127401. /**
  127402. * Observable raised after camera teleportation
  127403. */
  127404. onAfterCameraTeleport: Observable<Vector3>;
  127405. /**
  127406. * Should position compensation execute on first frame.
  127407. * This is used when copying the position from a native (non XR) camera
  127408. */
  127409. compensateOnFirstFrame: boolean;
  127410. /**
  127411. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  127412. * @param name the name of the camera
  127413. * @param scene the scene to add the camera to
  127414. * @param _xrSessionManager a constructed xr session manager
  127415. */
  127416. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  127417. /**
  127418. * Return the user's height, unrelated to the current ground.
  127419. * This will be the y position of this camera, when ground level is 0.
  127420. */
  127421. get realWorldHeight(): number;
  127422. /** @hidden */
  127423. _updateForDualEyeDebugging(): void;
  127424. /**
  127425. * Sets this camera's transformation based on a non-vr camera
  127426. * @param otherCamera the non-vr camera to copy the transformation from
  127427. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  127428. */
  127429. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  127430. /**
  127431. * Gets the current instance class name ("WebXRCamera").
  127432. * @returns the class name
  127433. */
  127434. getClassName(): string;
  127435. private _rotate180;
  127436. private _updateFromXRSession;
  127437. private _updateNumberOfRigCameras;
  127438. private _updateReferenceSpace;
  127439. private _updateReferenceSpaceOffset;
  127440. }
  127441. }
  127442. declare module BABYLON {
  127443. /**
  127444. * Defining the interface required for a (webxr) feature
  127445. */
  127446. export interface IWebXRFeature extends IDisposable {
  127447. /**
  127448. * Is this feature attached
  127449. */
  127450. attached: boolean;
  127451. /**
  127452. * Should auto-attach be disabled?
  127453. */
  127454. disableAutoAttach: boolean;
  127455. /**
  127456. * Attach the feature to the session
  127457. * Will usually be called by the features manager
  127458. *
  127459. * @param force should attachment be forced (even when already attached)
  127460. * @returns true if successful.
  127461. */
  127462. attach(force?: boolean): boolean;
  127463. /**
  127464. * Detach the feature from the session
  127465. * Will usually be called by the features manager
  127466. *
  127467. * @returns true if successful.
  127468. */
  127469. detach(): boolean;
  127470. /**
  127471. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127472. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127473. *
  127474. * @returns whether or not the feature is compatible in this environment
  127475. */
  127476. isCompatible(): boolean;
  127477. /**
  127478. * Was this feature disposed;
  127479. */
  127480. isDisposed: boolean;
  127481. /**
  127482. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  127483. */
  127484. xrNativeFeatureName?: string;
  127485. /**
  127486. * A list of (Babylon WebXR) features this feature depends on
  127487. */
  127488. dependsOn?: string[];
  127489. }
  127490. /**
  127491. * A list of the currently available features without referencing them
  127492. */
  127493. export class WebXRFeatureName {
  127494. /**
  127495. * The name of the anchor system feature
  127496. */
  127497. static readonly ANCHOR_SYSTEM: string;
  127498. /**
  127499. * The name of the background remover feature
  127500. */
  127501. static readonly BACKGROUND_REMOVER: string;
  127502. /**
  127503. * The name of the hit test feature
  127504. */
  127505. static readonly HIT_TEST: string;
  127506. /**
  127507. * physics impostors for xr controllers feature
  127508. */
  127509. static readonly PHYSICS_CONTROLLERS: string;
  127510. /**
  127511. * The name of the plane detection feature
  127512. */
  127513. static readonly PLANE_DETECTION: string;
  127514. /**
  127515. * The name of the pointer selection feature
  127516. */
  127517. static readonly POINTER_SELECTION: string;
  127518. /**
  127519. * The name of the teleportation feature
  127520. */
  127521. static readonly TELEPORTATION: string;
  127522. /**
  127523. * The name of the feature points feature.
  127524. */
  127525. static readonly FEATURE_POINTS: string;
  127526. /**
  127527. * The name of the hand tracking feature.
  127528. */
  127529. static readonly HAND_TRACKING: string;
  127530. }
  127531. /**
  127532. * Defining the constructor of a feature. Used to register the modules.
  127533. */
  127534. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  127535. /**
  127536. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  127537. * It is mainly used in AR sessions.
  127538. *
  127539. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  127540. */
  127541. export class WebXRFeaturesManager implements IDisposable {
  127542. private _xrSessionManager;
  127543. private static readonly _AvailableFeatures;
  127544. private _features;
  127545. /**
  127546. * constructs a new features manages.
  127547. *
  127548. * @param _xrSessionManager an instance of WebXRSessionManager
  127549. */
  127550. constructor(_xrSessionManager: WebXRSessionManager);
  127551. /**
  127552. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127553. * Mainly used internally.
  127554. *
  127555. * @param featureName the name of the feature to register
  127556. * @param constructorFunction the function used to construct the module
  127557. * @param version the (babylon) version of the module
  127558. * @param stable is that a stable version of this module
  127559. */
  127560. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127561. /**
  127562. * Returns a constructor of a specific feature.
  127563. *
  127564. * @param featureName the name of the feature to construct
  127565. * @param version the version of the feature to load
  127566. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127567. * @param options optional options provided to the module.
  127568. * @returns a function that, when called, will return a new instance of this feature
  127569. */
  127570. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127571. /**
  127572. * Can be used to return the list of features currently registered
  127573. *
  127574. * @returns an Array of available features
  127575. */
  127576. static GetAvailableFeatures(): string[];
  127577. /**
  127578. * Gets the versions available for a specific feature
  127579. * @param featureName the name of the feature
  127580. * @returns an array with the available versions
  127581. */
  127582. static GetAvailableVersions(featureName: string): string[];
  127583. /**
  127584. * Return the latest unstable version of this feature
  127585. * @param featureName the name of the feature to search
  127586. * @returns the version number. if not found will return -1
  127587. */
  127588. static GetLatestVersionOfFeature(featureName: string): number;
  127589. /**
  127590. * Return the latest stable version of this feature
  127591. * @param featureName the name of the feature to search
  127592. * @returns the version number. if not found will return -1
  127593. */
  127594. static GetStableVersionOfFeature(featureName: string): number;
  127595. /**
  127596. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127597. * Can be used during a session to start a feature
  127598. * @param featureName the name of feature to attach
  127599. */
  127600. attachFeature(featureName: string): void;
  127601. /**
  127602. * Can be used inside a session or when the session ends to detach a specific feature
  127603. * @param featureName the name of the feature to detach
  127604. */
  127605. detachFeature(featureName: string): void;
  127606. /**
  127607. * Used to disable an already-enabled feature
  127608. * The feature will be disposed and will be recreated once enabled.
  127609. * @param featureName the feature to disable
  127610. * @returns true if disable was successful
  127611. */
  127612. disableFeature(featureName: string | {
  127613. Name: string;
  127614. }): boolean;
  127615. /**
  127616. * dispose this features manager
  127617. */
  127618. dispose(): void;
  127619. /**
  127620. * 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.
  127621. * 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.
  127622. *
  127623. * @param featureName the name of the feature to load or the class of the feature
  127624. * @param version optional version to load. if not provided the latest version will be enabled
  127625. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127626. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127627. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127628. * @returns a new constructed feature or throws an error if feature not found.
  127629. */
  127630. enableFeature(featureName: string | {
  127631. Name: string;
  127632. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127633. /**
  127634. * get the implementation of an enabled feature.
  127635. * @param featureName the name of the feature to load
  127636. * @returns the feature class, if found
  127637. */
  127638. getEnabledFeature(featureName: string): IWebXRFeature;
  127639. /**
  127640. * Get the list of enabled features
  127641. * @returns an array of enabled features
  127642. */
  127643. getEnabledFeatures(): string[];
  127644. /**
  127645. * This function will exten the session creation configuration object with enabled features.
  127646. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  127647. * according to the defined "required" variable, provided during enableFeature call
  127648. * @param xrSessionInit the xr Session init object to extend
  127649. *
  127650. * @returns an extended XRSessionInit object
  127651. */
  127652. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  127653. }
  127654. }
  127655. declare module BABYLON {
  127656. /**
  127657. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  127658. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  127659. */
  127660. export class WebXRExperienceHelper implements IDisposable {
  127661. private scene;
  127662. private _nonVRCamera;
  127663. private _originalSceneAutoClear;
  127664. private _supported;
  127665. /**
  127666. * Camera used to render xr content
  127667. */
  127668. camera: WebXRCamera;
  127669. /** A features manager for this xr session */
  127670. featuresManager: WebXRFeaturesManager;
  127671. /**
  127672. * Observers registered here will be triggered after the camera's initial transformation is set
  127673. * This can be used to set a different ground level or an extra rotation.
  127674. *
  127675. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  127676. * to the position set after this observable is done executing.
  127677. */
  127678. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  127679. /**
  127680. * Fires when the state of the experience helper has changed
  127681. */
  127682. onStateChangedObservable: Observable<WebXRState>;
  127683. /** Session manager used to keep track of xr session */
  127684. sessionManager: WebXRSessionManager;
  127685. /**
  127686. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  127687. */
  127688. state: WebXRState;
  127689. /**
  127690. * Creates a WebXRExperienceHelper
  127691. * @param scene The scene the helper should be created in
  127692. */
  127693. private constructor();
  127694. /**
  127695. * Creates the experience helper
  127696. * @param scene the scene to attach the experience helper to
  127697. * @returns a promise for the experience helper
  127698. */
  127699. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  127700. /**
  127701. * Disposes of the experience helper
  127702. */
  127703. dispose(): void;
  127704. /**
  127705. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  127706. * @param sessionMode options for the XR session
  127707. * @param referenceSpaceType frame of reference of the XR session
  127708. * @param renderTarget the output canvas that will be used to enter XR mode
  127709. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  127710. * @returns promise that resolves after xr mode has entered
  127711. */
  127712. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  127713. /**
  127714. * Exits XR mode and returns the scene to its original state
  127715. * @returns promise that resolves after xr mode has exited
  127716. */
  127717. exitXRAsync(): Promise<void>;
  127718. private _nonXRToXRCamera;
  127719. private _setState;
  127720. }
  127721. }
  127722. declare module BABYLON {
  127723. /**
  127724. * X-Y values for axes in WebXR
  127725. */
  127726. export interface IWebXRMotionControllerAxesValue {
  127727. /**
  127728. * The value of the x axis
  127729. */
  127730. x: number;
  127731. /**
  127732. * The value of the y-axis
  127733. */
  127734. y: number;
  127735. }
  127736. /**
  127737. * changed / previous values for the values of this component
  127738. */
  127739. export interface IWebXRMotionControllerComponentChangesValues<T> {
  127740. /**
  127741. * current (this frame) value
  127742. */
  127743. current: T;
  127744. /**
  127745. * previous (last change) value
  127746. */
  127747. previous: T;
  127748. }
  127749. /**
  127750. * Represents changes in the component between current frame and last values recorded
  127751. */
  127752. export interface IWebXRMotionControllerComponentChanges {
  127753. /**
  127754. * will be populated with previous and current values if axes changed
  127755. */
  127756. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  127757. /**
  127758. * will be populated with previous and current values if pressed changed
  127759. */
  127760. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127761. /**
  127762. * will be populated with previous and current values if touched changed
  127763. */
  127764. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127765. /**
  127766. * will be populated with previous and current values if value changed
  127767. */
  127768. value?: IWebXRMotionControllerComponentChangesValues<number>;
  127769. }
  127770. /**
  127771. * This class represents a single component (for example button or thumbstick) of a motion controller
  127772. */
  127773. export class WebXRControllerComponent implements IDisposable {
  127774. /**
  127775. * the id of this component
  127776. */
  127777. id: string;
  127778. /**
  127779. * the type of the component
  127780. */
  127781. type: MotionControllerComponentType;
  127782. private _buttonIndex;
  127783. private _axesIndices;
  127784. private _axes;
  127785. private _changes;
  127786. private _currentValue;
  127787. private _hasChanges;
  127788. private _pressed;
  127789. private _touched;
  127790. /**
  127791. * button component type
  127792. */
  127793. static BUTTON_TYPE: MotionControllerComponentType;
  127794. /**
  127795. * squeeze component type
  127796. */
  127797. static SQUEEZE_TYPE: MotionControllerComponentType;
  127798. /**
  127799. * Thumbstick component type
  127800. */
  127801. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127802. /**
  127803. * Touchpad component type
  127804. */
  127805. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127806. /**
  127807. * trigger component type
  127808. */
  127809. static TRIGGER_TYPE: MotionControllerComponentType;
  127810. /**
  127811. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127812. * the axes data changes
  127813. */
  127814. onAxisValueChangedObservable: Observable<{
  127815. x: number;
  127816. y: number;
  127817. }>;
  127818. /**
  127819. * Observers registered here will be triggered when the state of a button changes
  127820. * State change is either pressed / touched / value
  127821. */
  127822. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127823. /**
  127824. * Creates a new component for a motion controller.
  127825. * It is created by the motion controller itself
  127826. *
  127827. * @param id the id of this component
  127828. * @param type the type of the component
  127829. * @param _buttonIndex index in the buttons array of the gamepad
  127830. * @param _axesIndices indices of the values in the axes array of the gamepad
  127831. */
  127832. constructor(
  127833. /**
  127834. * the id of this component
  127835. */
  127836. id: string,
  127837. /**
  127838. * the type of the component
  127839. */
  127840. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127841. /**
  127842. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127843. */
  127844. get axes(): IWebXRMotionControllerAxesValue;
  127845. /**
  127846. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127847. */
  127848. get changes(): IWebXRMotionControllerComponentChanges;
  127849. /**
  127850. * Return whether or not the component changed the last frame
  127851. */
  127852. get hasChanges(): boolean;
  127853. /**
  127854. * is the button currently pressed
  127855. */
  127856. get pressed(): boolean;
  127857. /**
  127858. * is the button currently touched
  127859. */
  127860. get touched(): boolean;
  127861. /**
  127862. * Get the current value of this component
  127863. */
  127864. get value(): number;
  127865. /**
  127866. * Dispose this component
  127867. */
  127868. dispose(): void;
  127869. /**
  127870. * Are there axes correlating to this component
  127871. * @return true is axes data is available
  127872. */
  127873. isAxes(): boolean;
  127874. /**
  127875. * Is this component a button (hence - pressable)
  127876. * @returns true if can be pressed
  127877. */
  127878. isButton(): boolean;
  127879. /**
  127880. * update this component using the gamepad object it is in. Called on every frame
  127881. * @param nativeController the native gamepad controller object
  127882. */
  127883. update(nativeController: IMinimalMotionControllerObject): void;
  127884. }
  127885. }
  127886. declare module BABYLON {
  127887. /**
  127888. * Interface used to represent data loading progression
  127889. */
  127890. export interface ISceneLoaderProgressEvent {
  127891. /**
  127892. * Defines if data length to load can be evaluated
  127893. */
  127894. readonly lengthComputable: boolean;
  127895. /**
  127896. * Defines the loaded data length
  127897. */
  127898. readonly loaded: number;
  127899. /**
  127900. * Defines the data length to load
  127901. */
  127902. readonly total: number;
  127903. }
  127904. /**
  127905. * Interface used by SceneLoader plugins to define supported file extensions
  127906. */
  127907. export interface ISceneLoaderPluginExtensions {
  127908. /**
  127909. * Defines the list of supported extensions
  127910. */
  127911. [extension: string]: {
  127912. isBinary: boolean;
  127913. };
  127914. }
  127915. /**
  127916. * Interface used by SceneLoader plugin factory
  127917. */
  127918. export interface ISceneLoaderPluginFactory {
  127919. /**
  127920. * Defines the name of the factory
  127921. */
  127922. name: string;
  127923. /**
  127924. * Function called to create a new plugin
  127925. * @return the new plugin
  127926. */
  127927. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  127928. /**
  127929. * The callback that returns true if the data can be directly loaded.
  127930. * @param data string containing the file data
  127931. * @returns if the data can be loaded directly
  127932. */
  127933. canDirectLoad?(data: string): boolean;
  127934. }
  127935. /**
  127936. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  127937. */
  127938. export interface ISceneLoaderPluginBase {
  127939. /**
  127940. * The friendly name of this plugin.
  127941. */
  127942. name: string;
  127943. /**
  127944. * The file extensions supported by this plugin.
  127945. */
  127946. extensions: string | ISceneLoaderPluginExtensions;
  127947. /**
  127948. * The callback called when loading from a url.
  127949. * @param scene scene loading this url
  127950. * @param url url to load
  127951. * @param onSuccess callback called when the file successfully loads
  127952. * @param onProgress callback called while file is loading (if the server supports this mode)
  127953. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127954. * @param onError callback called when the file fails to load
  127955. * @returns a file request object
  127956. */
  127957. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127958. /**
  127959. * The callback called when loading from a file object.
  127960. * @param scene scene loading this file
  127961. * @param file defines the file to load
  127962. * @param onSuccess defines the callback to call when data is loaded
  127963. * @param onProgress defines the callback to call during loading process
  127964. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  127965. * @param onError defines the callback to call when an error occurs
  127966. * @returns a file request object
  127967. */
  127968. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127969. /**
  127970. * The callback that returns true if the data can be directly loaded.
  127971. * @param data string containing the file data
  127972. * @returns if the data can be loaded directly
  127973. */
  127974. canDirectLoad?(data: string): boolean;
  127975. /**
  127976. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  127977. * @param scene scene loading this data
  127978. * @param data string containing the data
  127979. * @returns data to pass to the plugin
  127980. */
  127981. directLoad?(scene: Scene, data: string): any;
  127982. /**
  127983. * The callback that allows custom handling of the root url based on the response url.
  127984. * @param rootUrl the original root url
  127985. * @param responseURL the response url if available
  127986. * @returns the new root url
  127987. */
  127988. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  127989. }
  127990. /**
  127991. * Interface used to define a SceneLoader plugin
  127992. */
  127993. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  127994. /**
  127995. * Import meshes into a scene.
  127996. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127997. * @param scene The scene to import into
  127998. * @param data The data to import
  127999. * @param rootUrl The root url for scene and resources
  128000. * @param meshes The meshes array to import into
  128001. * @param particleSystems The particle systems array to import into
  128002. * @param skeletons The skeletons array to import into
  128003. * @param onError The callback when import fails
  128004. * @returns True if successful or false otherwise
  128005. */
  128006. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  128007. /**
  128008. * Load into a scene.
  128009. * @param scene The scene to load into
  128010. * @param data The data to import
  128011. * @param rootUrl The root url for scene and resources
  128012. * @param onError The callback when import fails
  128013. * @returns True if successful or false otherwise
  128014. */
  128015. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  128016. /**
  128017. * Load into an asset container.
  128018. * @param scene The scene to load into
  128019. * @param data The data to import
  128020. * @param rootUrl The root url for scene and resources
  128021. * @param onError The callback when import fails
  128022. * @returns The loaded asset container
  128023. */
  128024. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  128025. }
  128026. /**
  128027. * Interface used to define an async SceneLoader plugin
  128028. */
  128029. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  128030. /**
  128031. * Import meshes into a scene.
  128032. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128033. * @param scene The scene to import into
  128034. * @param data The data to import
  128035. * @param rootUrl The root url for scene and resources
  128036. * @param onProgress The callback when the load progresses
  128037. * @param fileName Defines the name of the file to load
  128038. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  128039. */
  128040. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  128041. meshes: AbstractMesh[];
  128042. particleSystems: IParticleSystem[];
  128043. skeletons: Skeleton[];
  128044. animationGroups: AnimationGroup[];
  128045. }>;
  128046. /**
  128047. * Load into a scene.
  128048. * @param scene The scene to load into
  128049. * @param data The data to import
  128050. * @param rootUrl The root url for scene and resources
  128051. * @param onProgress The callback when the load progresses
  128052. * @param fileName Defines the name of the file to load
  128053. * @returns Nothing
  128054. */
  128055. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  128056. /**
  128057. * Load into an asset container.
  128058. * @param scene The scene to load into
  128059. * @param data The data to import
  128060. * @param rootUrl The root url for scene and resources
  128061. * @param onProgress The callback when the load progresses
  128062. * @param fileName Defines the name of the file to load
  128063. * @returns The loaded asset container
  128064. */
  128065. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  128066. }
  128067. /**
  128068. * Mode that determines how to handle old animation groups before loading new ones.
  128069. */
  128070. export enum SceneLoaderAnimationGroupLoadingMode {
  128071. /**
  128072. * Reset all old animations to initial state then dispose them.
  128073. */
  128074. Clean = 0,
  128075. /**
  128076. * Stop all old animations.
  128077. */
  128078. Stop = 1,
  128079. /**
  128080. * Restart old animations from first frame.
  128081. */
  128082. Sync = 2,
  128083. /**
  128084. * Old animations remains untouched.
  128085. */
  128086. NoSync = 3
  128087. }
  128088. /**
  128089. * Defines a plugin registered by the SceneLoader
  128090. */
  128091. interface IRegisteredPlugin {
  128092. /**
  128093. * Defines the plugin to use
  128094. */
  128095. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128096. /**
  128097. * Defines if the plugin supports binary data
  128098. */
  128099. isBinary: boolean;
  128100. }
  128101. /**
  128102. * Class used to load scene from various file formats using registered plugins
  128103. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  128104. */
  128105. export class SceneLoader {
  128106. /**
  128107. * No logging while loading
  128108. */
  128109. static readonly NO_LOGGING: number;
  128110. /**
  128111. * Minimal logging while loading
  128112. */
  128113. static readonly MINIMAL_LOGGING: number;
  128114. /**
  128115. * Summary logging while loading
  128116. */
  128117. static readonly SUMMARY_LOGGING: number;
  128118. /**
  128119. * Detailled logging while loading
  128120. */
  128121. static readonly DETAILED_LOGGING: number;
  128122. /**
  128123. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  128124. */
  128125. static get ForceFullSceneLoadingForIncremental(): boolean;
  128126. static set ForceFullSceneLoadingForIncremental(value: boolean);
  128127. /**
  128128. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  128129. */
  128130. static get ShowLoadingScreen(): boolean;
  128131. static set ShowLoadingScreen(value: boolean);
  128132. /**
  128133. * Defines the current logging level (while loading the scene)
  128134. * @ignorenaming
  128135. */
  128136. static get loggingLevel(): number;
  128137. static set loggingLevel(value: number);
  128138. /**
  128139. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  128140. */
  128141. static get CleanBoneMatrixWeights(): boolean;
  128142. static set CleanBoneMatrixWeights(value: boolean);
  128143. /**
  128144. * Event raised when a plugin is used to load a scene
  128145. */
  128146. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  128147. private static _registeredPlugins;
  128148. private static _showingLoadingScreen;
  128149. /**
  128150. * Gets the default plugin (used to load Babylon files)
  128151. * @returns the .babylon plugin
  128152. */
  128153. static GetDefaultPlugin(): IRegisteredPlugin;
  128154. private static _GetPluginForExtension;
  128155. private static _GetPluginForDirectLoad;
  128156. private static _GetPluginForFilename;
  128157. private static _GetDirectLoad;
  128158. private static _LoadData;
  128159. private static _GetFileInfo;
  128160. /**
  128161. * Gets a plugin that can load the given extension
  128162. * @param extension defines the extension to load
  128163. * @returns a plugin or null if none works
  128164. */
  128165. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128166. /**
  128167. * Gets a boolean indicating that the given extension can be loaded
  128168. * @param extension defines the extension to load
  128169. * @returns true if the extension is supported
  128170. */
  128171. static IsPluginForExtensionAvailable(extension: string): boolean;
  128172. /**
  128173. * Adds a new plugin to the list of registered plugins
  128174. * @param plugin defines the plugin to add
  128175. */
  128176. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  128177. /**
  128178. * Import meshes into a scene
  128179. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128180. * @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)
  128181. * @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)
  128182. * @param scene the instance of BABYLON.Scene to append to
  128183. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  128184. * @param onProgress a callback with a progress event for each file being loaded
  128185. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128186. * @param pluginExtension the extension used to determine the plugin
  128187. * @returns The loaded plugin
  128188. */
  128189. 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>;
  128190. /**
  128191. * Import meshes into a scene
  128192. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128193. * @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)
  128194. * @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)
  128195. * @param scene the instance of BABYLON.Scene to append to
  128196. * @param onProgress a callback with a progress event for each file being loaded
  128197. * @param pluginExtension the extension used to determine the plugin
  128198. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  128199. */
  128200. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  128201. meshes: AbstractMesh[];
  128202. particleSystems: IParticleSystem[];
  128203. skeletons: Skeleton[];
  128204. animationGroups: AnimationGroup[];
  128205. }>;
  128206. /**
  128207. * Load a scene
  128208. * @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)
  128209. * @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)
  128210. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128211. * @param onSuccess a callback with the scene when import succeeds
  128212. * @param onProgress a callback with a progress event for each file being loaded
  128213. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128214. * @param pluginExtension the extension used to determine the plugin
  128215. * @returns The loaded plugin
  128216. */
  128217. 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>;
  128218. /**
  128219. * Load a scene
  128220. * @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)
  128221. * @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)
  128222. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128223. * @param onProgress a callback with a progress event for each file being loaded
  128224. * @param pluginExtension the extension used to determine the plugin
  128225. * @returns The loaded scene
  128226. */
  128227. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128228. /**
  128229. * Append a scene
  128230. * @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)
  128231. * @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)
  128232. * @param scene is the instance of BABYLON.Scene to append to
  128233. * @param onSuccess a callback with the scene when import succeeds
  128234. * @param onProgress a callback with a progress event for each file being loaded
  128235. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128236. * @param pluginExtension the extension used to determine the plugin
  128237. * @returns The loaded plugin
  128238. */
  128239. 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>;
  128240. /**
  128241. * Append a scene
  128242. * @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)
  128243. * @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)
  128244. * @param scene is the instance of BABYLON.Scene to append to
  128245. * @param onProgress a callback with a progress event for each file being loaded
  128246. * @param pluginExtension the extension used to determine the plugin
  128247. * @returns The given scene
  128248. */
  128249. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128250. /**
  128251. * Load a scene into an asset container
  128252. * @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)
  128253. * @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)
  128254. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128255. * @param onSuccess a callback with the scene when import succeeds
  128256. * @param onProgress a callback with a progress event for each file being loaded
  128257. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128258. * @param pluginExtension the extension used to determine the plugin
  128259. * @returns The loaded plugin
  128260. */
  128261. 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>;
  128262. /**
  128263. * Load a scene into an asset container
  128264. * @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)
  128265. * @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)
  128266. * @param scene is the instance of Scene to append to
  128267. * @param onProgress a callback with a progress event for each file being loaded
  128268. * @param pluginExtension the extension used to determine the plugin
  128269. * @returns The loaded asset container
  128270. */
  128271. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  128272. /**
  128273. * Import animations from a file into a scene
  128274. * @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)
  128275. * @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)
  128276. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128277. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128278. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128279. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128280. * @param onSuccess a callback with the scene when import succeeds
  128281. * @param onProgress a callback with a progress event for each file being loaded
  128282. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128283. * @param pluginExtension the extension used to determine the plugin
  128284. */
  128285. 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;
  128286. /**
  128287. * Import animations from a file into a scene
  128288. * @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)
  128289. * @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)
  128290. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128291. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128292. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128293. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128294. * @param onSuccess a callback with the scene when import succeeds
  128295. * @param onProgress a callback with a progress event for each file being loaded
  128296. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128297. * @param pluginExtension the extension used to determine the plugin
  128298. * @returns the updated scene with imported animations
  128299. */
  128300. 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>;
  128301. }
  128302. }
  128303. declare module BABYLON {
  128304. /**
  128305. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  128306. */
  128307. export type MotionControllerHandedness = "none" | "left" | "right";
  128308. /**
  128309. * The type of components available in motion controllers.
  128310. * This is not the name of the component.
  128311. */
  128312. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  128313. /**
  128314. * The state of a controller component
  128315. */
  128316. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  128317. /**
  128318. * The schema of motion controller layout.
  128319. * No object will be initialized using this interface
  128320. * This is used just to define the profile.
  128321. */
  128322. export interface IMotionControllerLayout {
  128323. /**
  128324. * Path to load the assets. Usually relative to the base path
  128325. */
  128326. assetPath: string;
  128327. /**
  128328. * Available components (unsorted)
  128329. */
  128330. components: {
  128331. /**
  128332. * A map of component Ids
  128333. */
  128334. [componentId: string]: {
  128335. /**
  128336. * The type of input the component outputs
  128337. */
  128338. type: MotionControllerComponentType;
  128339. /**
  128340. * The indices of this component in the gamepad object
  128341. */
  128342. gamepadIndices: {
  128343. /**
  128344. * Index of button
  128345. */
  128346. button?: number;
  128347. /**
  128348. * If available, index of x-axis
  128349. */
  128350. xAxis?: number;
  128351. /**
  128352. * If available, index of y-axis
  128353. */
  128354. yAxis?: number;
  128355. };
  128356. /**
  128357. * The mesh's root node name
  128358. */
  128359. rootNodeName: string;
  128360. /**
  128361. * Animation definitions for this model
  128362. */
  128363. visualResponses: {
  128364. [stateKey: string]: {
  128365. /**
  128366. * What property will be animated
  128367. */
  128368. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  128369. /**
  128370. * What states influence this visual response
  128371. */
  128372. states: MotionControllerComponentStateType[];
  128373. /**
  128374. * Type of animation - movement or visibility
  128375. */
  128376. valueNodeProperty: "transform" | "visibility";
  128377. /**
  128378. * Base node name to move. Its position will be calculated according to the min and max nodes
  128379. */
  128380. valueNodeName?: string;
  128381. /**
  128382. * Minimum movement node
  128383. */
  128384. minNodeName?: string;
  128385. /**
  128386. * Max movement node
  128387. */
  128388. maxNodeName?: string;
  128389. };
  128390. };
  128391. /**
  128392. * If touch enabled, what is the name of node to display user feedback
  128393. */
  128394. touchPointNodeName?: string;
  128395. };
  128396. };
  128397. /**
  128398. * Is it xr standard mapping or not
  128399. */
  128400. gamepadMapping: "" | "xr-standard";
  128401. /**
  128402. * Base root node of this entire model
  128403. */
  128404. rootNodeName: string;
  128405. /**
  128406. * Defines the main button component id
  128407. */
  128408. selectComponentId: string;
  128409. }
  128410. /**
  128411. * A definition for the layout map in the input profile
  128412. */
  128413. export interface IMotionControllerLayoutMap {
  128414. /**
  128415. * Layouts with handedness type as a key
  128416. */
  128417. [handedness: string]: IMotionControllerLayout;
  128418. }
  128419. /**
  128420. * The XR Input profile schema
  128421. * Profiles can be found here:
  128422. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  128423. */
  128424. export interface IMotionControllerProfile {
  128425. /**
  128426. * fallback profiles for this profileId
  128427. */
  128428. fallbackProfileIds: string[];
  128429. /**
  128430. * The layout map, with handedness as key
  128431. */
  128432. layouts: IMotionControllerLayoutMap;
  128433. /**
  128434. * The id of this profile
  128435. * correlates to the profile(s) in the xrInput.profiles array
  128436. */
  128437. profileId: string;
  128438. }
  128439. /**
  128440. * A helper-interface for the 3 meshes needed for controller button animation
  128441. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  128442. */
  128443. export interface IMotionControllerButtonMeshMap {
  128444. /**
  128445. * the mesh that defines the pressed value mesh position.
  128446. * This is used to find the max-position of this button
  128447. */
  128448. pressedMesh: AbstractMesh;
  128449. /**
  128450. * the mesh that defines the unpressed value mesh position.
  128451. * This is used to find the min (or initial) position of this button
  128452. */
  128453. unpressedMesh: AbstractMesh;
  128454. /**
  128455. * The mesh that will be changed when value changes
  128456. */
  128457. valueMesh: AbstractMesh;
  128458. }
  128459. /**
  128460. * A helper-interface for the 3 meshes needed for controller axis animation.
  128461. * This will be expanded when touchpad animations are fully supported
  128462. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  128463. */
  128464. export interface IMotionControllerMeshMap {
  128465. /**
  128466. * the mesh that defines the maximum value mesh position.
  128467. */
  128468. maxMesh?: AbstractMesh;
  128469. /**
  128470. * the mesh that defines the minimum value mesh position.
  128471. */
  128472. minMesh?: AbstractMesh;
  128473. /**
  128474. * The mesh that will be changed when axis value changes
  128475. */
  128476. valueMesh?: AbstractMesh;
  128477. }
  128478. /**
  128479. * The elements needed for change-detection of the gamepad objects in motion controllers
  128480. */
  128481. export interface IMinimalMotionControllerObject {
  128482. /**
  128483. * Available axes of this controller
  128484. */
  128485. axes: number[];
  128486. /**
  128487. * An array of available buttons
  128488. */
  128489. buttons: Array<{
  128490. /**
  128491. * Value of the button/trigger
  128492. */
  128493. value: number;
  128494. /**
  128495. * If the button/trigger is currently touched
  128496. */
  128497. touched: boolean;
  128498. /**
  128499. * If the button/trigger is currently pressed
  128500. */
  128501. pressed: boolean;
  128502. }>;
  128503. /**
  128504. * EXPERIMENTAL haptic support.
  128505. */
  128506. hapticActuators?: Array<{
  128507. pulse: (value: number, duration: number) => Promise<boolean>;
  128508. }>;
  128509. }
  128510. /**
  128511. * An Abstract Motion controller
  128512. * This class receives an xrInput and a profile layout and uses those to initialize the components
  128513. * Each component has an observable to check for changes in value and state
  128514. */
  128515. export abstract class WebXRAbstractMotionController implements IDisposable {
  128516. protected scene: Scene;
  128517. protected layout: IMotionControllerLayout;
  128518. /**
  128519. * The gamepad object correlating to this controller
  128520. */
  128521. gamepadObject: IMinimalMotionControllerObject;
  128522. /**
  128523. * handedness (left/right/none) of this controller
  128524. */
  128525. handedness: MotionControllerHandedness;
  128526. private _initComponent;
  128527. private _modelReady;
  128528. /**
  128529. * A map of components (WebXRControllerComponent) in this motion controller
  128530. * Components have a ComponentType and can also have both button and axis definitions
  128531. */
  128532. readonly components: {
  128533. [id: string]: WebXRControllerComponent;
  128534. };
  128535. /**
  128536. * Disable the model's animation. Can be set at any time.
  128537. */
  128538. disableAnimation: boolean;
  128539. /**
  128540. * Observers registered here will be triggered when the model of this controller is done loading
  128541. */
  128542. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  128543. /**
  128544. * The profile id of this motion controller
  128545. */
  128546. abstract profileId: string;
  128547. /**
  128548. * The root mesh of the model. It is null if the model was not yet initialized
  128549. */
  128550. rootMesh: Nullable<AbstractMesh>;
  128551. /**
  128552. * constructs a new abstract motion controller
  128553. * @param scene the scene to which the model of the controller will be added
  128554. * @param layout The profile layout to load
  128555. * @param gamepadObject The gamepad object correlating to this controller
  128556. * @param handedness handedness (left/right/none) of this controller
  128557. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128558. */
  128559. constructor(scene: Scene, layout: IMotionControllerLayout,
  128560. /**
  128561. * The gamepad object correlating to this controller
  128562. */
  128563. gamepadObject: IMinimalMotionControllerObject,
  128564. /**
  128565. * handedness (left/right/none) of this controller
  128566. */
  128567. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128568. /**
  128569. * Dispose this controller, the model mesh and all its components
  128570. */
  128571. dispose(): void;
  128572. /**
  128573. * Returns all components of specific type
  128574. * @param type the type to search for
  128575. * @return an array of components with this type
  128576. */
  128577. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128578. /**
  128579. * get a component based an its component id as defined in layout.components
  128580. * @param id the id of the component
  128581. * @returns the component correlates to the id or undefined if not found
  128582. */
  128583. getComponent(id: string): WebXRControllerComponent;
  128584. /**
  128585. * Get the list of components available in this motion controller
  128586. * @returns an array of strings correlating to available components
  128587. */
  128588. getComponentIds(): string[];
  128589. /**
  128590. * Get the first component of specific type
  128591. * @param type type of component to find
  128592. * @return a controller component or null if not found
  128593. */
  128594. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128595. /**
  128596. * Get the main (Select) component of this controller as defined in the layout
  128597. * @returns the main component of this controller
  128598. */
  128599. getMainComponent(): WebXRControllerComponent;
  128600. /**
  128601. * Loads the model correlating to this controller
  128602. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128603. * @returns A promise fulfilled with the result of the model loading
  128604. */
  128605. loadModel(): Promise<boolean>;
  128606. /**
  128607. * Update this model using the current XRFrame
  128608. * @param xrFrame the current xr frame to use and update the model
  128609. */
  128610. updateFromXRFrame(xrFrame: XRFrame): void;
  128611. /**
  128612. * Backwards compatibility due to a deeply-integrated typo
  128613. */
  128614. get handness(): XREye;
  128615. /**
  128616. * Pulse (vibrate) this controller
  128617. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128618. * Consecutive calls to this function will cancel the last pulse call
  128619. *
  128620. * @param value the strength of the pulse in 0.0...1.0 range
  128621. * @param duration Duration of the pulse in milliseconds
  128622. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128623. * @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
  128624. */
  128625. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128626. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128627. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128628. /**
  128629. * Moves the axis on the controller mesh based on its current state
  128630. * @param axis the index of the axis
  128631. * @param axisValue the value of the axis which determines the meshes new position
  128632. * @hidden
  128633. */
  128634. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128635. /**
  128636. * Update the model itself with the current frame data
  128637. * @param xrFrame the frame to use for updating the model mesh
  128638. */
  128639. protected updateModel(xrFrame: XRFrame): void;
  128640. /**
  128641. * Get the filename and path for this controller's model
  128642. * @returns a map of filename and path
  128643. */
  128644. protected abstract _getFilenameAndPath(): {
  128645. filename: string;
  128646. path: string;
  128647. };
  128648. /**
  128649. * This function is called before the mesh is loaded. It checks for loading constraints.
  128650. * For example, this function can check if the GLB loader is available
  128651. * If this function returns false, the generic controller will be loaded instead
  128652. * @returns Is the client ready to load the mesh
  128653. */
  128654. protected abstract _getModelLoadingConstraints(): boolean;
  128655. /**
  128656. * This function will be called after the model was successfully loaded and can be used
  128657. * for mesh transformations before it is available for the user
  128658. * @param meshes the loaded meshes
  128659. */
  128660. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  128661. /**
  128662. * Set the root mesh for this controller. Important for the WebXR controller class
  128663. * @param meshes the loaded meshes
  128664. */
  128665. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  128666. /**
  128667. * A function executed each frame that updates the mesh (if needed)
  128668. * @param xrFrame the current xrFrame
  128669. */
  128670. protected abstract _updateModel(xrFrame: XRFrame): void;
  128671. private _getGenericFilenameAndPath;
  128672. private _getGenericParentMesh;
  128673. }
  128674. }
  128675. declare module BABYLON {
  128676. /**
  128677. * A generic trigger-only motion controller for WebXR
  128678. */
  128679. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  128680. /**
  128681. * Static version of the profile id of this controller
  128682. */
  128683. static ProfileId: string;
  128684. profileId: string;
  128685. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  128686. protected _getFilenameAndPath(): {
  128687. filename: string;
  128688. path: string;
  128689. };
  128690. protected _getModelLoadingConstraints(): boolean;
  128691. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  128692. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128693. protected _updateModel(): void;
  128694. }
  128695. }
  128696. declare module BABYLON {
  128697. /**
  128698. * Class containing static functions to help procedurally build meshes
  128699. */
  128700. export class SphereBuilder {
  128701. /**
  128702. * Creates a sphere mesh
  128703. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128704. * * 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`)
  128705. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128706. * * 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
  128707. * * 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)
  128708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128709. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128711. * @param name defines the name of the mesh
  128712. * @param options defines the options used to create the mesh
  128713. * @param scene defines the hosting scene
  128714. * @returns the sphere mesh
  128715. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128716. */
  128717. static CreateSphere(name: string, options: {
  128718. segments?: number;
  128719. diameter?: number;
  128720. diameterX?: number;
  128721. diameterY?: number;
  128722. diameterZ?: number;
  128723. arc?: number;
  128724. slice?: number;
  128725. sideOrientation?: number;
  128726. frontUVs?: Vector4;
  128727. backUVs?: Vector4;
  128728. updatable?: boolean;
  128729. }, scene?: Nullable<Scene>): Mesh;
  128730. }
  128731. }
  128732. declare module BABYLON {
  128733. /**
  128734. * A profiled motion controller has its profile loaded from an online repository.
  128735. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  128736. */
  128737. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  128738. private _repositoryUrl;
  128739. private _buttonMeshMapping;
  128740. private _touchDots;
  128741. /**
  128742. * The profile ID of this controller. Will be populated when the controller initializes.
  128743. */
  128744. profileId: string;
  128745. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  128746. dispose(): void;
  128747. protected _getFilenameAndPath(): {
  128748. filename: string;
  128749. path: string;
  128750. };
  128751. protected _getModelLoadingConstraints(): boolean;
  128752. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  128753. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128754. protected _updateModel(_xrFrame: XRFrame): void;
  128755. }
  128756. }
  128757. declare module BABYLON {
  128758. /**
  128759. * A construction function type to create a new controller based on an xrInput object
  128760. */
  128761. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  128762. /**
  128763. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  128764. *
  128765. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  128766. * it should be replaced with auto-loaded controllers.
  128767. *
  128768. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  128769. */
  128770. export class WebXRMotionControllerManager {
  128771. private static _AvailableControllers;
  128772. private static _Fallbacks;
  128773. private static _ProfileLoadingPromises;
  128774. private static _ProfilesList;
  128775. /**
  128776. * The base URL of the online controller repository. Can be changed at any time.
  128777. */
  128778. static BaseRepositoryUrl: string;
  128779. /**
  128780. * Which repository gets priority - local or online
  128781. */
  128782. static PrioritizeOnlineRepository: boolean;
  128783. /**
  128784. * Use the online repository, or use only locally-defined controllers
  128785. */
  128786. static UseOnlineRepository: boolean;
  128787. /**
  128788. * Clear the cache used for profile loading and reload when requested again
  128789. */
  128790. static ClearProfilesCache(): void;
  128791. /**
  128792. * Register the default fallbacks.
  128793. * This function is called automatically when this file is imported.
  128794. */
  128795. static DefaultFallbacks(): void;
  128796. /**
  128797. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128798. * @param profileId the profile to which a fallback needs to be found
  128799. * @return an array with corresponding fallback profiles
  128800. */
  128801. static FindFallbackWithProfileId(profileId: string): string[];
  128802. /**
  128803. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128804. * The order of search:
  128805. *
  128806. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128807. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128808. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128809. * 4) return the generic trigger controller if none were found
  128810. *
  128811. * @param xrInput the xrInput to which a new controller is initialized
  128812. * @param scene the scene to which the model will be added
  128813. * @param forceProfile force a certain profile for this controller
  128814. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128815. */
  128816. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128817. /**
  128818. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128819. *
  128820. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128821. *
  128822. * @param type the profile type to register
  128823. * @param constructFunction the function to be called when loading this profile
  128824. */
  128825. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128826. /**
  128827. * Register a fallback to a specific profile.
  128828. * @param profileId the profileId that will receive the fallbacks
  128829. * @param fallbacks A list of fallback profiles
  128830. */
  128831. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128832. /**
  128833. * Will update the list of profiles available in the repository
  128834. * @return a promise that resolves to a map of profiles available online
  128835. */
  128836. static UpdateProfilesList(): Promise<{
  128837. [profile: string]: string;
  128838. }>;
  128839. private static _LoadProfileFromRepository;
  128840. private static _LoadProfilesFromAvailableControllers;
  128841. }
  128842. }
  128843. declare module BABYLON {
  128844. /**
  128845. * Configuration options for the WebXR controller creation
  128846. */
  128847. export interface IWebXRControllerOptions {
  128848. /**
  128849. * Should the controller mesh be animated when a user interacts with it
  128850. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128851. */
  128852. disableMotionControllerAnimation?: boolean;
  128853. /**
  128854. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128855. */
  128856. doNotLoadControllerMesh?: boolean;
  128857. /**
  128858. * Force a specific controller type for this controller.
  128859. * This can be used when creating your own profile or when testing different controllers
  128860. */
  128861. forceControllerProfile?: string;
  128862. /**
  128863. * Defines a rendering group ID for meshes that will be loaded.
  128864. * This is for the default controllers only.
  128865. */
  128866. renderingGroupId?: number;
  128867. }
  128868. /**
  128869. * Represents an XR controller
  128870. */
  128871. export class WebXRInputSource {
  128872. private _scene;
  128873. /** The underlying input source for the controller */
  128874. inputSource: XRInputSource;
  128875. private _options;
  128876. private _tmpVector;
  128877. private _uniqueId;
  128878. private _disposed;
  128879. /**
  128880. * 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
  128881. */
  128882. grip?: AbstractMesh;
  128883. /**
  128884. * If available, this is the gamepad object related to this controller.
  128885. * Using this object it is possible to get click events and trackpad changes of the
  128886. * webxr controller that is currently being used.
  128887. */
  128888. motionController?: WebXRAbstractMotionController;
  128889. /**
  128890. * Event that fires when the controller is removed/disposed.
  128891. * The object provided as event data is this controller, after associated assets were disposed.
  128892. * uniqueId is still available.
  128893. */
  128894. onDisposeObservable: Observable<WebXRInputSource>;
  128895. /**
  128896. * Will be triggered when the mesh associated with the motion controller is done loading.
  128897. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  128898. * A shortened version of controller -> motion controller -> on mesh loaded.
  128899. */
  128900. onMeshLoadedObservable: Observable<AbstractMesh>;
  128901. /**
  128902. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  128903. */
  128904. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  128905. /**
  128906. * Pointer which can be used to select objects or attach a visible laser to
  128907. */
  128908. pointer: AbstractMesh;
  128909. /**
  128910. * Creates the input source object
  128911. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  128912. * @param _scene the scene which the controller should be associated to
  128913. * @param inputSource the underlying input source for the controller
  128914. * @param _options options for this controller creation
  128915. */
  128916. constructor(_scene: Scene,
  128917. /** The underlying input source for the controller */
  128918. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  128919. /**
  128920. * Get this controllers unique id
  128921. */
  128922. get uniqueId(): string;
  128923. /**
  128924. * Disposes of the object
  128925. */
  128926. dispose(): void;
  128927. /**
  128928. * Gets a world space ray coming from the pointer or grip
  128929. * @param result the resulting ray
  128930. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  128931. */
  128932. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  128933. /**
  128934. * Updates the controller pose based on the given XRFrame
  128935. * @param xrFrame xr frame to update the pose with
  128936. * @param referenceSpace reference space to use
  128937. */
  128938. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  128939. }
  128940. }
  128941. declare module BABYLON {
  128942. /**
  128943. * The schema for initialization options of the XR Input class
  128944. */
  128945. export interface IWebXRInputOptions {
  128946. /**
  128947. * If set to true no model will be automatically loaded
  128948. */
  128949. doNotLoadControllerMeshes?: boolean;
  128950. /**
  128951. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  128952. * If not found, the xr input profile data will be used.
  128953. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  128954. */
  128955. forceInputProfile?: string;
  128956. /**
  128957. * Do not send a request to the controller repository to load the profile.
  128958. *
  128959. * Instead, use the controllers available in babylon itself.
  128960. */
  128961. disableOnlineControllerRepository?: boolean;
  128962. /**
  128963. * A custom URL for the controllers repository
  128964. */
  128965. customControllersRepositoryURL?: string;
  128966. /**
  128967. * Should the controller model's components not move according to the user input
  128968. */
  128969. disableControllerAnimation?: boolean;
  128970. /**
  128971. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  128972. */
  128973. controllerOptions?: IWebXRControllerOptions;
  128974. }
  128975. /**
  128976. * XR input used to track XR inputs such as controllers/rays
  128977. */
  128978. export class WebXRInput implements IDisposable {
  128979. /**
  128980. * the xr session manager for this session
  128981. */
  128982. xrSessionManager: WebXRSessionManager;
  128983. /**
  128984. * the WebXR camera for this session. Mainly used for teleportation
  128985. */
  128986. xrCamera: WebXRCamera;
  128987. private readonly options;
  128988. /**
  128989. * XR controllers being tracked
  128990. */
  128991. controllers: Array<WebXRInputSource>;
  128992. private _frameObserver;
  128993. private _sessionEndedObserver;
  128994. private _sessionInitObserver;
  128995. /**
  128996. * Event when a controller has been connected/added
  128997. */
  128998. onControllerAddedObservable: Observable<WebXRInputSource>;
  128999. /**
  129000. * Event when a controller has been removed/disconnected
  129001. */
  129002. onControllerRemovedObservable: Observable<WebXRInputSource>;
  129003. /**
  129004. * Initializes the WebXRInput
  129005. * @param xrSessionManager the xr session manager for this session
  129006. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  129007. * @param options = initialization options for this xr input
  129008. */
  129009. constructor(
  129010. /**
  129011. * the xr session manager for this session
  129012. */
  129013. xrSessionManager: WebXRSessionManager,
  129014. /**
  129015. * the WebXR camera for this session. Mainly used for teleportation
  129016. */
  129017. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  129018. private _onInputSourcesChange;
  129019. private _addAndRemoveControllers;
  129020. /**
  129021. * Disposes of the object
  129022. */
  129023. dispose(): void;
  129024. }
  129025. }
  129026. declare module BABYLON {
  129027. /**
  129028. * This is the base class for all WebXR features.
  129029. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  129030. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  129031. */
  129032. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  129033. protected _xrSessionManager: WebXRSessionManager;
  129034. private _attached;
  129035. private _removeOnDetach;
  129036. /**
  129037. * Is this feature disposed?
  129038. */
  129039. isDisposed: boolean;
  129040. /**
  129041. * Should auto-attach be disabled?
  129042. */
  129043. disableAutoAttach: boolean;
  129044. /**
  129045. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  129046. */
  129047. xrNativeFeatureName: string;
  129048. /**
  129049. * Construct a new (abstract) WebXR feature
  129050. * @param _xrSessionManager the xr session manager for this feature
  129051. */
  129052. constructor(_xrSessionManager: WebXRSessionManager);
  129053. /**
  129054. * Is this feature attached
  129055. */
  129056. get attached(): boolean;
  129057. /**
  129058. * attach this feature
  129059. *
  129060. * @param force should attachment be forced (even when already attached)
  129061. * @returns true if successful, false is failed or already attached
  129062. */
  129063. attach(force?: boolean): boolean;
  129064. /**
  129065. * detach this feature.
  129066. *
  129067. * @returns true if successful, false if failed or already detached
  129068. */
  129069. detach(): boolean;
  129070. /**
  129071. * Dispose this feature and all of the resources attached
  129072. */
  129073. dispose(): void;
  129074. /**
  129075. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  129076. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  129077. *
  129078. * @returns whether or not the feature is compatible in this environment
  129079. */
  129080. isCompatible(): boolean;
  129081. /**
  129082. * This is used to register callbacks that will automatically be removed when detach is called.
  129083. * @param observable the observable to which the observer will be attached
  129084. * @param callback the callback to register
  129085. */
  129086. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  129087. /**
  129088. * Code in this function will be executed on each xrFrame received from the browser.
  129089. * This function will not execute after the feature is detached.
  129090. * @param _xrFrame the current frame
  129091. */
  129092. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  129093. }
  129094. }
  129095. declare module BABYLON {
  129096. /**
  129097. * Renders a layer on top of an existing scene
  129098. */
  129099. export class UtilityLayerRenderer implements IDisposable {
  129100. /** the original scene that will be rendered on top of */
  129101. originalScene: Scene;
  129102. private _pointerCaptures;
  129103. private _lastPointerEvents;
  129104. private static _DefaultUtilityLayer;
  129105. private static _DefaultKeepDepthUtilityLayer;
  129106. private _sharedGizmoLight;
  129107. private _renderCamera;
  129108. /**
  129109. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  129110. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  129111. * @returns the camera that is used when rendering the utility layer
  129112. */
  129113. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  129114. /**
  129115. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  129116. * @param cam the camera that should be used when rendering the utility layer
  129117. */
  129118. setRenderCamera(cam: Nullable<Camera>): void;
  129119. /**
  129120. * @hidden
  129121. * Light which used by gizmos to get light shading
  129122. */
  129123. _getSharedGizmoLight(): HemisphericLight;
  129124. /**
  129125. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  129126. */
  129127. pickUtilitySceneFirst: boolean;
  129128. /**
  129129. * 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)
  129130. */
  129131. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  129132. /**
  129133. * 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)
  129134. */
  129135. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  129136. /**
  129137. * The scene that is rendered on top of the original scene
  129138. */
  129139. utilityLayerScene: Scene;
  129140. /**
  129141. * If the utility layer should automatically be rendered on top of existing scene
  129142. */
  129143. shouldRender: boolean;
  129144. /**
  129145. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  129146. */
  129147. onlyCheckPointerDownEvents: boolean;
  129148. /**
  129149. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  129150. */
  129151. processAllEvents: boolean;
  129152. /**
  129153. * Observable raised when the pointer move from the utility layer scene to the main scene
  129154. */
  129155. onPointerOutObservable: Observable<number>;
  129156. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  129157. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  129158. private _afterRenderObserver;
  129159. private _sceneDisposeObserver;
  129160. private _originalPointerObserver;
  129161. /**
  129162. * Instantiates a UtilityLayerRenderer
  129163. * @param originalScene the original scene that will be rendered on top of
  129164. * @param handleEvents boolean indicating if the utility layer should handle events
  129165. */
  129166. constructor(
  129167. /** the original scene that will be rendered on top of */
  129168. originalScene: Scene, handleEvents?: boolean);
  129169. private _notifyObservers;
  129170. /**
  129171. * Renders the utility layers scene on top of the original scene
  129172. */
  129173. render(): void;
  129174. /**
  129175. * Disposes of the renderer
  129176. */
  129177. dispose(): void;
  129178. private _updateCamera;
  129179. }
  129180. }
  129181. declare module BABYLON {
  129182. /**
  129183. * Options interface for the pointer selection module
  129184. */
  129185. export interface IWebXRControllerPointerSelectionOptions {
  129186. /**
  129187. * if provided, this scene will be used to render meshes.
  129188. */
  129189. customUtilityLayerScene?: Scene;
  129190. /**
  129191. * 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)
  129192. * If not disabled, the last picked point will be used to execute a pointer up event
  129193. * If disabled, pointer up event will be triggered right after the pointer down event.
  129194. * Used in screen and gaze target ray mode only
  129195. */
  129196. disablePointerUpOnTouchOut: boolean;
  129197. /**
  129198. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  129199. */
  129200. forceGazeMode: boolean;
  129201. /**
  129202. * 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
  129203. * to start a new countdown to the pointer down event.
  129204. * Defaults to 1.
  129205. */
  129206. gazeModePointerMovedFactor?: number;
  129207. /**
  129208. * Different button type to use instead of the main component
  129209. */
  129210. overrideButtonId?: string;
  129211. /**
  129212. * use this rendering group id for the meshes (optional)
  129213. */
  129214. renderingGroupId?: number;
  129215. /**
  129216. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  129217. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  129218. * 3000 means 3 seconds between pointing at something and selecting it
  129219. */
  129220. timeToSelect?: number;
  129221. /**
  129222. * Should meshes created here be added to a utility layer or the main scene
  129223. */
  129224. useUtilityLayer?: boolean;
  129225. /**
  129226. * Optional WebXR camera to be used for gaze selection
  129227. */
  129228. gazeCamera?: WebXRCamera;
  129229. /**
  129230. * the xr input to use with this pointer selection
  129231. */
  129232. xrInput: WebXRInput;
  129233. }
  129234. /**
  129235. * A module that will enable pointer selection for motion controllers of XR Input Sources
  129236. */
  129237. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  129238. private readonly _options;
  129239. private static _idCounter;
  129240. private _attachController;
  129241. private _controllers;
  129242. private _scene;
  129243. private _tmpVectorForPickCompare;
  129244. /**
  129245. * The module's name
  129246. */
  129247. static readonly Name: string;
  129248. /**
  129249. * The (Babylon) version of this module.
  129250. * This is an integer representing the implementation version.
  129251. * This number does not correspond to the WebXR specs version
  129252. */
  129253. static readonly Version: number;
  129254. /**
  129255. * Disable lighting on the laser pointer (so it will always be visible)
  129256. */
  129257. disablePointerLighting: boolean;
  129258. /**
  129259. * Disable lighting on the selection mesh (so it will always be visible)
  129260. */
  129261. disableSelectionMeshLighting: boolean;
  129262. /**
  129263. * Should the laser pointer be displayed
  129264. */
  129265. displayLaserPointer: boolean;
  129266. /**
  129267. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  129268. */
  129269. displaySelectionMesh: boolean;
  129270. /**
  129271. * This color will be set to the laser pointer when selection is triggered
  129272. */
  129273. laserPointerPickedColor: Color3;
  129274. /**
  129275. * Default color of the laser pointer
  129276. */
  129277. laserPointerDefaultColor: Color3;
  129278. /**
  129279. * default color of the selection ring
  129280. */
  129281. selectionMeshDefaultColor: Color3;
  129282. /**
  129283. * This color will be applied to the selection ring when selection is triggered
  129284. */
  129285. selectionMeshPickedColor: Color3;
  129286. /**
  129287. * Optional filter to be used for ray selection. This predicate shares behavior with
  129288. * scene.pointerMovePredicate which takes priority if it is also assigned.
  129289. */
  129290. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129291. /**
  129292. * constructs a new background remover module
  129293. * @param _xrSessionManager the session manager for this module
  129294. * @param _options read-only options to be used in this module
  129295. */
  129296. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  129297. /**
  129298. * attach this feature
  129299. * Will usually be called by the features manager
  129300. *
  129301. * @returns true if successful.
  129302. */
  129303. attach(): boolean;
  129304. /**
  129305. * detach this feature.
  129306. * Will usually be called by the features manager
  129307. *
  129308. * @returns true if successful.
  129309. */
  129310. detach(): boolean;
  129311. /**
  129312. * Will get the mesh under a specific pointer.
  129313. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  129314. * @param controllerId the controllerId to check
  129315. * @returns The mesh under pointer or null if no mesh is under the pointer
  129316. */
  129317. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  129318. /**
  129319. * Get the xr controller that correlates to the pointer id in the pointer event
  129320. *
  129321. * @param id the pointer id to search for
  129322. * @returns the controller that correlates to this id or null if not found
  129323. */
  129324. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  129325. protected _onXRFrame(_xrFrame: XRFrame): void;
  129326. private _attachGazeMode;
  129327. private _attachScreenRayMode;
  129328. private _attachTrackedPointerRayMode;
  129329. private _convertNormalToDirectionOfRay;
  129330. private _detachController;
  129331. private _generateNewMeshPair;
  129332. private _pickingMoved;
  129333. private _updatePointerDistance;
  129334. /** @hidden */
  129335. get lasterPointerDefaultColor(): Color3;
  129336. }
  129337. }
  129338. declare module BABYLON {
  129339. /**
  129340. * Button which can be used to enter a different mode of XR
  129341. */
  129342. export class WebXREnterExitUIButton {
  129343. /** button element */
  129344. element: HTMLElement;
  129345. /** XR initialization options for the button */
  129346. sessionMode: XRSessionMode;
  129347. /** Reference space type */
  129348. referenceSpaceType: XRReferenceSpaceType;
  129349. /**
  129350. * Creates a WebXREnterExitUIButton
  129351. * @param element button element
  129352. * @param sessionMode XR initialization session mode
  129353. * @param referenceSpaceType the type of reference space to be used
  129354. */
  129355. constructor(
  129356. /** button element */
  129357. element: HTMLElement,
  129358. /** XR initialization options for the button */
  129359. sessionMode: XRSessionMode,
  129360. /** Reference space type */
  129361. referenceSpaceType: XRReferenceSpaceType);
  129362. /**
  129363. * Extendable function which can be used to update the button's visuals when the state changes
  129364. * @param activeButton the current active button in the UI
  129365. */
  129366. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  129367. }
  129368. /**
  129369. * Options to create the webXR UI
  129370. */
  129371. export class WebXREnterExitUIOptions {
  129372. /**
  129373. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  129374. */
  129375. customButtons?: Array<WebXREnterExitUIButton>;
  129376. /**
  129377. * A reference space type to use when creating the default button.
  129378. * Default is local-floor
  129379. */
  129380. referenceSpaceType?: XRReferenceSpaceType;
  129381. /**
  129382. * Context to enter xr with
  129383. */
  129384. renderTarget?: Nullable<WebXRRenderTarget>;
  129385. /**
  129386. * A session mode to use when creating the default button.
  129387. * Default is immersive-vr
  129388. */
  129389. sessionMode?: XRSessionMode;
  129390. /**
  129391. * A list of optional features to init the session with
  129392. */
  129393. optionalFeatures?: string[];
  129394. /**
  129395. * A list of optional features to init the session with
  129396. */
  129397. requiredFeatures?: string[];
  129398. }
  129399. /**
  129400. * UI to allow the user to enter/exit XR mode
  129401. */
  129402. export class WebXREnterExitUI implements IDisposable {
  129403. private scene;
  129404. /** version of the options passed to this UI */
  129405. options: WebXREnterExitUIOptions;
  129406. private _activeButton;
  129407. private _buttons;
  129408. /**
  129409. * The HTML Div Element to which buttons are added.
  129410. */
  129411. readonly overlay: HTMLDivElement;
  129412. /**
  129413. * Fired every time the active button is changed.
  129414. *
  129415. * When xr is entered via a button that launches xr that button will be the callback parameter
  129416. *
  129417. * When exiting xr the callback parameter will be null)
  129418. */
  129419. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  129420. /**
  129421. *
  129422. * @param scene babylon scene object to use
  129423. * @param options (read-only) version of the options passed to this UI
  129424. */
  129425. private constructor();
  129426. /**
  129427. * Creates UI to allow the user to enter/exit XR mode
  129428. * @param scene the scene to add the ui to
  129429. * @param helper the xr experience helper to enter/exit xr with
  129430. * @param options options to configure the UI
  129431. * @returns the created ui
  129432. */
  129433. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  129434. /**
  129435. * Disposes of the XR UI component
  129436. */
  129437. dispose(): void;
  129438. private _updateButtons;
  129439. }
  129440. }
  129441. declare module BABYLON {
  129442. /**
  129443. * Class containing static functions to help procedurally build meshes
  129444. */
  129445. export class LinesBuilder {
  129446. /**
  129447. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129448. * * 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
  129449. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129450. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129451. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129452. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129453. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129454. * * 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
  129455. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  129458. * @param name defines the name of the new line system
  129459. * @param options defines the options used to create the line system
  129460. * @param scene defines the hosting scene
  129461. * @returns a new line system mesh
  129462. */
  129463. static CreateLineSystem(name: string, options: {
  129464. lines: Vector3[][];
  129465. updatable?: boolean;
  129466. instance?: Nullable<LinesMesh>;
  129467. colors?: Nullable<Color4[][]>;
  129468. useVertexAlpha?: boolean;
  129469. }, scene: Nullable<Scene>): LinesMesh;
  129470. /**
  129471. * Creates a line mesh
  129472. * 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
  129473. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129474. * * The parameter `points` is an array successive Vector3
  129475. * * 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
  129476. * * The optional parameter `colors` is an array of successive Color4, one per line point
  129477. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  129478. * * When updating an instance, remember that only point positions can change, not the number of points
  129479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129480. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  129481. * @param name defines the name of the new line system
  129482. * @param options defines the options used to create the line system
  129483. * @param scene defines the hosting scene
  129484. * @returns a new line mesh
  129485. */
  129486. static CreateLines(name: string, options: {
  129487. points: Vector3[];
  129488. updatable?: boolean;
  129489. instance?: Nullable<LinesMesh>;
  129490. colors?: Color4[];
  129491. useVertexAlpha?: boolean;
  129492. }, scene?: Nullable<Scene>): LinesMesh;
  129493. /**
  129494. * Creates a dashed line mesh
  129495. * * 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
  129496. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129497. * * The parameter `points` is an array successive Vector3
  129498. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  129499. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  129500. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  129501. * * 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
  129502. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129503. * * When updating an instance, remember that only point positions can change, not the number of points
  129504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129505. * @param name defines the name of the mesh
  129506. * @param options defines the options used to create the mesh
  129507. * @param scene defines the hosting scene
  129508. * @returns the dashed line mesh
  129509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  129510. */
  129511. static CreateDashedLines(name: string, options: {
  129512. points: Vector3[];
  129513. dashSize?: number;
  129514. gapSize?: number;
  129515. dashNb?: number;
  129516. updatable?: boolean;
  129517. instance?: LinesMesh;
  129518. useVertexAlpha?: boolean;
  129519. }, scene?: Nullable<Scene>): LinesMesh;
  129520. }
  129521. }
  129522. declare module BABYLON {
  129523. /**
  129524. * Construction options for a timer
  129525. */
  129526. export interface ITimerOptions<T> {
  129527. /**
  129528. * Time-to-end
  129529. */
  129530. timeout: number;
  129531. /**
  129532. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  129533. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  129534. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  129535. */
  129536. contextObservable: Observable<T>;
  129537. /**
  129538. * Optional parameters when adding an observer to the observable
  129539. */
  129540. observableParameters?: {
  129541. mask?: number;
  129542. insertFirst?: boolean;
  129543. scope?: any;
  129544. };
  129545. /**
  129546. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  129547. */
  129548. breakCondition?: (data?: ITimerData<T>) => boolean;
  129549. /**
  129550. * Will be triggered when the time condition has met
  129551. */
  129552. onEnded?: (data: ITimerData<any>) => void;
  129553. /**
  129554. * Will be triggered when the break condition has met (prematurely ended)
  129555. */
  129556. onAborted?: (data: ITimerData<any>) => void;
  129557. /**
  129558. * Optional function to execute on each tick (or count)
  129559. */
  129560. onTick?: (data: ITimerData<any>) => void;
  129561. }
  129562. /**
  129563. * An interface defining the data sent by the timer
  129564. */
  129565. export interface ITimerData<T> {
  129566. /**
  129567. * When did it start
  129568. */
  129569. startTime: number;
  129570. /**
  129571. * Time now
  129572. */
  129573. currentTime: number;
  129574. /**
  129575. * Time passed since started
  129576. */
  129577. deltaTime: number;
  129578. /**
  129579. * How much is completed, in [0.0...1.0].
  129580. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129581. */
  129582. completeRate: number;
  129583. /**
  129584. * What the registered observable sent in the last count
  129585. */
  129586. payload: T;
  129587. }
  129588. /**
  129589. * The current state of the timer
  129590. */
  129591. export enum TimerState {
  129592. /**
  129593. * Timer initialized, not yet started
  129594. */
  129595. INIT = 0,
  129596. /**
  129597. * Timer started and counting
  129598. */
  129599. STARTED = 1,
  129600. /**
  129601. * Timer ended (whether aborted or time reached)
  129602. */
  129603. ENDED = 2
  129604. }
  129605. /**
  129606. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129607. *
  129608. * @param options options with which to initialize this timer
  129609. */
  129610. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129611. /**
  129612. * An advanced implementation of a timer class
  129613. */
  129614. export class AdvancedTimer<T = any> implements IDisposable {
  129615. /**
  129616. * Will notify each time the timer calculates the remaining time
  129617. */
  129618. onEachCountObservable: Observable<ITimerData<T>>;
  129619. /**
  129620. * Will trigger when the timer was aborted due to the break condition
  129621. */
  129622. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129623. /**
  129624. * Will trigger when the timer ended successfully
  129625. */
  129626. onTimerEndedObservable: Observable<ITimerData<T>>;
  129627. /**
  129628. * Will trigger when the timer state has changed
  129629. */
  129630. onStateChangedObservable: Observable<TimerState>;
  129631. private _observer;
  129632. private _contextObservable;
  129633. private _observableParameters;
  129634. private _startTime;
  129635. private _timer;
  129636. private _state;
  129637. private _breakCondition;
  129638. private _timeToEnd;
  129639. private _breakOnNextTick;
  129640. /**
  129641. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  129642. * @param options construction options for this advanced timer
  129643. */
  129644. constructor(options: ITimerOptions<T>);
  129645. /**
  129646. * set a breaking condition for this timer. Default is to never break during count
  129647. * @param predicate the new break condition. Returns true to break, false otherwise
  129648. */
  129649. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  129650. /**
  129651. * Reset ALL associated observables in this advanced timer
  129652. */
  129653. clearObservables(): void;
  129654. /**
  129655. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  129656. *
  129657. * @param timeToEnd how much time to measure until timer ended
  129658. */
  129659. start(timeToEnd?: number): void;
  129660. /**
  129661. * Will force a stop on the next tick.
  129662. */
  129663. stop(): void;
  129664. /**
  129665. * Dispose this timer, clearing all resources
  129666. */
  129667. dispose(): void;
  129668. private _setState;
  129669. private _tick;
  129670. private _stop;
  129671. }
  129672. }
  129673. declare module BABYLON {
  129674. /**
  129675. * The options container for the teleportation module
  129676. */
  129677. export interface IWebXRTeleportationOptions {
  129678. /**
  129679. * if provided, this scene will be used to render meshes.
  129680. */
  129681. customUtilityLayerScene?: Scene;
  129682. /**
  129683. * Values to configure the default target mesh
  129684. */
  129685. defaultTargetMeshOptions?: {
  129686. /**
  129687. * Fill color of the teleportation area
  129688. */
  129689. teleportationFillColor?: string;
  129690. /**
  129691. * Border color for the teleportation area
  129692. */
  129693. teleportationBorderColor?: string;
  129694. /**
  129695. * Disable the mesh's animation sequence
  129696. */
  129697. disableAnimation?: boolean;
  129698. /**
  129699. * Disable lighting on the material or the ring and arrow
  129700. */
  129701. disableLighting?: boolean;
  129702. /**
  129703. * Override the default material of the torus and arrow
  129704. */
  129705. torusArrowMaterial?: Material;
  129706. };
  129707. /**
  129708. * A list of meshes to use as floor meshes.
  129709. * Meshes can be added and removed after initializing the feature using the
  129710. * addFloorMesh and removeFloorMesh functions
  129711. * If empty, rotation will still work
  129712. */
  129713. floorMeshes?: AbstractMesh[];
  129714. /**
  129715. * use this rendering group id for the meshes (optional)
  129716. */
  129717. renderingGroupId?: number;
  129718. /**
  129719. * Should teleportation move only to snap points
  129720. */
  129721. snapPointsOnly?: boolean;
  129722. /**
  129723. * An array of points to which the teleportation will snap to.
  129724. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  129725. */
  129726. snapPositions?: Vector3[];
  129727. /**
  129728. * How close should the teleportation ray be in order to snap to position.
  129729. * Default to 0.8 units (meters)
  129730. */
  129731. snapToPositionRadius?: number;
  129732. /**
  129733. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  129734. * If you want to support rotation, make sure your mesh has a direction indicator.
  129735. *
  129736. * When left untouched, the default mesh will be initialized.
  129737. */
  129738. teleportationTargetMesh?: AbstractMesh;
  129739. /**
  129740. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  129741. */
  129742. timeToTeleport?: number;
  129743. /**
  129744. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  129745. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  129746. */
  129747. useMainComponentOnly?: boolean;
  129748. /**
  129749. * Should meshes created here be added to a utility layer or the main scene
  129750. */
  129751. useUtilityLayer?: boolean;
  129752. /**
  129753. * Babylon XR Input class for controller
  129754. */
  129755. xrInput: WebXRInput;
  129756. /**
  129757. * Meshes that the teleportation ray cannot go through
  129758. */
  129759. pickBlockerMeshes?: AbstractMesh[];
  129760. }
  129761. /**
  129762. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  129763. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  129764. * the input of the attached controllers.
  129765. */
  129766. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  129767. private _options;
  129768. private _controllers;
  129769. private _currentTeleportationControllerId;
  129770. private _floorMeshes;
  129771. private _quadraticBezierCurve;
  129772. private _selectionFeature;
  129773. private _snapToPositions;
  129774. private _snappedToPoint;
  129775. private _teleportationRingMaterial?;
  129776. private _tmpRay;
  129777. private _tmpVector;
  129778. private _tmpQuaternion;
  129779. /**
  129780. * The module's name
  129781. */
  129782. static readonly Name: string;
  129783. /**
  129784. * The (Babylon) version of this module.
  129785. * This is an integer representing the implementation version.
  129786. * This number does not correspond to the webxr specs version
  129787. */
  129788. static readonly Version: number;
  129789. /**
  129790. * Is movement backwards enabled
  129791. */
  129792. backwardsMovementEnabled: boolean;
  129793. /**
  129794. * Distance to travel when moving backwards
  129795. */
  129796. backwardsTeleportationDistance: number;
  129797. /**
  129798. * The distance from the user to the inspection point in the direction of the controller
  129799. * A higher number will allow the user to move further
  129800. * defaults to 5 (meters, in xr units)
  129801. */
  129802. parabolicCheckRadius: number;
  129803. /**
  129804. * Should the module support parabolic ray on top of direct ray
  129805. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129806. * Very helpful when moving between floors / different heights
  129807. */
  129808. parabolicRayEnabled: boolean;
  129809. /**
  129810. * How much rotation should be applied when rotating right and left
  129811. */
  129812. rotationAngle: number;
  129813. /**
  129814. * Is rotation enabled when moving forward?
  129815. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129816. */
  129817. rotationEnabled: boolean;
  129818. /**
  129819. * constructs a new anchor system
  129820. * @param _xrSessionManager an instance of WebXRSessionManager
  129821. * @param _options configuration object for this feature
  129822. */
  129823. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129824. /**
  129825. * Get the snapPointsOnly flag
  129826. */
  129827. get snapPointsOnly(): boolean;
  129828. /**
  129829. * Sets the snapPointsOnly flag
  129830. * @param snapToPoints should teleportation be exclusively to snap points
  129831. */
  129832. set snapPointsOnly(snapToPoints: boolean);
  129833. /**
  129834. * Add a new mesh to the floor meshes array
  129835. * @param mesh the mesh to use as floor mesh
  129836. */
  129837. addFloorMesh(mesh: AbstractMesh): void;
  129838. /**
  129839. * Add a new snap-to point to fix teleportation to this position
  129840. * @param newSnapPoint The new Snap-To point
  129841. */
  129842. addSnapPoint(newSnapPoint: Vector3): void;
  129843. attach(): boolean;
  129844. detach(): boolean;
  129845. dispose(): void;
  129846. /**
  129847. * Remove a mesh from the floor meshes array
  129848. * @param mesh the mesh to remove
  129849. */
  129850. removeFloorMesh(mesh: AbstractMesh): void;
  129851. /**
  129852. * Remove a mesh from the floor meshes array using its name
  129853. * @param name the mesh name to remove
  129854. */
  129855. removeFloorMeshByName(name: string): void;
  129856. /**
  129857. * 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
  129858. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129859. * @returns was the point found and removed or not
  129860. */
  129861. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129862. /**
  129863. * This function sets a selection feature that will be disabled when
  129864. * the forward ray is shown and will be reattached when hidden.
  129865. * This is used to remove the selection rays when moving.
  129866. * @param selectionFeature the feature to disable when forward movement is enabled
  129867. */
  129868. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  129869. protected _onXRFrame(_xrFrame: XRFrame): void;
  129870. private _attachController;
  129871. private _createDefaultTargetMesh;
  129872. private _detachController;
  129873. private _findClosestSnapPointWithRadius;
  129874. private _setTargetMeshPosition;
  129875. private _setTargetMeshVisibility;
  129876. private _showParabolicPath;
  129877. private _teleportForward;
  129878. }
  129879. }
  129880. declare module BABYLON {
  129881. /**
  129882. * Options for the default xr helper
  129883. */
  129884. export class WebXRDefaultExperienceOptions {
  129885. /**
  129886. * Enable or disable default UI to enter XR
  129887. */
  129888. disableDefaultUI?: boolean;
  129889. /**
  129890. * Should teleportation not initialize. defaults to false.
  129891. */
  129892. disableTeleportation?: boolean;
  129893. /**
  129894. * Floor meshes that will be used for teleport
  129895. */
  129896. floorMeshes?: Array<AbstractMesh>;
  129897. /**
  129898. * If set to true, the first frame will not be used to reset position
  129899. * The first frame is mainly used when copying transformation from the old camera
  129900. * Mainly used in AR
  129901. */
  129902. ignoreNativeCameraTransformation?: boolean;
  129903. /**
  129904. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  129905. */
  129906. inputOptions?: IWebXRInputOptions;
  129907. /**
  129908. * optional configuration for the output canvas
  129909. */
  129910. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  129911. /**
  129912. * optional UI options. This can be used among other to change session mode and reference space type
  129913. */
  129914. uiOptions?: WebXREnterExitUIOptions;
  129915. /**
  129916. * When loading teleportation and pointer select, use stable versions instead of latest.
  129917. */
  129918. useStablePlugins?: boolean;
  129919. /**
  129920. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  129921. */
  129922. renderingGroupId?: number;
  129923. /**
  129924. * A list of optional features to init the session with
  129925. * If set to true, all features we support will be added
  129926. */
  129927. optionalFeatures?: boolean | string[];
  129928. }
  129929. /**
  129930. * Default experience which provides a similar setup to the previous webVRExperience
  129931. */
  129932. export class WebXRDefaultExperience {
  129933. /**
  129934. * Base experience
  129935. */
  129936. baseExperience: WebXRExperienceHelper;
  129937. /**
  129938. * Enables ui for entering/exiting xr
  129939. */
  129940. enterExitUI: WebXREnterExitUI;
  129941. /**
  129942. * Input experience extension
  129943. */
  129944. input: WebXRInput;
  129945. /**
  129946. * Enables laser pointer and selection
  129947. */
  129948. pointerSelection: WebXRControllerPointerSelection;
  129949. /**
  129950. * Default target xr should render to
  129951. */
  129952. renderTarget: WebXRRenderTarget;
  129953. /**
  129954. * Enables teleportation
  129955. */
  129956. teleportation: WebXRMotionControllerTeleportation;
  129957. private constructor();
  129958. /**
  129959. * Creates the default xr experience
  129960. * @param scene scene
  129961. * @param options options for basic configuration
  129962. * @returns resulting WebXRDefaultExperience
  129963. */
  129964. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  129965. /**
  129966. * DIsposes of the experience helper
  129967. */
  129968. dispose(): void;
  129969. }
  129970. }
  129971. declare module BABYLON {
  129972. /**
  129973. * Options to modify the vr teleportation behavior.
  129974. */
  129975. export interface VRTeleportationOptions {
  129976. /**
  129977. * The name of the mesh which should be used as the teleportation floor. (default: null)
  129978. */
  129979. floorMeshName?: string;
  129980. /**
  129981. * A list of meshes to be used as the teleportation floor. (default: empty)
  129982. */
  129983. floorMeshes?: Mesh[];
  129984. /**
  129985. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  129986. */
  129987. teleportationMode?: number;
  129988. /**
  129989. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  129990. */
  129991. teleportationTime?: number;
  129992. /**
  129993. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  129994. */
  129995. teleportationSpeed?: number;
  129996. /**
  129997. * The easing function used in the animation or null for Linear. (default CircleEase)
  129998. */
  129999. easingFunction?: EasingFunction;
  130000. }
  130001. /**
  130002. * Options to modify the vr experience helper's behavior.
  130003. */
  130004. export interface VRExperienceHelperOptions extends WebVROptions {
  130005. /**
  130006. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  130007. */
  130008. createDeviceOrientationCamera?: boolean;
  130009. /**
  130010. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  130011. */
  130012. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  130013. /**
  130014. * Uses the main button on the controller to toggle the laser casted. (default: true)
  130015. */
  130016. laserToggle?: boolean;
  130017. /**
  130018. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  130019. */
  130020. floorMeshes?: Mesh[];
  130021. /**
  130022. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  130023. */
  130024. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  130025. /**
  130026. * Defines if WebXR should be used instead of WebVR (if available)
  130027. */
  130028. useXR?: boolean;
  130029. }
  130030. /**
  130031. * Event containing information after VR has been entered
  130032. */
  130033. export class OnAfterEnteringVRObservableEvent {
  130034. /**
  130035. * If entering vr was successful
  130036. */
  130037. success: boolean;
  130038. }
  130039. /**
  130040. * Helps to quickly add VR support to an existing scene.
  130041. * See https://doc.babylonjs.com/how_to/webvr_helper
  130042. */
  130043. export class VRExperienceHelper {
  130044. /** Options to modify the vr experience helper's behavior. */
  130045. webVROptions: VRExperienceHelperOptions;
  130046. private _scene;
  130047. private _position;
  130048. private _btnVR;
  130049. private _btnVRDisplayed;
  130050. private _webVRsupported;
  130051. private _webVRready;
  130052. private _webVRrequesting;
  130053. private _webVRpresenting;
  130054. private _hasEnteredVR;
  130055. private _fullscreenVRpresenting;
  130056. private _inputElement;
  130057. private _webVRCamera;
  130058. private _vrDeviceOrientationCamera;
  130059. private _deviceOrientationCamera;
  130060. private _existingCamera;
  130061. private _onKeyDown;
  130062. private _onVrDisplayPresentChange;
  130063. private _onVRDisplayChanged;
  130064. private _onVRRequestPresentStart;
  130065. private _onVRRequestPresentComplete;
  130066. /**
  130067. * 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)
  130068. */
  130069. enableGazeEvenWhenNoPointerLock: boolean;
  130070. /**
  130071. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  130072. */
  130073. exitVROnDoubleTap: boolean;
  130074. /**
  130075. * Observable raised right before entering VR.
  130076. */
  130077. onEnteringVRObservable: Observable<VRExperienceHelper>;
  130078. /**
  130079. * Observable raised when entering VR has completed.
  130080. */
  130081. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  130082. /**
  130083. * Observable raised when exiting VR.
  130084. */
  130085. onExitingVRObservable: Observable<VRExperienceHelper>;
  130086. /**
  130087. * Observable raised when controller mesh is loaded.
  130088. */
  130089. onControllerMeshLoadedObservable: Observable<WebVRController>;
  130090. /** Return this.onEnteringVRObservable
  130091. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  130092. */
  130093. get onEnteringVR(): Observable<VRExperienceHelper>;
  130094. /** Return this.onExitingVRObservable
  130095. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  130096. */
  130097. get onExitingVR(): Observable<VRExperienceHelper>;
  130098. /** Return this.onControllerMeshLoadedObservable
  130099. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  130100. */
  130101. get onControllerMeshLoaded(): Observable<WebVRController>;
  130102. private _rayLength;
  130103. private _useCustomVRButton;
  130104. private _teleportationRequested;
  130105. private _teleportActive;
  130106. private _floorMeshName;
  130107. private _floorMeshesCollection;
  130108. private _teleportationMode;
  130109. private _teleportationTime;
  130110. private _teleportationSpeed;
  130111. private _teleportationEasing;
  130112. private _rotationAllowed;
  130113. private _teleportBackwardsVector;
  130114. private _teleportationTarget;
  130115. private _isDefaultTeleportationTarget;
  130116. private _postProcessMove;
  130117. private _teleportationFillColor;
  130118. private _teleportationBorderColor;
  130119. private _rotationAngle;
  130120. private _haloCenter;
  130121. private _cameraGazer;
  130122. private _padSensibilityUp;
  130123. private _padSensibilityDown;
  130124. private _leftController;
  130125. private _rightController;
  130126. private _gazeColor;
  130127. private _laserColor;
  130128. private _pickedLaserColor;
  130129. private _pickedGazeColor;
  130130. /**
  130131. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  130132. */
  130133. onNewMeshSelected: Observable<AbstractMesh>;
  130134. /**
  130135. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  130136. * This observable will provide the mesh and the controller used to select the mesh
  130137. */
  130138. onMeshSelectedWithController: Observable<{
  130139. mesh: AbstractMesh;
  130140. controller: WebVRController;
  130141. }>;
  130142. /**
  130143. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  130144. */
  130145. onNewMeshPicked: Observable<PickingInfo>;
  130146. private _circleEase;
  130147. /**
  130148. * Observable raised before camera teleportation
  130149. */
  130150. onBeforeCameraTeleport: Observable<Vector3>;
  130151. /**
  130152. * Observable raised after camera teleportation
  130153. */
  130154. onAfterCameraTeleport: Observable<Vector3>;
  130155. /**
  130156. * Observable raised when current selected mesh gets unselected
  130157. */
  130158. onSelectedMeshUnselected: Observable<AbstractMesh>;
  130159. private _raySelectionPredicate;
  130160. /**
  130161. * To be optionaly changed by user to define custom ray selection
  130162. */
  130163. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  130164. /**
  130165. * To be optionaly changed by user to define custom selection logic (after ray selection)
  130166. */
  130167. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130168. /**
  130169. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  130170. */
  130171. teleportationEnabled: boolean;
  130172. private _defaultHeight;
  130173. private _teleportationInitialized;
  130174. private _interactionsEnabled;
  130175. private _interactionsRequested;
  130176. private _displayGaze;
  130177. private _displayLaserPointer;
  130178. /**
  130179. * The mesh used to display where the user is going to teleport.
  130180. */
  130181. get teleportationTarget(): Mesh;
  130182. /**
  130183. * Sets the mesh to be used to display where the user is going to teleport.
  130184. */
  130185. set teleportationTarget(value: Mesh);
  130186. /**
  130187. * 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
  130188. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  130189. * See https://doc.babylonjs.com/resources/baking_transformations
  130190. */
  130191. get gazeTrackerMesh(): Mesh;
  130192. set gazeTrackerMesh(value: Mesh);
  130193. /**
  130194. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  130195. */
  130196. updateGazeTrackerScale: boolean;
  130197. /**
  130198. * If the gaze trackers color should be updated when selecting meshes
  130199. */
  130200. updateGazeTrackerColor: boolean;
  130201. /**
  130202. * If the controller laser color should be updated when selecting meshes
  130203. */
  130204. updateControllerLaserColor: boolean;
  130205. /**
  130206. * The gaze tracking mesh corresponding to the left controller
  130207. */
  130208. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  130209. /**
  130210. * The gaze tracking mesh corresponding to the right controller
  130211. */
  130212. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  130213. /**
  130214. * If the ray of the gaze should be displayed.
  130215. */
  130216. get displayGaze(): boolean;
  130217. /**
  130218. * Sets if the ray of the gaze should be displayed.
  130219. */
  130220. set displayGaze(value: boolean);
  130221. /**
  130222. * If the ray of the LaserPointer should be displayed.
  130223. */
  130224. get displayLaserPointer(): boolean;
  130225. /**
  130226. * Sets if the ray of the LaserPointer should be displayed.
  130227. */
  130228. set displayLaserPointer(value: boolean);
  130229. /**
  130230. * The deviceOrientationCamera used as the camera when not in VR.
  130231. */
  130232. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  130233. /**
  130234. * Based on the current WebVR support, returns the current VR camera used.
  130235. */
  130236. get currentVRCamera(): Nullable<Camera>;
  130237. /**
  130238. * The webVRCamera which is used when in VR.
  130239. */
  130240. get webVRCamera(): WebVRFreeCamera;
  130241. /**
  130242. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  130243. */
  130244. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  130245. /**
  130246. * The html button that is used to trigger entering into VR.
  130247. */
  130248. get vrButton(): Nullable<HTMLButtonElement>;
  130249. private get _teleportationRequestInitiated();
  130250. /**
  130251. * Defines whether or not Pointer lock should be requested when switching to
  130252. * full screen.
  130253. */
  130254. requestPointerLockOnFullScreen: boolean;
  130255. /**
  130256. * If asking to force XR, this will be populated with the default xr experience
  130257. */
  130258. xr: WebXRDefaultExperience;
  130259. /**
  130260. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  130261. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  130262. */
  130263. xrTestDone: boolean;
  130264. /**
  130265. * Instantiates a VRExperienceHelper.
  130266. * Helps to quickly add VR support to an existing scene.
  130267. * @param scene The scene the VRExperienceHelper belongs to.
  130268. * @param webVROptions Options to modify the vr experience helper's behavior.
  130269. */
  130270. constructor(scene: Scene,
  130271. /** Options to modify the vr experience helper's behavior. */
  130272. webVROptions?: VRExperienceHelperOptions);
  130273. private completeVRInit;
  130274. private _onDefaultMeshLoaded;
  130275. private _onResize;
  130276. private _onFullscreenChange;
  130277. /**
  130278. * Gets a value indicating if we are currently in VR mode.
  130279. */
  130280. get isInVRMode(): boolean;
  130281. private onVrDisplayPresentChange;
  130282. private onVRDisplayChanged;
  130283. private moveButtonToBottomRight;
  130284. private displayVRButton;
  130285. private updateButtonVisibility;
  130286. private _cachedAngularSensibility;
  130287. /**
  130288. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  130289. * Otherwise, will use the fullscreen API.
  130290. */
  130291. enterVR(): void;
  130292. /**
  130293. * Attempt to exit VR, or fullscreen.
  130294. */
  130295. exitVR(): void;
  130296. /**
  130297. * The position of the vr experience helper.
  130298. */
  130299. get position(): Vector3;
  130300. /**
  130301. * Sets the position of the vr experience helper.
  130302. */
  130303. set position(value: Vector3);
  130304. /**
  130305. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  130306. */
  130307. enableInteractions(): void;
  130308. private get _noControllerIsActive();
  130309. private beforeRender;
  130310. private _isTeleportationFloor;
  130311. /**
  130312. * Adds a floor mesh to be used for teleportation.
  130313. * @param floorMesh the mesh to be used for teleportation.
  130314. */
  130315. addFloorMesh(floorMesh: Mesh): void;
  130316. /**
  130317. * Removes a floor mesh from being used for teleportation.
  130318. * @param floorMesh the mesh to be removed.
  130319. */
  130320. removeFloorMesh(floorMesh: Mesh): void;
  130321. /**
  130322. * Enables interactions and teleportation using the VR controllers and gaze.
  130323. * @param vrTeleportationOptions options to modify teleportation behavior.
  130324. */
  130325. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  130326. private _onNewGamepadConnected;
  130327. private _tryEnableInteractionOnController;
  130328. private _onNewGamepadDisconnected;
  130329. private _enableInteractionOnController;
  130330. private _checkTeleportWithRay;
  130331. private _checkRotate;
  130332. private _checkTeleportBackwards;
  130333. private _enableTeleportationOnController;
  130334. private _createTeleportationCircles;
  130335. private _displayTeleportationTarget;
  130336. private _hideTeleportationTarget;
  130337. private _rotateCamera;
  130338. private _moveTeleportationSelectorTo;
  130339. private _workingVector;
  130340. private _workingQuaternion;
  130341. private _workingMatrix;
  130342. /**
  130343. * Time Constant Teleportation Mode
  130344. */
  130345. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  130346. /**
  130347. * Speed Constant Teleportation Mode
  130348. */
  130349. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  130350. /**
  130351. * Teleports the users feet to the desired location
  130352. * @param location The location where the user's feet should be placed
  130353. */
  130354. teleportCamera(location: Vector3): void;
  130355. private _convertNormalToDirectionOfRay;
  130356. private _castRayAndSelectObject;
  130357. private _notifySelectedMeshUnselected;
  130358. /**
  130359. * Permanently set new colors for the laser pointer
  130360. * @param color the new laser color
  130361. * @param pickedColor the new laser color when picked mesh detected
  130362. */
  130363. setLaserColor(color: Color3, pickedColor?: Color3): void;
  130364. /**
  130365. * Set lighting enabled / disabled on the laser pointer of both controllers
  130366. * @param enabled should the lighting be enabled on the laser pointer
  130367. */
  130368. setLaserLightingState(enabled?: boolean): void;
  130369. /**
  130370. * Permanently set new colors for the gaze pointer
  130371. * @param color the new gaze color
  130372. * @param pickedColor the new gaze color when picked mesh detected
  130373. */
  130374. setGazeColor(color: Color3, pickedColor?: Color3): void;
  130375. /**
  130376. * Sets the color of the laser ray from the vr controllers.
  130377. * @param color new color for the ray.
  130378. */
  130379. changeLaserColor(color: Color3): void;
  130380. /**
  130381. * Sets the color of the ray from the vr headsets gaze.
  130382. * @param color new color for the ray.
  130383. */
  130384. changeGazeColor(color: Color3): void;
  130385. /**
  130386. * Exits VR and disposes of the vr experience helper
  130387. */
  130388. dispose(): void;
  130389. /**
  130390. * Gets the name of the VRExperienceHelper class
  130391. * @returns "VRExperienceHelper"
  130392. */
  130393. getClassName(): string;
  130394. }
  130395. }
  130396. declare module BABYLON {
  130397. /**
  130398. * Contains an array of blocks representing the octree
  130399. */
  130400. export interface IOctreeContainer<T> {
  130401. /**
  130402. * Blocks within the octree
  130403. */
  130404. blocks: Array<OctreeBlock<T>>;
  130405. }
  130406. /**
  130407. * Class used to store a cell in an octree
  130408. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130409. */
  130410. export class OctreeBlock<T> {
  130411. /**
  130412. * Gets the content of the current block
  130413. */
  130414. entries: T[];
  130415. /**
  130416. * Gets the list of block children
  130417. */
  130418. blocks: Array<OctreeBlock<T>>;
  130419. private _depth;
  130420. private _maxDepth;
  130421. private _capacity;
  130422. private _minPoint;
  130423. private _maxPoint;
  130424. private _boundingVectors;
  130425. private _creationFunc;
  130426. /**
  130427. * Creates a new block
  130428. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  130429. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  130430. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130431. * @param depth defines the current depth of this block in the octree
  130432. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  130433. * @param creationFunc defines a callback to call when an element is added to the block
  130434. */
  130435. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  130436. /**
  130437. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130438. */
  130439. get capacity(): number;
  130440. /**
  130441. * Gets the minimum vector (in world space) of the block's bounding box
  130442. */
  130443. get minPoint(): Vector3;
  130444. /**
  130445. * Gets the maximum vector (in world space) of the block's bounding box
  130446. */
  130447. get maxPoint(): Vector3;
  130448. /**
  130449. * Add a new element to this block
  130450. * @param entry defines the element to add
  130451. */
  130452. addEntry(entry: T): void;
  130453. /**
  130454. * Remove an element from this block
  130455. * @param entry defines the element to remove
  130456. */
  130457. removeEntry(entry: T): void;
  130458. /**
  130459. * Add an array of elements to this block
  130460. * @param entries defines the array of elements to add
  130461. */
  130462. addEntries(entries: T[]): void;
  130463. /**
  130464. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  130465. * @param frustumPlanes defines the frustum planes to test
  130466. * @param selection defines the array to store current content if selection is positive
  130467. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130468. */
  130469. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130470. /**
  130471. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  130472. * @param sphereCenter defines the bounding sphere center
  130473. * @param sphereRadius defines the bounding sphere radius
  130474. * @param selection defines the array to store current content if selection is positive
  130475. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130476. */
  130477. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130478. /**
  130479. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  130480. * @param ray defines the ray to test with
  130481. * @param selection defines the array to store current content if selection is positive
  130482. */
  130483. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  130484. /**
  130485. * Subdivide the content into child blocks (this block will then be empty)
  130486. */
  130487. createInnerBlocks(): void;
  130488. /**
  130489. * @hidden
  130490. */
  130491. 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;
  130492. }
  130493. }
  130494. declare module BABYLON {
  130495. /**
  130496. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  130497. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130498. */
  130499. export class Octree<T> {
  130500. /** 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.) */
  130501. maxDepth: number;
  130502. /**
  130503. * Blocks within the octree containing objects
  130504. */
  130505. blocks: Array<OctreeBlock<T>>;
  130506. /**
  130507. * Content stored in the octree
  130508. */
  130509. dynamicContent: T[];
  130510. private _maxBlockCapacity;
  130511. private _selectionContent;
  130512. private _creationFunc;
  130513. /**
  130514. * Creates a octree
  130515. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130516. * @param creationFunc function to be used to instatiate the octree
  130517. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  130518. * @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.)
  130519. */
  130520. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  130521. /** 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.) */
  130522. maxDepth?: number);
  130523. /**
  130524. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  130525. * @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);
  130526. * @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);
  130527. * @param entries meshes to be added to the octree blocks
  130528. */
  130529. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  130530. /**
  130531. * Adds a mesh to the octree
  130532. * @param entry Mesh to add to the octree
  130533. */
  130534. addMesh(entry: T): void;
  130535. /**
  130536. * Remove an element from the octree
  130537. * @param entry defines the element to remove
  130538. */
  130539. removeMesh(entry: T): void;
  130540. /**
  130541. * Selects an array of meshes within the frustum
  130542. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  130543. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  130544. * @returns array of meshes within the frustum
  130545. */
  130546. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  130547. /**
  130548. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  130549. * @param sphereCenter defines the bounding sphere center
  130550. * @param sphereRadius defines the bounding sphere radius
  130551. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130552. * @returns an array of objects that intersect the sphere
  130553. */
  130554. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130555. /**
  130556. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130557. * @param ray defines the ray to test with
  130558. * @returns array of intersected objects
  130559. */
  130560. intersectsRay(ray: Ray): SmartArray<T>;
  130561. /**
  130562. * Adds a mesh into the octree block if it intersects the block
  130563. */
  130564. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130565. /**
  130566. * Adds a submesh into the octree block if it intersects the block
  130567. */
  130568. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130569. }
  130570. }
  130571. declare module BABYLON {
  130572. interface Scene {
  130573. /**
  130574. * @hidden
  130575. * Backing Filed
  130576. */
  130577. _selectionOctree: Octree<AbstractMesh>;
  130578. /**
  130579. * Gets the octree used to boost mesh selection (picking)
  130580. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130581. */
  130582. selectionOctree: Octree<AbstractMesh>;
  130583. /**
  130584. * Creates or updates the octree used to boost selection (picking)
  130585. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130586. * @param maxCapacity defines the maximum capacity per leaf
  130587. * @param maxDepth defines the maximum depth of the octree
  130588. * @returns an octree of AbstractMesh
  130589. */
  130590. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130591. }
  130592. interface AbstractMesh {
  130593. /**
  130594. * @hidden
  130595. * Backing Field
  130596. */
  130597. _submeshesOctree: Octree<SubMesh>;
  130598. /**
  130599. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130600. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130601. * @param maxCapacity defines the maximum size of each block (64 by default)
  130602. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130603. * @returns the new octree
  130604. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130605. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130606. */
  130607. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130608. }
  130609. /**
  130610. * Defines the octree scene component responsible to manage any octrees
  130611. * in a given scene.
  130612. */
  130613. export class OctreeSceneComponent {
  130614. /**
  130615. * The component name help to identify the component in the list of scene components.
  130616. */
  130617. readonly name: string;
  130618. /**
  130619. * The scene the component belongs to.
  130620. */
  130621. scene: Scene;
  130622. /**
  130623. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130624. */
  130625. readonly checksIsEnabled: boolean;
  130626. /**
  130627. * Creates a new instance of the component for the given scene
  130628. * @param scene Defines the scene to register the component in
  130629. */
  130630. constructor(scene: Scene);
  130631. /**
  130632. * Registers the component in a given scene
  130633. */
  130634. register(): void;
  130635. /**
  130636. * Return the list of active meshes
  130637. * @returns the list of active meshes
  130638. */
  130639. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  130640. /**
  130641. * Return the list of active sub meshes
  130642. * @param mesh The mesh to get the candidates sub meshes from
  130643. * @returns the list of active sub meshes
  130644. */
  130645. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  130646. private _tempRay;
  130647. /**
  130648. * Return the list of sub meshes intersecting with a given local ray
  130649. * @param mesh defines the mesh to find the submesh for
  130650. * @param localRay defines the ray in local space
  130651. * @returns the list of intersecting sub meshes
  130652. */
  130653. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  130654. /**
  130655. * Return the list of sub meshes colliding with a collider
  130656. * @param mesh defines the mesh to find the submesh for
  130657. * @param collider defines the collider to evaluate the collision against
  130658. * @returns the list of colliding sub meshes
  130659. */
  130660. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  130661. /**
  130662. * Rebuilds the elements related to this component in case of
  130663. * context lost for instance.
  130664. */
  130665. rebuild(): void;
  130666. /**
  130667. * Disposes the component and the associated ressources.
  130668. */
  130669. dispose(): void;
  130670. }
  130671. }
  130672. declare module BABYLON {
  130673. /**
  130674. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  130675. */
  130676. export class Gizmo implements IDisposable {
  130677. /** The utility layer the gizmo will be added to */
  130678. gizmoLayer: UtilityLayerRenderer;
  130679. /**
  130680. * The root mesh of the gizmo
  130681. */
  130682. _rootMesh: Mesh;
  130683. private _attachedMesh;
  130684. private _attachedNode;
  130685. /**
  130686. * Ratio for the scale of the gizmo (Default: 1)
  130687. */
  130688. protected _scaleRatio: number;
  130689. /**
  130690. * Ratio for the scale of the gizmo (Default: 1)
  130691. */
  130692. set scaleRatio(value: number);
  130693. get scaleRatio(): number;
  130694. /**
  130695. * If a custom mesh has been set (Default: false)
  130696. */
  130697. protected _customMeshSet: boolean;
  130698. /**
  130699. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  130700. * * When set, interactions will be enabled
  130701. */
  130702. get attachedMesh(): Nullable<AbstractMesh>;
  130703. set attachedMesh(value: Nullable<AbstractMesh>);
  130704. /**
  130705. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  130706. * * When set, interactions will be enabled
  130707. */
  130708. get attachedNode(): Nullable<Node>;
  130709. set attachedNode(value: Nullable<Node>);
  130710. /**
  130711. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130712. * @param mesh The mesh to replace the default mesh of the gizmo
  130713. */
  130714. setCustomMesh(mesh: Mesh): void;
  130715. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  130716. /**
  130717. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  130718. */
  130719. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130720. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130721. /**
  130722. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  130723. */
  130724. updateGizmoPositionToMatchAttachedMesh: boolean;
  130725. /**
  130726. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  130727. */
  130728. updateScale: boolean;
  130729. protected _interactionsEnabled: boolean;
  130730. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130731. private _beforeRenderObserver;
  130732. private _tempQuaternion;
  130733. private _tempVector;
  130734. private _tempVector2;
  130735. private _tempMatrix1;
  130736. private _tempMatrix2;
  130737. private _rightHandtoLeftHandMatrix;
  130738. /**
  130739. * Creates a gizmo
  130740. * @param gizmoLayer The utility layer the gizmo will be added to
  130741. */
  130742. constructor(
  130743. /** The utility layer the gizmo will be added to */
  130744. gizmoLayer?: UtilityLayerRenderer);
  130745. /**
  130746. * Updates the gizmo to match the attached mesh's position/rotation
  130747. */
  130748. protected _update(): void;
  130749. /**
  130750. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  130751. * @param value Node, TransformNode or mesh
  130752. */
  130753. protected _matrixChanged(): void;
  130754. /**
  130755. * Disposes of the gizmo
  130756. */
  130757. dispose(): void;
  130758. }
  130759. }
  130760. declare module BABYLON {
  130761. /**
  130762. * Single plane drag gizmo
  130763. */
  130764. export class PlaneDragGizmo extends Gizmo {
  130765. /**
  130766. * Drag behavior responsible for the gizmos dragging interactions
  130767. */
  130768. dragBehavior: PointerDragBehavior;
  130769. private _pointerObserver;
  130770. /**
  130771. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130772. */
  130773. snapDistance: number;
  130774. /**
  130775. * Event that fires each time the gizmo snaps to a new location.
  130776. * * snapDistance is the the change in distance
  130777. */
  130778. onSnapObservable: Observable<{
  130779. snapDistance: number;
  130780. }>;
  130781. private _plane;
  130782. private _coloredMaterial;
  130783. private _hoverMaterial;
  130784. private _isEnabled;
  130785. private _parent;
  130786. /** @hidden */
  130787. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  130788. /** @hidden */
  130789. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130790. /**
  130791. * Creates a PlaneDragGizmo
  130792. * @param gizmoLayer The utility layer the gizmo will be added to
  130793. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  130794. * @param color The color of the gizmo
  130795. */
  130796. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  130797. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130798. /**
  130799. * If the gizmo is enabled
  130800. */
  130801. set isEnabled(value: boolean);
  130802. get isEnabled(): boolean;
  130803. /**
  130804. * Disposes of the gizmo
  130805. */
  130806. dispose(): void;
  130807. }
  130808. }
  130809. declare module BABYLON {
  130810. /**
  130811. * Gizmo that enables dragging a mesh along 3 axis
  130812. */
  130813. export class PositionGizmo extends Gizmo {
  130814. /**
  130815. * Internal gizmo used for interactions on the x axis
  130816. */
  130817. xGizmo: AxisDragGizmo;
  130818. /**
  130819. * Internal gizmo used for interactions on the y axis
  130820. */
  130821. yGizmo: AxisDragGizmo;
  130822. /**
  130823. * Internal gizmo used for interactions on the z axis
  130824. */
  130825. zGizmo: AxisDragGizmo;
  130826. /**
  130827. * Internal gizmo used for interactions on the yz plane
  130828. */
  130829. xPlaneGizmo: PlaneDragGizmo;
  130830. /**
  130831. * Internal gizmo used for interactions on the xz plane
  130832. */
  130833. yPlaneGizmo: PlaneDragGizmo;
  130834. /**
  130835. * Internal gizmo used for interactions on the xy plane
  130836. */
  130837. zPlaneGizmo: PlaneDragGizmo;
  130838. /**
  130839. * private variables
  130840. */
  130841. private _meshAttached;
  130842. private _nodeAttached;
  130843. private _snapDistance;
  130844. /** Fires an event when any of it's sub gizmos are dragged */
  130845. onDragStartObservable: Observable<unknown>;
  130846. /** Fires an event when any of it's sub gizmos are released from dragging */
  130847. onDragEndObservable: Observable<unknown>;
  130848. /**
  130849. * If set to true, planar drag is enabled
  130850. */
  130851. private _planarGizmoEnabled;
  130852. get attachedMesh(): Nullable<AbstractMesh>;
  130853. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130854. get attachedNode(): Nullable<Node>;
  130855. set attachedNode(node: Nullable<Node>);
  130856. /**
  130857. * Creates a PositionGizmo
  130858. * @param gizmoLayer The utility layer the gizmo will be added to
  130859. @param thickness display gizmo axis thickness
  130860. */
  130861. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130862. /**
  130863. * If the planar drag gizmo is enabled
  130864. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130865. */
  130866. set planarGizmoEnabled(value: boolean);
  130867. get planarGizmoEnabled(): boolean;
  130868. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130869. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130870. /**
  130871. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130872. */
  130873. set snapDistance(value: number);
  130874. get snapDistance(): number;
  130875. /**
  130876. * Ratio for the scale of the gizmo (Default: 1)
  130877. */
  130878. set scaleRatio(value: number);
  130879. get scaleRatio(): number;
  130880. /**
  130881. * Disposes of the gizmo
  130882. */
  130883. dispose(): void;
  130884. /**
  130885. * CustomMeshes are not supported by this gizmo
  130886. * @param mesh The mesh to replace the default mesh of the gizmo
  130887. */
  130888. setCustomMesh(mesh: Mesh): void;
  130889. }
  130890. }
  130891. declare module BABYLON {
  130892. /**
  130893. * Single axis drag gizmo
  130894. */
  130895. export class AxisDragGizmo extends Gizmo {
  130896. /**
  130897. * Drag behavior responsible for the gizmos dragging interactions
  130898. */
  130899. dragBehavior: PointerDragBehavior;
  130900. private _pointerObserver;
  130901. /**
  130902. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130903. */
  130904. snapDistance: number;
  130905. /**
  130906. * Event that fires each time the gizmo snaps to a new location.
  130907. * * snapDistance is the the change in distance
  130908. */
  130909. onSnapObservable: Observable<{
  130910. snapDistance: number;
  130911. }>;
  130912. private _isEnabled;
  130913. private _parent;
  130914. private _arrow;
  130915. private _coloredMaterial;
  130916. private _hoverMaterial;
  130917. /** @hidden */
  130918. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  130919. /** @hidden */
  130920. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130921. /**
  130922. * Creates an AxisDragGizmo
  130923. * @param gizmoLayer The utility layer the gizmo will be added to
  130924. * @param dragAxis The axis which the gizmo will be able to drag on
  130925. * @param color The color of the gizmo
  130926. * @param thickness display gizmo axis thickness
  130927. */
  130928. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  130929. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130930. /**
  130931. * If the gizmo is enabled
  130932. */
  130933. set isEnabled(value: boolean);
  130934. get isEnabled(): boolean;
  130935. /**
  130936. * Disposes of the gizmo
  130937. */
  130938. dispose(): void;
  130939. }
  130940. }
  130941. declare module BABYLON.Debug {
  130942. /**
  130943. * The Axes viewer will show 3 axes in a specific point in space
  130944. */
  130945. export class AxesViewer {
  130946. private _xAxis;
  130947. private _yAxis;
  130948. private _zAxis;
  130949. private _scaleLinesFactor;
  130950. private _instanced;
  130951. /**
  130952. * Gets the hosting scene
  130953. */
  130954. scene: Nullable<Scene>;
  130955. /**
  130956. * Gets or sets a number used to scale line length
  130957. */
  130958. scaleLines: number;
  130959. /** Gets the node hierarchy used to render x-axis */
  130960. get xAxis(): TransformNode;
  130961. /** Gets the node hierarchy used to render y-axis */
  130962. get yAxis(): TransformNode;
  130963. /** Gets the node hierarchy used to render z-axis */
  130964. get zAxis(): TransformNode;
  130965. /**
  130966. * Creates a new AxesViewer
  130967. * @param scene defines the hosting scene
  130968. * @param scaleLines defines a number used to scale line length (1 by default)
  130969. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  130970. * @param xAxis defines the node hierarchy used to render the x-axis
  130971. * @param yAxis defines the node hierarchy used to render the y-axis
  130972. * @param zAxis defines the node hierarchy used to render the z-axis
  130973. */
  130974. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  130975. /**
  130976. * Force the viewer to update
  130977. * @param position defines the position of the viewer
  130978. * @param xaxis defines the x axis of the viewer
  130979. * @param yaxis defines the y axis of the viewer
  130980. * @param zaxis defines the z axis of the viewer
  130981. */
  130982. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  130983. /**
  130984. * Creates an instance of this axes viewer.
  130985. * @returns a new axes viewer with instanced meshes
  130986. */
  130987. createInstance(): AxesViewer;
  130988. /** Releases resources */
  130989. dispose(): void;
  130990. private static _SetRenderingGroupId;
  130991. }
  130992. }
  130993. declare module BABYLON.Debug {
  130994. /**
  130995. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  130996. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  130997. */
  130998. export class BoneAxesViewer extends AxesViewer {
  130999. /**
  131000. * Gets or sets the target mesh where to display the axes viewer
  131001. */
  131002. mesh: Nullable<Mesh>;
  131003. /**
  131004. * Gets or sets the target bone where to display the axes viewer
  131005. */
  131006. bone: Nullable<Bone>;
  131007. /** Gets current position */
  131008. pos: Vector3;
  131009. /** Gets direction of X axis */
  131010. xaxis: Vector3;
  131011. /** Gets direction of Y axis */
  131012. yaxis: Vector3;
  131013. /** Gets direction of Z axis */
  131014. zaxis: Vector3;
  131015. /**
  131016. * Creates a new BoneAxesViewer
  131017. * @param scene defines the hosting scene
  131018. * @param bone defines the target bone
  131019. * @param mesh defines the target mesh
  131020. * @param scaleLines defines a scaling factor for line length (1 by default)
  131021. */
  131022. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  131023. /**
  131024. * Force the viewer to update
  131025. */
  131026. update(): void;
  131027. /** Releases resources */
  131028. dispose(): void;
  131029. }
  131030. }
  131031. declare module BABYLON {
  131032. /**
  131033. * Interface used to define scene explorer extensibility option
  131034. */
  131035. export interface IExplorerExtensibilityOption {
  131036. /**
  131037. * Define the option label
  131038. */
  131039. label: string;
  131040. /**
  131041. * Defines the action to execute on click
  131042. */
  131043. action: (entity: any) => void;
  131044. }
  131045. /**
  131046. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  131047. */
  131048. export interface IExplorerExtensibilityGroup {
  131049. /**
  131050. * Defines a predicate to test if a given type mut be extended
  131051. */
  131052. predicate: (entity: any) => boolean;
  131053. /**
  131054. * Gets the list of options added to a type
  131055. */
  131056. entries: IExplorerExtensibilityOption[];
  131057. }
  131058. /**
  131059. * Interface used to define the options to use to create the Inspector
  131060. */
  131061. export interface IInspectorOptions {
  131062. /**
  131063. * Display in overlay mode (default: false)
  131064. */
  131065. overlay?: boolean;
  131066. /**
  131067. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  131068. */
  131069. globalRoot?: HTMLElement;
  131070. /**
  131071. * Display the Scene explorer
  131072. */
  131073. showExplorer?: boolean;
  131074. /**
  131075. * Display the property inspector
  131076. */
  131077. showInspector?: boolean;
  131078. /**
  131079. * Display in embed mode (both panes on the right)
  131080. */
  131081. embedMode?: boolean;
  131082. /**
  131083. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  131084. */
  131085. handleResize?: boolean;
  131086. /**
  131087. * Allow the panes to popup (default: true)
  131088. */
  131089. enablePopup?: boolean;
  131090. /**
  131091. * Allow the panes to be closed by users (default: true)
  131092. */
  131093. enableClose?: boolean;
  131094. /**
  131095. * Optional list of extensibility entries
  131096. */
  131097. explorerExtensibility?: IExplorerExtensibilityGroup[];
  131098. /**
  131099. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  131100. */
  131101. inspectorURL?: string;
  131102. /**
  131103. * Optional initial tab (default to DebugLayerTab.Properties)
  131104. */
  131105. initialTab?: DebugLayerTab;
  131106. }
  131107. interface Scene {
  131108. /**
  131109. * @hidden
  131110. * Backing field
  131111. */
  131112. _debugLayer: DebugLayer;
  131113. /**
  131114. * Gets the debug layer (aka Inspector) associated with the scene
  131115. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131116. */
  131117. debugLayer: DebugLayer;
  131118. }
  131119. /**
  131120. * Enum of inspector action tab
  131121. */
  131122. export enum DebugLayerTab {
  131123. /**
  131124. * Properties tag (default)
  131125. */
  131126. Properties = 0,
  131127. /**
  131128. * Debug tab
  131129. */
  131130. Debug = 1,
  131131. /**
  131132. * Statistics tab
  131133. */
  131134. Statistics = 2,
  131135. /**
  131136. * Tools tab
  131137. */
  131138. Tools = 3,
  131139. /**
  131140. * Settings tab
  131141. */
  131142. Settings = 4
  131143. }
  131144. /**
  131145. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131146. * what is happening in your scene
  131147. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131148. */
  131149. export class DebugLayer {
  131150. /**
  131151. * Define the url to get the inspector script from.
  131152. * By default it uses the babylonjs CDN.
  131153. * @ignoreNaming
  131154. */
  131155. static InspectorURL: string;
  131156. private _scene;
  131157. private BJSINSPECTOR;
  131158. private _onPropertyChangedObservable?;
  131159. /**
  131160. * Observable triggered when a property is changed through the inspector.
  131161. */
  131162. get onPropertyChangedObservable(): any;
  131163. /**
  131164. * Instantiates a new debug layer.
  131165. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131166. * what is happening in your scene
  131167. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131168. * @param scene Defines the scene to inspect
  131169. */
  131170. constructor(scene: Scene);
  131171. /** Creates the inspector window. */
  131172. private _createInspector;
  131173. /**
  131174. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  131175. * @param entity defines the entity to select
  131176. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  131177. */
  131178. select(entity: any, lineContainerTitles?: string | string[]): void;
  131179. /** Get the inspector from bundle or global */
  131180. private _getGlobalInspector;
  131181. /**
  131182. * Get if the inspector is visible or not.
  131183. * @returns true if visible otherwise, false
  131184. */
  131185. isVisible(): boolean;
  131186. /**
  131187. * Hide the inspector and close its window.
  131188. */
  131189. hide(): void;
  131190. /**
  131191. * Update the scene in the inspector
  131192. */
  131193. setAsActiveScene(): void;
  131194. /**
  131195. * Launch the debugLayer.
  131196. * @param config Define the configuration of the inspector
  131197. * @return a promise fulfilled when the debug layer is visible
  131198. */
  131199. show(config?: IInspectorOptions): Promise<DebugLayer>;
  131200. }
  131201. }
  131202. declare module BABYLON {
  131203. /**
  131204. * Class containing static functions to help procedurally build meshes
  131205. */
  131206. export class BoxBuilder {
  131207. /**
  131208. * Creates a box mesh
  131209. * * The parameter `size` sets the size (float) of each box side (default 1)
  131210. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  131211. * * 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)
  131212. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131216. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131217. * @param name defines the name of the mesh
  131218. * @param options defines the options used to create the mesh
  131219. * @param scene defines the hosting scene
  131220. * @returns the box mesh
  131221. */
  131222. static CreateBox(name: string, options: {
  131223. size?: number;
  131224. width?: number;
  131225. height?: number;
  131226. depth?: number;
  131227. faceUV?: Vector4[];
  131228. faceColors?: Color4[];
  131229. sideOrientation?: number;
  131230. frontUVs?: Vector4;
  131231. backUVs?: Vector4;
  131232. wrap?: boolean;
  131233. topBaseAt?: number;
  131234. bottomBaseAt?: number;
  131235. updatable?: boolean;
  131236. }, scene?: Nullable<Scene>): Mesh;
  131237. }
  131238. }
  131239. declare module BABYLON.Debug {
  131240. /**
  131241. * Used to show the physics impostor around the specific mesh
  131242. */
  131243. export class PhysicsViewer {
  131244. /** @hidden */
  131245. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  131246. /** @hidden */
  131247. protected _meshes: Array<Nullable<AbstractMesh>>;
  131248. /** @hidden */
  131249. protected _scene: Nullable<Scene>;
  131250. /** @hidden */
  131251. protected _numMeshes: number;
  131252. /** @hidden */
  131253. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  131254. private _renderFunction;
  131255. private _utilityLayer;
  131256. private _debugBoxMesh;
  131257. private _debugSphereMesh;
  131258. private _debugCylinderMesh;
  131259. private _debugMaterial;
  131260. private _debugMeshMeshes;
  131261. /**
  131262. * Creates a new PhysicsViewer
  131263. * @param scene defines the hosting scene
  131264. */
  131265. constructor(scene: Scene);
  131266. /** @hidden */
  131267. protected _updateDebugMeshes(): void;
  131268. /**
  131269. * Renders a specified physic impostor
  131270. * @param impostor defines the impostor to render
  131271. * @param targetMesh defines the mesh represented by the impostor
  131272. * @returns the new debug mesh used to render the impostor
  131273. */
  131274. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  131275. /**
  131276. * Hides a specified physic impostor
  131277. * @param impostor defines the impostor to hide
  131278. */
  131279. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  131280. private _getDebugMaterial;
  131281. private _getDebugBoxMesh;
  131282. private _getDebugSphereMesh;
  131283. private _getDebugCylinderMesh;
  131284. private _getDebugMeshMesh;
  131285. private _getDebugMesh;
  131286. /** Releases all resources */
  131287. dispose(): void;
  131288. }
  131289. }
  131290. declare module BABYLON {
  131291. /**
  131292. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131293. * in order to better appreciate the issue one might have.
  131294. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131295. */
  131296. export class RayHelper {
  131297. /**
  131298. * Defines the ray we are currently tryin to visualize.
  131299. */
  131300. ray: Nullable<Ray>;
  131301. private _renderPoints;
  131302. private _renderLine;
  131303. private _renderFunction;
  131304. private _scene;
  131305. private _onAfterRenderObserver;
  131306. private _onAfterStepObserver;
  131307. private _attachedToMesh;
  131308. private _meshSpaceDirection;
  131309. private _meshSpaceOrigin;
  131310. /**
  131311. * Helper function to create a colored helper in a scene in one line.
  131312. * @param ray Defines the ray we are currently tryin to visualize
  131313. * @param scene Defines the scene the ray is used in
  131314. * @param color Defines the color we want to see the ray in
  131315. * @returns The newly created ray helper.
  131316. */
  131317. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  131318. /**
  131319. * Instantiate a new ray helper.
  131320. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131321. * in order to better appreciate the issue one might have.
  131322. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131323. * @param ray Defines the ray we are currently tryin to visualize
  131324. */
  131325. constructor(ray: Ray);
  131326. /**
  131327. * Shows the ray we are willing to debug.
  131328. * @param scene Defines the scene the ray needs to be rendered in
  131329. * @param color Defines the color the ray needs to be rendered in
  131330. */
  131331. show(scene: Scene, color?: Color3): void;
  131332. /**
  131333. * Hides the ray we are debugging.
  131334. */
  131335. hide(): void;
  131336. private _render;
  131337. /**
  131338. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  131339. * @param mesh Defines the mesh we want the helper attached to
  131340. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  131341. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  131342. * @param length Defines the length of the ray
  131343. */
  131344. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  131345. /**
  131346. * Detach the ray helper from the mesh it has previously been attached to.
  131347. */
  131348. detachFromMesh(): void;
  131349. private _updateToMesh;
  131350. /**
  131351. * Dispose the helper and release its associated resources.
  131352. */
  131353. dispose(): void;
  131354. }
  131355. }
  131356. declare module BABYLON {
  131357. /**
  131358. * Defines the options associated with the creation of a SkeletonViewer.
  131359. */
  131360. export interface ISkeletonViewerOptions {
  131361. /** Should the system pause animations before building the Viewer? */
  131362. pauseAnimations: boolean;
  131363. /** Should the system return the skeleton to rest before building? */
  131364. returnToRest: boolean;
  131365. /** public Display Mode of the Viewer */
  131366. displayMode: number;
  131367. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131368. displayOptions: ISkeletonViewerDisplayOptions;
  131369. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131370. computeBonesUsingShaders: boolean;
  131371. /** Flag ignore non weighted bones */
  131372. useAllBones: boolean;
  131373. }
  131374. /**
  131375. * Defines how to display the various bone meshes for the viewer.
  131376. */
  131377. export interface ISkeletonViewerDisplayOptions {
  131378. /** How far down to start tapering the bone spurs */
  131379. midStep?: number;
  131380. /** How big is the midStep? */
  131381. midStepFactor?: number;
  131382. /** Base for the Sphere Size */
  131383. sphereBaseSize?: number;
  131384. /** The ratio of the sphere to the longest bone in units */
  131385. sphereScaleUnit?: number;
  131386. /** Ratio for the Sphere Size */
  131387. sphereFactor?: number;
  131388. }
  131389. /**
  131390. * Defines the constructor options for the BoneWeight Shader.
  131391. */
  131392. export interface IBoneWeightShaderOptions {
  131393. /** Skeleton to Map */
  131394. skeleton: Skeleton;
  131395. /** Colors for Uninfluenced bones */
  131396. colorBase?: Color3;
  131397. /** Colors for 0.0-0.25 Weight bones */
  131398. colorZero?: Color3;
  131399. /** Color for 0.25-0.5 Weight Influence */
  131400. colorQuarter?: Color3;
  131401. /** Color for 0.5-0.75 Weight Influence */
  131402. colorHalf?: Color3;
  131403. /** Color for 0.75-1 Weight Influence */
  131404. colorFull?: Color3;
  131405. /** Color for Zero Weight Influence */
  131406. targetBoneIndex?: number;
  131407. }
  131408. /**
  131409. * Simple structure of the gradient steps for the Color Map.
  131410. */
  131411. export interface ISkeletonMapShaderColorMapKnot {
  131412. /** Color of the Knot */
  131413. color: Color3;
  131414. /** Location of the Knot */
  131415. location: number;
  131416. }
  131417. /**
  131418. * Defines the constructor options for the SkeletonMap Shader.
  131419. */
  131420. export interface ISkeletonMapShaderOptions {
  131421. /** Skeleton to Map */
  131422. skeleton: Skeleton;
  131423. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  131424. colorMap?: ISkeletonMapShaderColorMapKnot[];
  131425. }
  131426. }
  131427. declare module BABYLON {
  131428. /**
  131429. * Class containing static functions to help procedurally build meshes
  131430. */
  131431. export class RibbonBuilder {
  131432. /**
  131433. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131434. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131435. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131436. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131437. * * 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
  131438. * * 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
  131439. * * 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
  131440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131442. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131443. * * 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
  131444. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131445. * * 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
  131446. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131448. * @param name defines the name of the mesh
  131449. * @param options defines the options used to create the mesh
  131450. * @param scene defines the hosting scene
  131451. * @returns the ribbon mesh
  131452. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131453. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131454. */
  131455. static CreateRibbon(name: string, options: {
  131456. pathArray: Vector3[][];
  131457. closeArray?: boolean;
  131458. closePath?: boolean;
  131459. offset?: number;
  131460. updatable?: boolean;
  131461. sideOrientation?: number;
  131462. frontUVs?: Vector4;
  131463. backUVs?: Vector4;
  131464. instance?: Mesh;
  131465. invertUV?: boolean;
  131466. uvs?: Vector2[];
  131467. colors?: Color4[];
  131468. }, scene?: Nullable<Scene>): Mesh;
  131469. }
  131470. }
  131471. declare module BABYLON {
  131472. /**
  131473. * Class containing static functions to help procedurally build meshes
  131474. */
  131475. export class ShapeBuilder {
  131476. /**
  131477. * 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.
  131478. * * 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.
  131479. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131480. * * 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.
  131481. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131482. * * 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
  131483. * * 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
  131484. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131487. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131489. * @param name defines the name of the mesh
  131490. * @param options defines the options used to create the mesh
  131491. * @param scene defines the hosting scene
  131492. * @returns the extruded shape mesh
  131493. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131495. */
  131496. static ExtrudeShape(name: string, options: {
  131497. shape: Vector3[];
  131498. path: Vector3[];
  131499. scale?: number;
  131500. rotation?: number;
  131501. cap?: number;
  131502. updatable?: boolean;
  131503. sideOrientation?: number;
  131504. frontUVs?: Vector4;
  131505. backUVs?: Vector4;
  131506. instance?: Mesh;
  131507. invertUV?: boolean;
  131508. }, scene?: Nullable<Scene>): Mesh;
  131509. /**
  131510. * Creates an custom extruded shape mesh.
  131511. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131512. * * 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.
  131513. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131514. * * 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
  131515. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131516. * * 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
  131517. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131518. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131519. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131520. * * 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
  131521. * * 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
  131522. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131525. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131527. * @param name defines the name of the mesh
  131528. * @param options defines the options used to create the mesh
  131529. * @param scene defines the hosting scene
  131530. * @returns the custom extruded shape mesh
  131531. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131532. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131533. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131534. */
  131535. static ExtrudeShapeCustom(name: string, options: {
  131536. shape: Vector3[];
  131537. path: Vector3[];
  131538. scaleFunction?: any;
  131539. rotationFunction?: any;
  131540. ribbonCloseArray?: boolean;
  131541. ribbonClosePath?: boolean;
  131542. cap?: number;
  131543. updatable?: boolean;
  131544. sideOrientation?: number;
  131545. frontUVs?: Vector4;
  131546. backUVs?: Vector4;
  131547. instance?: Mesh;
  131548. invertUV?: boolean;
  131549. }, scene?: Nullable<Scene>): Mesh;
  131550. private static _ExtrudeShapeGeneric;
  131551. }
  131552. }
  131553. declare module BABYLON.Debug {
  131554. /**
  131555. * Class used to render a debug view of a given skeleton
  131556. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131557. */
  131558. export class SkeletonViewer {
  131559. /** defines the skeleton to render */
  131560. skeleton: Skeleton;
  131561. /** defines the mesh attached to the skeleton */
  131562. mesh: AbstractMesh;
  131563. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131564. autoUpdateBonesMatrices: boolean;
  131565. /** defines the rendering group id to use with the viewer */
  131566. renderingGroupId: number;
  131567. /** is the options for the viewer */
  131568. options: Partial<ISkeletonViewerOptions>;
  131569. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131570. static readonly DISPLAY_LINES: number;
  131571. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131572. static readonly DISPLAY_SPHERES: number;
  131573. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131574. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131575. /** public static method to create a BoneWeight Shader
  131576. * @param options The constructor options
  131577. * @param scene The scene that the shader is scoped to
  131578. * @returns The created ShaderMaterial
  131579. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131580. */
  131581. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131582. /** public static method to create a BoneWeight Shader
  131583. * @param options The constructor options
  131584. * @param scene The scene that the shader is scoped to
  131585. * @returns The created ShaderMaterial
  131586. */
  131587. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131588. /** private static method to create a BoneWeight Shader
  131589. * @param size The size of the buffer to create (usually the bone count)
  131590. * @param colorMap The gradient data to generate
  131591. * @param scene The scene that the shader is scoped to
  131592. * @returns an Array of floats from the color gradient values
  131593. */
  131594. private static _CreateBoneMapColorBuffer;
  131595. /** If SkeletonViewer scene scope. */
  131596. private _scene;
  131597. /** Gets or sets the color used to render the skeleton */
  131598. color: Color3;
  131599. /** Array of the points of the skeleton fo the line view. */
  131600. private _debugLines;
  131601. /** The SkeletonViewers Mesh. */
  131602. private _debugMesh;
  131603. /** If SkeletonViewer is enabled. */
  131604. private _isEnabled;
  131605. /** If SkeletonViewer is ready. */
  131606. private _ready;
  131607. /** SkeletonViewer render observable. */
  131608. private _obs;
  131609. /** The Utility Layer to render the gizmos in. */
  131610. private _utilityLayer;
  131611. private _boneIndices;
  131612. /** Gets the Scene. */
  131613. get scene(): Scene;
  131614. /** Gets the utilityLayer. */
  131615. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131616. /** Checks Ready Status. */
  131617. get isReady(): Boolean;
  131618. /** Sets Ready Status. */
  131619. set ready(value: boolean);
  131620. /** Gets the debugMesh */
  131621. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  131622. /** Sets the debugMesh */
  131623. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  131624. /** Gets the displayMode */
  131625. get displayMode(): number;
  131626. /** Sets the displayMode */
  131627. set displayMode(value: number);
  131628. /**
  131629. * Creates a new SkeletonViewer
  131630. * @param skeleton defines the skeleton to render
  131631. * @param mesh defines the mesh attached to the skeleton
  131632. * @param scene defines the hosting scene
  131633. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  131634. * @param renderingGroupId defines the rendering group id to use with the viewer
  131635. * @param options All of the extra constructor options for the SkeletonViewer
  131636. */
  131637. constructor(
  131638. /** defines the skeleton to render */
  131639. skeleton: Skeleton,
  131640. /** defines the mesh attached to the skeleton */
  131641. mesh: AbstractMesh,
  131642. /** The Scene scope*/
  131643. scene: Scene,
  131644. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131645. autoUpdateBonesMatrices?: boolean,
  131646. /** defines the rendering group id to use with the viewer */
  131647. renderingGroupId?: number,
  131648. /** is the options for the viewer */
  131649. options?: Partial<ISkeletonViewerOptions>);
  131650. /** The Dynamic bindings for the update functions */
  131651. private _bindObs;
  131652. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  131653. update(): void;
  131654. /** Gets or sets a boolean indicating if the viewer is enabled */
  131655. set isEnabled(value: boolean);
  131656. get isEnabled(): boolean;
  131657. private _getBonePosition;
  131658. private _getLinesForBonesWithLength;
  131659. private _getLinesForBonesNoLength;
  131660. /** function to revert the mesh and scene back to the initial state. */
  131661. private _revert;
  131662. /** function to build and bind sphere joint points and spur bone representations. */
  131663. private _buildSpheresAndSpurs;
  131664. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  131665. private _displayLinesUpdate;
  131666. /** Changes the displayMode of the skeleton viewer
  131667. * @param mode The displayMode numerical value
  131668. */
  131669. changeDisplayMode(mode: number): void;
  131670. /** Changes the displayMode of the skeleton viewer
  131671. * @param option String of the option name
  131672. * @param value The numerical option value
  131673. */
  131674. changeDisplayOptions(option: string, value: number): void;
  131675. /** Release associated resources */
  131676. dispose(): void;
  131677. }
  131678. }
  131679. declare module BABYLON {
  131680. /**
  131681. * Enum for Device Types
  131682. */
  131683. export enum DeviceType {
  131684. /** Generic */
  131685. Generic = 0,
  131686. /** Keyboard */
  131687. Keyboard = 1,
  131688. /** Mouse */
  131689. Mouse = 2,
  131690. /** Touch Pointers */
  131691. Touch = 3,
  131692. /** PS4 Dual Shock */
  131693. DualShock = 4,
  131694. /** Xbox */
  131695. Xbox = 5,
  131696. /** Switch Controller */
  131697. Switch = 6
  131698. }
  131699. /**
  131700. * Enum for All Pointers (Touch/Mouse)
  131701. */
  131702. export enum PointerInput {
  131703. /** Horizontal Axis */
  131704. Horizontal = 0,
  131705. /** Vertical Axis */
  131706. Vertical = 1,
  131707. /** Left Click or Touch */
  131708. LeftClick = 2,
  131709. /** Middle Click */
  131710. MiddleClick = 3,
  131711. /** Right Click */
  131712. RightClick = 4,
  131713. /** Browser Back */
  131714. BrowserBack = 5,
  131715. /** Browser Forward */
  131716. BrowserForward = 6
  131717. }
  131718. /**
  131719. * Enum for Dual Shock Gamepad
  131720. */
  131721. export enum DualShockInput {
  131722. /** Cross */
  131723. Cross = 0,
  131724. /** Circle */
  131725. Circle = 1,
  131726. /** Square */
  131727. Square = 2,
  131728. /** Triangle */
  131729. Triangle = 3,
  131730. /** L1 */
  131731. L1 = 4,
  131732. /** R1 */
  131733. R1 = 5,
  131734. /** L2 */
  131735. L2 = 6,
  131736. /** R2 */
  131737. R2 = 7,
  131738. /** Share */
  131739. Share = 8,
  131740. /** Options */
  131741. Options = 9,
  131742. /** L3 */
  131743. L3 = 10,
  131744. /** R3 */
  131745. R3 = 11,
  131746. /** DPadUp */
  131747. DPadUp = 12,
  131748. /** DPadDown */
  131749. DPadDown = 13,
  131750. /** DPadLeft */
  131751. DPadLeft = 14,
  131752. /** DRight */
  131753. DPadRight = 15,
  131754. /** Home */
  131755. Home = 16,
  131756. /** TouchPad */
  131757. TouchPad = 17,
  131758. /** LStickXAxis */
  131759. LStickXAxis = 18,
  131760. /** LStickYAxis */
  131761. LStickYAxis = 19,
  131762. /** RStickXAxis */
  131763. RStickXAxis = 20,
  131764. /** RStickYAxis */
  131765. RStickYAxis = 21
  131766. }
  131767. /**
  131768. * Enum for Xbox Gamepad
  131769. */
  131770. export enum XboxInput {
  131771. /** A */
  131772. A = 0,
  131773. /** B */
  131774. B = 1,
  131775. /** X */
  131776. X = 2,
  131777. /** Y */
  131778. Y = 3,
  131779. /** LB */
  131780. LB = 4,
  131781. /** RB */
  131782. RB = 5,
  131783. /** LT */
  131784. LT = 6,
  131785. /** RT */
  131786. RT = 7,
  131787. /** Back */
  131788. Back = 8,
  131789. /** Start */
  131790. Start = 9,
  131791. /** LS */
  131792. LS = 10,
  131793. /** RS */
  131794. RS = 11,
  131795. /** DPadUp */
  131796. DPadUp = 12,
  131797. /** DPadDown */
  131798. DPadDown = 13,
  131799. /** DPadLeft */
  131800. DPadLeft = 14,
  131801. /** DRight */
  131802. DPadRight = 15,
  131803. /** Home */
  131804. Home = 16,
  131805. /** LStickXAxis */
  131806. LStickXAxis = 17,
  131807. /** LStickYAxis */
  131808. LStickYAxis = 18,
  131809. /** RStickXAxis */
  131810. RStickXAxis = 19,
  131811. /** RStickYAxis */
  131812. RStickYAxis = 20
  131813. }
  131814. /**
  131815. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  131816. */
  131817. export enum SwitchInput {
  131818. /** B */
  131819. B = 0,
  131820. /** A */
  131821. A = 1,
  131822. /** Y */
  131823. Y = 2,
  131824. /** X */
  131825. X = 3,
  131826. /** L */
  131827. L = 4,
  131828. /** R */
  131829. R = 5,
  131830. /** ZL */
  131831. ZL = 6,
  131832. /** ZR */
  131833. ZR = 7,
  131834. /** Minus */
  131835. Minus = 8,
  131836. /** Plus */
  131837. Plus = 9,
  131838. /** LS */
  131839. LS = 10,
  131840. /** RS */
  131841. RS = 11,
  131842. /** DPadUp */
  131843. DPadUp = 12,
  131844. /** DPadDown */
  131845. DPadDown = 13,
  131846. /** DPadLeft */
  131847. DPadLeft = 14,
  131848. /** DRight */
  131849. DPadRight = 15,
  131850. /** Home */
  131851. Home = 16,
  131852. /** Capture */
  131853. Capture = 17,
  131854. /** LStickXAxis */
  131855. LStickXAxis = 18,
  131856. /** LStickYAxis */
  131857. LStickYAxis = 19,
  131858. /** RStickXAxis */
  131859. RStickXAxis = 20,
  131860. /** RStickYAxis */
  131861. RStickYAxis = 21
  131862. }
  131863. }
  131864. declare module BABYLON {
  131865. /**
  131866. * This class will take all inputs from Keyboard, Pointer, and
  131867. * any Gamepads and provide a polling system that all devices
  131868. * will use. This class assumes that there will only be one
  131869. * pointer device and one keyboard.
  131870. */
  131871. export class DeviceInputSystem implements IDisposable {
  131872. /**
  131873. * Callback to be triggered when a device is connected
  131874. */
  131875. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131876. /**
  131877. * Callback to be triggered when a device is disconnected
  131878. */
  131879. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131880. /**
  131881. * Callback to be triggered when event driven input is updated
  131882. */
  131883. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  131884. private _inputs;
  131885. private _gamepads;
  131886. private _keyboardActive;
  131887. private _pointerActive;
  131888. private _elementToAttachTo;
  131889. private _keyboardDownEvent;
  131890. private _keyboardUpEvent;
  131891. private _pointerMoveEvent;
  131892. private _pointerDownEvent;
  131893. private _pointerUpEvent;
  131894. private _gamepadConnectedEvent;
  131895. private _gamepadDisconnectedEvent;
  131896. private static _MAX_KEYCODES;
  131897. private static _MAX_POINTER_INPUTS;
  131898. private constructor();
  131899. /**
  131900. * Creates a new DeviceInputSystem instance
  131901. * @param engine Engine to pull input element from
  131902. * @returns The new instance
  131903. */
  131904. static Create(engine: Engine): DeviceInputSystem;
  131905. /**
  131906. * Checks for current device input value, given an id and input index
  131907. * @param deviceName Id of connected device
  131908. * @param inputIndex Index of device input
  131909. * @returns Current value of input
  131910. */
  131911. /**
  131912. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  131913. * @param deviceType Enum specifiying device type
  131914. * @param deviceSlot "Slot" or index that device is referenced in
  131915. * @param inputIndex Id of input to be checked
  131916. * @returns Current value of input
  131917. */
  131918. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  131919. /**
  131920. * Dispose of all the eventlisteners
  131921. */
  131922. dispose(): void;
  131923. /**
  131924. * Add device and inputs to device array
  131925. * @param deviceType Enum specifiying device type
  131926. * @param deviceSlot "Slot" or index that device is referenced in
  131927. * @param numberOfInputs Number of input entries to create for given device
  131928. */
  131929. private _registerDevice;
  131930. /**
  131931. * Given a specific device name, remove that device from the device map
  131932. * @param deviceType Enum specifiying device type
  131933. * @param deviceSlot "Slot" or index that device is referenced in
  131934. */
  131935. private _unregisterDevice;
  131936. /**
  131937. * Handle all actions that come from keyboard interaction
  131938. */
  131939. private _handleKeyActions;
  131940. /**
  131941. * Handle all actions that come from pointer interaction
  131942. */
  131943. private _handlePointerActions;
  131944. /**
  131945. * Handle all actions that come from gamepad interaction
  131946. */
  131947. private _handleGamepadActions;
  131948. /**
  131949. * Update all non-event based devices with each frame
  131950. * @param deviceType Enum specifiying device type
  131951. * @param deviceSlot "Slot" or index that device is referenced in
  131952. * @param inputIndex Id of input to be checked
  131953. */
  131954. private _updateDevice;
  131955. /**
  131956. * Gets DeviceType from the device name
  131957. * @param deviceName Name of Device from DeviceInputSystem
  131958. * @returns DeviceType enum value
  131959. */
  131960. private _getGamepadDeviceType;
  131961. }
  131962. }
  131963. declare module BABYLON {
  131964. /**
  131965. * Type to handle enforcement of inputs
  131966. */
  131967. 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;
  131968. }
  131969. declare module BABYLON {
  131970. /**
  131971. * Class that handles all input for a specific device
  131972. */
  131973. export class DeviceSource<T extends DeviceType> {
  131974. /** Type of device */
  131975. readonly deviceType: DeviceType;
  131976. /** "Slot" or index that device is referenced in */
  131977. readonly deviceSlot: number;
  131978. /**
  131979. * Observable to handle device input changes per device
  131980. */
  131981. readonly onInputChangedObservable: Observable<{
  131982. inputIndex: DeviceInput<T>;
  131983. previousState: Nullable<number>;
  131984. currentState: Nullable<number>;
  131985. }>;
  131986. private readonly _deviceInputSystem;
  131987. /**
  131988. * Default Constructor
  131989. * @param deviceInputSystem Reference to DeviceInputSystem
  131990. * @param deviceType Type of device
  131991. * @param deviceSlot "Slot" or index that device is referenced in
  131992. */
  131993. constructor(deviceInputSystem: DeviceInputSystem,
  131994. /** Type of device */
  131995. deviceType: DeviceType,
  131996. /** "Slot" or index that device is referenced in */
  131997. deviceSlot?: number);
  131998. /**
  131999. * Get input for specific input
  132000. * @param inputIndex index of specific input on device
  132001. * @returns Input value from DeviceInputSystem
  132002. */
  132003. getInput(inputIndex: DeviceInput<T>): number;
  132004. }
  132005. /**
  132006. * Class to keep track of devices
  132007. */
  132008. export class DeviceSourceManager implements IDisposable {
  132009. /**
  132010. * Observable to be triggered when before a device is connected
  132011. */
  132012. readonly onBeforeDeviceConnectedObservable: Observable<{
  132013. deviceType: DeviceType;
  132014. deviceSlot: number;
  132015. }>;
  132016. /**
  132017. * Observable to be triggered when before a device is disconnected
  132018. */
  132019. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  132020. deviceType: DeviceType;
  132021. deviceSlot: number;
  132022. }>;
  132023. /**
  132024. * Observable to be triggered when after a device is connected
  132025. */
  132026. readonly onAfterDeviceConnectedObservable: Observable<{
  132027. deviceType: DeviceType;
  132028. deviceSlot: number;
  132029. }>;
  132030. /**
  132031. * Observable to be triggered when after a device is disconnected
  132032. */
  132033. readonly onAfterDeviceDisconnectedObservable: Observable<{
  132034. deviceType: DeviceType;
  132035. deviceSlot: number;
  132036. }>;
  132037. private readonly _devices;
  132038. private readonly _firstDevice;
  132039. private readonly _deviceInputSystem;
  132040. /**
  132041. * Default Constructor
  132042. * @param engine engine to pull input element from
  132043. */
  132044. constructor(engine: Engine);
  132045. /**
  132046. * Gets a DeviceSource, given a type and slot
  132047. * @param deviceType Enum specifying device type
  132048. * @param deviceSlot "Slot" or index that device is referenced in
  132049. * @returns DeviceSource object
  132050. */
  132051. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  132052. /**
  132053. * Gets an array of DeviceSource objects for a given device type
  132054. * @param deviceType Enum specifying device type
  132055. * @returns Array of DeviceSource objects
  132056. */
  132057. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  132058. /**
  132059. * Dispose of DeviceInputSystem and other parts
  132060. */
  132061. dispose(): void;
  132062. /**
  132063. * Function to add device name to device list
  132064. * @param deviceType Enum specifying device type
  132065. * @param deviceSlot "Slot" or index that device is referenced in
  132066. */
  132067. private _addDevice;
  132068. /**
  132069. * Function to remove device name to device list
  132070. * @param deviceType Enum specifying device type
  132071. * @param deviceSlot "Slot" or index that device is referenced in
  132072. */
  132073. private _removeDevice;
  132074. /**
  132075. * Updates array storing first connected device of each type
  132076. * @param type Type of Device
  132077. */
  132078. private _updateFirstDevices;
  132079. }
  132080. }
  132081. declare module BABYLON {
  132082. /**
  132083. * Options to create the null engine
  132084. */
  132085. export class NullEngineOptions {
  132086. /**
  132087. * Render width (Default: 512)
  132088. */
  132089. renderWidth: number;
  132090. /**
  132091. * Render height (Default: 256)
  132092. */
  132093. renderHeight: number;
  132094. /**
  132095. * Texture size (Default: 512)
  132096. */
  132097. textureSize: number;
  132098. /**
  132099. * If delta time between frames should be constant
  132100. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132101. */
  132102. deterministicLockstep: boolean;
  132103. /**
  132104. * Maximum about of steps between frames (Default: 4)
  132105. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132106. */
  132107. lockstepMaxSteps: number;
  132108. /**
  132109. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  132110. */
  132111. useHighPrecisionMatrix?: boolean;
  132112. }
  132113. /**
  132114. * The null engine class provides support for headless version of babylon.js.
  132115. * This can be used in server side scenario or for testing purposes
  132116. */
  132117. export class NullEngine extends Engine {
  132118. private _options;
  132119. /**
  132120. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  132121. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132122. * @returns true if engine is in deterministic lock step mode
  132123. */
  132124. isDeterministicLockStep(): boolean;
  132125. /**
  132126. * Gets the max steps when engine is running in deterministic lock step
  132127. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132128. * @returns the max steps
  132129. */
  132130. getLockstepMaxSteps(): number;
  132131. /**
  132132. * Gets the current hardware scaling level.
  132133. * By default the hardware scaling level is computed from the window device ratio.
  132134. * 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.
  132135. * @returns a number indicating the current hardware scaling level
  132136. */
  132137. getHardwareScalingLevel(): number;
  132138. constructor(options?: NullEngineOptions);
  132139. /**
  132140. * Creates a vertex buffer
  132141. * @param vertices the data for the vertex buffer
  132142. * @returns the new WebGL static buffer
  132143. */
  132144. createVertexBuffer(vertices: FloatArray): DataBuffer;
  132145. /**
  132146. * Creates a new index buffer
  132147. * @param indices defines the content of the index buffer
  132148. * @param updatable defines if the index buffer must be updatable
  132149. * @returns a new webGL buffer
  132150. */
  132151. createIndexBuffer(indices: IndicesArray): DataBuffer;
  132152. /**
  132153. * Clear the current render buffer or the current render target (if any is set up)
  132154. * @param color defines the color to use
  132155. * @param backBuffer defines if the back buffer must be cleared
  132156. * @param depth defines if the depth buffer must be cleared
  132157. * @param stencil defines if the stencil buffer must be cleared
  132158. */
  132159. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132160. /**
  132161. * Gets the current render width
  132162. * @param useScreen defines if screen size must be used (or the current render target if any)
  132163. * @returns a number defining the current render width
  132164. */
  132165. getRenderWidth(useScreen?: boolean): number;
  132166. /**
  132167. * Gets the current render height
  132168. * @param useScreen defines if screen size must be used (or the current render target if any)
  132169. * @returns a number defining the current render height
  132170. */
  132171. getRenderHeight(useScreen?: boolean): number;
  132172. /**
  132173. * Set the WebGL's viewport
  132174. * @param viewport defines the viewport element to be used
  132175. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  132176. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  132177. */
  132178. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  132179. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  132180. /**
  132181. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  132182. * @param pipelineContext defines the pipeline context to use
  132183. * @param uniformsNames defines the list of uniform names
  132184. * @returns an array of webGL uniform locations
  132185. */
  132186. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  132187. /**
  132188. * Gets the lsit of active attributes for a given webGL program
  132189. * @param pipelineContext defines the pipeline context to use
  132190. * @param attributesNames defines the list of attribute names to get
  132191. * @returns an array of indices indicating the offset of each attribute
  132192. */
  132193. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132194. /**
  132195. * Binds an effect to the webGL context
  132196. * @param effect defines the effect to bind
  132197. */
  132198. bindSamplers(effect: Effect): void;
  132199. /**
  132200. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  132201. * @param effect defines the effect to activate
  132202. */
  132203. enableEffect(effect: Effect): void;
  132204. /**
  132205. * Set various states to the webGL context
  132206. * @param culling defines backface culling state
  132207. * @param zOffset defines the value to apply to zOffset (0 by default)
  132208. * @param force defines if states must be applied even if cache is up to date
  132209. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  132210. */
  132211. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132212. /**
  132213. * Set the value of an uniform to an array of int32
  132214. * @param uniform defines the webGL uniform location where to store the value
  132215. * @param array defines the array of int32 to store
  132216. * @returns true if value was set
  132217. */
  132218. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132219. /**
  132220. * Set the value of an uniform to an array of int32 (stored as vec2)
  132221. * @param uniform defines the webGL uniform location where to store the value
  132222. * @param array defines the array of int32 to store
  132223. * @returns true if value was set
  132224. */
  132225. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132226. /**
  132227. * Set the value of an uniform to an array of int32 (stored as vec3)
  132228. * @param uniform defines the webGL uniform location where to store the value
  132229. * @param array defines the array of int32 to store
  132230. * @returns true if value was set
  132231. */
  132232. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132233. /**
  132234. * Set the value of an uniform to an array of int32 (stored as vec4)
  132235. * @param uniform defines the webGL uniform location where to store the value
  132236. * @param array defines the array of int32 to store
  132237. * @returns true if value was set
  132238. */
  132239. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132240. /**
  132241. * Set the value of an uniform to an array of float32
  132242. * @param uniform defines the webGL uniform location where to store the value
  132243. * @param array defines the array of float32 to store
  132244. * @returns true if value was set
  132245. */
  132246. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132247. /**
  132248. * Set the value of an uniform to an array of float32 (stored as vec2)
  132249. * @param uniform defines the webGL uniform location where to store the value
  132250. * @param array defines the array of float32 to store
  132251. * @returns true if value was set
  132252. */
  132253. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132254. /**
  132255. * Set the value of an uniform to an array of float32 (stored as vec3)
  132256. * @param uniform defines the webGL uniform location where to store the value
  132257. * @param array defines the array of float32 to store
  132258. * @returns true if value was set
  132259. */
  132260. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132261. /**
  132262. * Set the value of an uniform to an array of float32 (stored as vec4)
  132263. * @param uniform defines the webGL uniform location where to store the value
  132264. * @param array defines the array of float32 to store
  132265. * @returns true if value was set
  132266. */
  132267. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132268. /**
  132269. * Set the value of an uniform to an array of number
  132270. * @param uniform defines the webGL uniform location where to store the value
  132271. * @param array defines the array of number to store
  132272. * @returns true if value was set
  132273. */
  132274. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  132275. /**
  132276. * Set the value of an uniform to an array of number (stored as vec2)
  132277. * @param uniform defines the webGL uniform location where to store the value
  132278. * @param array defines the array of number to store
  132279. * @returns true if value was set
  132280. */
  132281. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  132282. /**
  132283. * Set the value of an uniform to an array of number (stored as vec3)
  132284. * @param uniform defines the webGL uniform location where to store the value
  132285. * @param array defines the array of number to store
  132286. * @returns true if value was set
  132287. */
  132288. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  132289. /**
  132290. * Set the value of an uniform to an array of number (stored as vec4)
  132291. * @param uniform defines the webGL uniform location where to store the value
  132292. * @param array defines the array of number to store
  132293. * @returns true if value was set
  132294. */
  132295. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  132296. /**
  132297. * Set the value of an uniform to an array of float32 (stored as matrices)
  132298. * @param uniform defines the webGL uniform location where to store the value
  132299. * @param matrices defines the array of float32 to store
  132300. * @returns true if value was set
  132301. */
  132302. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  132303. /**
  132304. * Set the value of an uniform to a matrix (3x3)
  132305. * @param uniform defines the webGL uniform location where to store the value
  132306. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  132307. * @returns true if value was set
  132308. */
  132309. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132310. /**
  132311. * Set the value of an uniform to a matrix (2x2)
  132312. * @param uniform defines the webGL uniform location where to store the value
  132313. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  132314. * @returns true if value was set
  132315. */
  132316. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132317. /**
  132318. * Set the value of an uniform to a number (float)
  132319. * @param uniform defines the webGL uniform location where to store the value
  132320. * @param value defines the float number to store
  132321. * @returns true if value was set
  132322. */
  132323. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  132324. /**
  132325. * Set the value of an uniform to a vec2
  132326. * @param uniform defines the webGL uniform location where to store the value
  132327. * @param x defines the 1st component of the value
  132328. * @param y defines the 2nd component of the value
  132329. * @returns true if value was set
  132330. */
  132331. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  132332. /**
  132333. * Set the value of an uniform to a vec3
  132334. * @param uniform defines the webGL uniform location where to store the value
  132335. * @param x defines the 1st component of the value
  132336. * @param y defines the 2nd component of the value
  132337. * @param z defines the 3rd component of the value
  132338. * @returns true if value was set
  132339. */
  132340. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  132341. /**
  132342. * Set the value of an uniform to a boolean
  132343. * @param uniform defines the webGL uniform location where to store the value
  132344. * @param bool defines the boolean to store
  132345. * @returns true if value was set
  132346. */
  132347. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  132348. /**
  132349. * Set the value of an uniform to a vec4
  132350. * @param uniform defines the webGL uniform location where to store the value
  132351. * @param x defines the 1st component of the value
  132352. * @param y defines the 2nd component of the value
  132353. * @param z defines the 3rd component of the value
  132354. * @param w defines the 4th component of the value
  132355. * @returns true if value was set
  132356. */
  132357. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  132358. /**
  132359. * Sets the current alpha mode
  132360. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  132361. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132362. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132363. */
  132364. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132365. /**
  132366. * Bind webGl buffers directly to the webGL context
  132367. * @param vertexBuffers defines the vertex buffer to bind
  132368. * @param indexBuffer defines the index buffer to bind
  132369. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  132370. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  132371. * @param effect defines the effect associated with the vertex buffer
  132372. */
  132373. bindBuffers(vertexBuffers: {
  132374. [key: string]: VertexBuffer;
  132375. }, indexBuffer: DataBuffer, effect: Effect): void;
  132376. /**
  132377. * Force the entire cache to be cleared
  132378. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  132379. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  132380. */
  132381. wipeCaches(bruteForce?: boolean): void;
  132382. /**
  132383. * Send a draw order
  132384. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  132385. * @param indexStart defines the starting index
  132386. * @param indexCount defines the number of index to draw
  132387. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132388. */
  132389. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  132390. /**
  132391. * Draw a list of indexed primitives
  132392. * @param fillMode defines the primitive to use
  132393. * @param indexStart defines the starting index
  132394. * @param indexCount defines the number of index to draw
  132395. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132396. */
  132397. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132398. /**
  132399. * Draw a list of unindexed primitives
  132400. * @param fillMode defines the primitive to use
  132401. * @param verticesStart defines the index of first vertex to draw
  132402. * @param verticesCount defines the count of vertices to draw
  132403. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132404. */
  132405. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132406. /** @hidden */
  132407. _createTexture(): WebGLTexture;
  132408. /** @hidden */
  132409. _releaseTexture(texture: InternalTexture): void;
  132410. /**
  132411. * Usually called from Texture.ts.
  132412. * Passed information to create a WebGLTexture
  132413. * @param urlArg defines a value which contains one of the following:
  132414. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132415. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132416. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132417. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132418. * @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)
  132419. * @param scene needed for loading to the correct scene
  132420. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132421. * @param onLoad optional callback to be called upon successful completion
  132422. * @param onError optional callback to be called upon failure
  132423. * @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
  132424. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132425. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132426. * @param forcedExtension defines the extension to use to pick the right loader
  132427. * @param mimeType defines an optional mime type
  132428. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132429. */
  132430. 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;
  132431. /**
  132432. * Creates a new render target texture
  132433. * @param size defines the size of the texture
  132434. * @param options defines the options used to create the texture
  132435. * @returns a new render target texture stored in an InternalTexture
  132436. */
  132437. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  132438. /**
  132439. * Update the sampling mode of a given texture
  132440. * @param samplingMode defines the required sampling mode
  132441. * @param texture defines the texture to update
  132442. */
  132443. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132444. /**
  132445. * Binds the frame buffer to the specified texture.
  132446. * @param texture The texture to render to or null for the default canvas
  132447. * @param faceIndex The face of the texture to render to in case of cube texture
  132448. * @param requiredWidth The width of the target to render to
  132449. * @param requiredHeight The height of the target to render to
  132450. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  132451. * @param lodLevel defines le lod level to bind to the frame buffer
  132452. */
  132453. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132454. /**
  132455. * Unbind the current render target texture from the webGL context
  132456. * @param texture defines the render target texture to unbind
  132457. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  132458. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  132459. */
  132460. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132461. /**
  132462. * Creates a dynamic vertex buffer
  132463. * @param vertices the data for the dynamic vertex buffer
  132464. * @returns the new WebGL dynamic buffer
  132465. */
  132466. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  132467. /**
  132468. * Update the content of a dynamic texture
  132469. * @param texture defines the texture to update
  132470. * @param canvas defines the canvas containing the source
  132471. * @param invertY defines if data must be stored with Y axis inverted
  132472. * @param premulAlpha defines if alpha is stored as premultiplied
  132473. * @param format defines the format of the data
  132474. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  132475. */
  132476. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  132477. /**
  132478. * Gets a boolean indicating if all created effects are ready
  132479. * @returns true if all effects are ready
  132480. */
  132481. areAllEffectsReady(): boolean;
  132482. /**
  132483. * @hidden
  132484. * Get the current error code of the webGL context
  132485. * @returns the error code
  132486. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  132487. */
  132488. getError(): number;
  132489. /** @hidden */
  132490. _getUnpackAlignement(): number;
  132491. /** @hidden */
  132492. _unpackFlipY(value: boolean): void;
  132493. /**
  132494. * Update a dynamic index buffer
  132495. * @param indexBuffer defines the target index buffer
  132496. * @param indices defines the data to update
  132497. * @param offset defines the offset in the target index buffer where update should start
  132498. */
  132499. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  132500. /**
  132501. * Updates a dynamic vertex buffer.
  132502. * @param vertexBuffer the vertex buffer to update
  132503. * @param vertices the data used to update the vertex buffer
  132504. * @param byteOffset the byte offset of the data (optional)
  132505. * @param byteLength the byte length of the data (optional)
  132506. */
  132507. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  132508. /** @hidden */
  132509. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  132510. /** @hidden */
  132511. _bindTexture(channel: number, texture: InternalTexture): void;
  132512. protected _deleteBuffer(buffer: WebGLBuffer): void;
  132513. /**
  132514. * 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
  132515. */
  132516. releaseEffects(): void;
  132517. displayLoadingUI(): void;
  132518. hideLoadingUI(): void;
  132519. /** @hidden */
  132520. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132521. /** @hidden */
  132522. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132523. /** @hidden */
  132524. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132525. /** @hidden */
  132526. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132527. }
  132528. }
  132529. declare module BABYLON {
  132530. /**
  132531. * @hidden
  132532. **/
  132533. export class _TimeToken {
  132534. _startTimeQuery: Nullable<WebGLQuery>;
  132535. _endTimeQuery: Nullable<WebGLQuery>;
  132536. _timeElapsedQuery: Nullable<WebGLQuery>;
  132537. _timeElapsedQueryEnded: boolean;
  132538. }
  132539. }
  132540. declare module BABYLON {
  132541. /** @hidden */
  132542. export class _OcclusionDataStorage {
  132543. /** @hidden */
  132544. occlusionInternalRetryCounter: number;
  132545. /** @hidden */
  132546. isOcclusionQueryInProgress: boolean;
  132547. /** @hidden */
  132548. isOccluded: boolean;
  132549. /** @hidden */
  132550. occlusionRetryCount: number;
  132551. /** @hidden */
  132552. occlusionType: number;
  132553. /** @hidden */
  132554. occlusionQueryAlgorithmType: number;
  132555. }
  132556. interface Engine {
  132557. /**
  132558. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  132559. * @return the new query
  132560. */
  132561. createQuery(): WebGLQuery;
  132562. /**
  132563. * Delete and release a webGL query
  132564. * @param query defines the query to delete
  132565. * @return the current engine
  132566. */
  132567. deleteQuery(query: WebGLQuery): Engine;
  132568. /**
  132569. * Check if a given query has resolved and got its value
  132570. * @param query defines the query to check
  132571. * @returns true if the query got its value
  132572. */
  132573. isQueryResultAvailable(query: WebGLQuery): boolean;
  132574. /**
  132575. * Gets the value of a given query
  132576. * @param query defines the query to check
  132577. * @returns the value of the query
  132578. */
  132579. getQueryResult(query: WebGLQuery): number;
  132580. /**
  132581. * Initiates an occlusion query
  132582. * @param algorithmType defines the algorithm to use
  132583. * @param query defines the query to use
  132584. * @returns the current engine
  132585. * @see https://doc.babylonjs.com/features/occlusionquery
  132586. */
  132587. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  132588. /**
  132589. * Ends an occlusion query
  132590. * @see https://doc.babylonjs.com/features/occlusionquery
  132591. * @param algorithmType defines the algorithm to use
  132592. * @returns the current engine
  132593. */
  132594. endOcclusionQuery(algorithmType: number): Engine;
  132595. /**
  132596. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132597. * Please note that only one query can be issued at a time
  132598. * @returns a time token used to track the time span
  132599. */
  132600. startTimeQuery(): Nullable<_TimeToken>;
  132601. /**
  132602. * Ends a time query
  132603. * @param token defines the token used to measure the time span
  132604. * @returns the time spent (in ns)
  132605. */
  132606. endTimeQuery(token: _TimeToken): int;
  132607. /** @hidden */
  132608. _currentNonTimestampToken: Nullable<_TimeToken>;
  132609. /** @hidden */
  132610. _createTimeQuery(): WebGLQuery;
  132611. /** @hidden */
  132612. _deleteTimeQuery(query: WebGLQuery): void;
  132613. /** @hidden */
  132614. _getGlAlgorithmType(algorithmType: number): number;
  132615. /** @hidden */
  132616. _getTimeQueryResult(query: WebGLQuery): any;
  132617. /** @hidden */
  132618. _getTimeQueryAvailability(query: WebGLQuery): any;
  132619. }
  132620. interface AbstractMesh {
  132621. /**
  132622. * Backing filed
  132623. * @hidden
  132624. */
  132625. __occlusionDataStorage: _OcclusionDataStorage;
  132626. /**
  132627. * Access property
  132628. * @hidden
  132629. */
  132630. _occlusionDataStorage: _OcclusionDataStorage;
  132631. /**
  132632. * 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.
  132633. * The default value is -1 which means don't break the query and wait till the result
  132634. * @see https://doc.babylonjs.com/features/occlusionquery
  132635. */
  132636. occlusionRetryCount: number;
  132637. /**
  132638. * 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:
  132639. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  132640. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  132641. * * 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.
  132642. * @see https://doc.babylonjs.com/features/occlusionquery
  132643. */
  132644. occlusionType: number;
  132645. /**
  132646. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  132647. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  132648. * * 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.
  132649. * @see https://doc.babylonjs.com/features/occlusionquery
  132650. */
  132651. occlusionQueryAlgorithmType: number;
  132652. /**
  132653. * 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
  132654. * @see https://doc.babylonjs.com/features/occlusionquery
  132655. */
  132656. isOccluded: boolean;
  132657. /**
  132658. * Flag to check the progress status of the query
  132659. * @see https://doc.babylonjs.com/features/occlusionquery
  132660. */
  132661. isOcclusionQueryInProgress: boolean;
  132662. }
  132663. }
  132664. declare module BABYLON {
  132665. /** @hidden */
  132666. export var _forceTransformFeedbackToBundle: boolean;
  132667. interface Engine {
  132668. /**
  132669. * Creates a webGL transform feedback object
  132670. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  132671. * @returns the webGL transform feedback object
  132672. */
  132673. createTransformFeedback(): WebGLTransformFeedback;
  132674. /**
  132675. * Delete a webGL transform feedback object
  132676. * @param value defines the webGL transform feedback object to delete
  132677. */
  132678. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  132679. /**
  132680. * Bind a webGL transform feedback object to the webgl context
  132681. * @param value defines the webGL transform feedback object to bind
  132682. */
  132683. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  132684. /**
  132685. * Begins a transform feedback operation
  132686. * @param usePoints defines if points or triangles must be used
  132687. */
  132688. beginTransformFeedback(usePoints: boolean): void;
  132689. /**
  132690. * Ends a transform feedback operation
  132691. */
  132692. endTransformFeedback(): void;
  132693. /**
  132694. * Specify the varyings to use with transform feedback
  132695. * @param program defines the associated webGL program
  132696. * @param value defines the list of strings representing the varying names
  132697. */
  132698. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  132699. /**
  132700. * Bind a webGL buffer for a transform feedback operation
  132701. * @param value defines the webGL buffer to bind
  132702. */
  132703. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  132704. }
  132705. }
  132706. declare module BABYLON {
  132707. /**
  132708. * Class used to define an additional view for the engine
  132709. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132710. */
  132711. export class EngineView {
  132712. /** Defines the canvas where to render the view */
  132713. target: HTMLCanvasElement;
  132714. /** Defines an optional camera used to render the view (will use active camera else) */
  132715. camera?: Camera;
  132716. }
  132717. interface Engine {
  132718. /**
  132719. * Gets or sets the HTML element to use for attaching events
  132720. */
  132721. inputElement: Nullable<HTMLElement>;
  132722. /**
  132723. * Gets the current engine view
  132724. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132725. */
  132726. activeView: Nullable<EngineView>;
  132727. /** Gets or sets the list of views */
  132728. views: EngineView[];
  132729. /**
  132730. * Register a new child canvas
  132731. * @param canvas defines the canvas to register
  132732. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  132733. * @returns the associated view
  132734. */
  132735. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  132736. /**
  132737. * Remove a registered child canvas
  132738. * @param canvas defines the canvas to remove
  132739. * @returns the current engine
  132740. */
  132741. unRegisterView(canvas: HTMLCanvasElement): Engine;
  132742. }
  132743. }
  132744. declare module BABYLON {
  132745. interface Engine {
  132746. /** @hidden */
  132747. _excludedCompressedTextures: string[];
  132748. /** @hidden */
  132749. _textureFormatInUse: string;
  132750. /**
  132751. * Gets the list of texture formats supported
  132752. */
  132753. readonly texturesSupported: Array<string>;
  132754. /**
  132755. * Gets the texture format in use
  132756. */
  132757. readonly textureFormatInUse: Nullable<string>;
  132758. /**
  132759. * Set the compressed texture extensions or file names to skip.
  132760. *
  132761. * @param skippedFiles defines the list of those texture files you want to skip
  132762. * Example: [".dds", ".env", "myfile.png"]
  132763. */
  132764. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  132765. /**
  132766. * Set the compressed texture format to use, based on the formats you have, and the formats
  132767. * supported by the hardware / browser.
  132768. *
  132769. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  132770. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  132771. * to API arguments needed to compressed textures. This puts the burden on the container
  132772. * generator to house the arcane code for determining these for current & future formats.
  132773. *
  132774. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132775. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132776. *
  132777. * Note: The result of this call is not taken into account when a texture is base64.
  132778. *
  132779. * @param formatsAvailable defines the list of those format families you have created
  132780. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  132781. *
  132782. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  132783. * @returns The extension selected.
  132784. */
  132785. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  132786. }
  132787. }
  132788. declare module BABYLON {
  132789. /**
  132790. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  132791. */
  132792. export interface CubeMapInfo {
  132793. /**
  132794. * The pixel array for the front face.
  132795. * This is stored in format, left to right, up to down format.
  132796. */
  132797. front: Nullable<ArrayBufferView>;
  132798. /**
  132799. * The pixel array for the back face.
  132800. * This is stored in format, left to right, up to down format.
  132801. */
  132802. back: Nullable<ArrayBufferView>;
  132803. /**
  132804. * The pixel array for the left face.
  132805. * This is stored in format, left to right, up to down format.
  132806. */
  132807. left: Nullable<ArrayBufferView>;
  132808. /**
  132809. * The pixel array for the right face.
  132810. * This is stored in format, left to right, up to down format.
  132811. */
  132812. right: Nullable<ArrayBufferView>;
  132813. /**
  132814. * The pixel array for the up face.
  132815. * This is stored in format, left to right, up to down format.
  132816. */
  132817. up: Nullable<ArrayBufferView>;
  132818. /**
  132819. * The pixel array for the down face.
  132820. * This is stored in format, left to right, up to down format.
  132821. */
  132822. down: Nullable<ArrayBufferView>;
  132823. /**
  132824. * The size of the cubemap stored.
  132825. *
  132826. * Each faces will be size * size pixels.
  132827. */
  132828. size: number;
  132829. /**
  132830. * The format of the texture.
  132831. *
  132832. * RGBA, RGB.
  132833. */
  132834. format: number;
  132835. /**
  132836. * The type of the texture data.
  132837. *
  132838. * UNSIGNED_INT, FLOAT.
  132839. */
  132840. type: number;
  132841. /**
  132842. * Specifies whether the texture is in gamma space.
  132843. */
  132844. gammaSpace: boolean;
  132845. }
  132846. /**
  132847. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  132848. */
  132849. export class PanoramaToCubeMapTools {
  132850. private static FACE_LEFT;
  132851. private static FACE_RIGHT;
  132852. private static FACE_FRONT;
  132853. private static FACE_BACK;
  132854. private static FACE_DOWN;
  132855. private static FACE_UP;
  132856. /**
  132857. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  132858. *
  132859. * @param float32Array The source data.
  132860. * @param inputWidth The width of the input panorama.
  132861. * @param inputHeight The height of the input panorama.
  132862. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  132863. * @return The cubemap data
  132864. */
  132865. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  132866. private static CreateCubemapTexture;
  132867. private static CalcProjectionSpherical;
  132868. }
  132869. }
  132870. declare module BABYLON {
  132871. /**
  132872. * Helper class dealing with the extraction of spherical polynomial dataArray
  132873. * from a cube map.
  132874. */
  132875. export class CubeMapToSphericalPolynomialTools {
  132876. private static FileFaces;
  132877. /**
  132878. * Converts a texture to the according Spherical Polynomial data.
  132879. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132880. *
  132881. * @param texture The texture to extract the information from.
  132882. * @return The Spherical Polynomial data.
  132883. */
  132884. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  132885. /**
  132886. * Converts a cubemap to the according Spherical Polynomial data.
  132887. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132888. *
  132889. * @param cubeInfo The Cube map to extract the information from.
  132890. * @return The Spherical Polynomial data.
  132891. */
  132892. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  132893. }
  132894. }
  132895. declare module BABYLON {
  132896. interface BaseTexture {
  132897. /**
  132898. * Get the polynomial representation of the texture data.
  132899. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  132900. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  132901. */
  132902. sphericalPolynomial: Nullable<SphericalPolynomial>;
  132903. }
  132904. }
  132905. declare module BABYLON {
  132906. /** @hidden */
  132907. export var rgbdEncodePixelShader: {
  132908. name: string;
  132909. shader: string;
  132910. };
  132911. }
  132912. declare module BABYLON {
  132913. /** @hidden */
  132914. export var rgbdDecodePixelShader: {
  132915. name: string;
  132916. shader: string;
  132917. };
  132918. }
  132919. declare module BABYLON {
  132920. /**
  132921. * Raw texture data and descriptor sufficient for WebGL texture upload
  132922. */
  132923. export interface EnvironmentTextureInfo {
  132924. /**
  132925. * Version of the environment map
  132926. */
  132927. version: number;
  132928. /**
  132929. * Width of image
  132930. */
  132931. width: number;
  132932. /**
  132933. * Irradiance information stored in the file.
  132934. */
  132935. irradiance: any;
  132936. /**
  132937. * Specular information stored in the file.
  132938. */
  132939. specular: any;
  132940. }
  132941. /**
  132942. * Defines One Image in the file. It requires only the position in the file
  132943. * as well as the length.
  132944. */
  132945. interface BufferImageData {
  132946. /**
  132947. * Length of the image data.
  132948. */
  132949. length: number;
  132950. /**
  132951. * Position of the data from the null terminator delimiting the end of the JSON.
  132952. */
  132953. position: number;
  132954. }
  132955. /**
  132956. * Defines the specular data enclosed in the file.
  132957. * This corresponds to the version 1 of the data.
  132958. */
  132959. export interface EnvironmentTextureSpecularInfoV1 {
  132960. /**
  132961. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  132962. */
  132963. specularDataPosition?: number;
  132964. /**
  132965. * This contains all the images data needed to reconstruct the cubemap.
  132966. */
  132967. mipmaps: Array<BufferImageData>;
  132968. /**
  132969. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  132970. */
  132971. lodGenerationScale: number;
  132972. }
  132973. /**
  132974. * Sets of helpers addressing the serialization and deserialization of environment texture
  132975. * stored in a BabylonJS env file.
  132976. * Those files are usually stored as .env files.
  132977. */
  132978. export class EnvironmentTextureTools {
  132979. /**
  132980. * Magic number identifying the env file.
  132981. */
  132982. private static _MagicBytes;
  132983. /**
  132984. * Gets the environment info from an env file.
  132985. * @param data The array buffer containing the .env bytes.
  132986. * @returns the environment file info (the json header) if successfully parsed.
  132987. */
  132988. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  132989. /**
  132990. * Creates an environment texture from a loaded cube texture.
  132991. * @param texture defines the cube texture to convert in env file
  132992. * @return a promise containing the environment data if succesfull.
  132993. */
  132994. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  132995. /**
  132996. * Creates a JSON representation of the spherical data.
  132997. * @param texture defines the texture containing the polynomials
  132998. * @return the JSON representation of the spherical info
  132999. */
  133000. private static _CreateEnvTextureIrradiance;
  133001. /**
  133002. * Creates the ArrayBufferViews used for initializing environment texture image data.
  133003. * @param data the image data
  133004. * @param info parameters that determine what views will be created for accessing the underlying buffer
  133005. * @return the views described by info providing access to the underlying buffer
  133006. */
  133007. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  133008. /**
  133009. * Uploads the texture info contained in the env file to the GPU.
  133010. * @param texture defines the internal texture to upload to
  133011. * @param data defines the data to load
  133012. * @param info defines the texture info retrieved through the GetEnvInfo method
  133013. * @returns a promise
  133014. */
  133015. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  133016. private static _OnImageReadyAsync;
  133017. /**
  133018. * Uploads the levels of image data to the GPU.
  133019. * @param texture defines the internal texture to upload to
  133020. * @param imageData defines the array buffer views of image data [mipmap][face]
  133021. * @returns a promise
  133022. */
  133023. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  133024. /**
  133025. * Uploads spherical polynomials information to the texture.
  133026. * @param texture defines the texture we are trying to upload the information to
  133027. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  133028. */
  133029. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  133030. /** @hidden */
  133031. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133032. }
  133033. }
  133034. declare module BABYLON {
  133035. /**
  133036. * Class used to inline functions in shader code
  133037. */
  133038. export class ShaderCodeInliner {
  133039. private static readonly _RegexpFindFunctionNameAndType;
  133040. private _sourceCode;
  133041. private _functionDescr;
  133042. private _numMaxIterations;
  133043. /** Gets or sets the token used to mark the functions to inline */
  133044. inlineToken: string;
  133045. /** Gets or sets the debug mode */
  133046. debug: boolean;
  133047. /** Gets the code after the inlining process */
  133048. get code(): string;
  133049. /**
  133050. * Initializes the inliner
  133051. * @param sourceCode shader code source to inline
  133052. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  133053. */
  133054. constructor(sourceCode: string, numMaxIterations?: number);
  133055. /**
  133056. * Start the processing of the shader code
  133057. */
  133058. processCode(): void;
  133059. private _collectFunctions;
  133060. private _processInlining;
  133061. private _extractBetweenMarkers;
  133062. private _skipWhitespaces;
  133063. private _removeComments;
  133064. private _replaceFunctionCallsByCode;
  133065. private _findBackward;
  133066. private _escapeRegExp;
  133067. private _replaceNames;
  133068. }
  133069. }
  133070. declare module BABYLON {
  133071. /**
  133072. * Container for accessors for natively-stored mesh data buffers.
  133073. */
  133074. class NativeDataBuffer extends DataBuffer {
  133075. /**
  133076. * Accessor value used to identify/retrieve a natively-stored index buffer.
  133077. */
  133078. nativeIndexBuffer?: any;
  133079. /**
  133080. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  133081. */
  133082. nativeVertexBuffer?: any;
  133083. }
  133084. /** @hidden */
  133085. class NativeTexture extends InternalTexture {
  133086. getInternalTexture(): InternalTexture;
  133087. getViewCount(): number;
  133088. }
  133089. /** @hidden */
  133090. export class NativeEngine extends Engine {
  133091. private readonly _native;
  133092. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  133093. private readonly INVALID_HANDLE;
  133094. private _boundBuffersVertexArray;
  133095. getHardwareScalingLevel(): number;
  133096. constructor();
  133097. dispose(): void;
  133098. /**
  133099. * Can be used to override the current requestAnimationFrame requester.
  133100. * @hidden
  133101. */
  133102. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  133103. /**
  133104. * Override default engine behavior.
  133105. * @param color
  133106. * @param backBuffer
  133107. * @param depth
  133108. * @param stencil
  133109. */
  133110. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  133111. /**
  133112. * Gets host document
  133113. * @returns the host document object
  133114. */
  133115. getHostDocument(): Nullable<Document>;
  133116. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  133117. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  133118. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  133119. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  133120. [key: string]: VertexBuffer;
  133121. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133122. bindBuffers(vertexBuffers: {
  133123. [key: string]: VertexBuffer;
  133124. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133125. recordVertexArrayObject(vertexBuffers: {
  133126. [key: string]: VertexBuffer;
  133127. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  133128. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133129. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133130. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  133131. /**
  133132. * Draw a list of indexed primitives
  133133. * @param fillMode defines the primitive to use
  133134. * @param indexStart defines the starting index
  133135. * @param indexCount defines the number of index to draw
  133136. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133137. */
  133138. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  133139. /**
  133140. * Draw a list of unindexed primitives
  133141. * @param fillMode defines the primitive to use
  133142. * @param verticesStart defines the index of first vertex to draw
  133143. * @param verticesCount defines the count of vertices to draw
  133144. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133145. */
  133146. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  133147. createPipelineContext(): IPipelineContext;
  133148. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  133149. /** @hidden */
  133150. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  133151. /** @hidden */
  133152. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  133153. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133154. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133155. protected _setProgram(program: WebGLProgram): void;
  133156. _releaseEffect(effect: Effect): void;
  133157. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  133158. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  133159. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  133160. bindSamplers(effect: Effect): void;
  133161. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  133162. getRenderWidth(useScreen?: boolean): number;
  133163. getRenderHeight(useScreen?: boolean): number;
  133164. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  133165. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  133166. /**
  133167. * Set the z offset to apply to current rendering
  133168. * @param value defines the offset to apply
  133169. */
  133170. setZOffset(value: number): void;
  133171. /**
  133172. * Gets the current value of the zOffset
  133173. * @returns the current zOffset state
  133174. */
  133175. getZOffset(): number;
  133176. /**
  133177. * Enable or disable depth buffering
  133178. * @param enable defines the state to set
  133179. */
  133180. setDepthBuffer(enable: boolean): void;
  133181. /**
  133182. * Gets a boolean indicating if depth writing is enabled
  133183. * @returns the current depth writing state
  133184. */
  133185. getDepthWrite(): boolean;
  133186. /**
  133187. * Enable or disable depth writing
  133188. * @param enable defines the state to set
  133189. */
  133190. setDepthWrite(enable: boolean): void;
  133191. /**
  133192. * Enable or disable color writing
  133193. * @param enable defines the state to set
  133194. */
  133195. setColorWrite(enable: boolean): void;
  133196. /**
  133197. * Gets a boolean indicating if color writing is enabled
  133198. * @returns the current color writing state
  133199. */
  133200. getColorWrite(): boolean;
  133201. /**
  133202. * Sets alpha constants used by some alpha blending modes
  133203. * @param r defines the red component
  133204. * @param g defines the green component
  133205. * @param b defines the blue component
  133206. * @param a defines the alpha component
  133207. */
  133208. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  133209. /**
  133210. * Sets the current alpha mode
  133211. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  133212. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  133213. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133214. */
  133215. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  133216. /**
  133217. * Gets the current alpha mode
  133218. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133219. * @returns the current alpha mode
  133220. */
  133221. getAlphaMode(): number;
  133222. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  133223. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133224. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133225. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133226. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133227. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133228. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133229. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133230. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133231. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  133232. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  133233. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  133234. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  133235. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  133236. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133237. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133238. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  133239. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  133240. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  133241. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  133242. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  133243. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  133244. wipeCaches(bruteForce?: boolean): void;
  133245. _createTexture(): WebGLTexture;
  133246. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  133247. /**
  133248. * Usually called from Texture.ts.
  133249. * Passed information to create a WebGLTexture
  133250. * @param url defines a value which contains one of the following:
  133251. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  133252. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  133253. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  133254. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  133255. * @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)
  133256. * @param scene needed for loading to the correct scene
  133257. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  133258. * @param onLoad optional callback to be called upon successful completion
  133259. * @param onError optional callback to be called upon failure
  133260. * @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
  133261. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  133262. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  133263. * @param forcedExtension defines the extension to use to pick the right loader
  133264. * @param mimeType defines an optional mime type
  133265. * @returns a InternalTexture for assignment back into BABYLON.Texture
  133266. */
  133267. 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;
  133268. /**
  133269. * Creates a cube texture
  133270. * @param rootUrl defines the url where the files to load is located
  133271. * @param scene defines the current scene
  133272. * @param files defines the list of files to load (1 per face)
  133273. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  133274. * @param onLoad defines an optional callback raised when the texture is loaded
  133275. * @param onError defines an optional callback raised if there is an issue to load the texture
  133276. * @param format defines the format of the data
  133277. * @param forcedExtension defines the extension to use to pick the right loader
  133278. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  133279. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133280. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133281. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  133282. * @returns the cube texture as an InternalTexture
  133283. */
  133284. 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;
  133285. private _getSamplingFilter;
  133286. private static _GetNativeTextureFormat;
  133287. createRenderTargetTexture(size: number | {
  133288. width: number;
  133289. height: number;
  133290. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  133291. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  133292. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  133293. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  133294. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  133295. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  133296. /**
  133297. * Updates a dynamic vertex buffer.
  133298. * @param vertexBuffer the vertex buffer to update
  133299. * @param data the data used to update the vertex buffer
  133300. * @param byteOffset the byte offset of the data (optional)
  133301. * @param byteLength the byte length of the data (optional)
  133302. */
  133303. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  133304. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  133305. private _updateAnisotropicLevel;
  133306. private _getAddressMode;
  133307. /** @hidden */
  133308. _bindTexture(channel: number, texture: InternalTexture): void;
  133309. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  133310. releaseEffects(): void;
  133311. /** @hidden */
  133312. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133313. /** @hidden */
  133314. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133315. /** @hidden */
  133316. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133317. /** @hidden */
  133318. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  133319. }
  133320. }
  133321. declare module BABYLON {
  133322. /**
  133323. * Gather the list of clipboard event types as constants.
  133324. */
  133325. export class ClipboardEventTypes {
  133326. /**
  133327. * The clipboard event is fired when a copy command is active (pressed).
  133328. */
  133329. static readonly COPY: number;
  133330. /**
  133331. * The clipboard event is fired when a cut command is active (pressed).
  133332. */
  133333. static readonly CUT: number;
  133334. /**
  133335. * The clipboard event is fired when a paste command is active (pressed).
  133336. */
  133337. static readonly PASTE: number;
  133338. }
  133339. /**
  133340. * This class is used to store clipboard related info for the onClipboardObservable event.
  133341. */
  133342. export class ClipboardInfo {
  133343. /**
  133344. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133345. */
  133346. type: number;
  133347. /**
  133348. * Defines the related dom event
  133349. */
  133350. event: ClipboardEvent;
  133351. /**
  133352. *Creates an instance of ClipboardInfo.
  133353. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  133354. * @param event Defines the related dom event
  133355. */
  133356. constructor(
  133357. /**
  133358. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133359. */
  133360. type: number,
  133361. /**
  133362. * Defines the related dom event
  133363. */
  133364. event: ClipboardEvent);
  133365. /**
  133366. * Get the clipboard event's type from the keycode.
  133367. * @param keyCode Defines the keyCode for the current keyboard event.
  133368. * @return {number}
  133369. */
  133370. static GetTypeFromCharacter(keyCode: number): number;
  133371. }
  133372. }
  133373. declare module BABYLON {
  133374. /**
  133375. * Google Daydream controller
  133376. */
  133377. export class DaydreamController extends WebVRController {
  133378. /**
  133379. * Base Url for the controller model.
  133380. */
  133381. static MODEL_BASE_URL: string;
  133382. /**
  133383. * File name for the controller model.
  133384. */
  133385. static MODEL_FILENAME: string;
  133386. /**
  133387. * Gamepad Id prefix used to identify Daydream Controller.
  133388. */
  133389. static readonly GAMEPAD_ID_PREFIX: string;
  133390. /**
  133391. * Creates a new DaydreamController from a gamepad
  133392. * @param vrGamepad the gamepad that the controller should be created from
  133393. */
  133394. constructor(vrGamepad: any);
  133395. /**
  133396. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133397. * @param scene scene in which to add meshes
  133398. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133399. */
  133400. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133401. /**
  133402. * Called once for each button that changed state since the last frame
  133403. * @param buttonIdx Which button index changed
  133404. * @param state New state of the button
  133405. * @param changes Which properties on the state changed since last frame
  133406. */
  133407. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133408. }
  133409. }
  133410. declare module BABYLON {
  133411. /**
  133412. * Gear VR Controller
  133413. */
  133414. export class GearVRController extends WebVRController {
  133415. /**
  133416. * Base Url for the controller model.
  133417. */
  133418. static MODEL_BASE_URL: string;
  133419. /**
  133420. * File name for the controller model.
  133421. */
  133422. static MODEL_FILENAME: string;
  133423. /**
  133424. * Gamepad Id prefix used to identify this controller.
  133425. */
  133426. static readonly GAMEPAD_ID_PREFIX: string;
  133427. private readonly _buttonIndexToObservableNameMap;
  133428. /**
  133429. * Creates a new GearVRController from a gamepad
  133430. * @param vrGamepad the gamepad that the controller should be created from
  133431. */
  133432. constructor(vrGamepad: any);
  133433. /**
  133434. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133435. * @param scene scene in which to add meshes
  133436. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133437. */
  133438. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133439. /**
  133440. * Called once for each button that changed state since the last frame
  133441. * @param buttonIdx Which button index changed
  133442. * @param state New state of the button
  133443. * @param changes Which properties on the state changed since last frame
  133444. */
  133445. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133446. }
  133447. }
  133448. declare module BABYLON {
  133449. /**
  133450. * Generic Controller
  133451. */
  133452. export class GenericController extends WebVRController {
  133453. /**
  133454. * Base Url for the controller model.
  133455. */
  133456. static readonly MODEL_BASE_URL: string;
  133457. /**
  133458. * File name for the controller model.
  133459. */
  133460. static readonly MODEL_FILENAME: string;
  133461. /**
  133462. * Creates a new GenericController from a gamepad
  133463. * @param vrGamepad the gamepad that the controller should be created from
  133464. */
  133465. constructor(vrGamepad: any);
  133466. /**
  133467. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133468. * @param scene scene in which to add meshes
  133469. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133470. */
  133471. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133472. /**
  133473. * Called once for each button that changed state since the last frame
  133474. * @param buttonIdx Which button index changed
  133475. * @param state New state of the button
  133476. * @param changes Which properties on the state changed since last frame
  133477. */
  133478. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133479. }
  133480. }
  133481. declare module BABYLON {
  133482. /**
  133483. * Oculus Touch Controller
  133484. */
  133485. export class OculusTouchController extends WebVRController {
  133486. /**
  133487. * Base Url for the controller model.
  133488. */
  133489. static MODEL_BASE_URL: string;
  133490. /**
  133491. * File name for the left controller model.
  133492. */
  133493. static MODEL_LEFT_FILENAME: string;
  133494. /**
  133495. * File name for the right controller model.
  133496. */
  133497. static MODEL_RIGHT_FILENAME: string;
  133498. /**
  133499. * Base Url for the Quest controller model.
  133500. */
  133501. static QUEST_MODEL_BASE_URL: string;
  133502. /**
  133503. * @hidden
  133504. * If the controllers are running on a device that needs the updated Quest controller models
  133505. */
  133506. static _IsQuest: boolean;
  133507. /**
  133508. * Fired when the secondary trigger on this controller is modified
  133509. */
  133510. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  133511. /**
  133512. * Fired when the thumb rest on this controller is modified
  133513. */
  133514. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  133515. /**
  133516. * Creates a new OculusTouchController from a gamepad
  133517. * @param vrGamepad the gamepad that the controller should be created from
  133518. */
  133519. constructor(vrGamepad: any);
  133520. /**
  133521. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133522. * @param scene scene in which to add meshes
  133523. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133524. */
  133525. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133526. /**
  133527. * Fired when the A button on this controller is modified
  133528. */
  133529. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133530. /**
  133531. * Fired when the B button on this controller is modified
  133532. */
  133533. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133534. /**
  133535. * Fired when the X button on this controller is modified
  133536. */
  133537. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133538. /**
  133539. * Fired when the Y button on this controller is modified
  133540. */
  133541. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133542. /**
  133543. * Called once for each button that changed state since the last frame
  133544. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  133545. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  133546. * 2) secondary trigger (same)
  133547. * 3) A (right) X (left), touch, pressed = value
  133548. * 4) B / Y
  133549. * 5) thumb rest
  133550. * @param buttonIdx Which button index changed
  133551. * @param state New state of the button
  133552. * @param changes Which properties on the state changed since last frame
  133553. */
  133554. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133555. }
  133556. }
  133557. declare module BABYLON {
  133558. /**
  133559. * Vive Controller
  133560. */
  133561. export class ViveController extends WebVRController {
  133562. /**
  133563. * Base Url for the controller model.
  133564. */
  133565. static MODEL_BASE_URL: string;
  133566. /**
  133567. * File name for the controller model.
  133568. */
  133569. static MODEL_FILENAME: string;
  133570. /**
  133571. * Creates a new ViveController from a gamepad
  133572. * @param vrGamepad the gamepad that the controller should be created from
  133573. */
  133574. constructor(vrGamepad: any);
  133575. /**
  133576. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133577. * @param scene scene in which to add meshes
  133578. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133579. */
  133580. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133581. /**
  133582. * Fired when the left button on this controller is modified
  133583. */
  133584. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133585. /**
  133586. * Fired when the right button on this controller is modified
  133587. */
  133588. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133589. /**
  133590. * Fired when the menu button on this controller is modified
  133591. */
  133592. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133593. /**
  133594. * Called once for each button that changed state since the last frame
  133595. * Vive mapping:
  133596. * 0: touchpad
  133597. * 1: trigger
  133598. * 2: left AND right buttons
  133599. * 3: menu button
  133600. * @param buttonIdx Which button index changed
  133601. * @param state New state of the button
  133602. * @param changes Which properties on the state changed since last frame
  133603. */
  133604. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133605. }
  133606. }
  133607. declare module BABYLON {
  133608. /**
  133609. * Defines the WindowsMotionController object that the state of the windows motion controller
  133610. */
  133611. export class WindowsMotionController extends WebVRController {
  133612. /**
  133613. * The base url used to load the left and right controller models
  133614. */
  133615. static MODEL_BASE_URL: string;
  133616. /**
  133617. * The name of the left controller model file
  133618. */
  133619. static MODEL_LEFT_FILENAME: string;
  133620. /**
  133621. * The name of the right controller model file
  133622. */
  133623. static MODEL_RIGHT_FILENAME: string;
  133624. /**
  133625. * The controller name prefix for this controller type
  133626. */
  133627. static readonly GAMEPAD_ID_PREFIX: string;
  133628. /**
  133629. * The controller id pattern for this controller type
  133630. */
  133631. private static readonly GAMEPAD_ID_PATTERN;
  133632. private _loadedMeshInfo;
  133633. protected readonly _mapping: {
  133634. buttons: string[];
  133635. buttonMeshNames: {
  133636. trigger: string;
  133637. menu: string;
  133638. grip: string;
  133639. thumbstick: string;
  133640. trackpad: string;
  133641. };
  133642. buttonObservableNames: {
  133643. trigger: string;
  133644. menu: string;
  133645. grip: string;
  133646. thumbstick: string;
  133647. trackpad: string;
  133648. };
  133649. axisMeshNames: string[];
  133650. pointingPoseMeshName: string;
  133651. };
  133652. /**
  133653. * Fired when the trackpad on this controller is clicked
  133654. */
  133655. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133656. /**
  133657. * Fired when the trackpad on this controller is modified
  133658. */
  133659. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133660. /**
  133661. * The current x and y values of this controller's trackpad
  133662. */
  133663. trackpad: StickValues;
  133664. /**
  133665. * Creates a new WindowsMotionController from a gamepad
  133666. * @param vrGamepad the gamepad that the controller should be created from
  133667. */
  133668. constructor(vrGamepad: any);
  133669. /**
  133670. * Fired when the trigger on this controller is modified
  133671. */
  133672. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133673. /**
  133674. * Fired when the menu button on this controller is modified
  133675. */
  133676. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133677. /**
  133678. * Fired when the grip button on this controller is modified
  133679. */
  133680. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133681. /**
  133682. * Fired when the thumbstick button on this controller is modified
  133683. */
  133684. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133685. /**
  133686. * Fired when the touchpad button on this controller is modified
  133687. */
  133688. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133689. /**
  133690. * Fired when the touchpad values on this controller are modified
  133691. */
  133692. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  133693. protected _updateTrackpad(): void;
  133694. /**
  133695. * Called once per frame by the engine.
  133696. */
  133697. update(): void;
  133698. /**
  133699. * Called once for each button that changed state since the last frame
  133700. * @param buttonIdx Which button index changed
  133701. * @param state New state of the button
  133702. * @param changes Which properties on the state changed since last frame
  133703. */
  133704. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133705. /**
  133706. * Moves the buttons on the controller mesh based on their current state
  133707. * @param buttonName the name of the button to move
  133708. * @param buttonValue the value of the button which determines the buttons new position
  133709. */
  133710. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  133711. /**
  133712. * Moves the axis on the controller mesh based on its current state
  133713. * @param axis the index of the axis
  133714. * @param axisValue the value of the axis which determines the meshes new position
  133715. * @hidden
  133716. */
  133717. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  133718. /**
  133719. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133720. * @param scene scene in which to add meshes
  133721. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133722. */
  133723. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  133724. /**
  133725. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  133726. * can be transformed by button presses and axes values, based on this._mapping.
  133727. *
  133728. * @param scene scene in which the meshes exist
  133729. * @param meshes list of meshes that make up the controller model to process
  133730. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  133731. */
  133732. private processModel;
  133733. private createMeshInfo;
  133734. /**
  133735. * Gets the ray of the controller in the direction the controller is pointing
  133736. * @param length the length the resulting ray should be
  133737. * @returns a ray in the direction the controller is pointing
  133738. */
  133739. getForwardRay(length?: number): Ray;
  133740. /**
  133741. * Disposes of the controller
  133742. */
  133743. dispose(): void;
  133744. }
  133745. /**
  133746. * This class represents a new windows motion controller in XR.
  133747. */
  133748. export class XRWindowsMotionController extends WindowsMotionController {
  133749. /**
  133750. * Changing the original WIndowsMotionController mapping to fir the new mapping
  133751. */
  133752. protected readonly _mapping: {
  133753. buttons: string[];
  133754. buttonMeshNames: {
  133755. trigger: string;
  133756. menu: string;
  133757. grip: string;
  133758. thumbstick: string;
  133759. trackpad: string;
  133760. };
  133761. buttonObservableNames: {
  133762. trigger: string;
  133763. menu: string;
  133764. grip: string;
  133765. thumbstick: string;
  133766. trackpad: string;
  133767. };
  133768. axisMeshNames: string[];
  133769. pointingPoseMeshName: string;
  133770. };
  133771. /**
  133772. * Construct a new XR-Based windows motion controller
  133773. *
  133774. * @param gamepadInfo the gamepad object from the browser
  133775. */
  133776. constructor(gamepadInfo: any);
  133777. /**
  133778. * holds the thumbstick values (X,Y)
  133779. */
  133780. thumbstickValues: StickValues;
  133781. /**
  133782. * Fired when the thumbstick on this controller is clicked
  133783. */
  133784. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  133785. /**
  133786. * Fired when the thumbstick on this controller is modified
  133787. */
  133788. onThumbstickValuesChangedObservable: Observable<StickValues>;
  133789. /**
  133790. * Fired when the touchpad button on this controller is modified
  133791. */
  133792. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133793. /**
  133794. * Fired when the touchpad values on this controller are modified
  133795. */
  133796. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133797. /**
  133798. * Fired when the thumbstick button on this controller is modified
  133799. * here to prevent breaking changes
  133800. */
  133801. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133802. /**
  133803. * updating the thumbstick(!) and not the trackpad.
  133804. * This is named this way due to the difference between WebVR and XR and to avoid
  133805. * changing the parent class.
  133806. */
  133807. protected _updateTrackpad(): void;
  133808. /**
  133809. * Disposes the class with joy
  133810. */
  133811. dispose(): void;
  133812. }
  133813. }
  133814. declare module BABYLON {
  133815. /**
  133816. * Class containing static functions to help procedurally build meshes
  133817. */
  133818. export class PolyhedronBuilder {
  133819. /**
  133820. * Creates a polyhedron mesh
  133821. * * 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
  133822. * * The parameter `size` (positive float, default 1) sets the polygon size
  133823. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133824. * * 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`
  133825. * * 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
  133826. * * 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)`)
  133827. * * 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
  133828. * * 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
  133829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133832. * @param name defines the name of the mesh
  133833. * @param options defines the options used to create the mesh
  133834. * @param scene defines the hosting scene
  133835. * @returns the polyhedron mesh
  133836. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133837. */
  133838. static CreatePolyhedron(name: string, options: {
  133839. type?: number;
  133840. size?: number;
  133841. sizeX?: number;
  133842. sizeY?: number;
  133843. sizeZ?: number;
  133844. custom?: any;
  133845. faceUV?: Vector4[];
  133846. faceColors?: Color4[];
  133847. flat?: boolean;
  133848. updatable?: boolean;
  133849. sideOrientation?: number;
  133850. frontUVs?: Vector4;
  133851. backUVs?: Vector4;
  133852. }, scene?: Nullable<Scene>): Mesh;
  133853. }
  133854. }
  133855. declare module BABYLON {
  133856. /**
  133857. * Gizmo that enables scaling a mesh along 3 axis
  133858. */
  133859. export class ScaleGizmo extends Gizmo {
  133860. /**
  133861. * Internal gizmo used for interactions on the x axis
  133862. */
  133863. xGizmo: AxisScaleGizmo;
  133864. /**
  133865. * Internal gizmo used for interactions on the y axis
  133866. */
  133867. yGizmo: AxisScaleGizmo;
  133868. /**
  133869. * Internal gizmo used for interactions on the z axis
  133870. */
  133871. zGizmo: AxisScaleGizmo;
  133872. /**
  133873. * Internal gizmo used to scale all axis equally
  133874. */
  133875. uniformScaleGizmo: AxisScaleGizmo;
  133876. private _meshAttached;
  133877. private _nodeAttached;
  133878. private _snapDistance;
  133879. private _uniformScalingMesh;
  133880. private _octahedron;
  133881. private _sensitivity;
  133882. /** Fires an event when any of it's sub gizmos are dragged */
  133883. onDragStartObservable: Observable<unknown>;
  133884. /** Fires an event when any of it's sub gizmos are released from dragging */
  133885. onDragEndObservable: Observable<unknown>;
  133886. get attachedMesh(): Nullable<AbstractMesh>;
  133887. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133888. get attachedNode(): Nullable<Node>;
  133889. set attachedNode(node: Nullable<Node>);
  133890. /**
  133891. * Creates a ScaleGizmo
  133892. * @param gizmoLayer The utility layer the gizmo will be added to
  133893. * @param thickness display gizmo axis thickness
  133894. */
  133895. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  133896. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133897. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133898. /**
  133899. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133900. */
  133901. set snapDistance(value: number);
  133902. get snapDistance(): number;
  133903. /**
  133904. * Ratio for the scale of the gizmo (Default: 1)
  133905. */
  133906. set scaleRatio(value: number);
  133907. get scaleRatio(): number;
  133908. /**
  133909. * Sensitivity factor for dragging (Default: 1)
  133910. */
  133911. set sensitivity(value: number);
  133912. get sensitivity(): number;
  133913. /**
  133914. * Disposes of the gizmo
  133915. */
  133916. dispose(): void;
  133917. }
  133918. }
  133919. declare module BABYLON {
  133920. /**
  133921. * Single axis scale gizmo
  133922. */
  133923. export class AxisScaleGizmo extends Gizmo {
  133924. /**
  133925. * Drag behavior responsible for the gizmos dragging interactions
  133926. */
  133927. dragBehavior: PointerDragBehavior;
  133928. private _pointerObserver;
  133929. /**
  133930. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133931. */
  133932. snapDistance: number;
  133933. /**
  133934. * Event that fires each time the gizmo snaps to a new location.
  133935. * * snapDistance is the the change in distance
  133936. */
  133937. onSnapObservable: Observable<{
  133938. snapDistance: number;
  133939. }>;
  133940. /**
  133941. * If the scaling operation should be done on all axis (default: false)
  133942. */
  133943. uniformScaling: boolean;
  133944. /**
  133945. * Custom sensitivity value for the drag strength
  133946. */
  133947. sensitivity: number;
  133948. private _isEnabled;
  133949. private _parent;
  133950. private _arrow;
  133951. private _coloredMaterial;
  133952. private _hoverMaterial;
  133953. /**
  133954. * Creates an AxisScaleGizmo
  133955. * @param gizmoLayer The utility layer the gizmo will be added to
  133956. * @param dragAxis The axis which the gizmo will be able to scale on
  133957. * @param color The color of the gizmo
  133958. * @param thickness display gizmo axis thickness
  133959. */
  133960. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  133961. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133962. /**
  133963. * If the gizmo is enabled
  133964. */
  133965. set isEnabled(value: boolean);
  133966. get isEnabled(): boolean;
  133967. /**
  133968. * Disposes of the gizmo
  133969. */
  133970. dispose(): void;
  133971. /**
  133972. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  133973. * @param mesh The mesh to replace the default mesh of the gizmo
  133974. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  133975. */
  133976. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  133977. }
  133978. }
  133979. declare module BABYLON {
  133980. /**
  133981. * Bounding box gizmo
  133982. */
  133983. export class BoundingBoxGizmo extends Gizmo {
  133984. private _lineBoundingBox;
  133985. private _rotateSpheresParent;
  133986. private _scaleBoxesParent;
  133987. private _boundingDimensions;
  133988. private _renderObserver;
  133989. private _pointerObserver;
  133990. private _scaleDragSpeed;
  133991. private _tmpQuaternion;
  133992. private _tmpVector;
  133993. private _tmpRotationMatrix;
  133994. /**
  133995. * 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)
  133996. */
  133997. ignoreChildren: boolean;
  133998. /**
  133999. * 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)
  134000. */
  134001. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  134002. /**
  134003. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  134004. */
  134005. rotationSphereSize: number;
  134006. /**
  134007. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  134008. */
  134009. scaleBoxSize: number;
  134010. /**
  134011. * 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)
  134012. */
  134013. fixedDragMeshScreenSize: boolean;
  134014. /**
  134015. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  134016. */
  134017. fixedDragMeshScreenSizeDistanceFactor: number;
  134018. /**
  134019. * Fired when a rotation sphere or scale box is dragged
  134020. */
  134021. onDragStartObservable: Observable<{}>;
  134022. /**
  134023. * Fired when a scale box is dragged
  134024. */
  134025. onScaleBoxDragObservable: Observable<{}>;
  134026. /**
  134027. * Fired when a scale box drag is ended
  134028. */
  134029. onScaleBoxDragEndObservable: Observable<{}>;
  134030. /**
  134031. * Fired when a rotation sphere is dragged
  134032. */
  134033. onRotationSphereDragObservable: Observable<{}>;
  134034. /**
  134035. * Fired when a rotation sphere drag is ended
  134036. */
  134037. onRotationSphereDragEndObservable: Observable<{}>;
  134038. /**
  134039. * 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)
  134040. */
  134041. scalePivot: Nullable<Vector3>;
  134042. /**
  134043. * Mesh used as a pivot to rotate the attached node
  134044. */
  134045. private _anchorMesh;
  134046. private _existingMeshScale;
  134047. private _dragMesh;
  134048. private pointerDragBehavior;
  134049. private coloredMaterial;
  134050. private hoverColoredMaterial;
  134051. /**
  134052. * Sets the color of the bounding box gizmo
  134053. * @param color the color to set
  134054. */
  134055. setColor(color: Color3): void;
  134056. /**
  134057. * Creates an BoundingBoxGizmo
  134058. * @param gizmoLayer The utility layer the gizmo will be added to
  134059. * @param color The color of the gizmo
  134060. */
  134061. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  134062. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  134063. private _selectNode;
  134064. /**
  134065. * Updates the bounding box information for the Gizmo
  134066. */
  134067. updateBoundingBox(): void;
  134068. private _updateRotationSpheres;
  134069. private _updateScaleBoxes;
  134070. /**
  134071. * Enables rotation on the specified axis and disables rotation on the others
  134072. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  134073. */
  134074. setEnabledRotationAxis(axis: string): void;
  134075. /**
  134076. * Enables/disables scaling
  134077. * @param enable if scaling should be enabled
  134078. * @param homogeneousScaling defines if scaling should only be homogeneous
  134079. */
  134080. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  134081. private _updateDummy;
  134082. /**
  134083. * Enables a pointer drag behavior on the bounding box of the gizmo
  134084. */
  134085. enableDragBehavior(): void;
  134086. /**
  134087. * Disposes of the gizmo
  134088. */
  134089. dispose(): void;
  134090. /**
  134091. * 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)
  134092. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  134093. * @returns the bounding box mesh with the passed in mesh as a child
  134094. */
  134095. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  134096. /**
  134097. * CustomMeshes are not supported by this gizmo
  134098. * @param mesh The mesh to replace the default mesh of the gizmo
  134099. */
  134100. setCustomMesh(mesh: Mesh): void;
  134101. }
  134102. }
  134103. declare module BABYLON {
  134104. /**
  134105. * Single plane rotation gizmo
  134106. */
  134107. export class PlaneRotationGizmo extends Gizmo {
  134108. /**
  134109. * Drag behavior responsible for the gizmos dragging interactions
  134110. */
  134111. dragBehavior: PointerDragBehavior;
  134112. private _pointerObserver;
  134113. /**
  134114. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  134115. */
  134116. snapDistance: number;
  134117. /**
  134118. * Event that fires each time the gizmo snaps to a new location.
  134119. * * snapDistance is the the change in distance
  134120. */
  134121. onSnapObservable: Observable<{
  134122. snapDistance: number;
  134123. }>;
  134124. private _isEnabled;
  134125. private _parent;
  134126. /**
  134127. * Creates a PlaneRotationGizmo
  134128. * @param gizmoLayer The utility layer the gizmo will be added to
  134129. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  134130. * @param color The color of the gizmo
  134131. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134132. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134133. * @param thickness display gizmo axis thickness
  134134. */
  134135. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  134136. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134137. /**
  134138. * If the gizmo is enabled
  134139. */
  134140. set isEnabled(value: boolean);
  134141. get isEnabled(): boolean;
  134142. /**
  134143. * Disposes of the gizmo
  134144. */
  134145. dispose(): void;
  134146. }
  134147. }
  134148. declare module BABYLON {
  134149. /**
  134150. * Gizmo that enables rotating a mesh along 3 axis
  134151. */
  134152. export class RotationGizmo extends Gizmo {
  134153. /**
  134154. * Internal gizmo used for interactions on the x axis
  134155. */
  134156. xGizmo: PlaneRotationGizmo;
  134157. /**
  134158. * Internal gizmo used for interactions on the y axis
  134159. */
  134160. yGizmo: PlaneRotationGizmo;
  134161. /**
  134162. * Internal gizmo used for interactions on the z axis
  134163. */
  134164. zGizmo: PlaneRotationGizmo;
  134165. /** Fires an event when any of it's sub gizmos are dragged */
  134166. onDragStartObservable: Observable<unknown>;
  134167. /** Fires an event when any of it's sub gizmos are released from dragging */
  134168. onDragEndObservable: Observable<unknown>;
  134169. private _meshAttached;
  134170. private _nodeAttached;
  134171. get attachedMesh(): Nullable<AbstractMesh>;
  134172. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134173. get attachedNode(): Nullable<Node>;
  134174. set attachedNode(node: Nullable<Node>);
  134175. /**
  134176. * Creates a RotationGizmo
  134177. * @param gizmoLayer The utility layer the gizmo will be added to
  134178. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134179. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134180. * @param thickness display gizmo axis thickness
  134181. */
  134182. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  134183. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134184. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134185. /**
  134186. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134187. */
  134188. set snapDistance(value: number);
  134189. get snapDistance(): number;
  134190. /**
  134191. * Ratio for the scale of the gizmo (Default: 1)
  134192. */
  134193. set scaleRatio(value: number);
  134194. get scaleRatio(): number;
  134195. /**
  134196. * Disposes of the gizmo
  134197. */
  134198. dispose(): void;
  134199. /**
  134200. * CustomMeshes are not supported by this gizmo
  134201. * @param mesh The mesh to replace the default mesh of the gizmo
  134202. */
  134203. setCustomMesh(mesh: Mesh): void;
  134204. }
  134205. }
  134206. declare module BABYLON {
  134207. /**
  134208. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  134209. */
  134210. export class GizmoManager implements IDisposable {
  134211. private scene;
  134212. /**
  134213. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  134214. */
  134215. gizmos: {
  134216. positionGizmo: Nullable<PositionGizmo>;
  134217. rotationGizmo: Nullable<RotationGizmo>;
  134218. scaleGizmo: Nullable<ScaleGizmo>;
  134219. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  134220. };
  134221. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  134222. clearGizmoOnEmptyPointerEvent: boolean;
  134223. /** Fires an event when the manager is attached to a mesh */
  134224. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  134225. /** Fires an event when the manager is attached to a node */
  134226. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  134227. private _gizmosEnabled;
  134228. private _pointerObserver;
  134229. private _attachedMesh;
  134230. private _attachedNode;
  134231. private _boundingBoxColor;
  134232. private _defaultUtilityLayer;
  134233. private _defaultKeepDepthUtilityLayer;
  134234. private _thickness;
  134235. /**
  134236. * When bounding box gizmo is enabled, this can be used to track drag/end events
  134237. */
  134238. boundingBoxDragBehavior: SixDofDragBehavior;
  134239. /**
  134240. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  134241. */
  134242. attachableMeshes: Nullable<Array<AbstractMesh>>;
  134243. /**
  134244. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  134245. */
  134246. attachableNodes: Nullable<Array<Node>>;
  134247. /**
  134248. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  134249. */
  134250. usePointerToAttachGizmos: boolean;
  134251. /**
  134252. * Utility layer that the bounding box gizmo belongs to
  134253. */
  134254. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  134255. /**
  134256. * Utility layer that all gizmos besides bounding box belong to
  134257. */
  134258. get utilityLayer(): UtilityLayerRenderer;
  134259. /**
  134260. * Instatiates a gizmo manager
  134261. * @param scene the scene to overlay the gizmos on top of
  134262. * @param thickness display gizmo axis thickness
  134263. */
  134264. constructor(scene: Scene, thickness?: number);
  134265. /**
  134266. * Attaches a set of gizmos to the specified mesh
  134267. * @param mesh The mesh the gizmo's should be attached to
  134268. */
  134269. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  134270. /**
  134271. * Attaches a set of gizmos to the specified node
  134272. * @param node The node the gizmo's should be attached to
  134273. */
  134274. attachToNode(node: Nullable<Node>): void;
  134275. /**
  134276. * If the position gizmo is enabled
  134277. */
  134278. set positionGizmoEnabled(value: boolean);
  134279. get positionGizmoEnabled(): boolean;
  134280. /**
  134281. * If the rotation gizmo is enabled
  134282. */
  134283. set rotationGizmoEnabled(value: boolean);
  134284. get rotationGizmoEnabled(): boolean;
  134285. /**
  134286. * If the scale gizmo is enabled
  134287. */
  134288. set scaleGizmoEnabled(value: boolean);
  134289. get scaleGizmoEnabled(): boolean;
  134290. /**
  134291. * If the boundingBox gizmo is enabled
  134292. */
  134293. set boundingBoxGizmoEnabled(value: boolean);
  134294. get boundingBoxGizmoEnabled(): boolean;
  134295. /**
  134296. * Disposes of the gizmo manager
  134297. */
  134298. dispose(): void;
  134299. }
  134300. }
  134301. declare module BABYLON {
  134302. /**
  134303. * A directional light is defined by a direction (what a surprise!).
  134304. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  134305. * 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.
  134306. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134307. */
  134308. export class DirectionalLight extends ShadowLight {
  134309. private _shadowFrustumSize;
  134310. /**
  134311. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  134312. */
  134313. get shadowFrustumSize(): number;
  134314. /**
  134315. * Specifies a fix frustum size for the shadow generation.
  134316. */
  134317. set shadowFrustumSize(value: number);
  134318. private _shadowOrthoScale;
  134319. /**
  134320. * Gets the shadow projection scale against the optimal computed one.
  134321. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134322. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134323. */
  134324. get shadowOrthoScale(): number;
  134325. /**
  134326. * Sets the shadow projection scale against the optimal computed one.
  134327. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134328. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134329. */
  134330. set shadowOrthoScale(value: number);
  134331. /**
  134332. * Automatically compute the projection matrix to best fit (including all the casters)
  134333. * on each frame.
  134334. */
  134335. autoUpdateExtends: boolean;
  134336. /**
  134337. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  134338. * on each frame. autoUpdateExtends must be set to true for this to work
  134339. */
  134340. autoCalcShadowZBounds: boolean;
  134341. private _orthoLeft;
  134342. private _orthoRight;
  134343. private _orthoTop;
  134344. private _orthoBottom;
  134345. /**
  134346. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  134347. * The directional light is emitted from everywhere in the given direction.
  134348. * It can cast shadows.
  134349. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134350. * @param name The friendly name of the light
  134351. * @param direction The direction of the light
  134352. * @param scene The scene the light belongs to
  134353. */
  134354. constructor(name: string, direction: Vector3, scene: Scene);
  134355. /**
  134356. * Returns the string "DirectionalLight".
  134357. * @return The class name
  134358. */
  134359. getClassName(): string;
  134360. /**
  134361. * Returns the integer 1.
  134362. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134363. */
  134364. getTypeID(): number;
  134365. /**
  134366. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  134367. * Returns the DirectionalLight Shadow projection matrix.
  134368. */
  134369. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134370. /**
  134371. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  134372. * Returns the DirectionalLight Shadow projection matrix.
  134373. */
  134374. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  134375. /**
  134376. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  134377. * Returns the DirectionalLight Shadow projection matrix.
  134378. */
  134379. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134380. protected _buildUniformLayout(): void;
  134381. /**
  134382. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  134383. * @param effect The effect to update
  134384. * @param lightIndex The index of the light in the effect to update
  134385. * @returns The directional light
  134386. */
  134387. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  134388. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  134389. /**
  134390. * Gets the minZ used for shadow according to both the scene and the light.
  134391. *
  134392. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134393. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134394. * @param activeCamera The camera we are returning the min for
  134395. * @returns the depth min z
  134396. */
  134397. getDepthMinZ(activeCamera: Camera): number;
  134398. /**
  134399. * Gets the maxZ used for shadow according to both the scene and the light.
  134400. *
  134401. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134402. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134403. * @param activeCamera The camera we are returning the max for
  134404. * @returns the depth max z
  134405. */
  134406. getDepthMaxZ(activeCamera: Camera): number;
  134407. /**
  134408. * Prepares the list of defines specific to the light type.
  134409. * @param defines the list of defines
  134410. * @param lightIndex defines the index of the light for the effect
  134411. */
  134412. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134413. }
  134414. }
  134415. declare module BABYLON {
  134416. /**
  134417. * Class containing static functions to help procedurally build meshes
  134418. */
  134419. export class HemisphereBuilder {
  134420. /**
  134421. * Creates a hemisphere mesh
  134422. * @param name defines the name of the mesh
  134423. * @param options defines the options used to create the mesh
  134424. * @param scene defines the hosting scene
  134425. * @returns the hemisphere mesh
  134426. */
  134427. static CreateHemisphere(name: string, options: {
  134428. segments?: number;
  134429. diameter?: number;
  134430. sideOrientation?: number;
  134431. }, scene: any): Mesh;
  134432. }
  134433. }
  134434. declare module BABYLON {
  134435. /**
  134436. * A spot light is defined by a position, a direction, an angle, and an exponent.
  134437. * These values define a cone of light starting from the position, emitting toward the direction.
  134438. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  134439. * and the exponent defines the speed of the decay of the light with distance (reach).
  134440. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134441. */
  134442. export class SpotLight extends ShadowLight {
  134443. private _angle;
  134444. private _innerAngle;
  134445. private _cosHalfAngle;
  134446. private _lightAngleScale;
  134447. private _lightAngleOffset;
  134448. /**
  134449. * Gets the cone angle of the spot light in Radians.
  134450. */
  134451. get angle(): number;
  134452. /**
  134453. * Sets the cone angle of the spot light in Radians.
  134454. */
  134455. set angle(value: number);
  134456. /**
  134457. * Only used in gltf falloff mode, this defines the angle where
  134458. * the directional falloff will start before cutting at angle which could be seen
  134459. * as outer angle.
  134460. */
  134461. get innerAngle(): number;
  134462. /**
  134463. * Only used in gltf falloff mode, this defines the angle where
  134464. * the directional falloff will start before cutting at angle which could be seen
  134465. * as outer angle.
  134466. */
  134467. set innerAngle(value: number);
  134468. private _shadowAngleScale;
  134469. /**
  134470. * Allows scaling the angle of the light for shadow generation only.
  134471. */
  134472. get shadowAngleScale(): number;
  134473. /**
  134474. * Allows scaling the angle of the light for shadow generation only.
  134475. */
  134476. set shadowAngleScale(value: number);
  134477. /**
  134478. * The light decay speed with the distance from the emission spot.
  134479. */
  134480. exponent: number;
  134481. private _projectionTextureMatrix;
  134482. /**
  134483. * Allows reading the projecton texture
  134484. */
  134485. get projectionTextureMatrix(): Matrix;
  134486. protected _projectionTextureLightNear: number;
  134487. /**
  134488. * Gets the near clip of the Spotlight for texture projection.
  134489. */
  134490. get projectionTextureLightNear(): number;
  134491. /**
  134492. * Sets the near clip of the Spotlight for texture projection.
  134493. */
  134494. set projectionTextureLightNear(value: number);
  134495. protected _projectionTextureLightFar: number;
  134496. /**
  134497. * Gets the far clip of the Spotlight for texture projection.
  134498. */
  134499. get projectionTextureLightFar(): number;
  134500. /**
  134501. * Sets the far clip of the Spotlight for texture projection.
  134502. */
  134503. set projectionTextureLightFar(value: number);
  134504. protected _projectionTextureUpDirection: Vector3;
  134505. /**
  134506. * Gets the Up vector of the Spotlight for texture projection.
  134507. */
  134508. get projectionTextureUpDirection(): Vector3;
  134509. /**
  134510. * Sets the Up vector of the Spotlight for texture projection.
  134511. */
  134512. set projectionTextureUpDirection(value: Vector3);
  134513. private _projectionTexture;
  134514. /**
  134515. * Gets the projection texture of the light.
  134516. */
  134517. get projectionTexture(): Nullable<BaseTexture>;
  134518. /**
  134519. * Sets the projection texture of the light.
  134520. */
  134521. set projectionTexture(value: Nullable<BaseTexture>);
  134522. private _projectionTextureViewLightDirty;
  134523. private _projectionTextureProjectionLightDirty;
  134524. private _projectionTextureDirty;
  134525. private _projectionTextureViewTargetVector;
  134526. private _projectionTextureViewLightMatrix;
  134527. private _projectionTextureProjectionLightMatrix;
  134528. private _projectionTextureScalingMatrix;
  134529. /**
  134530. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  134531. * It can cast shadows.
  134532. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134533. * @param name The light friendly name
  134534. * @param position The position of the spot light in the scene
  134535. * @param direction The direction of the light in the scene
  134536. * @param angle The cone angle of the light in Radians
  134537. * @param exponent The light decay speed with the distance from the emission spot
  134538. * @param scene The scene the lights belongs to
  134539. */
  134540. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  134541. /**
  134542. * Returns the string "SpotLight".
  134543. * @returns the class name
  134544. */
  134545. getClassName(): string;
  134546. /**
  134547. * Returns the integer 2.
  134548. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134549. */
  134550. getTypeID(): number;
  134551. /**
  134552. * Overrides the direction setter to recompute the projection texture view light Matrix.
  134553. */
  134554. protected _setDirection(value: Vector3): void;
  134555. /**
  134556. * Overrides the position setter to recompute the projection texture view light Matrix.
  134557. */
  134558. protected _setPosition(value: Vector3): void;
  134559. /**
  134560. * 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.
  134561. * Returns the SpotLight.
  134562. */
  134563. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134564. protected _computeProjectionTextureViewLightMatrix(): void;
  134565. protected _computeProjectionTextureProjectionLightMatrix(): void;
  134566. /**
  134567. * Main function for light texture projection matrix computing.
  134568. */
  134569. protected _computeProjectionTextureMatrix(): void;
  134570. protected _buildUniformLayout(): void;
  134571. private _computeAngleValues;
  134572. /**
  134573. * Sets the passed Effect "effect" with the Light textures.
  134574. * @param effect The effect to update
  134575. * @param lightIndex The index of the light in the effect to update
  134576. * @returns The light
  134577. */
  134578. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  134579. /**
  134580. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  134581. * @param effect The effect to update
  134582. * @param lightIndex The index of the light in the effect to update
  134583. * @returns The spot light
  134584. */
  134585. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  134586. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  134587. /**
  134588. * Disposes the light and the associated resources.
  134589. */
  134590. dispose(): void;
  134591. /**
  134592. * Prepares the list of defines specific to the light type.
  134593. * @param defines the list of defines
  134594. * @param lightIndex defines the index of the light for the effect
  134595. */
  134596. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134597. }
  134598. }
  134599. declare module BABYLON {
  134600. /**
  134601. * Gizmo that enables viewing a light
  134602. */
  134603. export class LightGizmo extends Gizmo {
  134604. private _lightMesh;
  134605. private _material;
  134606. private _cachedPosition;
  134607. private _cachedForward;
  134608. private _attachedMeshParent;
  134609. private _pointerObserver;
  134610. /**
  134611. * Event that fires each time the gizmo is clicked
  134612. */
  134613. onClickedObservable: Observable<Light>;
  134614. /**
  134615. * Creates a LightGizmo
  134616. * @param gizmoLayer The utility layer the gizmo will be added to
  134617. */
  134618. constructor(gizmoLayer?: UtilityLayerRenderer);
  134619. private _light;
  134620. /**
  134621. * The light that the gizmo is attached to
  134622. */
  134623. set light(light: Nullable<Light>);
  134624. get light(): Nullable<Light>;
  134625. /**
  134626. * Gets the material used to render the light gizmo
  134627. */
  134628. get material(): StandardMaterial;
  134629. /**
  134630. * @hidden
  134631. * Updates the gizmo to match the attached mesh's position/rotation
  134632. */
  134633. protected _update(): void;
  134634. private static _Scale;
  134635. /**
  134636. * Creates the lines for a light mesh
  134637. */
  134638. private static _CreateLightLines;
  134639. /**
  134640. * Disposes of the light gizmo
  134641. */
  134642. dispose(): void;
  134643. private static _CreateHemisphericLightMesh;
  134644. private static _CreatePointLightMesh;
  134645. private static _CreateSpotLightMesh;
  134646. private static _CreateDirectionalLightMesh;
  134647. }
  134648. }
  134649. declare module BABYLON {
  134650. /**
  134651. * Gizmo that enables viewing a camera
  134652. */
  134653. export class CameraGizmo extends Gizmo {
  134654. private _cameraMesh;
  134655. private _cameraLinesMesh;
  134656. private _material;
  134657. private _pointerObserver;
  134658. /**
  134659. * Event that fires each time the gizmo is clicked
  134660. */
  134661. onClickedObservable: Observable<Camera>;
  134662. /**
  134663. * Creates a CameraGizmo
  134664. * @param gizmoLayer The utility layer the gizmo will be added to
  134665. */
  134666. constructor(gizmoLayer?: UtilityLayerRenderer);
  134667. private _camera;
  134668. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  134669. get displayFrustum(): boolean;
  134670. set displayFrustum(value: boolean);
  134671. /**
  134672. * The camera that the gizmo is attached to
  134673. */
  134674. set camera(camera: Nullable<Camera>);
  134675. get camera(): Nullable<Camera>;
  134676. /**
  134677. * Gets the material used to render the camera gizmo
  134678. */
  134679. get material(): StandardMaterial;
  134680. /**
  134681. * @hidden
  134682. * Updates the gizmo to match the attached mesh's position/rotation
  134683. */
  134684. protected _update(): void;
  134685. private static _Scale;
  134686. private _invProjection;
  134687. /**
  134688. * Disposes of the camera gizmo
  134689. */
  134690. dispose(): void;
  134691. private static _CreateCameraMesh;
  134692. private static _CreateCameraFrustum;
  134693. }
  134694. }
  134695. declare module BABYLON {
  134696. /** @hidden */
  134697. export var backgroundFragmentDeclaration: {
  134698. name: string;
  134699. shader: string;
  134700. };
  134701. }
  134702. declare module BABYLON {
  134703. /** @hidden */
  134704. export var backgroundUboDeclaration: {
  134705. name: string;
  134706. shader: string;
  134707. };
  134708. }
  134709. declare module BABYLON {
  134710. /** @hidden */
  134711. export var backgroundPixelShader: {
  134712. name: string;
  134713. shader: string;
  134714. };
  134715. }
  134716. declare module BABYLON {
  134717. /** @hidden */
  134718. export var backgroundVertexDeclaration: {
  134719. name: string;
  134720. shader: string;
  134721. };
  134722. }
  134723. declare module BABYLON {
  134724. /** @hidden */
  134725. export var backgroundVertexShader: {
  134726. name: string;
  134727. shader: string;
  134728. };
  134729. }
  134730. declare module BABYLON {
  134731. /**
  134732. * Background material used to create an efficient environement around your scene.
  134733. */
  134734. export class BackgroundMaterial extends PushMaterial {
  134735. /**
  134736. * Standard reflectance value at parallel view angle.
  134737. */
  134738. static StandardReflectance0: number;
  134739. /**
  134740. * Standard reflectance value at grazing angle.
  134741. */
  134742. static StandardReflectance90: number;
  134743. protected _primaryColor: Color3;
  134744. /**
  134745. * Key light Color (multiply against the environement texture)
  134746. */
  134747. primaryColor: Color3;
  134748. protected __perceptualColor: Nullable<Color3>;
  134749. /**
  134750. * Experimental Internal Use Only.
  134751. *
  134752. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  134753. * This acts as a helper to set the primary color to a more "human friendly" value.
  134754. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  134755. * output color as close as possible from the chosen value.
  134756. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  134757. * part of lighting setup.)
  134758. */
  134759. get _perceptualColor(): Nullable<Color3>;
  134760. set _perceptualColor(value: Nullable<Color3>);
  134761. protected _primaryColorShadowLevel: float;
  134762. /**
  134763. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  134764. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  134765. */
  134766. get primaryColorShadowLevel(): float;
  134767. set primaryColorShadowLevel(value: float);
  134768. protected _primaryColorHighlightLevel: float;
  134769. /**
  134770. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  134771. * The primary color is used at the level chosen to define what the white area would look.
  134772. */
  134773. get primaryColorHighlightLevel(): float;
  134774. set primaryColorHighlightLevel(value: float);
  134775. protected _reflectionTexture: Nullable<BaseTexture>;
  134776. /**
  134777. * Reflection Texture used in the material.
  134778. * Should be author in a specific way for the best result (refer to the documentation).
  134779. */
  134780. reflectionTexture: Nullable<BaseTexture>;
  134781. protected _reflectionBlur: float;
  134782. /**
  134783. * Reflection Texture level of blur.
  134784. *
  134785. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  134786. * texture twice.
  134787. */
  134788. reflectionBlur: float;
  134789. protected _diffuseTexture: Nullable<BaseTexture>;
  134790. /**
  134791. * Diffuse Texture used in the material.
  134792. * Should be author in a specific way for the best result (refer to the documentation).
  134793. */
  134794. diffuseTexture: Nullable<BaseTexture>;
  134795. protected _shadowLights: Nullable<IShadowLight[]>;
  134796. /**
  134797. * Specify the list of lights casting shadow on the material.
  134798. * All scene shadow lights will be included if null.
  134799. */
  134800. shadowLights: Nullable<IShadowLight[]>;
  134801. protected _shadowLevel: float;
  134802. /**
  134803. * Helps adjusting the shadow to a softer level if required.
  134804. * 0 means black shadows and 1 means no shadows.
  134805. */
  134806. shadowLevel: float;
  134807. protected _sceneCenter: Vector3;
  134808. /**
  134809. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  134810. * It is usually zero but might be interesting to modify according to your setup.
  134811. */
  134812. sceneCenter: Vector3;
  134813. protected _opacityFresnel: boolean;
  134814. /**
  134815. * This helps specifying that the material is falling off to the sky box at grazing angle.
  134816. * This helps ensuring a nice transition when the camera goes under the ground.
  134817. */
  134818. opacityFresnel: boolean;
  134819. protected _reflectionFresnel: boolean;
  134820. /**
  134821. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  134822. * This helps adding a mirror texture on the ground.
  134823. */
  134824. reflectionFresnel: boolean;
  134825. protected _reflectionFalloffDistance: number;
  134826. /**
  134827. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  134828. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  134829. */
  134830. reflectionFalloffDistance: number;
  134831. protected _reflectionAmount: number;
  134832. /**
  134833. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  134834. */
  134835. reflectionAmount: number;
  134836. protected _reflectionReflectance0: number;
  134837. /**
  134838. * This specifies the weight of the reflection at grazing angle.
  134839. */
  134840. reflectionReflectance0: number;
  134841. protected _reflectionReflectance90: number;
  134842. /**
  134843. * This specifies the weight of the reflection at a perpendicular point of view.
  134844. */
  134845. reflectionReflectance90: number;
  134846. /**
  134847. * Sets the reflection reflectance fresnel values according to the default standard
  134848. * empirically know to work well :-)
  134849. */
  134850. set reflectionStandardFresnelWeight(value: number);
  134851. protected _useRGBColor: boolean;
  134852. /**
  134853. * Helps to directly use the maps channels instead of their level.
  134854. */
  134855. useRGBColor: boolean;
  134856. protected _enableNoise: boolean;
  134857. /**
  134858. * This helps reducing the banding effect that could occur on the background.
  134859. */
  134860. enableNoise: boolean;
  134861. /**
  134862. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134863. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  134864. * Recommended to be keep at 1.0 except for special cases.
  134865. */
  134866. get fovMultiplier(): number;
  134867. set fovMultiplier(value: number);
  134868. private _fovMultiplier;
  134869. /**
  134870. * Enable the FOV adjustment feature controlled by fovMultiplier.
  134871. */
  134872. useEquirectangularFOV: boolean;
  134873. private _maxSimultaneousLights;
  134874. /**
  134875. * Number of Simultaneous lights allowed on the material.
  134876. */
  134877. maxSimultaneousLights: int;
  134878. private _shadowOnly;
  134879. /**
  134880. * Make the material only render shadows
  134881. */
  134882. shadowOnly: boolean;
  134883. /**
  134884. * Default configuration related to image processing available in the Background Material.
  134885. */
  134886. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134887. /**
  134888. * Keep track of the image processing observer to allow dispose and replace.
  134889. */
  134890. private _imageProcessingObserver;
  134891. /**
  134892. * Attaches a new image processing configuration to the PBR Material.
  134893. * @param configuration (if null the scene configuration will be use)
  134894. */
  134895. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134896. /**
  134897. * Gets the image processing configuration used either in this material.
  134898. */
  134899. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  134900. /**
  134901. * Sets the Default image processing configuration used either in the this material.
  134902. *
  134903. * If sets to null, the scene one is in use.
  134904. */
  134905. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  134906. /**
  134907. * Gets wether the color curves effect is enabled.
  134908. */
  134909. get cameraColorCurvesEnabled(): boolean;
  134910. /**
  134911. * Sets wether the color curves effect is enabled.
  134912. */
  134913. set cameraColorCurvesEnabled(value: boolean);
  134914. /**
  134915. * Gets wether the color grading effect is enabled.
  134916. */
  134917. get cameraColorGradingEnabled(): boolean;
  134918. /**
  134919. * Gets wether the color grading effect is enabled.
  134920. */
  134921. set cameraColorGradingEnabled(value: boolean);
  134922. /**
  134923. * Gets wether tonemapping is enabled or not.
  134924. */
  134925. get cameraToneMappingEnabled(): boolean;
  134926. /**
  134927. * Sets wether tonemapping is enabled or not
  134928. */
  134929. set cameraToneMappingEnabled(value: boolean);
  134930. /**
  134931. * The camera exposure used on this material.
  134932. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134933. * This corresponds to a photographic exposure.
  134934. */
  134935. get cameraExposure(): float;
  134936. /**
  134937. * The camera exposure used on this material.
  134938. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134939. * This corresponds to a photographic exposure.
  134940. */
  134941. set cameraExposure(value: float);
  134942. /**
  134943. * Gets The camera contrast used on this material.
  134944. */
  134945. get cameraContrast(): float;
  134946. /**
  134947. * Sets The camera contrast used on this material.
  134948. */
  134949. set cameraContrast(value: float);
  134950. /**
  134951. * Gets the Color Grading 2D Lookup Texture.
  134952. */
  134953. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134954. /**
  134955. * Sets the Color Grading 2D Lookup Texture.
  134956. */
  134957. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134958. /**
  134959. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134960. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134961. * 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;
  134962. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134963. */
  134964. get cameraColorCurves(): Nullable<ColorCurves>;
  134965. /**
  134966. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134967. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134968. * 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;
  134969. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134970. */
  134971. set cameraColorCurves(value: Nullable<ColorCurves>);
  134972. /**
  134973. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  134974. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  134975. */
  134976. switchToBGR: boolean;
  134977. private _renderTargets;
  134978. private _reflectionControls;
  134979. private _white;
  134980. private _primaryShadowColor;
  134981. private _primaryHighlightColor;
  134982. /**
  134983. * Instantiates a Background Material in the given scene
  134984. * @param name The friendly name of the material
  134985. * @param scene The scene to add the material to
  134986. */
  134987. constructor(name: string, scene: Scene);
  134988. /**
  134989. * Gets a boolean indicating that current material needs to register RTT
  134990. */
  134991. get hasRenderTargetTextures(): boolean;
  134992. /**
  134993. * The entire material has been created in order to prevent overdraw.
  134994. * @returns false
  134995. */
  134996. needAlphaTesting(): boolean;
  134997. /**
  134998. * The entire material has been created in order to prevent overdraw.
  134999. * @returns true if blending is enable
  135000. */
  135001. needAlphaBlending(): boolean;
  135002. /**
  135003. * Checks wether the material is ready to be rendered for a given mesh.
  135004. * @param mesh The mesh to render
  135005. * @param subMesh The submesh to check against
  135006. * @param useInstances Specify wether or not the material is used with instances
  135007. * @returns true if all the dependencies are ready (Textures, Effects...)
  135008. */
  135009. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135010. /**
  135011. * Compute the primary color according to the chosen perceptual color.
  135012. */
  135013. private _computePrimaryColorFromPerceptualColor;
  135014. /**
  135015. * Compute the highlights and shadow colors according to their chosen levels.
  135016. */
  135017. private _computePrimaryColors;
  135018. /**
  135019. * Build the uniform buffer used in the material.
  135020. */
  135021. buildUniformLayout(): void;
  135022. /**
  135023. * Unbind the material.
  135024. */
  135025. unbind(): void;
  135026. /**
  135027. * Bind only the world matrix to the material.
  135028. * @param world The world matrix to bind.
  135029. */
  135030. bindOnlyWorldMatrix(world: Matrix): void;
  135031. /**
  135032. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  135033. * @param world The world matrix to bind.
  135034. * @param subMesh The submesh to bind for.
  135035. */
  135036. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135037. /**
  135038. * Checks to see if a texture is used in the material.
  135039. * @param texture - Base texture to use.
  135040. * @returns - Boolean specifying if a texture is used in the material.
  135041. */
  135042. hasTexture(texture: BaseTexture): boolean;
  135043. /**
  135044. * Dispose the material.
  135045. * @param forceDisposeEffect Force disposal of the associated effect.
  135046. * @param forceDisposeTextures Force disposal of the associated textures.
  135047. */
  135048. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135049. /**
  135050. * Clones the material.
  135051. * @param name The cloned name.
  135052. * @returns The cloned material.
  135053. */
  135054. clone(name: string): BackgroundMaterial;
  135055. /**
  135056. * Serializes the current material to its JSON representation.
  135057. * @returns The JSON representation.
  135058. */
  135059. serialize(): any;
  135060. /**
  135061. * Gets the class name of the material
  135062. * @returns "BackgroundMaterial"
  135063. */
  135064. getClassName(): string;
  135065. /**
  135066. * Parse a JSON input to create back a background material.
  135067. * @param source The JSON data to parse
  135068. * @param scene The scene to create the parsed material in
  135069. * @param rootUrl The root url of the assets the material depends upon
  135070. * @returns the instantiated BackgroundMaterial.
  135071. */
  135072. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  135073. }
  135074. }
  135075. declare module BABYLON {
  135076. /**
  135077. * Represents the different options available during the creation of
  135078. * a Environment helper.
  135079. *
  135080. * This can control the default ground, skybox and image processing setup of your scene.
  135081. */
  135082. export interface IEnvironmentHelperOptions {
  135083. /**
  135084. * Specifies whether or not to create a ground.
  135085. * True by default.
  135086. */
  135087. createGround: boolean;
  135088. /**
  135089. * Specifies the ground size.
  135090. * 15 by default.
  135091. */
  135092. groundSize: number;
  135093. /**
  135094. * The texture used on the ground for the main color.
  135095. * Comes from the BabylonJS CDN by default.
  135096. *
  135097. * Remarks: Can be either a texture or a url.
  135098. */
  135099. groundTexture: string | BaseTexture;
  135100. /**
  135101. * The color mixed in the ground texture by default.
  135102. * BabylonJS clearColor by default.
  135103. */
  135104. groundColor: Color3;
  135105. /**
  135106. * Specifies the ground opacity.
  135107. * 1 by default.
  135108. */
  135109. groundOpacity: number;
  135110. /**
  135111. * Enables the ground to receive shadows.
  135112. * True by default.
  135113. */
  135114. enableGroundShadow: boolean;
  135115. /**
  135116. * Helps preventing the shadow to be fully black on the ground.
  135117. * 0.5 by default.
  135118. */
  135119. groundShadowLevel: number;
  135120. /**
  135121. * Creates a mirror texture attach to the ground.
  135122. * false by default.
  135123. */
  135124. enableGroundMirror: boolean;
  135125. /**
  135126. * Specifies the ground mirror size ratio.
  135127. * 0.3 by default as the default kernel is 64.
  135128. */
  135129. groundMirrorSizeRatio: number;
  135130. /**
  135131. * Specifies the ground mirror blur kernel size.
  135132. * 64 by default.
  135133. */
  135134. groundMirrorBlurKernel: number;
  135135. /**
  135136. * Specifies the ground mirror visibility amount.
  135137. * 1 by default
  135138. */
  135139. groundMirrorAmount: number;
  135140. /**
  135141. * Specifies the ground mirror reflectance weight.
  135142. * This uses the standard weight of the background material to setup the fresnel effect
  135143. * of the mirror.
  135144. * 1 by default.
  135145. */
  135146. groundMirrorFresnelWeight: number;
  135147. /**
  135148. * Specifies the ground mirror Falloff distance.
  135149. * This can helps reducing the size of the reflection.
  135150. * 0 by Default.
  135151. */
  135152. groundMirrorFallOffDistance: number;
  135153. /**
  135154. * Specifies the ground mirror texture type.
  135155. * Unsigned Int by Default.
  135156. */
  135157. groundMirrorTextureType: number;
  135158. /**
  135159. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  135160. * the shown objects.
  135161. */
  135162. groundYBias: number;
  135163. /**
  135164. * Specifies whether or not to create a skybox.
  135165. * True by default.
  135166. */
  135167. createSkybox: boolean;
  135168. /**
  135169. * Specifies the skybox size.
  135170. * 20 by default.
  135171. */
  135172. skyboxSize: number;
  135173. /**
  135174. * The texture used on the skybox for the main color.
  135175. * Comes from the BabylonJS CDN by default.
  135176. *
  135177. * Remarks: Can be either a texture or a url.
  135178. */
  135179. skyboxTexture: string | BaseTexture;
  135180. /**
  135181. * The color mixed in the skybox texture by default.
  135182. * BabylonJS clearColor by default.
  135183. */
  135184. skyboxColor: Color3;
  135185. /**
  135186. * The background rotation around the Y axis of the scene.
  135187. * This helps aligning the key lights of your scene with the background.
  135188. * 0 by default.
  135189. */
  135190. backgroundYRotation: number;
  135191. /**
  135192. * Compute automatically the size of the elements to best fit with the scene.
  135193. */
  135194. sizeAuto: boolean;
  135195. /**
  135196. * Default position of the rootMesh if autoSize is not true.
  135197. */
  135198. rootPosition: Vector3;
  135199. /**
  135200. * Sets up the image processing in the scene.
  135201. * true by default.
  135202. */
  135203. setupImageProcessing: boolean;
  135204. /**
  135205. * The texture used as your environment texture in the scene.
  135206. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  135207. *
  135208. * Remarks: Can be either a texture or a url.
  135209. */
  135210. environmentTexture: string | BaseTexture;
  135211. /**
  135212. * The value of the exposure to apply to the scene.
  135213. * 0.6 by default if setupImageProcessing is true.
  135214. */
  135215. cameraExposure: number;
  135216. /**
  135217. * The value of the contrast to apply to the scene.
  135218. * 1.6 by default if setupImageProcessing is true.
  135219. */
  135220. cameraContrast: number;
  135221. /**
  135222. * Specifies whether or not tonemapping should be enabled in the scene.
  135223. * true by default if setupImageProcessing is true.
  135224. */
  135225. toneMappingEnabled: boolean;
  135226. }
  135227. /**
  135228. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  135229. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  135230. * It also helps with the default setup of your imageProcessing configuration.
  135231. */
  135232. export class EnvironmentHelper {
  135233. /**
  135234. * Default ground texture URL.
  135235. */
  135236. private static _groundTextureCDNUrl;
  135237. /**
  135238. * Default skybox texture URL.
  135239. */
  135240. private static _skyboxTextureCDNUrl;
  135241. /**
  135242. * Default environment texture URL.
  135243. */
  135244. private static _environmentTextureCDNUrl;
  135245. /**
  135246. * Creates the default options for the helper.
  135247. */
  135248. private static _getDefaultOptions;
  135249. private _rootMesh;
  135250. /**
  135251. * Gets the root mesh created by the helper.
  135252. */
  135253. get rootMesh(): Mesh;
  135254. private _skybox;
  135255. /**
  135256. * Gets the skybox created by the helper.
  135257. */
  135258. get skybox(): Nullable<Mesh>;
  135259. private _skyboxTexture;
  135260. /**
  135261. * Gets the skybox texture created by the helper.
  135262. */
  135263. get skyboxTexture(): Nullable<BaseTexture>;
  135264. private _skyboxMaterial;
  135265. /**
  135266. * Gets the skybox material created by the helper.
  135267. */
  135268. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  135269. private _ground;
  135270. /**
  135271. * Gets the ground mesh created by the helper.
  135272. */
  135273. get ground(): Nullable<Mesh>;
  135274. private _groundTexture;
  135275. /**
  135276. * Gets the ground texture created by the helper.
  135277. */
  135278. get groundTexture(): Nullable<BaseTexture>;
  135279. private _groundMirror;
  135280. /**
  135281. * Gets the ground mirror created by the helper.
  135282. */
  135283. get groundMirror(): Nullable<MirrorTexture>;
  135284. /**
  135285. * Gets the ground mirror render list to helps pushing the meshes
  135286. * you wish in the ground reflection.
  135287. */
  135288. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  135289. private _groundMaterial;
  135290. /**
  135291. * Gets the ground material created by the helper.
  135292. */
  135293. get groundMaterial(): Nullable<BackgroundMaterial>;
  135294. /**
  135295. * Stores the creation options.
  135296. */
  135297. private readonly _scene;
  135298. private _options;
  135299. /**
  135300. * This observable will be notified with any error during the creation of the environment,
  135301. * mainly texture creation errors.
  135302. */
  135303. onErrorObservable: Observable<{
  135304. message?: string;
  135305. exception?: any;
  135306. }>;
  135307. /**
  135308. * constructor
  135309. * @param options Defines the options we want to customize the helper
  135310. * @param scene The scene to add the material to
  135311. */
  135312. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  135313. /**
  135314. * Updates the background according to the new options
  135315. * @param options
  135316. */
  135317. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  135318. /**
  135319. * Sets the primary color of all the available elements.
  135320. * @param color the main color to affect to the ground and the background
  135321. */
  135322. setMainColor(color: Color3): void;
  135323. /**
  135324. * Setup the image processing according to the specified options.
  135325. */
  135326. private _setupImageProcessing;
  135327. /**
  135328. * Setup the environment texture according to the specified options.
  135329. */
  135330. private _setupEnvironmentTexture;
  135331. /**
  135332. * Setup the background according to the specified options.
  135333. */
  135334. private _setupBackground;
  135335. /**
  135336. * Get the scene sizes according to the setup.
  135337. */
  135338. private _getSceneSize;
  135339. /**
  135340. * Setup the ground according to the specified options.
  135341. */
  135342. private _setupGround;
  135343. /**
  135344. * Setup the ground material according to the specified options.
  135345. */
  135346. private _setupGroundMaterial;
  135347. /**
  135348. * Setup the ground diffuse texture according to the specified options.
  135349. */
  135350. private _setupGroundDiffuseTexture;
  135351. /**
  135352. * Setup the ground mirror texture according to the specified options.
  135353. */
  135354. private _setupGroundMirrorTexture;
  135355. /**
  135356. * Setup the ground to receive the mirror texture.
  135357. */
  135358. private _setupMirrorInGroundMaterial;
  135359. /**
  135360. * Setup the skybox according to the specified options.
  135361. */
  135362. private _setupSkybox;
  135363. /**
  135364. * Setup the skybox material according to the specified options.
  135365. */
  135366. private _setupSkyboxMaterial;
  135367. /**
  135368. * Setup the skybox reflection texture according to the specified options.
  135369. */
  135370. private _setupSkyboxReflectionTexture;
  135371. private _errorHandler;
  135372. /**
  135373. * Dispose all the elements created by the Helper.
  135374. */
  135375. dispose(): void;
  135376. }
  135377. }
  135378. declare module BABYLON {
  135379. /**
  135380. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  135381. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  135382. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135383. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135384. */
  135385. export abstract class TextureDome<T extends Texture> extends TransformNode {
  135386. protected onError: Nullable<(message?: string, exception?: any) => void>;
  135387. /**
  135388. * Define the source as a Monoscopic panoramic 360/180.
  135389. */
  135390. static readonly MODE_MONOSCOPIC: number;
  135391. /**
  135392. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  135393. */
  135394. static readonly MODE_TOPBOTTOM: number;
  135395. /**
  135396. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  135397. */
  135398. static readonly MODE_SIDEBYSIDE: number;
  135399. private _halfDome;
  135400. protected _useDirectMapping: boolean;
  135401. /**
  135402. * The texture being displayed on the sphere
  135403. */
  135404. protected _texture: T;
  135405. /**
  135406. * Gets the texture being displayed on the sphere
  135407. */
  135408. get texture(): T;
  135409. /**
  135410. * Sets the texture being displayed on the sphere
  135411. */
  135412. set texture(newTexture: T);
  135413. /**
  135414. * The skybox material
  135415. */
  135416. protected _material: BackgroundMaterial;
  135417. /**
  135418. * The surface used for the dome
  135419. */
  135420. protected _mesh: Mesh;
  135421. /**
  135422. * Gets the mesh used for the dome.
  135423. */
  135424. get mesh(): Mesh;
  135425. /**
  135426. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  135427. */
  135428. private _halfDomeMask;
  135429. /**
  135430. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135431. * Also see the options.resolution property.
  135432. */
  135433. get fovMultiplier(): number;
  135434. set fovMultiplier(value: number);
  135435. protected _textureMode: number;
  135436. /**
  135437. * Gets or set the current texture mode for the texture. It can be:
  135438. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135439. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135440. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135441. */
  135442. get textureMode(): number;
  135443. /**
  135444. * Sets the current texture mode for the texture. It can be:
  135445. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135446. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135447. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135448. */
  135449. set textureMode(value: number);
  135450. /**
  135451. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  135452. */
  135453. get halfDome(): boolean;
  135454. /**
  135455. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135456. */
  135457. set halfDome(enabled: boolean);
  135458. /**
  135459. * Oberserver used in Stereoscopic VR Mode.
  135460. */
  135461. private _onBeforeCameraRenderObserver;
  135462. /**
  135463. * Observable raised when an error occured while loading the 360 image
  135464. */
  135465. onLoadErrorObservable: Observable<string>;
  135466. /**
  135467. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  135468. * @param name Element's name, child elements will append suffixes for their own names.
  135469. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  135470. * @param options An object containing optional or exposed sub element properties
  135471. */
  135472. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  135473. resolution?: number;
  135474. clickToPlay?: boolean;
  135475. autoPlay?: boolean;
  135476. loop?: boolean;
  135477. size?: number;
  135478. poster?: string;
  135479. faceForward?: boolean;
  135480. useDirectMapping?: boolean;
  135481. halfDomeMode?: boolean;
  135482. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  135483. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  135484. protected _changeTextureMode(value: number): void;
  135485. /**
  135486. * Releases resources associated with this node.
  135487. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135488. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135489. */
  135490. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135491. }
  135492. }
  135493. declare module BABYLON {
  135494. /**
  135495. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  135496. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  135497. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135498. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135499. */
  135500. export class PhotoDome extends TextureDome<Texture> {
  135501. /**
  135502. * Define the image as a Monoscopic panoramic 360 image.
  135503. */
  135504. static readonly MODE_MONOSCOPIC: number;
  135505. /**
  135506. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  135507. */
  135508. static readonly MODE_TOPBOTTOM: number;
  135509. /**
  135510. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  135511. */
  135512. static readonly MODE_SIDEBYSIDE: number;
  135513. /**
  135514. * Gets or sets the texture being displayed on the sphere
  135515. */
  135516. get photoTexture(): Texture;
  135517. /**
  135518. * sets the texture being displayed on the sphere
  135519. */
  135520. set photoTexture(value: Texture);
  135521. /**
  135522. * Gets the current video mode for the video. It can be:
  135523. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135524. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135525. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135526. */
  135527. get imageMode(): number;
  135528. /**
  135529. * Sets the current video mode for the video. It can be:
  135530. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135531. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135532. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135533. */
  135534. set imageMode(value: number);
  135535. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  135536. }
  135537. }
  135538. declare module BABYLON {
  135539. /**
  135540. * Class used to host RGBD texture specific utilities
  135541. */
  135542. export class RGBDTextureTools {
  135543. /**
  135544. * Expand the RGBD Texture from RGBD to Half Float if possible.
  135545. * @param texture the texture to expand.
  135546. */
  135547. static ExpandRGBDTexture(texture: Texture): void;
  135548. }
  135549. }
  135550. declare module BABYLON {
  135551. /**
  135552. * Class used to host texture specific utilities
  135553. */
  135554. export class BRDFTextureTools {
  135555. /**
  135556. * Prevents texture cache collision
  135557. */
  135558. private static _instanceNumber;
  135559. /**
  135560. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  135561. * @param scene defines the hosting scene
  135562. * @returns the environment BRDF texture
  135563. */
  135564. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  135565. private static _environmentBRDFBase64Texture;
  135566. }
  135567. }
  135568. declare module BABYLON {
  135569. /**
  135570. * @hidden
  135571. */
  135572. export interface IMaterialClearCoatDefines {
  135573. CLEARCOAT: boolean;
  135574. CLEARCOAT_DEFAULTIOR: boolean;
  135575. CLEARCOAT_TEXTURE: boolean;
  135576. CLEARCOAT_TEXTUREDIRECTUV: number;
  135577. CLEARCOAT_BUMP: boolean;
  135578. CLEARCOAT_BUMPDIRECTUV: number;
  135579. CLEARCOAT_TINT: boolean;
  135580. CLEARCOAT_TINT_TEXTURE: boolean;
  135581. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135582. /** @hidden */
  135583. _areTexturesDirty: boolean;
  135584. }
  135585. /**
  135586. * Define the code related to the clear coat parameters of the pbr material.
  135587. */
  135588. export class PBRClearCoatConfiguration {
  135589. /**
  135590. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135591. * The default fits with a polyurethane material.
  135592. */
  135593. private static readonly _DefaultIndexOfRefraction;
  135594. private _isEnabled;
  135595. /**
  135596. * Defines if the clear coat is enabled in the material.
  135597. */
  135598. isEnabled: boolean;
  135599. /**
  135600. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  135601. */
  135602. intensity: number;
  135603. /**
  135604. * Defines the clear coat layer roughness.
  135605. */
  135606. roughness: number;
  135607. private _indexOfRefraction;
  135608. /**
  135609. * Defines the index of refraction of the clear coat.
  135610. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135611. * The default fits with a polyurethane material.
  135612. * Changing the default value is more performance intensive.
  135613. */
  135614. indexOfRefraction: number;
  135615. private _texture;
  135616. /**
  135617. * Stores the clear coat values in a texture.
  135618. */
  135619. texture: Nullable<BaseTexture>;
  135620. private _bumpTexture;
  135621. /**
  135622. * Define the clear coat specific bump texture.
  135623. */
  135624. bumpTexture: Nullable<BaseTexture>;
  135625. private _isTintEnabled;
  135626. /**
  135627. * Defines if the clear coat tint is enabled in the material.
  135628. */
  135629. isTintEnabled: boolean;
  135630. /**
  135631. * Defines the clear coat tint of the material.
  135632. * This is only use if tint is enabled
  135633. */
  135634. tintColor: Color3;
  135635. /**
  135636. * Defines the distance at which the tint color should be found in the
  135637. * clear coat media.
  135638. * This is only use if tint is enabled
  135639. */
  135640. tintColorAtDistance: number;
  135641. /**
  135642. * Defines the clear coat layer thickness.
  135643. * This is only use if tint is enabled
  135644. */
  135645. tintThickness: number;
  135646. private _tintTexture;
  135647. /**
  135648. * Stores the clear tint values in a texture.
  135649. * rgb is tint
  135650. * a is a thickness factor
  135651. */
  135652. tintTexture: Nullable<BaseTexture>;
  135653. /** @hidden */
  135654. private _internalMarkAllSubMeshesAsTexturesDirty;
  135655. /** @hidden */
  135656. _markAllSubMeshesAsTexturesDirty(): void;
  135657. /**
  135658. * Instantiate a new istance of clear coat configuration.
  135659. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135660. */
  135661. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135662. /**
  135663. * Gets wehter the submesh is ready to be used or not.
  135664. * @param defines the list of "defines" to update.
  135665. * @param scene defines the scene the material belongs to.
  135666. * @param engine defines the engine the material belongs to.
  135667. * @param disableBumpMap defines wether the material disables bump or not.
  135668. * @returns - boolean indicating that the submesh is ready or not.
  135669. */
  135670. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  135671. /**
  135672. * Checks to see if a texture is used in the material.
  135673. * @param defines the list of "defines" to update.
  135674. * @param scene defines the scene to the material belongs to.
  135675. */
  135676. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  135677. /**
  135678. * Binds the material data.
  135679. * @param uniformBuffer defines the Uniform buffer to fill in.
  135680. * @param scene defines the scene the material belongs to.
  135681. * @param engine defines the engine the material belongs to.
  135682. * @param disableBumpMap defines wether the material disables bump or not.
  135683. * @param isFrozen defines wether the material is frozen or not.
  135684. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135685. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135686. */
  135687. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  135688. /**
  135689. * Checks to see if a texture is used in the material.
  135690. * @param texture - Base texture to use.
  135691. * @returns - Boolean specifying if a texture is used in the material.
  135692. */
  135693. hasTexture(texture: BaseTexture): boolean;
  135694. /**
  135695. * Returns an array of the actively used textures.
  135696. * @param activeTextures Array of BaseTextures
  135697. */
  135698. getActiveTextures(activeTextures: BaseTexture[]): void;
  135699. /**
  135700. * Returns the animatable textures.
  135701. * @param animatables Array of animatable textures.
  135702. */
  135703. getAnimatables(animatables: IAnimatable[]): void;
  135704. /**
  135705. * Disposes the resources of the material.
  135706. * @param forceDisposeTextures - Forces the disposal of all textures.
  135707. */
  135708. dispose(forceDisposeTextures?: boolean): void;
  135709. /**
  135710. * Get the current class name of the texture useful for serialization or dynamic coding.
  135711. * @returns "PBRClearCoatConfiguration"
  135712. */
  135713. getClassName(): string;
  135714. /**
  135715. * Add fallbacks to the effect fallbacks list.
  135716. * @param defines defines the Base texture to use.
  135717. * @param fallbacks defines the current fallback list.
  135718. * @param currentRank defines the current fallback rank.
  135719. * @returns the new fallback rank.
  135720. */
  135721. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135722. /**
  135723. * Add the required uniforms to the current list.
  135724. * @param uniforms defines the current uniform list.
  135725. */
  135726. static AddUniforms(uniforms: string[]): void;
  135727. /**
  135728. * Add the required samplers to the current list.
  135729. * @param samplers defines the current sampler list.
  135730. */
  135731. static AddSamplers(samplers: string[]): void;
  135732. /**
  135733. * Add the required uniforms to the current buffer.
  135734. * @param uniformBuffer defines the current uniform buffer.
  135735. */
  135736. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135737. /**
  135738. * Makes a duplicate of the current configuration into another one.
  135739. * @param clearCoatConfiguration define the config where to copy the info
  135740. */
  135741. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  135742. /**
  135743. * Serializes this clear coat configuration.
  135744. * @returns - An object with the serialized config.
  135745. */
  135746. serialize(): any;
  135747. /**
  135748. * Parses a anisotropy Configuration from a serialized object.
  135749. * @param source - Serialized object.
  135750. * @param scene Defines the scene we are parsing for
  135751. * @param rootUrl Defines the rootUrl to load from
  135752. */
  135753. parse(source: any, scene: Scene, rootUrl: string): void;
  135754. }
  135755. }
  135756. declare module BABYLON {
  135757. /**
  135758. * @hidden
  135759. */
  135760. export interface IMaterialAnisotropicDefines {
  135761. ANISOTROPIC: boolean;
  135762. ANISOTROPIC_TEXTURE: boolean;
  135763. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135764. MAINUV1: boolean;
  135765. _areTexturesDirty: boolean;
  135766. _needUVs: boolean;
  135767. }
  135768. /**
  135769. * Define the code related to the anisotropic parameters of the pbr material.
  135770. */
  135771. export class PBRAnisotropicConfiguration {
  135772. private _isEnabled;
  135773. /**
  135774. * Defines if the anisotropy is enabled in the material.
  135775. */
  135776. isEnabled: boolean;
  135777. /**
  135778. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  135779. */
  135780. intensity: number;
  135781. /**
  135782. * Defines if the effect is along the tangents, bitangents or in between.
  135783. * By default, the effect is "strectching" the highlights along the tangents.
  135784. */
  135785. direction: Vector2;
  135786. private _texture;
  135787. /**
  135788. * Stores the anisotropy values in a texture.
  135789. * rg is direction (like normal from -1 to 1)
  135790. * b is a intensity
  135791. */
  135792. texture: Nullable<BaseTexture>;
  135793. /** @hidden */
  135794. private _internalMarkAllSubMeshesAsTexturesDirty;
  135795. /** @hidden */
  135796. _markAllSubMeshesAsTexturesDirty(): void;
  135797. /**
  135798. * Instantiate a new istance of anisotropy configuration.
  135799. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135800. */
  135801. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135802. /**
  135803. * Specifies that the submesh is ready to be used.
  135804. * @param defines the list of "defines" to update.
  135805. * @param scene defines the scene the material belongs to.
  135806. * @returns - boolean indicating that the submesh is ready or not.
  135807. */
  135808. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  135809. /**
  135810. * Checks to see if a texture is used in the material.
  135811. * @param defines the list of "defines" to update.
  135812. * @param mesh the mesh we are preparing the defines for.
  135813. * @param scene defines the scene the material belongs to.
  135814. */
  135815. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  135816. /**
  135817. * Binds the material data.
  135818. * @param uniformBuffer defines the Uniform buffer to fill in.
  135819. * @param scene defines the scene the material belongs to.
  135820. * @param isFrozen defines wether the material is frozen or not.
  135821. */
  135822. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135823. /**
  135824. * Checks to see if a texture is used in the material.
  135825. * @param texture - Base texture to use.
  135826. * @returns - Boolean specifying if a texture is used in the material.
  135827. */
  135828. hasTexture(texture: BaseTexture): boolean;
  135829. /**
  135830. * Returns an array of the actively used textures.
  135831. * @param activeTextures Array of BaseTextures
  135832. */
  135833. getActiveTextures(activeTextures: BaseTexture[]): void;
  135834. /**
  135835. * Returns the animatable textures.
  135836. * @param animatables Array of animatable textures.
  135837. */
  135838. getAnimatables(animatables: IAnimatable[]): void;
  135839. /**
  135840. * Disposes the resources of the material.
  135841. * @param forceDisposeTextures - Forces the disposal of all textures.
  135842. */
  135843. dispose(forceDisposeTextures?: boolean): void;
  135844. /**
  135845. * Get the current class name of the texture useful for serialization or dynamic coding.
  135846. * @returns "PBRAnisotropicConfiguration"
  135847. */
  135848. getClassName(): string;
  135849. /**
  135850. * Add fallbacks to the effect fallbacks list.
  135851. * @param defines defines the Base texture to use.
  135852. * @param fallbacks defines the current fallback list.
  135853. * @param currentRank defines the current fallback rank.
  135854. * @returns the new fallback rank.
  135855. */
  135856. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135857. /**
  135858. * Add the required uniforms to the current list.
  135859. * @param uniforms defines the current uniform list.
  135860. */
  135861. static AddUniforms(uniforms: string[]): void;
  135862. /**
  135863. * Add the required uniforms to the current buffer.
  135864. * @param uniformBuffer defines the current uniform buffer.
  135865. */
  135866. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135867. /**
  135868. * Add the required samplers to the current list.
  135869. * @param samplers defines the current sampler list.
  135870. */
  135871. static AddSamplers(samplers: string[]): void;
  135872. /**
  135873. * Makes a duplicate of the current configuration into another one.
  135874. * @param anisotropicConfiguration define the config where to copy the info
  135875. */
  135876. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  135877. /**
  135878. * Serializes this anisotropy configuration.
  135879. * @returns - An object with the serialized config.
  135880. */
  135881. serialize(): any;
  135882. /**
  135883. * Parses a anisotropy Configuration from a serialized object.
  135884. * @param source - Serialized object.
  135885. * @param scene Defines the scene we are parsing for
  135886. * @param rootUrl Defines the rootUrl to load from
  135887. */
  135888. parse(source: any, scene: Scene, rootUrl: string): void;
  135889. }
  135890. }
  135891. declare module BABYLON {
  135892. /**
  135893. * @hidden
  135894. */
  135895. export interface IMaterialBRDFDefines {
  135896. BRDF_V_HEIGHT_CORRELATED: boolean;
  135897. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135898. SPHERICAL_HARMONICS: boolean;
  135899. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135900. /** @hidden */
  135901. _areMiscDirty: boolean;
  135902. }
  135903. /**
  135904. * Define the code related to the BRDF parameters of the pbr material.
  135905. */
  135906. export class PBRBRDFConfiguration {
  135907. /**
  135908. * Default value used for the energy conservation.
  135909. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135910. */
  135911. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  135912. /**
  135913. * Default value used for the Smith Visibility Height Correlated mode.
  135914. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135915. */
  135916. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  135917. /**
  135918. * Default value used for the IBL diffuse part.
  135919. * This can help switching back to the polynomials mode globally which is a tiny bit
  135920. * less GPU intensive at the drawback of a lower quality.
  135921. */
  135922. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  135923. /**
  135924. * Default value used for activating energy conservation for the specular workflow.
  135925. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135926. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135927. */
  135928. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  135929. private _useEnergyConservation;
  135930. /**
  135931. * Defines if the material uses energy conservation.
  135932. */
  135933. useEnergyConservation: boolean;
  135934. private _useSmithVisibilityHeightCorrelated;
  135935. /**
  135936. * LEGACY Mode set to false
  135937. * Defines if the material uses height smith correlated visibility term.
  135938. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  135939. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  135940. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  135941. * Not relying on height correlated will also disable energy conservation.
  135942. */
  135943. useSmithVisibilityHeightCorrelated: boolean;
  135944. private _useSphericalHarmonics;
  135945. /**
  135946. * LEGACY Mode set to false
  135947. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  135948. * diffuse part of the IBL.
  135949. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  135950. * to the ground truth.
  135951. */
  135952. useSphericalHarmonics: boolean;
  135953. private _useSpecularGlossinessInputEnergyConservation;
  135954. /**
  135955. * Defines if the material uses energy conservation, when the specular workflow is active.
  135956. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135957. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135958. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  135959. */
  135960. useSpecularGlossinessInputEnergyConservation: boolean;
  135961. /** @hidden */
  135962. private _internalMarkAllSubMeshesAsMiscDirty;
  135963. /** @hidden */
  135964. _markAllSubMeshesAsMiscDirty(): void;
  135965. /**
  135966. * Instantiate a new istance of clear coat configuration.
  135967. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  135968. */
  135969. constructor(markAllSubMeshesAsMiscDirty: () => void);
  135970. /**
  135971. * Checks to see if a texture is used in the material.
  135972. * @param defines the list of "defines" to update.
  135973. */
  135974. prepareDefines(defines: IMaterialBRDFDefines): void;
  135975. /**
  135976. * Get the current class name of the texture useful for serialization or dynamic coding.
  135977. * @returns "PBRClearCoatConfiguration"
  135978. */
  135979. getClassName(): string;
  135980. /**
  135981. * Makes a duplicate of the current configuration into another one.
  135982. * @param brdfConfiguration define the config where to copy the info
  135983. */
  135984. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  135985. /**
  135986. * Serializes this BRDF configuration.
  135987. * @returns - An object with the serialized config.
  135988. */
  135989. serialize(): any;
  135990. /**
  135991. * Parses a anisotropy Configuration from a serialized object.
  135992. * @param source - Serialized object.
  135993. * @param scene Defines the scene we are parsing for
  135994. * @param rootUrl Defines the rootUrl to load from
  135995. */
  135996. parse(source: any, scene: Scene, rootUrl: string): void;
  135997. }
  135998. }
  135999. declare module BABYLON {
  136000. /**
  136001. * @hidden
  136002. */
  136003. export interface IMaterialSheenDefines {
  136004. SHEEN: boolean;
  136005. SHEEN_TEXTURE: boolean;
  136006. SHEEN_TEXTUREDIRECTUV: number;
  136007. SHEEN_LINKWITHALBEDO: boolean;
  136008. SHEEN_ROUGHNESS: boolean;
  136009. SHEEN_ALBEDOSCALING: boolean;
  136010. /** @hidden */
  136011. _areTexturesDirty: boolean;
  136012. }
  136013. /**
  136014. * Define the code related to the Sheen parameters of the pbr material.
  136015. */
  136016. export class PBRSheenConfiguration {
  136017. private _isEnabled;
  136018. /**
  136019. * Defines if the material uses sheen.
  136020. */
  136021. isEnabled: boolean;
  136022. private _linkSheenWithAlbedo;
  136023. /**
  136024. * Defines if the sheen is linked to the sheen color.
  136025. */
  136026. linkSheenWithAlbedo: boolean;
  136027. /**
  136028. * Defines the sheen intensity.
  136029. */
  136030. intensity: number;
  136031. /**
  136032. * Defines the sheen color.
  136033. */
  136034. color: Color3;
  136035. private _texture;
  136036. /**
  136037. * Stores the sheen tint values in a texture.
  136038. * rgb is tint
  136039. * a is a intensity or roughness if roughness has been defined
  136040. */
  136041. texture: Nullable<BaseTexture>;
  136042. private _roughness;
  136043. /**
  136044. * Defines the sheen roughness.
  136045. * It is not taken into account if linkSheenWithAlbedo is true.
  136046. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  136047. */
  136048. roughness: Nullable<number>;
  136049. private _albedoScaling;
  136050. /**
  136051. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  136052. * It allows the strength of the sheen effect to not depend on the base color of the material,
  136053. * making it easier to setup and tweak the effect
  136054. */
  136055. albedoScaling: boolean;
  136056. /** @hidden */
  136057. private _internalMarkAllSubMeshesAsTexturesDirty;
  136058. /** @hidden */
  136059. _markAllSubMeshesAsTexturesDirty(): void;
  136060. /**
  136061. * Instantiate a new istance of clear coat configuration.
  136062. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136063. */
  136064. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136065. /**
  136066. * Specifies that the submesh is ready to be used.
  136067. * @param defines the list of "defines" to update.
  136068. * @param scene defines the scene the material belongs to.
  136069. * @returns - boolean indicating that the submesh is ready or not.
  136070. */
  136071. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  136072. /**
  136073. * Checks to see if a texture is used in the material.
  136074. * @param defines the list of "defines" to update.
  136075. * @param scene defines the scene the material belongs to.
  136076. */
  136077. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  136078. /**
  136079. * Binds the material data.
  136080. * @param uniformBuffer defines the Uniform buffer to fill in.
  136081. * @param scene defines the scene the material belongs to.
  136082. * @param isFrozen defines wether the material is frozen or not.
  136083. */
  136084. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  136085. /**
  136086. * Checks to see if a texture is used in the material.
  136087. * @param texture - Base texture to use.
  136088. * @returns - Boolean specifying if a texture is used in the material.
  136089. */
  136090. hasTexture(texture: BaseTexture): boolean;
  136091. /**
  136092. * Returns an array of the actively used textures.
  136093. * @param activeTextures Array of BaseTextures
  136094. */
  136095. getActiveTextures(activeTextures: BaseTexture[]): void;
  136096. /**
  136097. * Returns the animatable textures.
  136098. * @param animatables Array of animatable textures.
  136099. */
  136100. getAnimatables(animatables: IAnimatable[]): void;
  136101. /**
  136102. * Disposes the resources of the material.
  136103. * @param forceDisposeTextures - Forces the disposal of all textures.
  136104. */
  136105. dispose(forceDisposeTextures?: boolean): void;
  136106. /**
  136107. * Get the current class name of the texture useful for serialization or dynamic coding.
  136108. * @returns "PBRSheenConfiguration"
  136109. */
  136110. getClassName(): string;
  136111. /**
  136112. * Add fallbacks to the effect fallbacks list.
  136113. * @param defines defines the Base texture to use.
  136114. * @param fallbacks defines the current fallback list.
  136115. * @param currentRank defines the current fallback rank.
  136116. * @returns the new fallback rank.
  136117. */
  136118. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136119. /**
  136120. * Add the required uniforms to the current list.
  136121. * @param uniforms defines the current uniform list.
  136122. */
  136123. static AddUniforms(uniforms: string[]): void;
  136124. /**
  136125. * Add the required uniforms to the current buffer.
  136126. * @param uniformBuffer defines the current uniform buffer.
  136127. */
  136128. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136129. /**
  136130. * Add the required samplers to the current list.
  136131. * @param samplers defines the current sampler list.
  136132. */
  136133. static AddSamplers(samplers: string[]): void;
  136134. /**
  136135. * Makes a duplicate of the current configuration into another one.
  136136. * @param sheenConfiguration define the config where to copy the info
  136137. */
  136138. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  136139. /**
  136140. * Serializes this BRDF configuration.
  136141. * @returns - An object with the serialized config.
  136142. */
  136143. serialize(): any;
  136144. /**
  136145. * Parses a anisotropy Configuration from a serialized object.
  136146. * @param source - Serialized object.
  136147. * @param scene Defines the scene we are parsing for
  136148. * @param rootUrl Defines the rootUrl to load from
  136149. */
  136150. parse(source: any, scene: Scene, rootUrl: string): void;
  136151. }
  136152. }
  136153. declare module BABYLON {
  136154. /**
  136155. * @hidden
  136156. */
  136157. export interface IMaterialSubSurfaceDefines {
  136158. SUBSURFACE: boolean;
  136159. SS_REFRACTION: boolean;
  136160. SS_TRANSLUCENCY: boolean;
  136161. SS_SCATTERING: boolean;
  136162. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136163. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136164. SS_REFRACTIONMAP_3D: boolean;
  136165. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136166. SS_LODINREFRACTIONALPHA: boolean;
  136167. SS_GAMMAREFRACTION: boolean;
  136168. SS_RGBDREFRACTION: boolean;
  136169. SS_LINEARSPECULARREFRACTION: boolean;
  136170. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136171. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136172. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136173. /** @hidden */
  136174. _areTexturesDirty: boolean;
  136175. }
  136176. /**
  136177. * Define the code related to the sub surface parameters of the pbr material.
  136178. */
  136179. export class PBRSubSurfaceConfiguration {
  136180. private _isRefractionEnabled;
  136181. /**
  136182. * Defines if the refraction is enabled in the material.
  136183. */
  136184. isRefractionEnabled: boolean;
  136185. private _isTranslucencyEnabled;
  136186. /**
  136187. * Defines if the translucency is enabled in the material.
  136188. */
  136189. isTranslucencyEnabled: boolean;
  136190. private _isScatteringEnabled;
  136191. /**
  136192. * Defines if the sub surface scattering is enabled in the material.
  136193. */
  136194. isScatteringEnabled: boolean;
  136195. private _scatteringDiffusionProfileIndex;
  136196. /**
  136197. * Diffusion profile for subsurface scattering.
  136198. * Useful for better scattering in the skins or foliages.
  136199. */
  136200. get scatteringDiffusionProfile(): Nullable<Color3>;
  136201. set scatteringDiffusionProfile(c: Nullable<Color3>);
  136202. /**
  136203. * Defines the refraction intensity of the material.
  136204. * The refraction when enabled replaces the Diffuse part of the material.
  136205. * The intensity helps transitionning between diffuse and refraction.
  136206. */
  136207. refractionIntensity: number;
  136208. /**
  136209. * Defines the translucency intensity of the material.
  136210. * When translucency has been enabled, this defines how much of the "translucency"
  136211. * is addded to the diffuse part of the material.
  136212. */
  136213. translucencyIntensity: number;
  136214. /**
  136215. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  136216. */
  136217. useAlbedoToTintRefraction: boolean;
  136218. private _thicknessTexture;
  136219. /**
  136220. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  136221. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  136222. * 0 would mean minimumThickness
  136223. * 1 would mean maximumThickness
  136224. * The other channels might be use as a mask to vary the different effects intensity.
  136225. */
  136226. thicknessTexture: Nullable<BaseTexture>;
  136227. private _refractionTexture;
  136228. /**
  136229. * Defines the texture to use for refraction.
  136230. */
  136231. refractionTexture: Nullable<BaseTexture>;
  136232. private _indexOfRefraction;
  136233. /**
  136234. * Index of refraction of the material base layer.
  136235. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136236. *
  136237. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136238. *
  136239. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136240. */
  136241. indexOfRefraction: number;
  136242. private _volumeIndexOfRefraction;
  136243. /**
  136244. * Index of refraction of the material's volume.
  136245. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136246. *
  136247. * This ONLY impacts refraction. If not provided or given a non-valid value,
  136248. * the volume will use the same IOR as the surface.
  136249. */
  136250. get volumeIndexOfRefraction(): number;
  136251. set volumeIndexOfRefraction(value: number);
  136252. private _invertRefractionY;
  136253. /**
  136254. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136255. */
  136256. invertRefractionY: boolean;
  136257. private _linkRefractionWithTransparency;
  136258. /**
  136259. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136260. * Materials half opaque for instance using refraction could benefit from this control.
  136261. */
  136262. linkRefractionWithTransparency: boolean;
  136263. /**
  136264. * Defines the minimum thickness stored in the thickness map.
  136265. * If no thickness map is defined, this value will be used to simulate thickness.
  136266. */
  136267. minimumThickness: number;
  136268. /**
  136269. * Defines the maximum thickness stored in the thickness map.
  136270. */
  136271. maximumThickness: number;
  136272. /**
  136273. * Defines the volume tint of the material.
  136274. * This is used for both translucency and scattering.
  136275. */
  136276. tintColor: Color3;
  136277. /**
  136278. * Defines the distance at which the tint color should be found in the media.
  136279. * This is used for refraction only.
  136280. */
  136281. tintColorAtDistance: number;
  136282. /**
  136283. * Defines how far each channel transmit through the media.
  136284. * It is defined as a color to simplify it selection.
  136285. */
  136286. diffusionDistance: Color3;
  136287. private _useMaskFromThicknessTexture;
  136288. /**
  136289. * Stores the intensity of the different subsurface effects in the thickness texture.
  136290. * * the green channel is the translucency intensity.
  136291. * * the blue channel is the scattering intensity.
  136292. * * the alpha channel is the refraction intensity.
  136293. */
  136294. useMaskFromThicknessTexture: boolean;
  136295. private _scene;
  136296. /** @hidden */
  136297. private _internalMarkAllSubMeshesAsTexturesDirty;
  136298. private _internalMarkScenePrePassDirty;
  136299. /** @hidden */
  136300. _markAllSubMeshesAsTexturesDirty(): void;
  136301. /** @hidden */
  136302. _markScenePrePassDirty(): void;
  136303. /**
  136304. * Instantiate a new istance of sub surface configuration.
  136305. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136306. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  136307. * @param scene The scene
  136308. */
  136309. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  136310. /**
  136311. * Gets wehter the submesh is ready to be used or not.
  136312. * @param defines the list of "defines" to update.
  136313. * @param scene defines the scene the material belongs to.
  136314. * @returns - boolean indicating that the submesh is ready or not.
  136315. */
  136316. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  136317. /**
  136318. * Checks to see if a texture is used in the material.
  136319. * @param defines the list of "defines" to update.
  136320. * @param scene defines the scene to the material belongs to.
  136321. */
  136322. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  136323. /**
  136324. * Binds the material data.
  136325. * @param uniformBuffer defines the Uniform buffer to fill in.
  136326. * @param scene defines the scene the material belongs to.
  136327. * @param engine defines the engine the material belongs to.
  136328. * @param isFrozen defines whether the material is frozen or not.
  136329. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  136330. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  136331. */
  136332. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  136333. /**
  136334. * Unbinds the material from the mesh.
  136335. * @param activeEffect defines the effect that should be unbound from.
  136336. * @returns true if unbound, otherwise false
  136337. */
  136338. unbind(activeEffect: Effect): boolean;
  136339. /**
  136340. * Returns the texture used for refraction or null if none is used.
  136341. * @param scene defines the scene the material belongs to.
  136342. * @returns - Refraction texture if present. If no refraction texture and refraction
  136343. * is linked with transparency, returns environment texture. Otherwise, returns null.
  136344. */
  136345. private _getRefractionTexture;
  136346. /**
  136347. * Returns true if alpha blending should be disabled.
  136348. */
  136349. get disableAlphaBlending(): boolean;
  136350. /**
  136351. * Fills the list of render target textures.
  136352. * @param renderTargets the list of render targets to update
  136353. */
  136354. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  136355. /**
  136356. * Checks to see if a texture is used in the material.
  136357. * @param texture - Base texture to use.
  136358. * @returns - Boolean specifying if a texture is used in the material.
  136359. */
  136360. hasTexture(texture: BaseTexture): boolean;
  136361. /**
  136362. * Gets a boolean indicating that current material needs to register RTT
  136363. * @returns true if this uses a render target otherwise false.
  136364. */
  136365. hasRenderTargetTextures(): boolean;
  136366. /**
  136367. * Returns an array of the actively used textures.
  136368. * @param activeTextures Array of BaseTextures
  136369. */
  136370. getActiveTextures(activeTextures: BaseTexture[]): void;
  136371. /**
  136372. * Returns the animatable textures.
  136373. * @param animatables Array of animatable textures.
  136374. */
  136375. getAnimatables(animatables: IAnimatable[]): void;
  136376. /**
  136377. * Disposes the resources of the material.
  136378. * @param forceDisposeTextures - Forces the disposal of all textures.
  136379. */
  136380. dispose(forceDisposeTextures?: boolean): void;
  136381. /**
  136382. * Get the current class name of the texture useful for serialization or dynamic coding.
  136383. * @returns "PBRSubSurfaceConfiguration"
  136384. */
  136385. getClassName(): string;
  136386. /**
  136387. * Add fallbacks to the effect fallbacks list.
  136388. * @param defines defines the Base texture to use.
  136389. * @param fallbacks defines the current fallback list.
  136390. * @param currentRank defines the current fallback rank.
  136391. * @returns the new fallback rank.
  136392. */
  136393. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136394. /**
  136395. * Add the required uniforms to the current list.
  136396. * @param uniforms defines the current uniform list.
  136397. */
  136398. static AddUniforms(uniforms: string[]): void;
  136399. /**
  136400. * Add the required samplers to the current list.
  136401. * @param samplers defines the current sampler list.
  136402. */
  136403. static AddSamplers(samplers: string[]): void;
  136404. /**
  136405. * Add the required uniforms to the current buffer.
  136406. * @param uniformBuffer defines the current uniform buffer.
  136407. */
  136408. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136409. /**
  136410. * Makes a duplicate of the current configuration into another one.
  136411. * @param configuration define the config where to copy the info
  136412. */
  136413. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  136414. /**
  136415. * Serializes this Sub Surface configuration.
  136416. * @returns - An object with the serialized config.
  136417. */
  136418. serialize(): any;
  136419. /**
  136420. * Parses a anisotropy Configuration from a serialized object.
  136421. * @param source - Serialized object.
  136422. * @param scene Defines the scene we are parsing for
  136423. * @param rootUrl Defines the rootUrl to load from
  136424. */
  136425. parse(source: any, scene: Scene, rootUrl: string): void;
  136426. }
  136427. }
  136428. declare module BABYLON {
  136429. /** @hidden */
  136430. export var pbrFragmentDeclaration: {
  136431. name: string;
  136432. shader: string;
  136433. };
  136434. }
  136435. declare module BABYLON {
  136436. /** @hidden */
  136437. export var pbrUboDeclaration: {
  136438. name: string;
  136439. shader: string;
  136440. };
  136441. }
  136442. declare module BABYLON {
  136443. /** @hidden */
  136444. export var pbrFragmentExtraDeclaration: {
  136445. name: string;
  136446. shader: string;
  136447. };
  136448. }
  136449. declare module BABYLON {
  136450. /** @hidden */
  136451. export var pbrFragmentSamplersDeclaration: {
  136452. name: string;
  136453. shader: string;
  136454. };
  136455. }
  136456. declare module BABYLON {
  136457. /** @hidden */
  136458. export var subSurfaceScatteringFunctions: {
  136459. name: string;
  136460. shader: string;
  136461. };
  136462. }
  136463. declare module BABYLON {
  136464. /** @hidden */
  136465. export var importanceSampling: {
  136466. name: string;
  136467. shader: string;
  136468. };
  136469. }
  136470. declare module BABYLON {
  136471. /** @hidden */
  136472. export var pbrHelperFunctions: {
  136473. name: string;
  136474. shader: string;
  136475. };
  136476. }
  136477. declare module BABYLON {
  136478. /** @hidden */
  136479. export var harmonicsFunctions: {
  136480. name: string;
  136481. shader: string;
  136482. };
  136483. }
  136484. declare module BABYLON {
  136485. /** @hidden */
  136486. export var pbrDirectLightingSetupFunctions: {
  136487. name: string;
  136488. shader: string;
  136489. };
  136490. }
  136491. declare module BABYLON {
  136492. /** @hidden */
  136493. export var pbrDirectLightingFalloffFunctions: {
  136494. name: string;
  136495. shader: string;
  136496. };
  136497. }
  136498. declare module BABYLON {
  136499. /** @hidden */
  136500. export var pbrBRDFFunctions: {
  136501. name: string;
  136502. shader: string;
  136503. };
  136504. }
  136505. declare module BABYLON {
  136506. /** @hidden */
  136507. export var hdrFilteringFunctions: {
  136508. name: string;
  136509. shader: string;
  136510. };
  136511. }
  136512. declare module BABYLON {
  136513. /** @hidden */
  136514. export var pbrDirectLightingFunctions: {
  136515. name: string;
  136516. shader: string;
  136517. };
  136518. }
  136519. declare module BABYLON {
  136520. /** @hidden */
  136521. export var pbrIBLFunctions: {
  136522. name: string;
  136523. shader: string;
  136524. };
  136525. }
  136526. declare module BABYLON {
  136527. /** @hidden */
  136528. export var pbrBlockAlbedoOpacity: {
  136529. name: string;
  136530. shader: string;
  136531. };
  136532. }
  136533. declare module BABYLON {
  136534. /** @hidden */
  136535. export var pbrBlockReflectivity: {
  136536. name: string;
  136537. shader: string;
  136538. };
  136539. }
  136540. declare module BABYLON {
  136541. /** @hidden */
  136542. export var pbrBlockAmbientOcclusion: {
  136543. name: string;
  136544. shader: string;
  136545. };
  136546. }
  136547. declare module BABYLON {
  136548. /** @hidden */
  136549. export var pbrBlockAlphaFresnel: {
  136550. name: string;
  136551. shader: string;
  136552. };
  136553. }
  136554. declare module BABYLON {
  136555. /** @hidden */
  136556. export var pbrBlockAnisotropic: {
  136557. name: string;
  136558. shader: string;
  136559. };
  136560. }
  136561. declare module BABYLON {
  136562. /** @hidden */
  136563. export var pbrBlockReflection: {
  136564. name: string;
  136565. shader: string;
  136566. };
  136567. }
  136568. declare module BABYLON {
  136569. /** @hidden */
  136570. export var pbrBlockSheen: {
  136571. name: string;
  136572. shader: string;
  136573. };
  136574. }
  136575. declare module BABYLON {
  136576. /** @hidden */
  136577. export var pbrBlockClearcoat: {
  136578. name: string;
  136579. shader: string;
  136580. };
  136581. }
  136582. declare module BABYLON {
  136583. /** @hidden */
  136584. export var pbrBlockSubSurface: {
  136585. name: string;
  136586. shader: string;
  136587. };
  136588. }
  136589. declare module BABYLON {
  136590. /** @hidden */
  136591. export var pbrBlockNormalGeometric: {
  136592. name: string;
  136593. shader: string;
  136594. };
  136595. }
  136596. declare module BABYLON {
  136597. /** @hidden */
  136598. export var pbrBlockNormalFinal: {
  136599. name: string;
  136600. shader: string;
  136601. };
  136602. }
  136603. declare module BABYLON {
  136604. /** @hidden */
  136605. export var pbrBlockLightmapInit: {
  136606. name: string;
  136607. shader: string;
  136608. };
  136609. }
  136610. declare module BABYLON {
  136611. /** @hidden */
  136612. export var pbrBlockGeometryInfo: {
  136613. name: string;
  136614. shader: string;
  136615. };
  136616. }
  136617. declare module BABYLON {
  136618. /** @hidden */
  136619. export var pbrBlockReflectance0: {
  136620. name: string;
  136621. shader: string;
  136622. };
  136623. }
  136624. declare module BABYLON {
  136625. /** @hidden */
  136626. export var pbrBlockReflectance: {
  136627. name: string;
  136628. shader: string;
  136629. };
  136630. }
  136631. declare module BABYLON {
  136632. /** @hidden */
  136633. export var pbrBlockDirectLighting: {
  136634. name: string;
  136635. shader: string;
  136636. };
  136637. }
  136638. declare module BABYLON {
  136639. /** @hidden */
  136640. export var pbrBlockFinalLitComponents: {
  136641. name: string;
  136642. shader: string;
  136643. };
  136644. }
  136645. declare module BABYLON {
  136646. /** @hidden */
  136647. export var pbrBlockFinalUnlitComponents: {
  136648. name: string;
  136649. shader: string;
  136650. };
  136651. }
  136652. declare module BABYLON {
  136653. /** @hidden */
  136654. export var pbrBlockFinalColorComposition: {
  136655. name: string;
  136656. shader: string;
  136657. };
  136658. }
  136659. declare module BABYLON {
  136660. /** @hidden */
  136661. export var pbrBlockImageProcessing: {
  136662. name: string;
  136663. shader: string;
  136664. };
  136665. }
  136666. declare module BABYLON {
  136667. /** @hidden */
  136668. export var pbrDebug: {
  136669. name: string;
  136670. shader: string;
  136671. };
  136672. }
  136673. declare module BABYLON {
  136674. /** @hidden */
  136675. export var pbrPixelShader: {
  136676. name: string;
  136677. shader: string;
  136678. };
  136679. }
  136680. declare module BABYLON {
  136681. /** @hidden */
  136682. export var pbrVertexDeclaration: {
  136683. name: string;
  136684. shader: string;
  136685. };
  136686. }
  136687. declare module BABYLON {
  136688. /** @hidden */
  136689. export var pbrVertexShader: {
  136690. name: string;
  136691. shader: string;
  136692. };
  136693. }
  136694. declare module BABYLON {
  136695. /**
  136696. * Manages the defines for the PBR Material.
  136697. * @hidden
  136698. */
  136699. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  136700. PBR: boolean;
  136701. NUM_SAMPLES: string;
  136702. REALTIME_FILTERING: boolean;
  136703. MAINUV1: boolean;
  136704. MAINUV2: boolean;
  136705. UV1: boolean;
  136706. UV2: boolean;
  136707. ALBEDO: boolean;
  136708. GAMMAALBEDO: boolean;
  136709. ALBEDODIRECTUV: number;
  136710. VERTEXCOLOR: boolean;
  136711. DETAIL: boolean;
  136712. DETAILDIRECTUV: number;
  136713. DETAIL_NORMALBLENDMETHOD: number;
  136714. AMBIENT: boolean;
  136715. AMBIENTDIRECTUV: number;
  136716. AMBIENTINGRAYSCALE: boolean;
  136717. OPACITY: boolean;
  136718. VERTEXALPHA: boolean;
  136719. OPACITYDIRECTUV: number;
  136720. OPACITYRGB: boolean;
  136721. ALPHATEST: boolean;
  136722. DEPTHPREPASS: boolean;
  136723. ALPHABLEND: boolean;
  136724. ALPHAFROMALBEDO: boolean;
  136725. ALPHATESTVALUE: string;
  136726. SPECULAROVERALPHA: boolean;
  136727. RADIANCEOVERALPHA: boolean;
  136728. ALPHAFRESNEL: boolean;
  136729. LINEARALPHAFRESNEL: boolean;
  136730. PREMULTIPLYALPHA: boolean;
  136731. EMISSIVE: boolean;
  136732. EMISSIVEDIRECTUV: number;
  136733. REFLECTIVITY: boolean;
  136734. REFLECTIVITYDIRECTUV: number;
  136735. SPECULARTERM: boolean;
  136736. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  136737. MICROSURFACEAUTOMATIC: boolean;
  136738. LODBASEDMICROSFURACE: boolean;
  136739. MICROSURFACEMAP: boolean;
  136740. MICROSURFACEMAPDIRECTUV: number;
  136741. METALLICWORKFLOW: boolean;
  136742. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  136743. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  136744. METALLNESSSTOREINMETALMAPBLUE: boolean;
  136745. AOSTOREINMETALMAPRED: boolean;
  136746. METALLIC_REFLECTANCE: boolean;
  136747. METALLIC_REFLECTANCEDIRECTUV: number;
  136748. ENVIRONMENTBRDF: boolean;
  136749. ENVIRONMENTBRDF_RGBD: boolean;
  136750. NORMAL: boolean;
  136751. TANGENT: boolean;
  136752. BUMP: boolean;
  136753. BUMPDIRECTUV: number;
  136754. OBJECTSPACE_NORMALMAP: boolean;
  136755. PARALLAX: boolean;
  136756. PARALLAXOCCLUSION: boolean;
  136757. NORMALXYSCALE: boolean;
  136758. LIGHTMAP: boolean;
  136759. LIGHTMAPDIRECTUV: number;
  136760. USELIGHTMAPASSHADOWMAP: boolean;
  136761. GAMMALIGHTMAP: boolean;
  136762. RGBDLIGHTMAP: boolean;
  136763. REFLECTION: boolean;
  136764. REFLECTIONMAP_3D: boolean;
  136765. REFLECTIONMAP_SPHERICAL: boolean;
  136766. REFLECTIONMAP_PLANAR: boolean;
  136767. REFLECTIONMAP_CUBIC: boolean;
  136768. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  136769. REFLECTIONMAP_PROJECTION: boolean;
  136770. REFLECTIONMAP_SKYBOX: boolean;
  136771. REFLECTIONMAP_EXPLICIT: boolean;
  136772. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  136773. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  136774. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  136775. INVERTCUBICMAP: boolean;
  136776. USESPHERICALFROMREFLECTIONMAP: boolean;
  136777. USEIRRADIANCEMAP: boolean;
  136778. SPHERICAL_HARMONICS: boolean;
  136779. USESPHERICALINVERTEX: boolean;
  136780. REFLECTIONMAP_OPPOSITEZ: boolean;
  136781. LODINREFLECTIONALPHA: boolean;
  136782. GAMMAREFLECTION: boolean;
  136783. RGBDREFLECTION: boolean;
  136784. LINEARSPECULARREFLECTION: boolean;
  136785. RADIANCEOCCLUSION: boolean;
  136786. HORIZONOCCLUSION: boolean;
  136787. INSTANCES: boolean;
  136788. THIN_INSTANCES: boolean;
  136789. PREPASS: boolean;
  136790. PREPASS_IRRADIANCE: boolean;
  136791. PREPASS_IRRADIANCE_INDEX: number;
  136792. PREPASS_ALBEDO: boolean;
  136793. PREPASS_ALBEDO_INDEX: number;
  136794. PREPASS_DEPTHNORMAL: boolean;
  136795. PREPASS_DEPTHNORMAL_INDEX: number;
  136796. SCENE_MRT_COUNT: number;
  136797. NUM_BONE_INFLUENCERS: number;
  136798. BonesPerMesh: number;
  136799. BONETEXTURE: boolean;
  136800. NONUNIFORMSCALING: boolean;
  136801. MORPHTARGETS: boolean;
  136802. MORPHTARGETS_NORMAL: boolean;
  136803. MORPHTARGETS_TANGENT: boolean;
  136804. MORPHTARGETS_UV: boolean;
  136805. NUM_MORPH_INFLUENCERS: number;
  136806. IMAGEPROCESSING: boolean;
  136807. VIGNETTE: boolean;
  136808. VIGNETTEBLENDMODEMULTIPLY: boolean;
  136809. VIGNETTEBLENDMODEOPAQUE: boolean;
  136810. TONEMAPPING: boolean;
  136811. TONEMAPPING_ACES: boolean;
  136812. CONTRAST: boolean;
  136813. COLORCURVES: boolean;
  136814. COLORGRADING: boolean;
  136815. COLORGRADING3D: boolean;
  136816. SAMPLER3DGREENDEPTH: boolean;
  136817. SAMPLER3DBGRMAP: boolean;
  136818. IMAGEPROCESSINGPOSTPROCESS: boolean;
  136819. EXPOSURE: boolean;
  136820. MULTIVIEW: boolean;
  136821. USEPHYSICALLIGHTFALLOFF: boolean;
  136822. USEGLTFLIGHTFALLOFF: boolean;
  136823. TWOSIDEDLIGHTING: boolean;
  136824. SHADOWFLOAT: boolean;
  136825. CLIPPLANE: boolean;
  136826. CLIPPLANE2: boolean;
  136827. CLIPPLANE3: boolean;
  136828. CLIPPLANE4: boolean;
  136829. CLIPPLANE5: boolean;
  136830. CLIPPLANE6: boolean;
  136831. POINTSIZE: boolean;
  136832. FOG: boolean;
  136833. LOGARITHMICDEPTH: boolean;
  136834. FORCENORMALFORWARD: boolean;
  136835. SPECULARAA: boolean;
  136836. CLEARCOAT: boolean;
  136837. CLEARCOAT_DEFAULTIOR: boolean;
  136838. CLEARCOAT_TEXTURE: boolean;
  136839. CLEARCOAT_TEXTUREDIRECTUV: number;
  136840. CLEARCOAT_BUMP: boolean;
  136841. CLEARCOAT_BUMPDIRECTUV: number;
  136842. CLEARCOAT_TINT: boolean;
  136843. CLEARCOAT_TINT_TEXTURE: boolean;
  136844. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  136845. ANISOTROPIC: boolean;
  136846. ANISOTROPIC_TEXTURE: boolean;
  136847. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136848. BRDF_V_HEIGHT_CORRELATED: boolean;
  136849. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136850. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136851. SHEEN: boolean;
  136852. SHEEN_TEXTURE: boolean;
  136853. SHEEN_TEXTUREDIRECTUV: number;
  136854. SHEEN_LINKWITHALBEDO: boolean;
  136855. SHEEN_ROUGHNESS: boolean;
  136856. SHEEN_ALBEDOSCALING: boolean;
  136857. SUBSURFACE: boolean;
  136858. SS_REFRACTION: boolean;
  136859. SS_TRANSLUCENCY: boolean;
  136860. SS_SCATTERING: boolean;
  136861. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136862. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136863. SS_REFRACTIONMAP_3D: boolean;
  136864. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136865. SS_LODINREFRACTIONALPHA: boolean;
  136866. SS_GAMMAREFRACTION: boolean;
  136867. SS_RGBDREFRACTION: boolean;
  136868. SS_LINEARSPECULARREFRACTION: boolean;
  136869. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136870. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136871. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136872. UNLIT: boolean;
  136873. DEBUGMODE: number;
  136874. /**
  136875. * Initializes the PBR Material defines.
  136876. */
  136877. constructor();
  136878. /**
  136879. * Resets the PBR Material defines.
  136880. */
  136881. reset(): void;
  136882. }
  136883. /**
  136884. * The Physically based material base class of BJS.
  136885. *
  136886. * This offers the main features of a standard PBR material.
  136887. * For more information, please refer to the documentation :
  136888. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136889. */
  136890. export abstract class PBRBaseMaterial extends PushMaterial {
  136891. /**
  136892. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136893. */
  136894. static readonly PBRMATERIAL_OPAQUE: number;
  136895. /**
  136896. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136897. */
  136898. static readonly PBRMATERIAL_ALPHATEST: number;
  136899. /**
  136900. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136901. */
  136902. static readonly PBRMATERIAL_ALPHABLEND: number;
  136903. /**
  136904. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136905. * They are also discarded below the alpha cutoff threshold to improve performances.
  136906. */
  136907. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136908. /**
  136909. * Defines the default value of how much AO map is occluding the analytical lights
  136910. * (point spot...).
  136911. */
  136912. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136913. /**
  136914. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  136915. */
  136916. static readonly LIGHTFALLOFF_PHYSICAL: number;
  136917. /**
  136918. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  136919. * to enhance interoperability with other engines.
  136920. */
  136921. static readonly LIGHTFALLOFF_GLTF: number;
  136922. /**
  136923. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  136924. * to enhance interoperability with other materials.
  136925. */
  136926. static readonly LIGHTFALLOFF_STANDARD: number;
  136927. /**
  136928. * Intensity of the direct lights e.g. the four lights available in your scene.
  136929. * This impacts both the direct diffuse and specular highlights.
  136930. */
  136931. protected _directIntensity: number;
  136932. /**
  136933. * Intensity of the emissive part of the material.
  136934. * This helps controlling the emissive effect without modifying the emissive color.
  136935. */
  136936. protected _emissiveIntensity: number;
  136937. /**
  136938. * Intensity of the environment e.g. how much the environment will light the object
  136939. * either through harmonics for rough material or through the refelction for shiny ones.
  136940. */
  136941. protected _environmentIntensity: number;
  136942. /**
  136943. * This is a special control allowing the reduction of the specular highlights coming from the
  136944. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136945. */
  136946. protected _specularIntensity: number;
  136947. /**
  136948. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  136949. */
  136950. private _lightingInfos;
  136951. /**
  136952. * Debug Control allowing disabling the bump map on this material.
  136953. */
  136954. protected _disableBumpMap: boolean;
  136955. /**
  136956. * AKA Diffuse Texture in standard nomenclature.
  136957. */
  136958. protected _albedoTexture: Nullable<BaseTexture>;
  136959. /**
  136960. * AKA Occlusion Texture in other nomenclature.
  136961. */
  136962. protected _ambientTexture: Nullable<BaseTexture>;
  136963. /**
  136964. * AKA Occlusion Texture Intensity in other nomenclature.
  136965. */
  136966. protected _ambientTextureStrength: number;
  136967. /**
  136968. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136969. * 1 means it completely occludes it
  136970. * 0 mean it has no impact
  136971. */
  136972. protected _ambientTextureImpactOnAnalyticalLights: number;
  136973. /**
  136974. * Stores the alpha values in a texture.
  136975. */
  136976. protected _opacityTexture: Nullable<BaseTexture>;
  136977. /**
  136978. * Stores the reflection values in a texture.
  136979. */
  136980. protected _reflectionTexture: Nullable<BaseTexture>;
  136981. /**
  136982. * Stores the emissive values in a texture.
  136983. */
  136984. protected _emissiveTexture: Nullable<BaseTexture>;
  136985. /**
  136986. * AKA Specular texture in other nomenclature.
  136987. */
  136988. protected _reflectivityTexture: Nullable<BaseTexture>;
  136989. /**
  136990. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136991. */
  136992. protected _metallicTexture: Nullable<BaseTexture>;
  136993. /**
  136994. * Specifies the metallic scalar of the metallic/roughness workflow.
  136995. * Can also be used to scale the metalness values of the metallic texture.
  136996. */
  136997. protected _metallic: Nullable<number>;
  136998. /**
  136999. * Specifies the roughness scalar of the metallic/roughness workflow.
  137000. * Can also be used to scale the roughness values of the metallic texture.
  137001. */
  137002. protected _roughness: Nullable<number>;
  137003. /**
  137004. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137005. * By default the indexOfrefraction is used to compute F0;
  137006. *
  137007. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137008. *
  137009. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137010. * F90 = metallicReflectanceColor;
  137011. */
  137012. protected _metallicF0Factor: number;
  137013. /**
  137014. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137015. * By default the F90 is always 1;
  137016. *
  137017. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137018. *
  137019. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137020. * F90 = metallicReflectanceColor;
  137021. */
  137022. protected _metallicReflectanceColor: Color3;
  137023. /**
  137024. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137025. * This is multiply against the scalar values defined in the material.
  137026. */
  137027. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  137028. /**
  137029. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137030. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137031. */
  137032. protected _microSurfaceTexture: Nullable<BaseTexture>;
  137033. /**
  137034. * Stores surface normal data used to displace a mesh in a texture.
  137035. */
  137036. protected _bumpTexture: Nullable<BaseTexture>;
  137037. /**
  137038. * Stores the pre-calculated light information of a mesh in a texture.
  137039. */
  137040. protected _lightmapTexture: Nullable<BaseTexture>;
  137041. /**
  137042. * The color of a material in ambient lighting.
  137043. */
  137044. protected _ambientColor: Color3;
  137045. /**
  137046. * AKA Diffuse Color in other nomenclature.
  137047. */
  137048. protected _albedoColor: Color3;
  137049. /**
  137050. * AKA Specular Color in other nomenclature.
  137051. */
  137052. protected _reflectivityColor: Color3;
  137053. /**
  137054. * The color applied when light is reflected from a material.
  137055. */
  137056. protected _reflectionColor: Color3;
  137057. /**
  137058. * The color applied when light is emitted from a material.
  137059. */
  137060. protected _emissiveColor: Color3;
  137061. /**
  137062. * AKA Glossiness in other nomenclature.
  137063. */
  137064. protected _microSurface: number;
  137065. /**
  137066. * Specifies that the material will use the light map as a show map.
  137067. */
  137068. protected _useLightmapAsShadowmap: boolean;
  137069. /**
  137070. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137071. * makes the reflect vector face the model (under horizon).
  137072. */
  137073. protected _useHorizonOcclusion: boolean;
  137074. /**
  137075. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137076. * too much the area relying on ambient texture to define their ambient occlusion.
  137077. */
  137078. protected _useRadianceOcclusion: boolean;
  137079. /**
  137080. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137081. */
  137082. protected _useAlphaFromAlbedoTexture: boolean;
  137083. /**
  137084. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  137085. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137086. */
  137087. protected _useSpecularOverAlpha: boolean;
  137088. /**
  137089. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137090. */
  137091. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137092. /**
  137093. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137094. */
  137095. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  137096. /**
  137097. * Specifies if the metallic texture contains the roughness information in its green channel.
  137098. */
  137099. protected _useRoughnessFromMetallicTextureGreen: boolean;
  137100. /**
  137101. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137102. */
  137103. protected _useMetallnessFromMetallicTextureBlue: boolean;
  137104. /**
  137105. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137106. */
  137107. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  137108. /**
  137109. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137110. */
  137111. protected _useAmbientInGrayScale: boolean;
  137112. /**
  137113. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137114. * The material will try to infer what glossiness each pixel should be.
  137115. */
  137116. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  137117. /**
  137118. * Defines the falloff type used in this material.
  137119. * It by default is Physical.
  137120. */
  137121. protected _lightFalloff: number;
  137122. /**
  137123. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137124. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137125. */
  137126. protected _useRadianceOverAlpha: boolean;
  137127. /**
  137128. * Allows using an object space normal map (instead of tangent space).
  137129. */
  137130. protected _useObjectSpaceNormalMap: boolean;
  137131. /**
  137132. * Allows using the bump map in parallax mode.
  137133. */
  137134. protected _useParallax: boolean;
  137135. /**
  137136. * Allows using the bump map in parallax occlusion mode.
  137137. */
  137138. protected _useParallaxOcclusion: boolean;
  137139. /**
  137140. * Controls the scale bias of the parallax mode.
  137141. */
  137142. protected _parallaxScaleBias: number;
  137143. /**
  137144. * If sets to true, disables all the lights affecting the material.
  137145. */
  137146. protected _disableLighting: boolean;
  137147. /**
  137148. * Number of Simultaneous lights allowed on the material.
  137149. */
  137150. protected _maxSimultaneousLights: number;
  137151. /**
  137152. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  137153. */
  137154. protected _invertNormalMapX: boolean;
  137155. /**
  137156. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  137157. */
  137158. protected _invertNormalMapY: boolean;
  137159. /**
  137160. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137161. */
  137162. protected _twoSidedLighting: boolean;
  137163. /**
  137164. * Defines the alpha limits in alpha test mode.
  137165. */
  137166. protected _alphaCutOff: number;
  137167. /**
  137168. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137169. */
  137170. protected _forceAlphaTest: boolean;
  137171. /**
  137172. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137173. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137174. */
  137175. protected _useAlphaFresnel: boolean;
  137176. /**
  137177. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137178. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137179. */
  137180. protected _useLinearAlphaFresnel: boolean;
  137181. /**
  137182. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  137183. * from cos thetav and roughness:
  137184. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  137185. */
  137186. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  137187. /**
  137188. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137189. */
  137190. protected _forceIrradianceInFragment: boolean;
  137191. private _realTimeFiltering;
  137192. /**
  137193. * Enables realtime filtering on the texture.
  137194. */
  137195. get realTimeFiltering(): boolean;
  137196. set realTimeFiltering(b: boolean);
  137197. private _realTimeFilteringQuality;
  137198. /**
  137199. * Quality switch for realtime filtering
  137200. */
  137201. get realTimeFilteringQuality(): number;
  137202. set realTimeFilteringQuality(n: number);
  137203. /**
  137204. * Can this material render to several textures at once
  137205. */
  137206. get canRenderToMRT(): boolean;
  137207. /**
  137208. * Force normal to face away from face.
  137209. */
  137210. protected _forceNormalForward: boolean;
  137211. /**
  137212. * Enables specular anti aliasing in the PBR shader.
  137213. * It will both interacts on the Geometry for analytical and IBL lighting.
  137214. * It also prefilter the roughness map based on the bump values.
  137215. */
  137216. protected _enableSpecularAntiAliasing: boolean;
  137217. /**
  137218. * Default configuration related to image processing available in the PBR Material.
  137219. */
  137220. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  137221. /**
  137222. * Keep track of the image processing observer to allow dispose and replace.
  137223. */
  137224. private _imageProcessingObserver;
  137225. /**
  137226. * Attaches a new image processing configuration to the PBR Material.
  137227. * @param configuration
  137228. */
  137229. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  137230. /**
  137231. * Stores the available render targets.
  137232. */
  137233. private _renderTargets;
  137234. /**
  137235. * Sets the global ambient color for the material used in lighting calculations.
  137236. */
  137237. private _globalAmbientColor;
  137238. /**
  137239. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  137240. */
  137241. private _useLogarithmicDepth;
  137242. /**
  137243. * If set to true, no lighting calculations will be applied.
  137244. */
  137245. private _unlit;
  137246. private _debugMode;
  137247. /**
  137248. * @hidden
  137249. * This is reserved for the inspector.
  137250. * Defines the material debug mode.
  137251. * It helps seeing only some components of the material while troubleshooting.
  137252. */
  137253. debugMode: number;
  137254. /**
  137255. * @hidden
  137256. * This is reserved for the inspector.
  137257. * Specify from where on screen the debug mode should start.
  137258. * The value goes from -1 (full screen) to 1 (not visible)
  137259. * It helps with side by side comparison against the final render
  137260. * This defaults to -1
  137261. */
  137262. private debugLimit;
  137263. /**
  137264. * @hidden
  137265. * This is reserved for the inspector.
  137266. * As the default viewing range might not be enough (if the ambient is really small for instance)
  137267. * You can use the factor to better multiply the final value.
  137268. */
  137269. private debugFactor;
  137270. /**
  137271. * Defines the clear coat layer parameters for the material.
  137272. */
  137273. readonly clearCoat: PBRClearCoatConfiguration;
  137274. /**
  137275. * Defines the anisotropic parameters for the material.
  137276. */
  137277. readonly anisotropy: PBRAnisotropicConfiguration;
  137278. /**
  137279. * Defines the BRDF parameters for the material.
  137280. */
  137281. readonly brdf: PBRBRDFConfiguration;
  137282. /**
  137283. * Defines the Sheen parameters for the material.
  137284. */
  137285. readonly sheen: PBRSheenConfiguration;
  137286. /**
  137287. * Defines the SubSurface parameters for the material.
  137288. */
  137289. readonly subSurface: PBRSubSurfaceConfiguration;
  137290. /**
  137291. * Defines the detail map parameters for the material.
  137292. */
  137293. readonly detailMap: DetailMapConfiguration;
  137294. protected _rebuildInParallel: boolean;
  137295. /**
  137296. * Instantiates a new PBRMaterial instance.
  137297. *
  137298. * @param name The material name
  137299. * @param scene The scene the material will be use in.
  137300. */
  137301. constructor(name: string, scene: Scene);
  137302. /**
  137303. * Gets a boolean indicating that current material needs to register RTT
  137304. */
  137305. get hasRenderTargetTextures(): boolean;
  137306. /**
  137307. * Gets the name of the material class.
  137308. */
  137309. getClassName(): string;
  137310. /**
  137311. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137312. */
  137313. get useLogarithmicDepth(): boolean;
  137314. /**
  137315. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137316. */
  137317. set useLogarithmicDepth(value: boolean);
  137318. /**
  137319. * Returns true if alpha blending should be disabled.
  137320. */
  137321. protected get _disableAlphaBlending(): boolean;
  137322. /**
  137323. * Specifies whether or not this material should be rendered in alpha blend mode.
  137324. */
  137325. needAlphaBlending(): boolean;
  137326. /**
  137327. * Specifies whether or not this material should be rendered in alpha test mode.
  137328. */
  137329. needAlphaTesting(): boolean;
  137330. /**
  137331. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  137332. */
  137333. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  137334. /**
  137335. * Gets the texture used for the alpha test.
  137336. */
  137337. getAlphaTestTexture(): Nullable<BaseTexture>;
  137338. /**
  137339. * Specifies that the submesh is ready to be used.
  137340. * @param mesh - BJS mesh.
  137341. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  137342. * @param useInstances - Specifies that instances should be used.
  137343. * @returns - boolean indicating that the submesh is ready or not.
  137344. */
  137345. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  137346. /**
  137347. * Specifies if the material uses metallic roughness workflow.
  137348. * @returns boolean specifiying if the material uses metallic roughness workflow.
  137349. */
  137350. isMetallicWorkflow(): boolean;
  137351. private _prepareEffect;
  137352. private _prepareDefines;
  137353. /**
  137354. * Force shader compilation
  137355. */
  137356. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  137357. /**
  137358. * Initializes the uniform buffer layout for the shader.
  137359. */
  137360. buildUniformLayout(): void;
  137361. /**
  137362. * Unbinds the material from the mesh
  137363. */
  137364. unbind(): void;
  137365. /**
  137366. * Binds the submesh data.
  137367. * @param world - The world matrix.
  137368. * @param mesh - The BJS mesh.
  137369. * @param subMesh - A submesh of the BJS mesh.
  137370. */
  137371. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  137372. /**
  137373. * Returns the animatable textures.
  137374. * @returns - Array of animatable textures.
  137375. */
  137376. getAnimatables(): IAnimatable[];
  137377. /**
  137378. * Returns the texture used for reflections.
  137379. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  137380. */
  137381. private _getReflectionTexture;
  137382. /**
  137383. * Returns an array of the actively used textures.
  137384. * @returns - Array of BaseTextures
  137385. */
  137386. getActiveTextures(): BaseTexture[];
  137387. /**
  137388. * Checks to see if a texture is used in the material.
  137389. * @param texture - Base texture to use.
  137390. * @returns - Boolean specifying if a texture is used in the material.
  137391. */
  137392. hasTexture(texture: BaseTexture): boolean;
  137393. /**
  137394. * Sets the required values to the prepass renderer.
  137395. * @param prePassRenderer defines the prepass renderer to setup
  137396. */
  137397. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  137398. /**
  137399. * Disposes the resources of the material.
  137400. * @param forceDisposeEffect - Forces the disposal of effects.
  137401. * @param forceDisposeTextures - Forces the disposal of all textures.
  137402. */
  137403. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  137404. }
  137405. }
  137406. declare module BABYLON {
  137407. /**
  137408. * The Physically based material of BJS.
  137409. *
  137410. * This offers the main features of a standard PBR material.
  137411. * For more information, please refer to the documentation :
  137412. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137413. */
  137414. export class PBRMaterial extends PBRBaseMaterial {
  137415. /**
  137416. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137417. */
  137418. static readonly PBRMATERIAL_OPAQUE: number;
  137419. /**
  137420. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137421. */
  137422. static readonly PBRMATERIAL_ALPHATEST: number;
  137423. /**
  137424. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137425. */
  137426. static readonly PBRMATERIAL_ALPHABLEND: number;
  137427. /**
  137428. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137429. * They are also discarded below the alpha cutoff threshold to improve performances.
  137430. */
  137431. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137432. /**
  137433. * Defines the default value of how much AO map is occluding the analytical lights
  137434. * (point spot...).
  137435. */
  137436. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137437. /**
  137438. * Intensity of the direct lights e.g. the four lights available in your scene.
  137439. * This impacts both the direct diffuse and specular highlights.
  137440. */
  137441. directIntensity: number;
  137442. /**
  137443. * Intensity of the emissive part of the material.
  137444. * This helps controlling the emissive effect without modifying the emissive color.
  137445. */
  137446. emissiveIntensity: number;
  137447. /**
  137448. * Intensity of the environment e.g. how much the environment will light the object
  137449. * either through harmonics for rough material or through the refelction for shiny ones.
  137450. */
  137451. environmentIntensity: number;
  137452. /**
  137453. * This is a special control allowing the reduction of the specular highlights coming from the
  137454. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137455. */
  137456. specularIntensity: number;
  137457. /**
  137458. * Debug Control allowing disabling the bump map on this material.
  137459. */
  137460. disableBumpMap: boolean;
  137461. /**
  137462. * AKA Diffuse Texture in standard nomenclature.
  137463. */
  137464. albedoTexture: BaseTexture;
  137465. /**
  137466. * AKA Occlusion Texture in other nomenclature.
  137467. */
  137468. ambientTexture: BaseTexture;
  137469. /**
  137470. * AKA Occlusion Texture Intensity in other nomenclature.
  137471. */
  137472. ambientTextureStrength: number;
  137473. /**
  137474. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137475. * 1 means it completely occludes it
  137476. * 0 mean it has no impact
  137477. */
  137478. ambientTextureImpactOnAnalyticalLights: number;
  137479. /**
  137480. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  137481. */
  137482. opacityTexture: BaseTexture;
  137483. /**
  137484. * Stores the reflection values in a texture.
  137485. */
  137486. reflectionTexture: Nullable<BaseTexture>;
  137487. /**
  137488. * Stores the emissive values in a texture.
  137489. */
  137490. emissiveTexture: BaseTexture;
  137491. /**
  137492. * AKA Specular texture in other nomenclature.
  137493. */
  137494. reflectivityTexture: BaseTexture;
  137495. /**
  137496. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137497. */
  137498. metallicTexture: BaseTexture;
  137499. /**
  137500. * Specifies the metallic scalar of the metallic/roughness workflow.
  137501. * Can also be used to scale the metalness values of the metallic texture.
  137502. */
  137503. metallic: Nullable<number>;
  137504. /**
  137505. * Specifies the roughness scalar of the metallic/roughness workflow.
  137506. * Can also be used to scale the roughness values of the metallic texture.
  137507. */
  137508. roughness: Nullable<number>;
  137509. /**
  137510. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137511. * By default the indexOfrefraction is used to compute F0;
  137512. *
  137513. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137514. *
  137515. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137516. * F90 = metallicReflectanceColor;
  137517. */
  137518. metallicF0Factor: number;
  137519. /**
  137520. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137521. * By default the F90 is always 1;
  137522. *
  137523. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137524. *
  137525. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137526. * F90 = metallicReflectanceColor;
  137527. */
  137528. metallicReflectanceColor: Color3;
  137529. /**
  137530. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137531. * This is multiply against the scalar values defined in the material.
  137532. */
  137533. metallicReflectanceTexture: Nullable<BaseTexture>;
  137534. /**
  137535. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137536. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137537. */
  137538. microSurfaceTexture: BaseTexture;
  137539. /**
  137540. * Stores surface normal data used to displace a mesh in a texture.
  137541. */
  137542. bumpTexture: BaseTexture;
  137543. /**
  137544. * Stores the pre-calculated light information of a mesh in a texture.
  137545. */
  137546. lightmapTexture: BaseTexture;
  137547. /**
  137548. * Stores the refracted light information in a texture.
  137549. */
  137550. get refractionTexture(): Nullable<BaseTexture>;
  137551. set refractionTexture(value: Nullable<BaseTexture>);
  137552. /**
  137553. * The color of a material in ambient lighting.
  137554. */
  137555. ambientColor: Color3;
  137556. /**
  137557. * AKA Diffuse Color in other nomenclature.
  137558. */
  137559. albedoColor: Color3;
  137560. /**
  137561. * AKA Specular Color in other nomenclature.
  137562. */
  137563. reflectivityColor: Color3;
  137564. /**
  137565. * The color reflected from the material.
  137566. */
  137567. reflectionColor: Color3;
  137568. /**
  137569. * The color emitted from the material.
  137570. */
  137571. emissiveColor: Color3;
  137572. /**
  137573. * AKA Glossiness in other nomenclature.
  137574. */
  137575. microSurface: number;
  137576. /**
  137577. * Index of refraction of the material base layer.
  137578. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  137579. *
  137580. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  137581. *
  137582. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  137583. */
  137584. get indexOfRefraction(): number;
  137585. set indexOfRefraction(value: number);
  137586. /**
  137587. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  137588. */
  137589. get invertRefractionY(): boolean;
  137590. set invertRefractionY(value: boolean);
  137591. /**
  137592. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  137593. * Materials half opaque for instance using refraction could benefit from this control.
  137594. */
  137595. get linkRefractionWithTransparency(): boolean;
  137596. set linkRefractionWithTransparency(value: boolean);
  137597. /**
  137598. * If true, the light map contains occlusion information instead of lighting info.
  137599. */
  137600. useLightmapAsShadowmap: boolean;
  137601. /**
  137602. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137603. */
  137604. useAlphaFromAlbedoTexture: boolean;
  137605. /**
  137606. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137607. */
  137608. forceAlphaTest: boolean;
  137609. /**
  137610. * Defines the alpha limits in alpha test mode.
  137611. */
  137612. alphaCutOff: number;
  137613. /**
  137614. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  137615. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137616. */
  137617. useSpecularOverAlpha: boolean;
  137618. /**
  137619. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137620. */
  137621. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137622. /**
  137623. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137624. */
  137625. useRoughnessFromMetallicTextureAlpha: boolean;
  137626. /**
  137627. * Specifies if the metallic texture contains the roughness information in its green channel.
  137628. */
  137629. useRoughnessFromMetallicTextureGreen: boolean;
  137630. /**
  137631. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137632. */
  137633. useMetallnessFromMetallicTextureBlue: boolean;
  137634. /**
  137635. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137636. */
  137637. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137638. /**
  137639. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137640. */
  137641. useAmbientInGrayScale: boolean;
  137642. /**
  137643. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137644. * The material will try to infer what glossiness each pixel should be.
  137645. */
  137646. useAutoMicroSurfaceFromReflectivityMap: boolean;
  137647. /**
  137648. * BJS is using an harcoded light falloff based on a manually sets up range.
  137649. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137650. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137651. */
  137652. get usePhysicalLightFalloff(): boolean;
  137653. /**
  137654. * BJS is using an harcoded light falloff based on a manually sets up range.
  137655. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137656. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137657. */
  137658. set usePhysicalLightFalloff(value: boolean);
  137659. /**
  137660. * In order to support the falloff compatibility with gltf, a special mode has been added
  137661. * to reproduce the gltf light falloff.
  137662. */
  137663. get useGLTFLightFalloff(): boolean;
  137664. /**
  137665. * In order to support the falloff compatibility with gltf, a special mode has been added
  137666. * to reproduce the gltf light falloff.
  137667. */
  137668. set useGLTFLightFalloff(value: boolean);
  137669. /**
  137670. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137671. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137672. */
  137673. useRadianceOverAlpha: boolean;
  137674. /**
  137675. * Allows using an object space normal map (instead of tangent space).
  137676. */
  137677. useObjectSpaceNormalMap: boolean;
  137678. /**
  137679. * Allows using the bump map in parallax mode.
  137680. */
  137681. useParallax: boolean;
  137682. /**
  137683. * Allows using the bump map in parallax occlusion mode.
  137684. */
  137685. useParallaxOcclusion: boolean;
  137686. /**
  137687. * Controls the scale bias of the parallax mode.
  137688. */
  137689. parallaxScaleBias: number;
  137690. /**
  137691. * If sets to true, disables all the lights affecting the material.
  137692. */
  137693. disableLighting: boolean;
  137694. /**
  137695. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137696. */
  137697. forceIrradianceInFragment: boolean;
  137698. /**
  137699. * Number of Simultaneous lights allowed on the material.
  137700. */
  137701. maxSimultaneousLights: number;
  137702. /**
  137703. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137704. */
  137705. invertNormalMapX: boolean;
  137706. /**
  137707. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137708. */
  137709. invertNormalMapY: boolean;
  137710. /**
  137711. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137712. */
  137713. twoSidedLighting: boolean;
  137714. /**
  137715. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137716. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137717. */
  137718. useAlphaFresnel: boolean;
  137719. /**
  137720. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137721. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137722. */
  137723. useLinearAlphaFresnel: boolean;
  137724. /**
  137725. * Let user defines the brdf lookup texture used for IBL.
  137726. * A default 8bit version is embedded but you could point at :
  137727. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  137728. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  137729. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  137730. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  137731. */
  137732. environmentBRDFTexture: Nullable<BaseTexture>;
  137733. /**
  137734. * Force normal to face away from face.
  137735. */
  137736. forceNormalForward: boolean;
  137737. /**
  137738. * Enables specular anti aliasing in the PBR shader.
  137739. * It will both interacts on the Geometry for analytical and IBL lighting.
  137740. * It also prefilter the roughness map based on the bump values.
  137741. */
  137742. enableSpecularAntiAliasing: boolean;
  137743. /**
  137744. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137745. * makes the reflect vector face the model (under horizon).
  137746. */
  137747. useHorizonOcclusion: boolean;
  137748. /**
  137749. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137750. * too much the area relying on ambient texture to define their ambient occlusion.
  137751. */
  137752. useRadianceOcclusion: boolean;
  137753. /**
  137754. * If set to true, no lighting calculations will be applied.
  137755. */
  137756. unlit: boolean;
  137757. /**
  137758. * Gets the image processing configuration used either in this material.
  137759. */
  137760. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  137761. /**
  137762. * Sets the Default image processing configuration used either in the this material.
  137763. *
  137764. * If sets to null, the scene one is in use.
  137765. */
  137766. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  137767. /**
  137768. * Gets wether the color curves effect is enabled.
  137769. */
  137770. get cameraColorCurvesEnabled(): boolean;
  137771. /**
  137772. * Sets wether the color curves effect is enabled.
  137773. */
  137774. set cameraColorCurvesEnabled(value: boolean);
  137775. /**
  137776. * Gets wether the color grading effect is enabled.
  137777. */
  137778. get cameraColorGradingEnabled(): boolean;
  137779. /**
  137780. * Gets wether the color grading effect is enabled.
  137781. */
  137782. set cameraColorGradingEnabled(value: boolean);
  137783. /**
  137784. * Gets wether tonemapping is enabled or not.
  137785. */
  137786. get cameraToneMappingEnabled(): boolean;
  137787. /**
  137788. * Sets wether tonemapping is enabled or not
  137789. */
  137790. set cameraToneMappingEnabled(value: boolean);
  137791. /**
  137792. * The camera exposure used on this material.
  137793. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137794. * This corresponds to a photographic exposure.
  137795. */
  137796. get cameraExposure(): number;
  137797. /**
  137798. * The camera exposure used on this material.
  137799. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137800. * This corresponds to a photographic exposure.
  137801. */
  137802. set cameraExposure(value: number);
  137803. /**
  137804. * Gets The camera contrast used on this material.
  137805. */
  137806. get cameraContrast(): number;
  137807. /**
  137808. * Sets The camera contrast used on this material.
  137809. */
  137810. set cameraContrast(value: number);
  137811. /**
  137812. * Gets the Color Grading 2D Lookup Texture.
  137813. */
  137814. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  137815. /**
  137816. * Sets the Color Grading 2D Lookup Texture.
  137817. */
  137818. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  137819. /**
  137820. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137821. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137822. * 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;
  137823. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137824. */
  137825. get cameraColorCurves(): Nullable<ColorCurves>;
  137826. /**
  137827. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137828. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137829. * 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;
  137830. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137831. */
  137832. set cameraColorCurves(value: Nullable<ColorCurves>);
  137833. /**
  137834. * Instantiates a new PBRMaterial instance.
  137835. *
  137836. * @param name The material name
  137837. * @param scene The scene the material will be use in.
  137838. */
  137839. constructor(name: string, scene: Scene);
  137840. /**
  137841. * Returns the name of this material class.
  137842. */
  137843. getClassName(): string;
  137844. /**
  137845. * Makes a duplicate of the current material.
  137846. * @param name - name to use for the new material.
  137847. */
  137848. clone(name: string): PBRMaterial;
  137849. /**
  137850. * Serializes this PBR Material.
  137851. * @returns - An object with the serialized material.
  137852. */
  137853. serialize(): any;
  137854. /**
  137855. * Parses a PBR Material from a serialized object.
  137856. * @param source - Serialized object.
  137857. * @param scene - BJS scene instance.
  137858. * @param rootUrl - url for the scene object
  137859. * @returns - PBRMaterial
  137860. */
  137861. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  137862. }
  137863. }
  137864. declare module BABYLON {
  137865. /**
  137866. * Direct draw surface info
  137867. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  137868. */
  137869. export interface DDSInfo {
  137870. /**
  137871. * Width of the texture
  137872. */
  137873. width: number;
  137874. /**
  137875. * Width of the texture
  137876. */
  137877. height: number;
  137878. /**
  137879. * Number of Mipmaps for the texture
  137880. * @see https://en.wikipedia.org/wiki/Mipmap
  137881. */
  137882. mipmapCount: number;
  137883. /**
  137884. * If the textures format is a known fourCC format
  137885. * @see https://www.fourcc.org/
  137886. */
  137887. isFourCC: boolean;
  137888. /**
  137889. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  137890. */
  137891. isRGB: boolean;
  137892. /**
  137893. * If the texture is a lumincance format
  137894. */
  137895. isLuminance: boolean;
  137896. /**
  137897. * If this is a cube texture
  137898. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  137899. */
  137900. isCube: boolean;
  137901. /**
  137902. * If the texture is a compressed format eg. FOURCC_DXT1
  137903. */
  137904. isCompressed: boolean;
  137905. /**
  137906. * The dxgiFormat of the texture
  137907. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  137908. */
  137909. dxgiFormat: number;
  137910. /**
  137911. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  137912. */
  137913. textureType: number;
  137914. /**
  137915. * Sphericle polynomial created for the dds texture
  137916. */
  137917. sphericalPolynomial?: SphericalPolynomial;
  137918. }
  137919. /**
  137920. * Class used to provide DDS decompression tools
  137921. */
  137922. export class DDSTools {
  137923. /**
  137924. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  137925. */
  137926. static StoreLODInAlphaChannel: boolean;
  137927. /**
  137928. * Gets DDS information from an array buffer
  137929. * @param data defines the array buffer view to read data from
  137930. * @returns the DDS information
  137931. */
  137932. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  137933. private static _FloatView;
  137934. private static _Int32View;
  137935. private static _ToHalfFloat;
  137936. private static _FromHalfFloat;
  137937. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  137938. private static _GetHalfFloatRGBAArrayBuffer;
  137939. private static _GetFloatRGBAArrayBuffer;
  137940. private static _GetFloatAsUIntRGBAArrayBuffer;
  137941. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  137942. private static _GetRGBAArrayBuffer;
  137943. private static _ExtractLongWordOrder;
  137944. private static _GetRGBArrayBuffer;
  137945. private static _GetLuminanceArrayBuffer;
  137946. /**
  137947. * Uploads DDS Levels to a Babylon Texture
  137948. * @hidden
  137949. */
  137950. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  137951. }
  137952. interface ThinEngine {
  137953. /**
  137954. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  137955. * @param rootUrl defines the url where the file to load is located
  137956. * @param scene defines the current scene
  137957. * @param lodScale defines scale to apply to the mip map selection
  137958. * @param lodOffset defines offset to apply to the mip map selection
  137959. * @param onLoad defines an optional callback raised when the texture is loaded
  137960. * @param onError defines an optional callback raised if there is an issue to load the texture
  137961. * @param format defines the format of the data
  137962. * @param forcedExtension defines the extension to use to pick the right loader
  137963. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  137964. * @returns the cube texture as an InternalTexture
  137965. */
  137966. 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;
  137967. }
  137968. }
  137969. declare module BABYLON {
  137970. /**
  137971. * Implementation of the DDS Texture Loader.
  137972. * @hidden
  137973. */
  137974. export class _DDSTextureLoader implements IInternalTextureLoader {
  137975. /**
  137976. * Defines wether the loader supports cascade loading the different faces.
  137977. */
  137978. readonly supportCascades: boolean;
  137979. /**
  137980. * This returns if the loader support the current file information.
  137981. * @param extension defines the file extension of the file being loaded
  137982. * @returns true if the loader can load the specified file
  137983. */
  137984. canLoad(extension: string): boolean;
  137985. /**
  137986. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137987. * @param data contains the texture data
  137988. * @param texture defines the BabylonJS internal texture
  137989. * @param createPolynomials will be true if polynomials have been requested
  137990. * @param onLoad defines the callback to trigger once the texture is ready
  137991. * @param onError defines the callback to trigger in case of error
  137992. */
  137993. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137994. /**
  137995. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137996. * @param data contains the texture data
  137997. * @param texture defines the BabylonJS internal texture
  137998. * @param callback defines the method to call once ready to upload
  137999. */
  138000. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138001. }
  138002. }
  138003. declare module BABYLON {
  138004. /**
  138005. * Implementation of the ENV Texture Loader.
  138006. * @hidden
  138007. */
  138008. export class _ENVTextureLoader implements IInternalTextureLoader {
  138009. /**
  138010. * Defines wether the loader supports cascade loading the different faces.
  138011. */
  138012. readonly supportCascades: boolean;
  138013. /**
  138014. * This returns if the loader support the current file information.
  138015. * @param extension defines the file extension of the file being loaded
  138016. * @returns true if the loader can load the specified file
  138017. */
  138018. canLoad(extension: string): boolean;
  138019. /**
  138020. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138021. * @param data contains the texture data
  138022. * @param texture defines the BabylonJS internal texture
  138023. * @param createPolynomials will be true if polynomials have been requested
  138024. * @param onLoad defines the callback to trigger once the texture is ready
  138025. * @param onError defines the callback to trigger in case of error
  138026. */
  138027. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138028. /**
  138029. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138030. * @param data contains the texture data
  138031. * @param texture defines the BabylonJS internal texture
  138032. * @param callback defines the method to call once ready to upload
  138033. */
  138034. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138035. }
  138036. }
  138037. declare module BABYLON {
  138038. /**
  138039. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138040. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138041. */
  138042. export class KhronosTextureContainer {
  138043. /** contents of the KTX container file */
  138044. data: ArrayBufferView;
  138045. private static HEADER_LEN;
  138046. private static COMPRESSED_2D;
  138047. private static COMPRESSED_3D;
  138048. private static TEX_2D;
  138049. private static TEX_3D;
  138050. /**
  138051. * Gets the openGL type
  138052. */
  138053. glType: number;
  138054. /**
  138055. * Gets the openGL type size
  138056. */
  138057. glTypeSize: number;
  138058. /**
  138059. * Gets the openGL format
  138060. */
  138061. glFormat: number;
  138062. /**
  138063. * Gets the openGL internal format
  138064. */
  138065. glInternalFormat: number;
  138066. /**
  138067. * Gets the base internal format
  138068. */
  138069. glBaseInternalFormat: number;
  138070. /**
  138071. * Gets image width in pixel
  138072. */
  138073. pixelWidth: number;
  138074. /**
  138075. * Gets image height in pixel
  138076. */
  138077. pixelHeight: number;
  138078. /**
  138079. * Gets image depth in pixels
  138080. */
  138081. pixelDepth: number;
  138082. /**
  138083. * Gets the number of array elements
  138084. */
  138085. numberOfArrayElements: number;
  138086. /**
  138087. * Gets the number of faces
  138088. */
  138089. numberOfFaces: number;
  138090. /**
  138091. * Gets the number of mipmap levels
  138092. */
  138093. numberOfMipmapLevels: number;
  138094. /**
  138095. * Gets the bytes of key value data
  138096. */
  138097. bytesOfKeyValueData: number;
  138098. /**
  138099. * Gets the load type
  138100. */
  138101. loadType: number;
  138102. /**
  138103. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  138104. */
  138105. isInvalid: boolean;
  138106. /**
  138107. * Creates a new KhronosTextureContainer
  138108. * @param data contents of the KTX container file
  138109. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  138110. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  138111. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  138112. */
  138113. constructor(
  138114. /** contents of the KTX container file */
  138115. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  138116. /**
  138117. * Uploads KTX content to a Babylon Texture.
  138118. * It is assumed that the texture has already been created & is currently bound
  138119. * @hidden
  138120. */
  138121. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  138122. private _upload2DCompressedLevels;
  138123. /**
  138124. * Checks if the given data starts with a KTX file identifier.
  138125. * @param data the data to check
  138126. * @returns true if the data is a KTX file or false otherwise
  138127. */
  138128. static IsValid(data: ArrayBufferView): boolean;
  138129. }
  138130. }
  138131. declare module BABYLON {
  138132. /**
  138133. * Helper class to push actions to a pool of workers.
  138134. */
  138135. export class WorkerPool implements IDisposable {
  138136. private _workerInfos;
  138137. private _pendingActions;
  138138. /**
  138139. * Constructor
  138140. * @param workers Array of workers to use for actions
  138141. */
  138142. constructor(workers: Array<Worker>);
  138143. /**
  138144. * Terminates all workers and clears any pending actions.
  138145. */
  138146. dispose(): void;
  138147. /**
  138148. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138149. * pended until a worker has completed its action.
  138150. * @param action The action to perform. Call onComplete when the action is complete.
  138151. */
  138152. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138153. private _execute;
  138154. }
  138155. }
  138156. declare module BABYLON {
  138157. /**
  138158. * Class for loading KTX2 files
  138159. * @hidden
  138160. */
  138161. export class KhronosTextureContainer2 {
  138162. private static _WorkerPoolPromise?;
  138163. private static _Initialized;
  138164. private static _Ktx2Decoder;
  138165. /**
  138166. * URL to use when loading the KTX2 decoder module
  138167. */
  138168. static JSModuleURL: string;
  138169. /**
  138170. * Default number of workers used to handle data decoding
  138171. */
  138172. static DefaultNumWorkers: number;
  138173. private static GetDefaultNumWorkers;
  138174. private _engine;
  138175. private static _CreateWorkerPool;
  138176. /**
  138177. * Constructor
  138178. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138179. */
  138180. constructor(engine: ThinEngine, numWorkers?: number);
  138181. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  138182. /**
  138183. * Stop all async operations and release resources.
  138184. */
  138185. dispose(): void;
  138186. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  138187. /**
  138188. * Checks if the given data starts with a KTX2 file identifier.
  138189. * @param data the data to check
  138190. * @returns true if the data is a KTX2 file or false otherwise
  138191. */
  138192. static IsValid(data: ArrayBufferView): boolean;
  138193. }
  138194. export function workerFunc(): void;
  138195. }
  138196. declare module BABYLON {
  138197. /**
  138198. * Implementation of the KTX Texture Loader.
  138199. * @hidden
  138200. */
  138201. export class _KTXTextureLoader implements IInternalTextureLoader {
  138202. /**
  138203. * Defines wether the loader supports cascade loading the different faces.
  138204. */
  138205. readonly supportCascades: boolean;
  138206. /**
  138207. * This returns if the loader support the current file information.
  138208. * @param extension defines the file extension of the file being loaded
  138209. * @param mimeType defines the optional mime type of the file being loaded
  138210. * @returns true if the loader can load the specified file
  138211. */
  138212. canLoad(extension: string, mimeType?: string): boolean;
  138213. /**
  138214. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138215. * @param data contains the texture data
  138216. * @param texture defines the BabylonJS internal texture
  138217. * @param createPolynomials will be true if polynomials have been requested
  138218. * @param onLoad defines the callback to trigger once the texture is ready
  138219. * @param onError defines the callback to trigger in case of error
  138220. */
  138221. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138222. /**
  138223. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138224. * @param data contains the texture data
  138225. * @param texture defines the BabylonJS internal texture
  138226. * @param callback defines the method to call once ready to upload
  138227. */
  138228. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  138229. }
  138230. }
  138231. declare module BABYLON {
  138232. /** @hidden */
  138233. export var _forceSceneHelpersToBundle: boolean;
  138234. interface Scene {
  138235. /**
  138236. * Creates a default light for the scene.
  138237. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  138238. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  138239. */
  138240. createDefaultLight(replace?: boolean): void;
  138241. /**
  138242. * Creates a default camera for the scene.
  138243. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  138244. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138245. * @param replace has default false, when true replaces the active camera in the scene
  138246. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  138247. */
  138248. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138249. /**
  138250. * Creates a default camera and a default light.
  138251. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  138252. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138253. * @param replace has the default false, when true replaces the active camera/light in the scene
  138254. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  138255. */
  138256. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138257. /**
  138258. * Creates a new sky box
  138259. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  138260. * @param environmentTexture defines the texture to use as environment texture
  138261. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  138262. * @param scale defines the overall scale of the skybox
  138263. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  138264. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  138265. * @returns a new mesh holding the sky box
  138266. */
  138267. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  138268. /**
  138269. * Creates a new environment
  138270. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  138271. * @param options defines the options you can use to configure the environment
  138272. * @returns the new EnvironmentHelper
  138273. */
  138274. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  138275. /**
  138276. * Creates a new VREXperienceHelper
  138277. * @see https://doc.babylonjs.com/how_to/webvr_helper
  138278. * @param webVROptions defines the options used to create the new VREXperienceHelper
  138279. * @returns a new VREXperienceHelper
  138280. */
  138281. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  138282. /**
  138283. * Creates a new WebXRDefaultExperience
  138284. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  138285. * @param options experience options
  138286. * @returns a promise for a new WebXRDefaultExperience
  138287. */
  138288. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  138289. }
  138290. }
  138291. declare module BABYLON {
  138292. /**
  138293. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  138294. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  138295. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  138296. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138297. */
  138298. export class VideoDome extends TextureDome<VideoTexture> {
  138299. /**
  138300. * Define the video source as a Monoscopic panoramic 360 video.
  138301. */
  138302. static readonly MODE_MONOSCOPIC: number;
  138303. /**
  138304. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  138305. */
  138306. static readonly MODE_TOPBOTTOM: number;
  138307. /**
  138308. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  138309. */
  138310. static readonly MODE_SIDEBYSIDE: number;
  138311. /**
  138312. * Get the video texture associated with this video dome
  138313. */
  138314. get videoTexture(): VideoTexture;
  138315. /**
  138316. * Get the video mode of this dome
  138317. */
  138318. get videoMode(): number;
  138319. /**
  138320. * Set the video mode of this dome.
  138321. * @see textureMode
  138322. */
  138323. set videoMode(value: number);
  138324. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  138325. }
  138326. }
  138327. declare module BABYLON {
  138328. /**
  138329. * This class can be used to get instrumentation data from a Babylon engine
  138330. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138331. */
  138332. export class EngineInstrumentation implements IDisposable {
  138333. /**
  138334. * Define the instrumented engine.
  138335. */
  138336. engine: Engine;
  138337. private _captureGPUFrameTime;
  138338. private _gpuFrameTimeToken;
  138339. private _gpuFrameTime;
  138340. private _captureShaderCompilationTime;
  138341. private _shaderCompilationTime;
  138342. private _onBeginFrameObserver;
  138343. private _onEndFrameObserver;
  138344. private _onBeforeShaderCompilationObserver;
  138345. private _onAfterShaderCompilationObserver;
  138346. /**
  138347. * Gets the perf counter used for GPU frame time
  138348. */
  138349. get gpuFrameTimeCounter(): PerfCounter;
  138350. /**
  138351. * Gets the GPU frame time capture status
  138352. */
  138353. get captureGPUFrameTime(): boolean;
  138354. /**
  138355. * Enable or disable the GPU frame time capture
  138356. */
  138357. set captureGPUFrameTime(value: boolean);
  138358. /**
  138359. * Gets the perf counter used for shader compilation time
  138360. */
  138361. get shaderCompilationTimeCounter(): PerfCounter;
  138362. /**
  138363. * Gets the shader compilation time capture status
  138364. */
  138365. get captureShaderCompilationTime(): boolean;
  138366. /**
  138367. * Enable or disable the shader compilation time capture
  138368. */
  138369. set captureShaderCompilationTime(value: boolean);
  138370. /**
  138371. * Instantiates a new engine instrumentation.
  138372. * This class can be used to get instrumentation data from a Babylon engine
  138373. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138374. * @param engine Defines the engine to instrument
  138375. */
  138376. constructor(
  138377. /**
  138378. * Define the instrumented engine.
  138379. */
  138380. engine: Engine);
  138381. /**
  138382. * Dispose and release associated resources.
  138383. */
  138384. dispose(): void;
  138385. }
  138386. }
  138387. declare module BABYLON {
  138388. /**
  138389. * This class can be used to get instrumentation data from a Babylon engine
  138390. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138391. */
  138392. export class SceneInstrumentation implements IDisposable {
  138393. /**
  138394. * Defines the scene to instrument
  138395. */
  138396. scene: Scene;
  138397. private _captureActiveMeshesEvaluationTime;
  138398. private _activeMeshesEvaluationTime;
  138399. private _captureRenderTargetsRenderTime;
  138400. private _renderTargetsRenderTime;
  138401. private _captureFrameTime;
  138402. private _frameTime;
  138403. private _captureRenderTime;
  138404. private _renderTime;
  138405. private _captureInterFrameTime;
  138406. private _interFrameTime;
  138407. private _captureParticlesRenderTime;
  138408. private _particlesRenderTime;
  138409. private _captureSpritesRenderTime;
  138410. private _spritesRenderTime;
  138411. private _capturePhysicsTime;
  138412. private _physicsTime;
  138413. private _captureAnimationsTime;
  138414. private _animationsTime;
  138415. private _captureCameraRenderTime;
  138416. private _cameraRenderTime;
  138417. private _onBeforeActiveMeshesEvaluationObserver;
  138418. private _onAfterActiveMeshesEvaluationObserver;
  138419. private _onBeforeRenderTargetsRenderObserver;
  138420. private _onAfterRenderTargetsRenderObserver;
  138421. private _onAfterRenderObserver;
  138422. private _onBeforeDrawPhaseObserver;
  138423. private _onAfterDrawPhaseObserver;
  138424. private _onBeforeAnimationsObserver;
  138425. private _onBeforeParticlesRenderingObserver;
  138426. private _onAfterParticlesRenderingObserver;
  138427. private _onBeforeSpritesRenderingObserver;
  138428. private _onAfterSpritesRenderingObserver;
  138429. private _onBeforePhysicsObserver;
  138430. private _onAfterPhysicsObserver;
  138431. private _onAfterAnimationsObserver;
  138432. private _onBeforeCameraRenderObserver;
  138433. private _onAfterCameraRenderObserver;
  138434. /**
  138435. * Gets the perf counter used for active meshes evaluation time
  138436. */
  138437. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  138438. /**
  138439. * Gets the active meshes evaluation time capture status
  138440. */
  138441. get captureActiveMeshesEvaluationTime(): boolean;
  138442. /**
  138443. * Enable or disable the active meshes evaluation time capture
  138444. */
  138445. set captureActiveMeshesEvaluationTime(value: boolean);
  138446. /**
  138447. * Gets the perf counter used for render targets render time
  138448. */
  138449. get renderTargetsRenderTimeCounter(): PerfCounter;
  138450. /**
  138451. * Gets the render targets render time capture status
  138452. */
  138453. get captureRenderTargetsRenderTime(): boolean;
  138454. /**
  138455. * Enable or disable the render targets render time capture
  138456. */
  138457. set captureRenderTargetsRenderTime(value: boolean);
  138458. /**
  138459. * Gets the perf counter used for particles render time
  138460. */
  138461. get particlesRenderTimeCounter(): PerfCounter;
  138462. /**
  138463. * Gets the particles render time capture status
  138464. */
  138465. get captureParticlesRenderTime(): boolean;
  138466. /**
  138467. * Enable or disable the particles render time capture
  138468. */
  138469. set captureParticlesRenderTime(value: boolean);
  138470. /**
  138471. * Gets the perf counter used for sprites render time
  138472. */
  138473. get spritesRenderTimeCounter(): PerfCounter;
  138474. /**
  138475. * Gets the sprites render time capture status
  138476. */
  138477. get captureSpritesRenderTime(): boolean;
  138478. /**
  138479. * Enable or disable the sprites render time capture
  138480. */
  138481. set captureSpritesRenderTime(value: boolean);
  138482. /**
  138483. * Gets the perf counter used for physics time
  138484. */
  138485. get physicsTimeCounter(): PerfCounter;
  138486. /**
  138487. * Gets the physics time capture status
  138488. */
  138489. get capturePhysicsTime(): boolean;
  138490. /**
  138491. * Enable or disable the physics time capture
  138492. */
  138493. set capturePhysicsTime(value: boolean);
  138494. /**
  138495. * Gets the perf counter used for animations time
  138496. */
  138497. get animationsTimeCounter(): PerfCounter;
  138498. /**
  138499. * Gets the animations time capture status
  138500. */
  138501. get captureAnimationsTime(): boolean;
  138502. /**
  138503. * Enable or disable the animations time capture
  138504. */
  138505. set captureAnimationsTime(value: boolean);
  138506. /**
  138507. * Gets the perf counter used for frame time capture
  138508. */
  138509. get frameTimeCounter(): PerfCounter;
  138510. /**
  138511. * Gets the frame time capture status
  138512. */
  138513. get captureFrameTime(): boolean;
  138514. /**
  138515. * Enable or disable the frame time capture
  138516. */
  138517. set captureFrameTime(value: boolean);
  138518. /**
  138519. * Gets the perf counter used for inter-frames time capture
  138520. */
  138521. get interFrameTimeCounter(): PerfCounter;
  138522. /**
  138523. * Gets the inter-frames time capture status
  138524. */
  138525. get captureInterFrameTime(): boolean;
  138526. /**
  138527. * Enable or disable the inter-frames time capture
  138528. */
  138529. set captureInterFrameTime(value: boolean);
  138530. /**
  138531. * Gets the perf counter used for render time capture
  138532. */
  138533. get renderTimeCounter(): PerfCounter;
  138534. /**
  138535. * Gets the render time capture status
  138536. */
  138537. get captureRenderTime(): boolean;
  138538. /**
  138539. * Enable or disable the render time capture
  138540. */
  138541. set captureRenderTime(value: boolean);
  138542. /**
  138543. * Gets the perf counter used for camera render time capture
  138544. */
  138545. get cameraRenderTimeCounter(): PerfCounter;
  138546. /**
  138547. * Gets the camera render time capture status
  138548. */
  138549. get captureCameraRenderTime(): boolean;
  138550. /**
  138551. * Enable or disable the camera render time capture
  138552. */
  138553. set captureCameraRenderTime(value: boolean);
  138554. /**
  138555. * Gets the perf counter used for draw calls
  138556. */
  138557. get drawCallsCounter(): PerfCounter;
  138558. /**
  138559. * Instantiates a new scene instrumentation.
  138560. * This class can be used to get instrumentation data from a Babylon engine
  138561. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138562. * @param scene Defines the scene to instrument
  138563. */
  138564. constructor(
  138565. /**
  138566. * Defines the scene to instrument
  138567. */
  138568. scene: Scene);
  138569. /**
  138570. * Dispose and release associated resources.
  138571. */
  138572. dispose(): void;
  138573. }
  138574. }
  138575. declare module BABYLON {
  138576. /** @hidden */
  138577. export var glowMapGenerationPixelShader: {
  138578. name: string;
  138579. shader: string;
  138580. };
  138581. }
  138582. declare module BABYLON {
  138583. /** @hidden */
  138584. export var glowMapGenerationVertexShader: {
  138585. name: string;
  138586. shader: string;
  138587. };
  138588. }
  138589. declare module BABYLON {
  138590. /**
  138591. * Effect layer options. This helps customizing the behaviour
  138592. * of the effect layer.
  138593. */
  138594. export interface IEffectLayerOptions {
  138595. /**
  138596. * Multiplication factor apply to the canvas size to compute the render target size
  138597. * used to generated the objects (the smaller the faster).
  138598. */
  138599. mainTextureRatio: number;
  138600. /**
  138601. * Enforces a fixed size texture to ensure effect stability across devices.
  138602. */
  138603. mainTextureFixedSize?: number;
  138604. /**
  138605. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  138606. */
  138607. alphaBlendingMode: number;
  138608. /**
  138609. * The camera attached to the layer.
  138610. */
  138611. camera: Nullable<Camera>;
  138612. /**
  138613. * The rendering group to draw the layer in.
  138614. */
  138615. renderingGroupId: number;
  138616. }
  138617. /**
  138618. * The effect layer Helps adding post process effect blended with the main pass.
  138619. *
  138620. * This can be for instance use to generate glow or higlight effects on the scene.
  138621. *
  138622. * The effect layer class can not be used directly and is intented to inherited from to be
  138623. * customized per effects.
  138624. */
  138625. export abstract class EffectLayer {
  138626. private _vertexBuffers;
  138627. private _indexBuffer;
  138628. private _cachedDefines;
  138629. private _effectLayerMapGenerationEffect;
  138630. private _effectLayerOptions;
  138631. private _mergeEffect;
  138632. protected _scene: Scene;
  138633. protected _engine: Engine;
  138634. protected _maxSize: number;
  138635. protected _mainTextureDesiredSize: ISize;
  138636. protected _mainTexture: RenderTargetTexture;
  138637. protected _shouldRender: boolean;
  138638. protected _postProcesses: PostProcess[];
  138639. protected _textures: BaseTexture[];
  138640. protected _emissiveTextureAndColor: {
  138641. texture: Nullable<BaseTexture>;
  138642. color: Color4;
  138643. };
  138644. /**
  138645. * The name of the layer
  138646. */
  138647. name: string;
  138648. /**
  138649. * The clear color of the texture used to generate the glow map.
  138650. */
  138651. neutralColor: Color4;
  138652. /**
  138653. * Specifies whether the highlight layer is enabled or not.
  138654. */
  138655. isEnabled: boolean;
  138656. /**
  138657. * Gets the camera attached to the layer.
  138658. */
  138659. get camera(): Nullable<Camera>;
  138660. /**
  138661. * Gets the rendering group id the layer should render in.
  138662. */
  138663. get renderingGroupId(): number;
  138664. set renderingGroupId(renderingGroupId: number);
  138665. /**
  138666. * An event triggered when the effect layer has been disposed.
  138667. */
  138668. onDisposeObservable: Observable<EffectLayer>;
  138669. /**
  138670. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  138671. */
  138672. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  138673. /**
  138674. * An event triggered when the generated texture is being merged in the scene.
  138675. */
  138676. onBeforeComposeObservable: Observable<EffectLayer>;
  138677. /**
  138678. * An event triggered when the mesh is rendered into the effect render target.
  138679. */
  138680. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  138681. /**
  138682. * An event triggered after the mesh has been rendered into the effect render target.
  138683. */
  138684. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  138685. /**
  138686. * An event triggered when the generated texture has been merged in the scene.
  138687. */
  138688. onAfterComposeObservable: Observable<EffectLayer>;
  138689. /**
  138690. * An event triggered when the efffect layer changes its size.
  138691. */
  138692. onSizeChangedObservable: Observable<EffectLayer>;
  138693. /** @hidden */
  138694. static _SceneComponentInitialization: (scene: Scene) => void;
  138695. /**
  138696. * Instantiates a new effect Layer and references it in the scene.
  138697. * @param name The name of the layer
  138698. * @param scene The scene to use the layer in
  138699. */
  138700. constructor(
  138701. /** The Friendly of the effect in the scene */
  138702. name: string, scene: Scene);
  138703. /**
  138704. * Get the effect name of the layer.
  138705. * @return The effect name
  138706. */
  138707. abstract getEffectName(): string;
  138708. /**
  138709. * Checks for the readiness of the element composing the layer.
  138710. * @param subMesh the mesh to check for
  138711. * @param useInstances specify whether or not to use instances to render the mesh
  138712. * @return true if ready otherwise, false
  138713. */
  138714. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138715. /**
  138716. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138717. * @returns true if the effect requires stencil during the main canvas render pass.
  138718. */
  138719. abstract needStencil(): boolean;
  138720. /**
  138721. * Create the merge effect. This is the shader use to blit the information back
  138722. * to the main canvas at the end of the scene rendering.
  138723. * @returns The effect containing the shader used to merge the effect on the main canvas
  138724. */
  138725. protected abstract _createMergeEffect(): Effect;
  138726. /**
  138727. * Creates the render target textures and post processes used in the effect layer.
  138728. */
  138729. protected abstract _createTextureAndPostProcesses(): void;
  138730. /**
  138731. * Implementation specific of rendering the generating effect on the main canvas.
  138732. * @param effect The effect used to render through
  138733. */
  138734. protected abstract _internalRender(effect: Effect): void;
  138735. /**
  138736. * Sets the required values for both the emissive texture and and the main color.
  138737. */
  138738. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138739. /**
  138740. * Free any resources and references associated to a mesh.
  138741. * Internal use
  138742. * @param mesh The mesh to free.
  138743. */
  138744. abstract _disposeMesh(mesh: Mesh): void;
  138745. /**
  138746. * Serializes this layer (Glow or Highlight for example)
  138747. * @returns a serialized layer object
  138748. */
  138749. abstract serialize?(): any;
  138750. /**
  138751. * Initializes the effect layer with the required options.
  138752. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  138753. */
  138754. protected _init(options: Partial<IEffectLayerOptions>): void;
  138755. /**
  138756. * Generates the index buffer of the full screen quad blending to the main canvas.
  138757. */
  138758. private _generateIndexBuffer;
  138759. /**
  138760. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  138761. */
  138762. private _generateVertexBuffer;
  138763. /**
  138764. * Sets the main texture desired size which is the closest power of two
  138765. * of the engine canvas size.
  138766. */
  138767. private _setMainTextureSize;
  138768. /**
  138769. * Creates the main texture for the effect layer.
  138770. */
  138771. protected _createMainTexture(): void;
  138772. /**
  138773. * Adds specific effects defines.
  138774. * @param defines The defines to add specifics to.
  138775. */
  138776. protected _addCustomEffectDefines(defines: string[]): void;
  138777. /**
  138778. * Checks for the readiness of the element composing the layer.
  138779. * @param subMesh the mesh to check for
  138780. * @param useInstances specify whether or not to use instances to render the mesh
  138781. * @param emissiveTexture the associated emissive texture used to generate the glow
  138782. * @return true if ready otherwise, false
  138783. */
  138784. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  138785. /**
  138786. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  138787. */
  138788. render(): void;
  138789. /**
  138790. * Determine if a given mesh will be used in the current effect.
  138791. * @param mesh mesh to test
  138792. * @returns true if the mesh will be used
  138793. */
  138794. hasMesh(mesh: AbstractMesh): boolean;
  138795. /**
  138796. * Returns true if the layer contains information to display, otherwise false.
  138797. * @returns true if the glow layer should be rendered
  138798. */
  138799. shouldRender(): boolean;
  138800. /**
  138801. * Returns true if the mesh should render, otherwise false.
  138802. * @param mesh The mesh to render
  138803. * @returns true if it should render otherwise false
  138804. */
  138805. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  138806. /**
  138807. * Returns true if the mesh can be rendered, otherwise false.
  138808. * @param mesh The mesh to render
  138809. * @param material The material used on the mesh
  138810. * @returns true if it can be rendered otherwise false
  138811. */
  138812. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138813. /**
  138814. * Returns true if the mesh should render, otherwise false.
  138815. * @param mesh The mesh to render
  138816. * @returns true if it should render otherwise false
  138817. */
  138818. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  138819. /**
  138820. * Renders the submesh passed in parameter to the generation map.
  138821. */
  138822. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  138823. /**
  138824. * Defines whether the current material of the mesh should be use to render the effect.
  138825. * @param mesh defines the current mesh to render
  138826. */
  138827. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138828. /**
  138829. * Rebuild the required buffers.
  138830. * @hidden Internal use only.
  138831. */
  138832. _rebuild(): void;
  138833. /**
  138834. * Dispose only the render target textures and post process.
  138835. */
  138836. private _disposeTextureAndPostProcesses;
  138837. /**
  138838. * Dispose the highlight layer and free resources.
  138839. */
  138840. dispose(): void;
  138841. /**
  138842. * Gets the class name of the effect layer
  138843. * @returns the string with the class name of the effect layer
  138844. */
  138845. getClassName(): string;
  138846. /**
  138847. * Creates an effect layer from parsed effect layer data
  138848. * @param parsedEffectLayer defines effect layer data
  138849. * @param scene defines the current scene
  138850. * @param rootUrl defines the root URL containing the effect layer information
  138851. * @returns a parsed effect Layer
  138852. */
  138853. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  138854. }
  138855. }
  138856. declare module BABYLON {
  138857. interface AbstractScene {
  138858. /**
  138859. * The list of effect layers (highlights/glow) added to the scene
  138860. * @see https://doc.babylonjs.com/how_to/highlight_layer
  138861. * @see https://doc.babylonjs.com/how_to/glow_layer
  138862. */
  138863. effectLayers: Array<EffectLayer>;
  138864. /**
  138865. * Removes the given effect layer from this scene.
  138866. * @param toRemove defines the effect layer to remove
  138867. * @returns the index of the removed effect layer
  138868. */
  138869. removeEffectLayer(toRemove: EffectLayer): number;
  138870. /**
  138871. * Adds the given effect layer to this scene
  138872. * @param newEffectLayer defines the effect layer to add
  138873. */
  138874. addEffectLayer(newEffectLayer: EffectLayer): void;
  138875. }
  138876. /**
  138877. * Defines the layer scene component responsible to manage any effect layers
  138878. * in a given scene.
  138879. */
  138880. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  138881. /**
  138882. * The component name helpfull to identify the component in the list of scene components.
  138883. */
  138884. readonly name: string;
  138885. /**
  138886. * The scene the component belongs to.
  138887. */
  138888. scene: Scene;
  138889. private _engine;
  138890. private _renderEffects;
  138891. private _needStencil;
  138892. private _previousStencilState;
  138893. /**
  138894. * Creates a new instance of the component for the given scene
  138895. * @param scene Defines the scene to register the component in
  138896. */
  138897. constructor(scene: Scene);
  138898. /**
  138899. * Registers the component in a given scene
  138900. */
  138901. register(): void;
  138902. /**
  138903. * Rebuilds the elements related to this component in case of
  138904. * context lost for instance.
  138905. */
  138906. rebuild(): void;
  138907. /**
  138908. * Serializes the component data to the specified json object
  138909. * @param serializationObject The object to serialize to
  138910. */
  138911. serialize(serializationObject: any): void;
  138912. /**
  138913. * Adds all the elements from the container to the scene
  138914. * @param container the container holding the elements
  138915. */
  138916. addFromContainer(container: AbstractScene): void;
  138917. /**
  138918. * Removes all the elements in the container from the scene
  138919. * @param container contains the elements to remove
  138920. * @param dispose if the removed element should be disposed (default: false)
  138921. */
  138922. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138923. /**
  138924. * Disposes the component and the associated ressources.
  138925. */
  138926. dispose(): void;
  138927. private _isReadyForMesh;
  138928. private _renderMainTexture;
  138929. private _setStencil;
  138930. private _setStencilBack;
  138931. private _draw;
  138932. private _drawCamera;
  138933. private _drawRenderingGroup;
  138934. }
  138935. }
  138936. declare module BABYLON {
  138937. /** @hidden */
  138938. export var glowMapMergePixelShader: {
  138939. name: string;
  138940. shader: string;
  138941. };
  138942. }
  138943. declare module BABYLON {
  138944. /** @hidden */
  138945. export var glowMapMergeVertexShader: {
  138946. name: string;
  138947. shader: string;
  138948. };
  138949. }
  138950. declare module BABYLON {
  138951. interface AbstractScene {
  138952. /**
  138953. * Return a the first highlight layer of the scene with a given name.
  138954. * @param name The name of the highlight layer to look for.
  138955. * @return The highlight layer if found otherwise null.
  138956. */
  138957. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  138958. }
  138959. /**
  138960. * Glow layer options. This helps customizing the behaviour
  138961. * of the glow layer.
  138962. */
  138963. export interface IGlowLayerOptions {
  138964. /**
  138965. * Multiplication factor apply to the canvas size to compute the render target size
  138966. * used to generated the glowing objects (the smaller the faster).
  138967. */
  138968. mainTextureRatio: number;
  138969. /**
  138970. * Enforces a fixed size texture to ensure resize independant blur.
  138971. */
  138972. mainTextureFixedSize?: number;
  138973. /**
  138974. * How big is the kernel of the blur texture.
  138975. */
  138976. blurKernelSize: number;
  138977. /**
  138978. * The camera attached to the layer.
  138979. */
  138980. camera: Nullable<Camera>;
  138981. /**
  138982. * Enable MSAA by chosing the number of samples.
  138983. */
  138984. mainTextureSamples?: number;
  138985. /**
  138986. * The rendering group to draw the layer in.
  138987. */
  138988. renderingGroupId: number;
  138989. }
  138990. /**
  138991. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  138992. *
  138993. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  138994. *
  138995. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  138996. */
  138997. export class GlowLayer extends EffectLayer {
  138998. /**
  138999. * Effect Name of the layer.
  139000. */
  139001. static readonly EffectName: string;
  139002. /**
  139003. * The default blur kernel size used for the glow.
  139004. */
  139005. static DefaultBlurKernelSize: number;
  139006. /**
  139007. * The default texture size ratio used for the glow.
  139008. */
  139009. static DefaultTextureRatio: number;
  139010. /**
  139011. * Sets the kernel size of the blur.
  139012. */
  139013. set blurKernelSize(value: number);
  139014. /**
  139015. * Gets the kernel size of the blur.
  139016. */
  139017. get blurKernelSize(): number;
  139018. /**
  139019. * Sets the glow intensity.
  139020. */
  139021. set intensity(value: number);
  139022. /**
  139023. * Gets the glow intensity.
  139024. */
  139025. get intensity(): number;
  139026. private _options;
  139027. private _intensity;
  139028. private _horizontalBlurPostprocess1;
  139029. private _verticalBlurPostprocess1;
  139030. private _horizontalBlurPostprocess2;
  139031. private _verticalBlurPostprocess2;
  139032. private _blurTexture1;
  139033. private _blurTexture2;
  139034. private _postProcesses1;
  139035. private _postProcesses2;
  139036. private _includedOnlyMeshes;
  139037. private _excludedMeshes;
  139038. private _meshesUsingTheirOwnMaterials;
  139039. /**
  139040. * Callback used to let the user override the color selection on a per mesh basis
  139041. */
  139042. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  139043. /**
  139044. * Callback used to let the user override the texture selection on a per mesh basis
  139045. */
  139046. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  139047. /**
  139048. * Instantiates a new glow Layer and references it to the scene.
  139049. * @param name The name of the layer
  139050. * @param scene The scene to use the layer in
  139051. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  139052. */
  139053. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  139054. /**
  139055. * Get the effect name of the layer.
  139056. * @return The effect name
  139057. */
  139058. getEffectName(): string;
  139059. /**
  139060. * Create the merge effect. This is the shader use to blit the information back
  139061. * to the main canvas at the end of the scene rendering.
  139062. */
  139063. protected _createMergeEffect(): Effect;
  139064. /**
  139065. * Creates the render target textures and post processes used in the glow layer.
  139066. */
  139067. protected _createTextureAndPostProcesses(): void;
  139068. /**
  139069. * Checks for the readiness of the element composing the layer.
  139070. * @param subMesh the mesh to check for
  139071. * @param useInstances specify wether or not to use instances to render the mesh
  139072. * @param emissiveTexture the associated emissive texture used to generate the glow
  139073. * @return true if ready otherwise, false
  139074. */
  139075. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139076. /**
  139077. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139078. */
  139079. needStencil(): boolean;
  139080. /**
  139081. * Returns true if the mesh can be rendered, otherwise false.
  139082. * @param mesh The mesh to render
  139083. * @param material The material used on the mesh
  139084. * @returns true if it can be rendered otherwise false
  139085. */
  139086. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139087. /**
  139088. * Implementation specific of rendering the generating effect on the main canvas.
  139089. * @param effect The effect used to render through
  139090. */
  139091. protected _internalRender(effect: Effect): void;
  139092. /**
  139093. * Sets the required values for both the emissive texture and and the main color.
  139094. */
  139095. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139096. /**
  139097. * Returns true if the mesh should render, otherwise false.
  139098. * @param mesh The mesh to render
  139099. * @returns true if it should render otherwise false
  139100. */
  139101. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139102. /**
  139103. * Adds specific effects defines.
  139104. * @param defines The defines to add specifics to.
  139105. */
  139106. protected _addCustomEffectDefines(defines: string[]): void;
  139107. /**
  139108. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  139109. * @param mesh The mesh to exclude from the glow layer
  139110. */
  139111. addExcludedMesh(mesh: Mesh): void;
  139112. /**
  139113. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  139114. * @param mesh The mesh to remove
  139115. */
  139116. removeExcludedMesh(mesh: Mesh): void;
  139117. /**
  139118. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  139119. * @param mesh The mesh to include in the glow layer
  139120. */
  139121. addIncludedOnlyMesh(mesh: Mesh): void;
  139122. /**
  139123. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  139124. * @param mesh The mesh to remove
  139125. */
  139126. removeIncludedOnlyMesh(mesh: Mesh): void;
  139127. /**
  139128. * Determine if a given mesh will be used in the glow layer
  139129. * @param mesh The mesh to test
  139130. * @returns true if the mesh will be highlighted by the current glow layer
  139131. */
  139132. hasMesh(mesh: AbstractMesh): boolean;
  139133. /**
  139134. * Defines whether the current material of the mesh should be use to render the effect.
  139135. * @param mesh defines the current mesh to render
  139136. */
  139137. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139138. /**
  139139. * Add a mesh to be rendered through its own material and not with emissive only.
  139140. * @param mesh The mesh for which we need to use its material
  139141. */
  139142. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  139143. /**
  139144. * Remove a mesh from being rendered through its own material and not with emissive only.
  139145. * @param mesh The mesh for which we need to not use its material
  139146. */
  139147. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  139148. /**
  139149. * Free any resources and references associated to a mesh.
  139150. * Internal use
  139151. * @param mesh The mesh to free.
  139152. * @hidden
  139153. */
  139154. _disposeMesh(mesh: Mesh): void;
  139155. /**
  139156. * Gets the class name of the effect layer
  139157. * @returns the string with the class name of the effect layer
  139158. */
  139159. getClassName(): string;
  139160. /**
  139161. * Serializes this glow layer
  139162. * @returns a serialized glow layer object
  139163. */
  139164. serialize(): any;
  139165. /**
  139166. * Creates a Glow Layer from parsed glow layer data
  139167. * @param parsedGlowLayer defines glow layer data
  139168. * @param scene defines the current scene
  139169. * @param rootUrl defines the root URL containing the glow layer information
  139170. * @returns a parsed Glow Layer
  139171. */
  139172. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  139173. }
  139174. }
  139175. declare module BABYLON {
  139176. /** @hidden */
  139177. export var glowBlurPostProcessPixelShader: {
  139178. name: string;
  139179. shader: string;
  139180. };
  139181. }
  139182. declare module BABYLON {
  139183. interface AbstractScene {
  139184. /**
  139185. * Return a the first highlight layer of the scene with a given name.
  139186. * @param name The name of the highlight layer to look for.
  139187. * @return The highlight layer if found otherwise null.
  139188. */
  139189. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  139190. }
  139191. /**
  139192. * Highlight layer options. This helps customizing the behaviour
  139193. * of the highlight layer.
  139194. */
  139195. export interface IHighlightLayerOptions {
  139196. /**
  139197. * Multiplication factor apply to the canvas size to compute the render target size
  139198. * used to generated the glowing objects (the smaller the faster).
  139199. */
  139200. mainTextureRatio: number;
  139201. /**
  139202. * Enforces a fixed size texture to ensure resize independant blur.
  139203. */
  139204. mainTextureFixedSize?: number;
  139205. /**
  139206. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  139207. * of the picture to blur (the smaller the faster).
  139208. */
  139209. blurTextureSizeRatio: number;
  139210. /**
  139211. * How big in texel of the blur texture is the vertical blur.
  139212. */
  139213. blurVerticalSize: number;
  139214. /**
  139215. * How big in texel of the blur texture is the horizontal blur.
  139216. */
  139217. blurHorizontalSize: number;
  139218. /**
  139219. * Alpha blending mode used to apply the blur. Default is combine.
  139220. */
  139221. alphaBlendingMode: number;
  139222. /**
  139223. * The camera attached to the layer.
  139224. */
  139225. camera: Nullable<Camera>;
  139226. /**
  139227. * Should we display highlight as a solid stroke?
  139228. */
  139229. isStroke?: boolean;
  139230. /**
  139231. * The rendering group to draw the layer in.
  139232. */
  139233. renderingGroupId: number;
  139234. }
  139235. /**
  139236. * The highlight layer Helps adding a glow effect around a mesh.
  139237. *
  139238. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  139239. * glowy meshes to your scene.
  139240. *
  139241. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  139242. */
  139243. export class HighlightLayer extends EffectLayer {
  139244. name: string;
  139245. /**
  139246. * Effect Name of the highlight layer.
  139247. */
  139248. static readonly EffectName: string;
  139249. /**
  139250. * The neutral color used during the preparation of the glow effect.
  139251. * This is black by default as the blend operation is a blend operation.
  139252. */
  139253. static NeutralColor: Color4;
  139254. /**
  139255. * Stencil value used for glowing meshes.
  139256. */
  139257. static GlowingMeshStencilReference: number;
  139258. /**
  139259. * Stencil value used for the other meshes in the scene.
  139260. */
  139261. static NormalMeshStencilReference: number;
  139262. /**
  139263. * Specifies whether or not the inner glow is ACTIVE in the layer.
  139264. */
  139265. innerGlow: boolean;
  139266. /**
  139267. * Specifies whether or not the outer glow is ACTIVE in the layer.
  139268. */
  139269. outerGlow: boolean;
  139270. /**
  139271. * Specifies the horizontal size of the blur.
  139272. */
  139273. set blurHorizontalSize(value: number);
  139274. /**
  139275. * Specifies the vertical size of the blur.
  139276. */
  139277. set blurVerticalSize(value: number);
  139278. /**
  139279. * Gets the horizontal size of the blur.
  139280. */
  139281. get blurHorizontalSize(): number;
  139282. /**
  139283. * Gets the vertical size of the blur.
  139284. */
  139285. get blurVerticalSize(): number;
  139286. /**
  139287. * An event triggered when the highlight layer is being blurred.
  139288. */
  139289. onBeforeBlurObservable: Observable<HighlightLayer>;
  139290. /**
  139291. * An event triggered when the highlight layer has been blurred.
  139292. */
  139293. onAfterBlurObservable: Observable<HighlightLayer>;
  139294. private _instanceGlowingMeshStencilReference;
  139295. private _options;
  139296. private _downSamplePostprocess;
  139297. private _horizontalBlurPostprocess;
  139298. private _verticalBlurPostprocess;
  139299. private _blurTexture;
  139300. private _meshes;
  139301. private _excludedMeshes;
  139302. /**
  139303. * Instantiates a new highlight Layer and references it to the scene..
  139304. * @param name The name of the layer
  139305. * @param scene The scene to use the layer in
  139306. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  139307. */
  139308. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  139309. /**
  139310. * Get the effect name of the layer.
  139311. * @return The effect name
  139312. */
  139313. getEffectName(): string;
  139314. /**
  139315. * Create the merge effect. This is the shader use to blit the information back
  139316. * to the main canvas at the end of the scene rendering.
  139317. */
  139318. protected _createMergeEffect(): Effect;
  139319. /**
  139320. * Creates the render target textures and post processes used in the highlight layer.
  139321. */
  139322. protected _createTextureAndPostProcesses(): void;
  139323. /**
  139324. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  139325. */
  139326. needStencil(): boolean;
  139327. /**
  139328. * Checks for the readiness of the element composing the layer.
  139329. * @param subMesh the mesh to check for
  139330. * @param useInstances specify wether or not to use instances to render the mesh
  139331. * @param emissiveTexture the associated emissive texture used to generate the glow
  139332. * @return true if ready otherwise, false
  139333. */
  139334. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139335. /**
  139336. * Implementation specific of rendering the generating effect on the main canvas.
  139337. * @param effect The effect used to render through
  139338. */
  139339. protected _internalRender(effect: Effect): void;
  139340. /**
  139341. * Returns true if the layer contains information to display, otherwise false.
  139342. */
  139343. shouldRender(): boolean;
  139344. /**
  139345. * Returns true if the mesh should render, otherwise false.
  139346. * @param mesh The mesh to render
  139347. * @returns true if it should render otherwise false
  139348. */
  139349. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139350. /**
  139351. * Returns true if the mesh can be rendered, otherwise false.
  139352. * @param mesh The mesh to render
  139353. * @param material The material used on the mesh
  139354. * @returns true if it can be rendered otherwise false
  139355. */
  139356. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139357. /**
  139358. * Adds specific effects defines.
  139359. * @param defines The defines to add specifics to.
  139360. */
  139361. protected _addCustomEffectDefines(defines: string[]): void;
  139362. /**
  139363. * Sets the required values for both the emissive texture and and the main color.
  139364. */
  139365. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139366. /**
  139367. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  139368. * @param mesh The mesh to exclude from the highlight layer
  139369. */
  139370. addExcludedMesh(mesh: Mesh): void;
  139371. /**
  139372. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  139373. * @param mesh The mesh to highlight
  139374. */
  139375. removeExcludedMesh(mesh: Mesh): void;
  139376. /**
  139377. * Determine if a given mesh will be highlighted by the current HighlightLayer
  139378. * @param mesh mesh to test
  139379. * @returns true if the mesh will be highlighted by the current HighlightLayer
  139380. */
  139381. hasMesh(mesh: AbstractMesh): boolean;
  139382. /**
  139383. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  139384. * @param mesh The mesh to highlight
  139385. * @param color The color of the highlight
  139386. * @param glowEmissiveOnly Extract the glow from the emissive texture
  139387. */
  139388. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  139389. /**
  139390. * Remove a mesh from the highlight layer in order to make it stop glowing.
  139391. * @param mesh The mesh to highlight
  139392. */
  139393. removeMesh(mesh: Mesh): void;
  139394. /**
  139395. * Remove all the meshes currently referenced in the highlight layer
  139396. */
  139397. removeAllMeshes(): void;
  139398. /**
  139399. * Force the stencil to the normal expected value for none glowing parts
  139400. */
  139401. private _defaultStencilReference;
  139402. /**
  139403. * Free any resources and references associated to a mesh.
  139404. * Internal use
  139405. * @param mesh The mesh to free.
  139406. * @hidden
  139407. */
  139408. _disposeMesh(mesh: Mesh): void;
  139409. /**
  139410. * Dispose the highlight layer and free resources.
  139411. */
  139412. dispose(): void;
  139413. /**
  139414. * Gets the class name of the effect layer
  139415. * @returns the string with the class name of the effect layer
  139416. */
  139417. getClassName(): string;
  139418. /**
  139419. * Serializes this Highlight layer
  139420. * @returns a serialized Highlight layer object
  139421. */
  139422. serialize(): any;
  139423. /**
  139424. * Creates a Highlight layer from parsed Highlight layer data
  139425. * @param parsedHightlightLayer defines the Highlight layer data
  139426. * @param scene defines the current scene
  139427. * @param rootUrl defines the root URL containing the Highlight layer information
  139428. * @returns a parsed Highlight layer
  139429. */
  139430. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  139431. }
  139432. }
  139433. declare module BABYLON {
  139434. interface AbstractScene {
  139435. /**
  139436. * The list of layers (background and foreground) of the scene
  139437. */
  139438. layers: Array<Layer>;
  139439. }
  139440. /**
  139441. * Defines the layer scene component responsible to manage any layers
  139442. * in a given scene.
  139443. */
  139444. export class LayerSceneComponent implements ISceneComponent {
  139445. /**
  139446. * The component name helpfull to identify the component in the list of scene components.
  139447. */
  139448. readonly name: string;
  139449. /**
  139450. * The scene the component belongs to.
  139451. */
  139452. scene: Scene;
  139453. private _engine;
  139454. /**
  139455. * Creates a new instance of the component for the given scene
  139456. * @param scene Defines the scene to register the component in
  139457. */
  139458. constructor(scene: Scene);
  139459. /**
  139460. * Registers the component in a given scene
  139461. */
  139462. register(): void;
  139463. /**
  139464. * Rebuilds the elements related to this component in case of
  139465. * context lost for instance.
  139466. */
  139467. rebuild(): void;
  139468. /**
  139469. * Disposes the component and the associated ressources.
  139470. */
  139471. dispose(): void;
  139472. private _draw;
  139473. private _drawCameraPredicate;
  139474. private _drawCameraBackground;
  139475. private _drawCameraForeground;
  139476. private _drawRenderTargetPredicate;
  139477. private _drawRenderTargetBackground;
  139478. private _drawRenderTargetForeground;
  139479. /**
  139480. * Adds all the elements from the container to the scene
  139481. * @param container the container holding the elements
  139482. */
  139483. addFromContainer(container: AbstractScene): void;
  139484. /**
  139485. * Removes all the elements in the container from the scene
  139486. * @param container contains the elements to remove
  139487. * @param dispose if the removed element should be disposed (default: false)
  139488. */
  139489. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139490. }
  139491. }
  139492. declare module BABYLON {
  139493. /** @hidden */
  139494. export var layerPixelShader: {
  139495. name: string;
  139496. shader: string;
  139497. };
  139498. }
  139499. declare module BABYLON {
  139500. /** @hidden */
  139501. export var layerVertexShader: {
  139502. name: string;
  139503. shader: string;
  139504. };
  139505. }
  139506. declare module BABYLON {
  139507. /**
  139508. * This represents a full screen 2d layer.
  139509. * This can be useful to display a picture in the background of your scene for instance.
  139510. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139511. */
  139512. export class Layer {
  139513. /**
  139514. * Define the name of the layer.
  139515. */
  139516. name: string;
  139517. /**
  139518. * Define the texture the layer should display.
  139519. */
  139520. texture: Nullable<Texture>;
  139521. /**
  139522. * Is the layer in background or foreground.
  139523. */
  139524. isBackground: boolean;
  139525. /**
  139526. * Define the color of the layer (instead of texture).
  139527. */
  139528. color: Color4;
  139529. /**
  139530. * Define the scale of the layer in order to zoom in out of the texture.
  139531. */
  139532. scale: Vector2;
  139533. /**
  139534. * Define an offset for the layer in order to shift the texture.
  139535. */
  139536. offset: Vector2;
  139537. /**
  139538. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  139539. */
  139540. alphaBlendingMode: number;
  139541. /**
  139542. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  139543. * Alpha test will not mix with the background color in case of transparency.
  139544. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  139545. */
  139546. alphaTest: boolean;
  139547. /**
  139548. * Define a mask to restrict the layer to only some of the scene cameras.
  139549. */
  139550. layerMask: number;
  139551. /**
  139552. * Define the list of render target the layer is visible into.
  139553. */
  139554. renderTargetTextures: RenderTargetTexture[];
  139555. /**
  139556. * Define if the layer is only used in renderTarget or if it also
  139557. * renders in the main frame buffer of the canvas.
  139558. */
  139559. renderOnlyInRenderTargetTextures: boolean;
  139560. private _scene;
  139561. private _vertexBuffers;
  139562. private _indexBuffer;
  139563. private _effect;
  139564. private _previousDefines;
  139565. /**
  139566. * An event triggered when the layer is disposed.
  139567. */
  139568. onDisposeObservable: Observable<Layer>;
  139569. private _onDisposeObserver;
  139570. /**
  139571. * Back compatibility with callback before the onDisposeObservable existed.
  139572. * The set callback will be triggered when the layer has been disposed.
  139573. */
  139574. set onDispose(callback: () => void);
  139575. /**
  139576. * An event triggered before rendering the scene
  139577. */
  139578. onBeforeRenderObservable: Observable<Layer>;
  139579. private _onBeforeRenderObserver;
  139580. /**
  139581. * Back compatibility with callback before the onBeforeRenderObservable existed.
  139582. * The set callback will be triggered just before rendering the layer.
  139583. */
  139584. set onBeforeRender(callback: () => void);
  139585. /**
  139586. * An event triggered after rendering the scene
  139587. */
  139588. onAfterRenderObservable: Observable<Layer>;
  139589. private _onAfterRenderObserver;
  139590. /**
  139591. * Back compatibility with callback before the onAfterRenderObservable existed.
  139592. * The set callback will be triggered just after rendering the layer.
  139593. */
  139594. set onAfterRender(callback: () => void);
  139595. /**
  139596. * Instantiates a new layer.
  139597. * This represents a full screen 2d layer.
  139598. * This can be useful to display a picture in the background of your scene for instance.
  139599. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139600. * @param name Define the name of the layer in the scene
  139601. * @param imgUrl Define the url of the texture to display in the layer
  139602. * @param scene Define the scene the layer belongs to
  139603. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  139604. * @param color Defines a color for the layer
  139605. */
  139606. constructor(
  139607. /**
  139608. * Define the name of the layer.
  139609. */
  139610. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  139611. private _createIndexBuffer;
  139612. /** @hidden */
  139613. _rebuild(): void;
  139614. /**
  139615. * Renders the layer in the scene.
  139616. */
  139617. render(): void;
  139618. /**
  139619. * Disposes and releases the associated ressources.
  139620. */
  139621. dispose(): void;
  139622. }
  139623. }
  139624. declare module BABYLON {
  139625. /** @hidden */
  139626. export var lensFlarePixelShader: {
  139627. name: string;
  139628. shader: string;
  139629. };
  139630. }
  139631. declare module BABYLON {
  139632. /** @hidden */
  139633. export var lensFlareVertexShader: {
  139634. name: string;
  139635. shader: string;
  139636. };
  139637. }
  139638. declare module BABYLON {
  139639. /**
  139640. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139641. * It is usually composed of several `lensFlare`.
  139642. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139643. */
  139644. export class LensFlareSystem {
  139645. /**
  139646. * Define the name of the lens flare system
  139647. */
  139648. name: string;
  139649. /**
  139650. * List of lens flares used in this system.
  139651. */
  139652. lensFlares: LensFlare[];
  139653. /**
  139654. * Define a limit from the border the lens flare can be visible.
  139655. */
  139656. borderLimit: number;
  139657. /**
  139658. * Define a viewport border we do not want to see the lens flare in.
  139659. */
  139660. viewportBorder: number;
  139661. /**
  139662. * Define a predicate which could limit the list of meshes able to occlude the effect.
  139663. */
  139664. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  139665. /**
  139666. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  139667. */
  139668. layerMask: number;
  139669. /**
  139670. * Define the id of the lens flare system in the scene.
  139671. * (equal to name by default)
  139672. */
  139673. id: string;
  139674. private _scene;
  139675. private _emitter;
  139676. private _vertexBuffers;
  139677. private _indexBuffer;
  139678. private _effect;
  139679. private _positionX;
  139680. private _positionY;
  139681. private _isEnabled;
  139682. /** @hidden */
  139683. static _SceneComponentInitialization: (scene: Scene) => void;
  139684. /**
  139685. * Instantiates a lens flare system.
  139686. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139687. * It is usually composed of several `lensFlare`.
  139688. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139689. * @param name Define the name of the lens flare system in the scene
  139690. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  139691. * @param scene Define the scene the lens flare system belongs to
  139692. */
  139693. constructor(
  139694. /**
  139695. * Define the name of the lens flare system
  139696. */
  139697. name: string, emitter: any, scene: Scene);
  139698. /**
  139699. * Define if the lens flare system is enabled.
  139700. */
  139701. get isEnabled(): boolean;
  139702. set isEnabled(value: boolean);
  139703. /**
  139704. * Get the scene the effects belongs to.
  139705. * @returns the scene holding the lens flare system
  139706. */
  139707. getScene(): Scene;
  139708. /**
  139709. * Get the emitter of the lens flare system.
  139710. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139711. * @returns the emitter of the lens flare system
  139712. */
  139713. getEmitter(): any;
  139714. /**
  139715. * Set the emitter of the lens flare system.
  139716. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139717. * @param newEmitter Define the new emitter of the system
  139718. */
  139719. setEmitter(newEmitter: any): void;
  139720. /**
  139721. * Get the lens flare system emitter position.
  139722. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  139723. * @returns the position
  139724. */
  139725. getEmitterPosition(): Vector3;
  139726. /**
  139727. * @hidden
  139728. */
  139729. computeEffectivePosition(globalViewport: Viewport): boolean;
  139730. /** @hidden */
  139731. _isVisible(): boolean;
  139732. /**
  139733. * @hidden
  139734. */
  139735. render(): boolean;
  139736. /**
  139737. * Dispose and release the lens flare with its associated resources.
  139738. */
  139739. dispose(): void;
  139740. /**
  139741. * Parse a lens flare system from a JSON repressentation
  139742. * @param parsedLensFlareSystem Define the JSON to parse
  139743. * @param scene Define the scene the parsed system should be instantiated in
  139744. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  139745. * @returns the parsed system
  139746. */
  139747. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  139748. /**
  139749. * Serialize the current Lens Flare System into a JSON representation.
  139750. * @returns the serialized JSON
  139751. */
  139752. serialize(): any;
  139753. }
  139754. }
  139755. declare module BABYLON {
  139756. /**
  139757. * This represents one of the lens effect in a `lensFlareSystem`.
  139758. * It controls one of the indiviual texture used in the effect.
  139759. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139760. */
  139761. export class LensFlare {
  139762. /**
  139763. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139764. */
  139765. size: number;
  139766. /**
  139767. * 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.
  139768. */
  139769. position: number;
  139770. /**
  139771. * Define the lens color.
  139772. */
  139773. color: Color3;
  139774. /**
  139775. * Define the lens texture.
  139776. */
  139777. texture: Nullable<Texture>;
  139778. /**
  139779. * Define the alpha mode to render this particular lens.
  139780. */
  139781. alphaMode: number;
  139782. private _system;
  139783. /**
  139784. * Creates a new Lens Flare.
  139785. * This represents one of the lens effect in a `lensFlareSystem`.
  139786. * It controls one of the indiviual texture used in the effect.
  139787. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139788. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  139789. * @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.
  139790. * @param color Define the lens color
  139791. * @param imgUrl Define the lens texture url
  139792. * @param system Define the `lensFlareSystem` this flare is part of
  139793. * @returns The newly created Lens Flare
  139794. */
  139795. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  139796. /**
  139797. * Instantiates a new Lens Flare.
  139798. * This represents one of the lens effect in a `lensFlareSystem`.
  139799. * It controls one of the indiviual texture used in the effect.
  139800. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139801. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  139802. * @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.
  139803. * @param color Define the lens color
  139804. * @param imgUrl Define the lens texture url
  139805. * @param system Define the `lensFlareSystem` this flare is part of
  139806. */
  139807. constructor(
  139808. /**
  139809. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139810. */
  139811. size: number,
  139812. /**
  139813. * 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.
  139814. */
  139815. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  139816. /**
  139817. * Dispose and release the lens flare with its associated resources.
  139818. */
  139819. dispose(): void;
  139820. }
  139821. }
  139822. declare module BABYLON {
  139823. interface AbstractScene {
  139824. /**
  139825. * The list of lens flare system added to the scene
  139826. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139827. */
  139828. lensFlareSystems: Array<LensFlareSystem>;
  139829. /**
  139830. * Removes the given lens flare system from this scene.
  139831. * @param toRemove The lens flare system to remove
  139832. * @returns The index of the removed lens flare system
  139833. */
  139834. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  139835. /**
  139836. * Adds the given lens flare system to this scene
  139837. * @param newLensFlareSystem The lens flare system to add
  139838. */
  139839. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  139840. /**
  139841. * Gets a lens flare system using its name
  139842. * @param name defines the name to look for
  139843. * @returns the lens flare system or null if not found
  139844. */
  139845. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  139846. /**
  139847. * Gets a lens flare system using its id
  139848. * @param id defines the id to look for
  139849. * @returns the lens flare system or null if not found
  139850. */
  139851. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  139852. }
  139853. /**
  139854. * Defines the lens flare scene component responsible to manage any lens flares
  139855. * in a given scene.
  139856. */
  139857. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  139858. /**
  139859. * The component name helpfull to identify the component in the list of scene components.
  139860. */
  139861. readonly name: string;
  139862. /**
  139863. * The scene the component belongs to.
  139864. */
  139865. scene: Scene;
  139866. /**
  139867. * Creates a new instance of the component for the given scene
  139868. * @param scene Defines the scene to register the component in
  139869. */
  139870. constructor(scene: Scene);
  139871. /**
  139872. * Registers the component in a given scene
  139873. */
  139874. register(): void;
  139875. /**
  139876. * Rebuilds the elements related to this component in case of
  139877. * context lost for instance.
  139878. */
  139879. rebuild(): void;
  139880. /**
  139881. * Adds all the elements from the container to the scene
  139882. * @param container the container holding the elements
  139883. */
  139884. addFromContainer(container: AbstractScene): void;
  139885. /**
  139886. * Removes all the elements in the container from the scene
  139887. * @param container contains the elements to remove
  139888. * @param dispose if the removed element should be disposed (default: false)
  139889. */
  139890. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139891. /**
  139892. * Serializes the component data to the specified json object
  139893. * @param serializationObject The object to serialize to
  139894. */
  139895. serialize(serializationObject: any): void;
  139896. /**
  139897. * Disposes the component and the associated ressources.
  139898. */
  139899. dispose(): void;
  139900. private _draw;
  139901. }
  139902. }
  139903. declare module BABYLON {
  139904. /** @hidden */
  139905. export var depthPixelShader: {
  139906. name: string;
  139907. shader: string;
  139908. };
  139909. }
  139910. declare module BABYLON {
  139911. /** @hidden */
  139912. export var depthVertexShader: {
  139913. name: string;
  139914. shader: string;
  139915. };
  139916. }
  139917. declare module BABYLON {
  139918. /**
  139919. * This represents a depth renderer in Babylon.
  139920. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  139921. */
  139922. export class DepthRenderer {
  139923. private _scene;
  139924. private _depthMap;
  139925. private _effect;
  139926. private readonly _storeNonLinearDepth;
  139927. private readonly _clearColor;
  139928. /** Get if the depth renderer is using packed depth or not */
  139929. readonly isPacked: boolean;
  139930. private _cachedDefines;
  139931. private _camera;
  139932. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  139933. enabled: boolean;
  139934. /**
  139935. * Specifiess that the depth renderer will only be used within
  139936. * the camera it is created for.
  139937. * This can help forcing its rendering during the camera processing.
  139938. */
  139939. useOnlyInActiveCamera: boolean;
  139940. /** @hidden */
  139941. static _SceneComponentInitialization: (scene: Scene) => void;
  139942. /**
  139943. * Instantiates a depth renderer
  139944. * @param scene The scene the renderer belongs to
  139945. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  139946. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  139947. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139948. */
  139949. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  139950. /**
  139951. * Creates the depth rendering effect and checks if the effect is ready.
  139952. * @param subMesh The submesh to be used to render the depth map of
  139953. * @param useInstances If multiple world instances should be used
  139954. * @returns if the depth renderer is ready to render the depth map
  139955. */
  139956. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139957. /**
  139958. * Gets the texture which the depth map will be written to.
  139959. * @returns The depth map texture
  139960. */
  139961. getDepthMap(): RenderTargetTexture;
  139962. /**
  139963. * Disposes of the depth renderer.
  139964. */
  139965. dispose(): void;
  139966. }
  139967. }
  139968. declare module BABYLON {
  139969. /** @hidden */
  139970. export var minmaxReduxPixelShader: {
  139971. name: string;
  139972. shader: string;
  139973. };
  139974. }
  139975. declare module BABYLON {
  139976. /**
  139977. * This class computes a min/max reduction from a texture: it means it computes the minimum
  139978. * and maximum values from all values of the texture.
  139979. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  139980. * The source values are read from the red channel of the texture.
  139981. */
  139982. export class MinMaxReducer {
  139983. /**
  139984. * Observable triggered when the computation has been performed
  139985. */
  139986. onAfterReductionPerformed: Observable<{
  139987. min: number;
  139988. max: number;
  139989. }>;
  139990. protected _camera: Camera;
  139991. protected _sourceTexture: Nullable<RenderTargetTexture>;
  139992. protected _reductionSteps: Nullable<Array<PostProcess>>;
  139993. protected _postProcessManager: PostProcessManager;
  139994. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  139995. protected _forceFullscreenViewport: boolean;
  139996. /**
  139997. * Creates a min/max reducer
  139998. * @param camera The camera to use for the post processes
  139999. */
  140000. constructor(camera: Camera);
  140001. /**
  140002. * Gets the texture used to read the values from.
  140003. */
  140004. get sourceTexture(): Nullable<RenderTargetTexture>;
  140005. /**
  140006. * Sets the source texture to read the values from.
  140007. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  140008. * because in such textures '1' value must not be taken into account to compute the maximum
  140009. * as this value is used to clear the texture.
  140010. * Note that the computation is not activated by calling this function, you must call activate() for that!
  140011. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  140012. * @param depthRedux Indicates if the texture is a depth texture or not
  140013. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  140014. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140015. */
  140016. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140017. /**
  140018. * Defines the refresh rate of the computation.
  140019. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140020. */
  140021. get refreshRate(): number;
  140022. set refreshRate(value: number);
  140023. protected _activated: boolean;
  140024. /**
  140025. * Gets the activation status of the reducer
  140026. */
  140027. get activated(): boolean;
  140028. /**
  140029. * Activates the reduction computation.
  140030. * When activated, the observers registered in onAfterReductionPerformed are
  140031. * called after the compuation is performed
  140032. */
  140033. activate(): void;
  140034. /**
  140035. * Deactivates the reduction computation.
  140036. */
  140037. deactivate(): void;
  140038. /**
  140039. * Disposes the min/max reducer
  140040. * @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.
  140041. */
  140042. dispose(disposeAll?: boolean): void;
  140043. }
  140044. }
  140045. declare module BABYLON {
  140046. /**
  140047. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  140048. */
  140049. export class DepthReducer extends MinMaxReducer {
  140050. private _depthRenderer;
  140051. private _depthRendererId;
  140052. /**
  140053. * Gets the depth renderer used for the computation.
  140054. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  140055. */
  140056. get depthRenderer(): Nullable<DepthRenderer>;
  140057. /**
  140058. * Creates a depth reducer
  140059. * @param camera The camera used to render the depth texture
  140060. */
  140061. constructor(camera: Camera);
  140062. /**
  140063. * Sets the depth renderer to use to generate the depth map
  140064. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  140065. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  140066. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140067. */
  140068. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  140069. /** @hidden */
  140070. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140071. /**
  140072. * Activates the reduction computation.
  140073. * When activated, the observers registered in onAfterReductionPerformed are
  140074. * called after the compuation is performed
  140075. */
  140076. activate(): void;
  140077. /**
  140078. * Deactivates the reduction computation.
  140079. */
  140080. deactivate(): void;
  140081. /**
  140082. * Disposes the depth reducer
  140083. * @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.
  140084. */
  140085. dispose(disposeAll?: boolean): void;
  140086. }
  140087. }
  140088. declare module BABYLON {
  140089. /**
  140090. * A CSM implementation allowing casting shadows on large scenes.
  140091. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140092. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  140093. */
  140094. export class CascadedShadowGenerator extends ShadowGenerator {
  140095. private static readonly frustumCornersNDCSpace;
  140096. /**
  140097. * Name of the CSM class
  140098. */
  140099. static CLASSNAME: string;
  140100. /**
  140101. * Defines the default number of cascades used by the CSM.
  140102. */
  140103. static readonly DEFAULT_CASCADES_COUNT: number;
  140104. /**
  140105. * Defines the minimum number of cascades used by the CSM.
  140106. */
  140107. static readonly MIN_CASCADES_COUNT: number;
  140108. /**
  140109. * Defines the maximum number of cascades used by the CSM.
  140110. */
  140111. static readonly MAX_CASCADES_COUNT: number;
  140112. protected _validateFilter(filter: number): number;
  140113. /**
  140114. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  140115. */
  140116. penumbraDarkness: number;
  140117. private _numCascades;
  140118. /**
  140119. * Gets or set the number of cascades used by the CSM.
  140120. */
  140121. get numCascades(): number;
  140122. set numCascades(value: number);
  140123. /**
  140124. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  140125. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  140126. */
  140127. stabilizeCascades: boolean;
  140128. private _freezeShadowCastersBoundingInfo;
  140129. private _freezeShadowCastersBoundingInfoObservable;
  140130. /**
  140131. * Enables or disables the shadow casters bounding info computation.
  140132. * If your shadow casters don't move, you can disable this feature.
  140133. * If it is enabled, the bounding box computation is done every frame.
  140134. */
  140135. get freezeShadowCastersBoundingInfo(): boolean;
  140136. set freezeShadowCastersBoundingInfo(freeze: boolean);
  140137. private _scbiMin;
  140138. private _scbiMax;
  140139. protected _computeShadowCastersBoundingInfo(): void;
  140140. protected _shadowCastersBoundingInfo: BoundingInfo;
  140141. /**
  140142. * Gets or sets the shadow casters bounding info.
  140143. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  140144. * so that the system won't overwrite the bounds you provide
  140145. */
  140146. get shadowCastersBoundingInfo(): BoundingInfo;
  140147. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  140148. protected _breaksAreDirty: boolean;
  140149. protected _minDistance: number;
  140150. protected _maxDistance: number;
  140151. /**
  140152. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  140153. *
  140154. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  140155. * If you don't know these values, simply leave them to their defaults and don't call this function.
  140156. * @param min minimal distance for the breaks (default to 0.)
  140157. * @param max maximal distance for the breaks (default to 1.)
  140158. */
  140159. setMinMaxDistance(min: number, max: number): void;
  140160. /** Gets the minimal distance used in the cascade break computation */
  140161. get minDistance(): number;
  140162. /** Gets the maximal distance used in the cascade break computation */
  140163. get maxDistance(): number;
  140164. /**
  140165. * Gets the class name of that object
  140166. * @returns "CascadedShadowGenerator"
  140167. */
  140168. getClassName(): string;
  140169. private _cascadeMinExtents;
  140170. private _cascadeMaxExtents;
  140171. /**
  140172. * Gets a cascade minimum extents
  140173. * @param cascadeIndex index of the cascade
  140174. * @returns the minimum cascade extents
  140175. */
  140176. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  140177. /**
  140178. * Gets a cascade maximum extents
  140179. * @param cascadeIndex index of the cascade
  140180. * @returns the maximum cascade extents
  140181. */
  140182. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  140183. private _cascades;
  140184. private _currentLayer;
  140185. private _viewSpaceFrustumsZ;
  140186. private _viewMatrices;
  140187. private _projectionMatrices;
  140188. private _transformMatrices;
  140189. private _transformMatricesAsArray;
  140190. private _frustumLengths;
  140191. private _lightSizeUVCorrection;
  140192. private _depthCorrection;
  140193. private _frustumCornersWorldSpace;
  140194. private _frustumCenter;
  140195. private _shadowCameraPos;
  140196. private _shadowMaxZ;
  140197. /**
  140198. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  140199. * It defaults to camera.maxZ
  140200. */
  140201. get shadowMaxZ(): number;
  140202. /**
  140203. * Sets the shadow max z distance.
  140204. */
  140205. set shadowMaxZ(value: number);
  140206. protected _debug: boolean;
  140207. /**
  140208. * Gets or sets the debug flag.
  140209. * When enabled, the cascades are materialized by different colors on the screen.
  140210. */
  140211. get debug(): boolean;
  140212. set debug(dbg: boolean);
  140213. private _depthClamp;
  140214. /**
  140215. * Gets or sets the depth clamping value.
  140216. *
  140217. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  140218. * to account for the shadow casters far away.
  140219. *
  140220. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  140221. */
  140222. get depthClamp(): boolean;
  140223. set depthClamp(value: boolean);
  140224. private _cascadeBlendPercentage;
  140225. /**
  140226. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  140227. * It defaults to 0.1 (10% blending).
  140228. */
  140229. get cascadeBlendPercentage(): number;
  140230. set cascadeBlendPercentage(value: number);
  140231. private _lambda;
  140232. /**
  140233. * Gets or set the lambda parameter.
  140234. * This parameter is used to split the camera frustum and create the cascades.
  140235. * 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.
  140236. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  140237. */
  140238. get lambda(): number;
  140239. set lambda(value: number);
  140240. /**
  140241. * Gets the view matrix corresponding to a given cascade
  140242. * @param cascadeNum cascade to retrieve the view matrix from
  140243. * @returns the cascade view matrix
  140244. */
  140245. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  140246. /**
  140247. * Gets the projection matrix corresponding to a given cascade
  140248. * @param cascadeNum cascade to retrieve the projection matrix from
  140249. * @returns the cascade projection matrix
  140250. */
  140251. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  140252. /**
  140253. * Gets the transformation matrix corresponding to a given cascade
  140254. * @param cascadeNum cascade to retrieve the transformation matrix from
  140255. * @returns the cascade transformation matrix
  140256. */
  140257. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  140258. private _depthRenderer;
  140259. /**
  140260. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  140261. *
  140262. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  140263. *
  140264. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  140265. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  140266. * @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
  140267. */
  140268. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  140269. private _depthReducer;
  140270. private _autoCalcDepthBounds;
  140271. /**
  140272. * Gets or sets the autoCalcDepthBounds property.
  140273. *
  140274. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  140275. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  140276. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  140277. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  140278. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  140279. */
  140280. get autoCalcDepthBounds(): boolean;
  140281. set autoCalcDepthBounds(value: boolean);
  140282. /**
  140283. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  140284. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140285. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  140286. * for setting the refresh rate on the renderer yourself!
  140287. */
  140288. get autoCalcDepthBoundsRefreshRate(): number;
  140289. set autoCalcDepthBoundsRefreshRate(value: number);
  140290. /**
  140291. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  140292. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  140293. * you change the camera near/far planes!
  140294. */
  140295. splitFrustum(): void;
  140296. private _splitFrustum;
  140297. private _computeMatrices;
  140298. private _computeFrustumInWorldSpace;
  140299. private _computeCascadeFrustum;
  140300. /**
  140301. * Support test.
  140302. */
  140303. static get IsSupported(): boolean;
  140304. /** @hidden */
  140305. static _SceneComponentInitialization: (scene: Scene) => void;
  140306. /**
  140307. * Creates a Cascaded Shadow Generator object.
  140308. * A ShadowGenerator is the required tool to use the shadows.
  140309. * Each directional light casting shadows needs to use its own ShadowGenerator.
  140310. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140311. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  140312. * @param light The directional light object generating the shadows.
  140313. * @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.
  140314. */
  140315. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  140316. protected _initializeGenerator(): void;
  140317. protected _createTargetRenderTexture(): void;
  140318. protected _initializeShadowMap(): void;
  140319. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  140320. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  140321. /**
  140322. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  140323. * @param defines Defines of the material we want to update
  140324. * @param lightIndex Index of the light in the enabled light list of the material
  140325. */
  140326. prepareDefines(defines: any, lightIndex: number): void;
  140327. /**
  140328. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  140329. * defined in the generator but impacting the effect).
  140330. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  140331. * @param effect The effect we are binfing the information for
  140332. */
  140333. bindShadowLight(lightIndex: string, effect: Effect): void;
  140334. /**
  140335. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  140336. * (eq to view projection * shadow projection matrices)
  140337. * @returns The transform matrix used to create the shadow map
  140338. */
  140339. getTransformMatrix(): Matrix;
  140340. /**
  140341. * Disposes the ShadowGenerator.
  140342. * Returns nothing.
  140343. */
  140344. dispose(): void;
  140345. /**
  140346. * Serializes the shadow generator setup to a json object.
  140347. * @returns The serialized JSON object
  140348. */
  140349. serialize(): any;
  140350. /**
  140351. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  140352. * @param parsedShadowGenerator The JSON object to parse
  140353. * @param scene The scene to create the shadow map for
  140354. * @returns The parsed shadow generator
  140355. */
  140356. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  140357. }
  140358. }
  140359. declare module BABYLON {
  140360. /**
  140361. * Defines the shadow generator component responsible to manage any shadow generators
  140362. * in a given scene.
  140363. */
  140364. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  140365. /**
  140366. * The component name helpfull to identify the component in the list of scene components.
  140367. */
  140368. readonly name: string;
  140369. /**
  140370. * The scene the component belongs to.
  140371. */
  140372. scene: Scene;
  140373. /**
  140374. * Creates a new instance of the component for the given scene
  140375. * @param scene Defines the scene to register the component in
  140376. */
  140377. constructor(scene: Scene);
  140378. /**
  140379. * Registers the component in a given scene
  140380. */
  140381. register(): void;
  140382. /**
  140383. * Rebuilds the elements related to this component in case of
  140384. * context lost for instance.
  140385. */
  140386. rebuild(): void;
  140387. /**
  140388. * Serializes the component data to the specified json object
  140389. * @param serializationObject The object to serialize to
  140390. */
  140391. serialize(serializationObject: any): void;
  140392. /**
  140393. * Adds all the elements from the container to the scene
  140394. * @param container the container holding the elements
  140395. */
  140396. addFromContainer(container: AbstractScene): void;
  140397. /**
  140398. * Removes all the elements in the container from the scene
  140399. * @param container contains the elements to remove
  140400. * @param dispose if the removed element should be disposed (default: false)
  140401. */
  140402. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140403. /**
  140404. * Rebuilds the elements related to this component in case of
  140405. * context lost for instance.
  140406. */
  140407. dispose(): void;
  140408. private _gatherRenderTargets;
  140409. }
  140410. }
  140411. declare module BABYLON {
  140412. /**
  140413. * A point light is a light defined by an unique point in world space.
  140414. * The light is emitted in every direction from this point.
  140415. * A good example of a point light is a standard light bulb.
  140416. * Documentation: https://doc.babylonjs.com/babylon101/lights
  140417. */
  140418. export class PointLight extends ShadowLight {
  140419. private _shadowAngle;
  140420. /**
  140421. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140422. * This specifies what angle the shadow will use to be created.
  140423. *
  140424. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140425. */
  140426. get shadowAngle(): number;
  140427. /**
  140428. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140429. * This specifies what angle the shadow will use to be created.
  140430. *
  140431. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140432. */
  140433. set shadowAngle(value: number);
  140434. /**
  140435. * Gets the direction if it has been set.
  140436. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140437. */
  140438. get direction(): Vector3;
  140439. /**
  140440. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140441. */
  140442. set direction(value: Vector3);
  140443. /**
  140444. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  140445. * A PointLight emits the light in every direction.
  140446. * It can cast shadows.
  140447. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  140448. * ```javascript
  140449. * var pointLight = new PointLight("pl", camera.position, scene);
  140450. * ```
  140451. * Documentation : https://doc.babylonjs.com/babylon101/lights
  140452. * @param name The light friendly name
  140453. * @param position The position of the point light in the scene
  140454. * @param scene The scene the lights belongs to
  140455. */
  140456. constructor(name: string, position: Vector3, scene: Scene);
  140457. /**
  140458. * Returns the string "PointLight"
  140459. * @returns the class name
  140460. */
  140461. getClassName(): string;
  140462. /**
  140463. * Returns the integer 0.
  140464. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  140465. */
  140466. getTypeID(): number;
  140467. /**
  140468. * Specifies wether or not the shadowmap should be a cube texture.
  140469. * @returns true if the shadowmap needs to be a cube texture.
  140470. */
  140471. needCube(): boolean;
  140472. /**
  140473. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  140474. * @param faceIndex The index of the face we are computed the direction to generate shadow
  140475. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  140476. */
  140477. getShadowDirection(faceIndex?: number): Vector3;
  140478. /**
  140479. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  140480. * - fov = PI / 2
  140481. * - aspect ratio : 1.0
  140482. * - z-near and far equal to the active camera minZ and maxZ.
  140483. * Returns the PointLight.
  140484. */
  140485. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  140486. protected _buildUniformLayout(): void;
  140487. /**
  140488. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  140489. * @param effect The effect to update
  140490. * @param lightIndex The index of the light in the effect to update
  140491. * @returns The point light
  140492. */
  140493. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  140494. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  140495. /**
  140496. * Prepares the list of defines specific to the light type.
  140497. * @param defines the list of defines
  140498. * @param lightIndex defines the index of the light for the effect
  140499. */
  140500. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  140501. }
  140502. }
  140503. declare module BABYLON {
  140504. /**
  140505. * Header information of HDR texture files.
  140506. */
  140507. export interface HDRInfo {
  140508. /**
  140509. * The height of the texture in pixels.
  140510. */
  140511. height: number;
  140512. /**
  140513. * The width of the texture in pixels.
  140514. */
  140515. width: number;
  140516. /**
  140517. * The index of the beginning of the data in the binary file.
  140518. */
  140519. dataPosition: number;
  140520. }
  140521. /**
  140522. * This groups tools to convert HDR texture to native colors array.
  140523. */
  140524. export class HDRTools {
  140525. private static Ldexp;
  140526. private static Rgbe2float;
  140527. private static readStringLine;
  140528. /**
  140529. * Reads header information from an RGBE texture stored in a native array.
  140530. * More information on this format are available here:
  140531. * https://en.wikipedia.org/wiki/RGBE_image_format
  140532. *
  140533. * @param uint8array The binary file stored in native array.
  140534. * @return The header information.
  140535. */
  140536. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  140537. /**
  140538. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  140539. * This RGBE texture needs to store the information as a panorama.
  140540. *
  140541. * More information on this format are available here:
  140542. * https://en.wikipedia.org/wiki/RGBE_image_format
  140543. *
  140544. * @param buffer The binary file stored in an array buffer.
  140545. * @param size The expected size of the extracted cubemap.
  140546. * @return The Cube Map information.
  140547. */
  140548. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  140549. /**
  140550. * Returns the pixels data extracted from an RGBE texture.
  140551. * This pixels will be stored left to right up to down in the R G B order in one array.
  140552. *
  140553. * More information on this format are available here:
  140554. * https://en.wikipedia.org/wiki/RGBE_image_format
  140555. *
  140556. * @param uint8array The binary file stored in an array buffer.
  140557. * @param hdrInfo The header information of the file.
  140558. * @return The pixels data in RGB right to left up to down order.
  140559. */
  140560. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  140561. private static RGBE_ReadPixels_RLE;
  140562. private static RGBE_ReadPixels_NOT_RLE;
  140563. }
  140564. }
  140565. declare module BABYLON {
  140566. /**
  140567. * Effect Render Options
  140568. */
  140569. export interface IEffectRendererOptions {
  140570. /**
  140571. * Defines the vertices positions.
  140572. */
  140573. positions?: number[];
  140574. /**
  140575. * Defines the indices.
  140576. */
  140577. indices?: number[];
  140578. }
  140579. /**
  140580. * Helper class to render one or more effects.
  140581. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  140582. */
  140583. export class EffectRenderer {
  140584. private engine;
  140585. private static _DefaultOptions;
  140586. private _vertexBuffers;
  140587. private _indexBuffer;
  140588. private _fullscreenViewport;
  140589. /**
  140590. * Creates an effect renderer
  140591. * @param engine the engine to use for rendering
  140592. * @param options defines the options of the effect renderer
  140593. */
  140594. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  140595. /**
  140596. * Sets the current viewport in normalized coordinates 0-1
  140597. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  140598. */
  140599. setViewport(viewport?: Viewport): void;
  140600. /**
  140601. * Binds the embedded attributes buffer to the effect.
  140602. * @param effect Defines the effect to bind the attributes for
  140603. */
  140604. bindBuffers(effect: Effect): void;
  140605. /**
  140606. * Sets the current effect wrapper to use during draw.
  140607. * The effect needs to be ready before calling this api.
  140608. * This also sets the default full screen position attribute.
  140609. * @param effectWrapper Defines the effect to draw with
  140610. */
  140611. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  140612. /**
  140613. * Restores engine states
  140614. */
  140615. restoreStates(): void;
  140616. /**
  140617. * Draws a full screen quad.
  140618. */
  140619. draw(): void;
  140620. private isRenderTargetTexture;
  140621. /**
  140622. * renders one or more effects to a specified texture
  140623. * @param effectWrapper the effect to renderer
  140624. * @param outputTexture texture to draw to, if null it will render to the screen.
  140625. */
  140626. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  140627. /**
  140628. * Disposes of the effect renderer
  140629. */
  140630. dispose(): void;
  140631. }
  140632. /**
  140633. * Options to create an EffectWrapper
  140634. */
  140635. interface EffectWrapperCreationOptions {
  140636. /**
  140637. * Engine to use to create the effect
  140638. */
  140639. engine: ThinEngine;
  140640. /**
  140641. * Fragment shader for the effect
  140642. */
  140643. fragmentShader: string;
  140644. /**
  140645. * Use the shader store instead of direct source code
  140646. */
  140647. useShaderStore?: boolean;
  140648. /**
  140649. * Vertex shader for the effect
  140650. */
  140651. vertexShader?: string;
  140652. /**
  140653. * Attributes to use in the shader
  140654. */
  140655. attributeNames?: Array<string>;
  140656. /**
  140657. * Uniforms to use in the shader
  140658. */
  140659. uniformNames?: Array<string>;
  140660. /**
  140661. * Texture sampler names to use in the shader
  140662. */
  140663. samplerNames?: Array<string>;
  140664. /**
  140665. * Defines to use in the shader
  140666. */
  140667. defines?: Array<string>;
  140668. /**
  140669. * Callback when effect is compiled
  140670. */
  140671. onCompiled?: Nullable<(effect: Effect) => void>;
  140672. /**
  140673. * The friendly name of the effect displayed in Spector.
  140674. */
  140675. name?: string;
  140676. }
  140677. /**
  140678. * Wraps an effect to be used for rendering
  140679. */
  140680. export class EffectWrapper {
  140681. /**
  140682. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  140683. */
  140684. onApplyObservable: Observable<{}>;
  140685. /**
  140686. * The underlying effect
  140687. */
  140688. effect: Effect;
  140689. /**
  140690. * Creates an effect to be renderer
  140691. * @param creationOptions options to create the effect
  140692. */
  140693. constructor(creationOptions: EffectWrapperCreationOptions);
  140694. /**
  140695. * Disposes of the effect wrapper
  140696. */
  140697. dispose(): void;
  140698. }
  140699. }
  140700. declare module BABYLON {
  140701. /** @hidden */
  140702. export var hdrFilteringVertexShader: {
  140703. name: string;
  140704. shader: string;
  140705. };
  140706. }
  140707. declare module BABYLON {
  140708. /** @hidden */
  140709. export var hdrFilteringPixelShader: {
  140710. name: string;
  140711. shader: string;
  140712. };
  140713. }
  140714. declare module BABYLON {
  140715. /**
  140716. * Options for texture filtering
  140717. */
  140718. interface IHDRFilteringOptions {
  140719. /**
  140720. * Scales pixel intensity for the input HDR map.
  140721. */
  140722. hdrScale?: number;
  140723. /**
  140724. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  140725. */
  140726. quality?: number;
  140727. }
  140728. /**
  140729. * Filters HDR maps to get correct renderings of PBR reflections
  140730. */
  140731. export class HDRFiltering {
  140732. private _engine;
  140733. private _effectRenderer;
  140734. private _effectWrapper;
  140735. private _lodGenerationOffset;
  140736. private _lodGenerationScale;
  140737. /**
  140738. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  140739. * you care about baking speed.
  140740. */
  140741. quality: number;
  140742. /**
  140743. * Scales pixel intensity for the input HDR map.
  140744. */
  140745. hdrScale: number;
  140746. /**
  140747. * Instantiates HDR filter for reflection maps
  140748. *
  140749. * @param engine Thin engine
  140750. * @param options Options
  140751. */
  140752. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  140753. private _createRenderTarget;
  140754. private _prefilterInternal;
  140755. private _createEffect;
  140756. /**
  140757. * Get a value indicating if the filter is ready to be used
  140758. * @param texture Texture to filter
  140759. * @returns true if the filter is ready
  140760. */
  140761. isReady(texture: BaseTexture): boolean;
  140762. /**
  140763. * Prefilters a cube texture to have mipmap levels representing roughness values.
  140764. * Prefiltering will be invoked at the end of next rendering pass.
  140765. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  140766. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  140767. * @param texture Texture to filter
  140768. * @param onFinished Callback when filtering is done
  140769. * @return Promise called when prefiltering is done
  140770. */
  140771. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  140772. }
  140773. }
  140774. declare module BABYLON {
  140775. /**
  140776. * This represents a texture coming from an HDR input.
  140777. *
  140778. * The only supported format is currently panorama picture stored in RGBE format.
  140779. * Example of such files can be found on HDRLib: http://hdrlib.com/
  140780. */
  140781. export class HDRCubeTexture extends BaseTexture {
  140782. private static _facesMapping;
  140783. private _generateHarmonics;
  140784. private _noMipmap;
  140785. private _prefilterOnLoad;
  140786. private _textureMatrix;
  140787. private _size;
  140788. private _onLoad;
  140789. private _onError;
  140790. /**
  140791. * The texture URL.
  140792. */
  140793. url: string;
  140794. protected _isBlocking: boolean;
  140795. /**
  140796. * Sets wether or not the texture is blocking during loading.
  140797. */
  140798. set isBlocking(value: boolean);
  140799. /**
  140800. * Gets wether or not the texture is blocking during loading.
  140801. */
  140802. get isBlocking(): boolean;
  140803. protected _rotationY: number;
  140804. /**
  140805. * Sets texture matrix rotation angle around Y axis in radians.
  140806. */
  140807. set rotationY(value: number);
  140808. /**
  140809. * Gets texture matrix rotation angle around Y axis radians.
  140810. */
  140811. get rotationY(): number;
  140812. /**
  140813. * Gets or sets the center of the bounding box associated with the cube texture
  140814. * It must define where the camera used to render the texture was set
  140815. */
  140816. boundingBoxPosition: Vector3;
  140817. private _boundingBoxSize;
  140818. /**
  140819. * Gets or sets the size of the bounding box associated with the cube texture
  140820. * When defined, the cubemap will switch to local mode
  140821. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  140822. * @example https://www.babylonjs-playground.com/#RNASML
  140823. */
  140824. set boundingBoxSize(value: Vector3);
  140825. get boundingBoxSize(): Vector3;
  140826. /**
  140827. * Instantiates an HDRTexture from the following parameters.
  140828. *
  140829. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  140830. * @param sceneOrEngine The scene or engine the texture will be used in
  140831. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140832. * @param noMipmap Forces to not generate the mipmap if true
  140833. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  140834. * @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)
  140835. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  140836. */
  140837. 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>);
  140838. /**
  140839. * Get the current class name of the texture useful for serialization or dynamic coding.
  140840. * @returns "HDRCubeTexture"
  140841. */
  140842. getClassName(): string;
  140843. /**
  140844. * Occurs when the file is raw .hdr file.
  140845. */
  140846. private loadTexture;
  140847. clone(): HDRCubeTexture;
  140848. delayLoad(): void;
  140849. /**
  140850. * Get the texture reflection matrix used to rotate/transform the reflection.
  140851. * @returns the reflection matrix
  140852. */
  140853. getReflectionTextureMatrix(): Matrix;
  140854. /**
  140855. * Set the texture reflection matrix used to rotate/transform the reflection.
  140856. * @param value Define the reflection matrix to set
  140857. */
  140858. setReflectionTextureMatrix(value: Matrix): void;
  140859. /**
  140860. * Parses a JSON representation of an HDR Texture in order to create the texture
  140861. * @param parsedTexture Define the JSON representation
  140862. * @param scene Define the scene the texture should be created in
  140863. * @param rootUrl Define the root url in case we need to load relative dependencies
  140864. * @returns the newly created texture after parsing
  140865. */
  140866. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  140867. serialize(): any;
  140868. }
  140869. }
  140870. declare module BABYLON {
  140871. /**
  140872. * Class used to control physics engine
  140873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140874. */
  140875. export class PhysicsEngine implements IPhysicsEngine {
  140876. private _physicsPlugin;
  140877. /**
  140878. * Global value used to control the smallest number supported by the simulation
  140879. */
  140880. static Epsilon: number;
  140881. private _impostors;
  140882. private _joints;
  140883. private _subTimeStep;
  140884. /**
  140885. * Gets the gravity vector used by the simulation
  140886. */
  140887. gravity: Vector3;
  140888. /**
  140889. * Factory used to create the default physics plugin.
  140890. * @returns The default physics plugin
  140891. */
  140892. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  140893. /**
  140894. * Creates a new Physics Engine
  140895. * @param gravity defines the gravity vector used by the simulation
  140896. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  140897. */
  140898. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  140899. /**
  140900. * Sets the gravity vector used by the simulation
  140901. * @param gravity defines the gravity vector to use
  140902. */
  140903. setGravity(gravity: Vector3): void;
  140904. /**
  140905. * Set the time step of the physics engine.
  140906. * Default is 1/60.
  140907. * To slow it down, enter 1/600 for example.
  140908. * To speed it up, 1/30
  140909. * @param newTimeStep defines the new timestep to apply to this world.
  140910. */
  140911. setTimeStep(newTimeStep?: number): void;
  140912. /**
  140913. * Get the time step of the physics engine.
  140914. * @returns the current time step
  140915. */
  140916. getTimeStep(): number;
  140917. /**
  140918. * Set the sub time step of the physics engine.
  140919. * Default is 0 meaning there is no sub steps
  140920. * To increase physics resolution precision, set a small value (like 1 ms)
  140921. * @param subTimeStep defines the new sub timestep used for physics resolution.
  140922. */
  140923. setSubTimeStep(subTimeStep?: number): void;
  140924. /**
  140925. * Get the sub time step of the physics engine.
  140926. * @returns the current sub time step
  140927. */
  140928. getSubTimeStep(): number;
  140929. /**
  140930. * Release all resources
  140931. */
  140932. dispose(): void;
  140933. /**
  140934. * Gets the name of the current physics plugin
  140935. * @returns the name of the plugin
  140936. */
  140937. getPhysicsPluginName(): string;
  140938. /**
  140939. * Adding a new impostor for the impostor tracking.
  140940. * This will be done by the impostor itself.
  140941. * @param impostor the impostor to add
  140942. */
  140943. addImpostor(impostor: PhysicsImpostor): void;
  140944. /**
  140945. * Remove an impostor from the engine.
  140946. * This impostor and its mesh will not longer be updated by the physics engine.
  140947. * @param impostor the impostor to remove
  140948. */
  140949. removeImpostor(impostor: PhysicsImpostor): void;
  140950. /**
  140951. * Add a joint to the physics engine
  140952. * @param mainImpostor defines the main impostor to which the joint is added.
  140953. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  140954. * @param joint defines the joint that will connect both impostors.
  140955. */
  140956. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140957. /**
  140958. * Removes a joint from the simulation
  140959. * @param mainImpostor defines the impostor used with the joint
  140960. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  140961. * @param joint defines the joint to remove
  140962. */
  140963. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140964. /**
  140965. * Called by the scene. No need to call it.
  140966. * @param delta defines the timespam between frames
  140967. */
  140968. _step(delta: number): void;
  140969. /**
  140970. * Gets the current plugin used to run the simulation
  140971. * @returns current plugin
  140972. */
  140973. getPhysicsPlugin(): IPhysicsEnginePlugin;
  140974. /**
  140975. * Gets the list of physic impostors
  140976. * @returns an array of PhysicsImpostor
  140977. */
  140978. getImpostors(): Array<PhysicsImpostor>;
  140979. /**
  140980. * Gets the impostor for a physics enabled object
  140981. * @param object defines the object impersonated by the impostor
  140982. * @returns the PhysicsImpostor or null if not found
  140983. */
  140984. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  140985. /**
  140986. * Gets the impostor for a physics body object
  140987. * @param body defines physics body used by the impostor
  140988. * @returns the PhysicsImpostor or null if not found
  140989. */
  140990. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  140991. /**
  140992. * Does a raycast in the physics world
  140993. * @param from when should the ray start?
  140994. * @param to when should the ray end?
  140995. * @returns PhysicsRaycastResult
  140996. */
  140997. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140998. }
  140999. }
  141000. declare module BABYLON {
  141001. /** @hidden */
  141002. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  141003. private _useDeltaForWorldStep;
  141004. world: any;
  141005. name: string;
  141006. private _physicsMaterials;
  141007. private _fixedTimeStep;
  141008. private _cannonRaycastResult;
  141009. private _raycastResult;
  141010. private _physicsBodysToRemoveAfterStep;
  141011. private _firstFrame;
  141012. BJSCANNON: any;
  141013. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  141014. setGravity(gravity: Vector3): void;
  141015. setTimeStep(timeStep: number): void;
  141016. getTimeStep(): number;
  141017. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141018. private _removeMarkedPhysicsBodiesFromWorld;
  141019. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141020. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141021. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141022. private _processChildMeshes;
  141023. removePhysicsBody(impostor: PhysicsImpostor): void;
  141024. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141025. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141026. private _addMaterial;
  141027. private _checkWithEpsilon;
  141028. private _createShape;
  141029. private _createHeightmap;
  141030. private _minus90X;
  141031. private _plus90X;
  141032. private _tmpPosition;
  141033. private _tmpDeltaPosition;
  141034. private _tmpUnityRotation;
  141035. private _updatePhysicsBodyTransformation;
  141036. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141037. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141038. isSupported(): boolean;
  141039. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141040. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141041. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141042. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141043. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141044. getBodyMass(impostor: PhysicsImpostor): number;
  141045. getBodyFriction(impostor: PhysicsImpostor): number;
  141046. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141047. getBodyRestitution(impostor: PhysicsImpostor): number;
  141048. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141049. sleepBody(impostor: PhysicsImpostor): void;
  141050. wakeUpBody(impostor: PhysicsImpostor): void;
  141051. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  141052. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141053. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141054. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141055. getRadius(impostor: PhysicsImpostor): number;
  141056. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141057. dispose(): void;
  141058. private _extendNamespace;
  141059. /**
  141060. * Does a raycast in the physics world
  141061. * @param from when should the ray start?
  141062. * @param to when should the ray end?
  141063. * @returns PhysicsRaycastResult
  141064. */
  141065. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141066. }
  141067. }
  141068. declare module BABYLON {
  141069. /** @hidden */
  141070. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  141071. private _useDeltaForWorldStep;
  141072. world: any;
  141073. name: string;
  141074. BJSOIMO: any;
  141075. private _raycastResult;
  141076. private _fixedTimeStep;
  141077. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  141078. setGravity(gravity: Vector3): void;
  141079. setTimeStep(timeStep: number): void;
  141080. getTimeStep(): number;
  141081. private _tmpImpostorsArray;
  141082. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141083. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141084. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141085. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141086. private _tmpPositionVector;
  141087. removePhysicsBody(impostor: PhysicsImpostor): void;
  141088. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141089. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141090. isSupported(): boolean;
  141091. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141092. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141093. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141094. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141095. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141096. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141097. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141098. getBodyMass(impostor: PhysicsImpostor): number;
  141099. getBodyFriction(impostor: PhysicsImpostor): number;
  141100. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141101. getBodyRestitution(impostor: PhysicsImpostor): number;
  141102. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141103. sleepBody(impostor: PhysicsImpostor): void;
  141104. wakeUpBody(impostor: PhysicsImpostor): void;
  141105. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141106. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  141107. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  141108. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141109. getRadius(impostor: PhysicsImpostor): number;
  141110. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141111. dispose(): void;
  141112. /**
  141113. * Does a raycast in the physics world
  141114. * @param from when should the ray start?
  141115. * @param to when should the ray end?
  141116. * @returns PhysicsRaycastResult
  141117. */
  141118. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141119. }
  141120. }
  141121. declare module BABYLON {
  141122. /**
  141123. * AmmoJS Physics plugin
  141124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141125. * @see https://github.com/kripken/ammo.js/
  141126. */
  141127. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  141128. private _useDeltaForWorldStep;
  141129. /**
  141130. * Reference to the Ammo library
  141131. */
  141132. bjsAMMO: any;
  141133. /**
  141134. * Created ammoJS world which physics bodies are added to
  141135. */
  141136. world: any;
  141137. /**
  141138. * Name of the plugin
  141139. */
  141140. name: string;
  141141. private _timeStep;
  141142. private _fixedTimeStep;
  141143. private _maxSteps;
  141144. private _tmpQuaternion;
  141145. private _tmpAmmoTransform;
  141146. private _tmpAmmoQuaternion;
  141147. private _tmpAmmoConcreteContactResultCallback;
  141148. private _collisionConfiguration;
  141149. private _dispatcher;
  141150. private _overlappingPairCache;
  141151. private _solver;
  141152. private _softBodySolver;
  141153. private _tmpAmmoVectorA;
  141154. private _tmpAmmoVectorB;
  141155. private _tmpAmmoVectorC;
  141156. private _tmpAmmoVectorD;
  141157. private _tmpContactCallbackResult;
  141158. private _tmpAmmoVectorRCA;
  141159. private _tmpAmmoVectorRCB;
  141160. private _raycastResult;
  141161. private static readonly DISABLE_COLLISION_FLAG;
  141162. private static readonly KINEMATIC_FLAG;
  141163. private static readonly DISABLE_DEACTIVATION_FLAG;
  141164. /**
  141165. * Initializes the ammoJS plugin
  141166. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  141167. * @param ammoInjection can be used to inject your own ammo reference
  141168. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  141169. */
  141170. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  141171. /**
  141172. * Sets the gravity of the physics world (m/(s^2))
  141173. * @param gravity Gravity to set
  141174. */
  141175. setGravity(gravity: Vector3): void;
  141176. /**
  141177. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  141178. * @param timeStep timestep to use in seconds
  141179. */
  141180. setTimeStep(timeStep: number): void;
  141181. /**
  141182. * 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)
  141183. * @param fixedTimeStep fixedTimeStep to use in seconds
  141184. */
  141185. setFixedTimeStep(fixedTimeStep: number): void;
  141186. /**
  141187. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  141188. * @param maxSteps the maximum number of steps by the physics engine per frame
  141189. */
  141190. setMaxSteps(maxSteps: number): void;
  141191. /**
  141192. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  141193. * @returns the current timestep in seconds
  141194. */
  141195. getTimeStep(): number;
  141196. /**
  141197. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  141198. */
  141199. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  141200. private _isImpostorInContact;
  141201. private _isImpostorPairInContact;
  141202. private _stepSimulation;
  141203. /**
  141204. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  141205. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  141206. * After the step the babylon meshes are set to the position of the physics imposters
  141207. * @param delta amount of time to step forward
  141208. * @param impostors array of imposters to update before/after the step
  141209. */
  141210. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141211. /**
  141212. * Update babylon mesh to match physics world object
  141213. * @param impostor imposter to match
  141214. */
  141215. private _afterSoftStep;
  141216. /**
  141217. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141218. * @param impostor imposter to match
  141219. */
  141220. private _ropeStep;
  141221. /**
  141222. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141223. * @param impostor imposter to match
  141224. */
  141225. private _softbodyOrClothStep;
  141226. private _tmpMatrix;
  141227. /**
  141228. * Applies an impulse on the imposter
  141229. * @param impostor imposter to apply impulse to
  141230. * @param force amount of force to be applied to the imposter
  141231. * @param contactPoint the location to apply the impulse on the imposter
  141232. */
  141233. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141234. /**
  141235. * Applies a force on the imposter
  141236. * @param impostor imposter to apply force
  141237. * @param force amount of force to be applied to the imposter
  141238. * @param contactPoint the location to apply the force on the imposter
  141239. */
  141240. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141241. /**
  141242. * Creates a physics body using the plugin
  141243. * @param impostor the imposter to create the physics body on
  141244. */
  141245. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141246. /**
  141247. * Removes the physics body from the imposter and disposes of the body's memory
  141248. * @param impostor imposter to remove the physics body from
  141249. */
  141250. removePhysicsBody(impostor: PhysicsImpostor): void;
  141251. /**
  141252. * Generates a joint
  141253. * @param impostorJoint the imposter joint to create the joint with
  141254. */
  141255. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141256. /**
  141257. * Removes a joint
  141258. * @param impostorJoint the imposter joint to remove the joint from
  141259. */
  141260. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141261. private _addMeshVerts;
  141262. /**
  141263. * Initialise the soft body vertices to match its object's (mesh) vertices
  141264. * Softbody vertices (nodes) are in world space and to match this
  141265. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  141266. * @param impostor to create the softbody for
  141267. */
  141268. private _softVertexData;
  141269. /**
  141270. * Create an impostor's soft body
  141271. * @param impostor to create the softbody for
  141272. */
  141273. private _createSoftbody;
  141274. /**
  141275. * Create cloth for an impostor
  141276. * @param impostor to create the softbody for
  141277. */
  141278. private _createCloth;
  141279. /**
  141280. * Create rope for an impostor
  141281. * @param impostor to create the softbody for
  141282. */
  141283. private _createRope;
  141284. /**
  141285. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  141286. * @param impostor to create the custom physics shape for
  141287. */
  141288. private _createCustom;
  141289. private _addHullVerts;
  141290. private _createShape;
  141291. /**
  141292. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  141293. * @param impostor imposter containing the physics body and babylon object
  141294. */
  141295. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141296. /**
  141297. * Sets the babylon object's position/rotation from the physics body's position/rotation
  141298. * @param impostor imposter containing the physics body and babylon object
  141299. * @param newPosition new position
  141300. * @param newRotation new rotation
  141301. */
  141302. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141303. /**
  141304. * If this plugin is supported
  141305. * @returns true if its supported
  141306. */
  141307. isSupported(): boolean;
  141308. /**
  141309. * Sets the linear velocity of the physics body
  141310. * @param impostor imposter to set the velocity on
  141311. * @param velocity velocity to set
  141312. */
  141313. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141314. /**
  141315. * Sets the angular velocity of the physics body
  141316. * @param impostor imposter to set the velocity on
  141317. * @param velocity velocity to set
  141318. */
  141319. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141320. /**
  141321. * gets the linear velocity
  141322. * @param impostor imposter to get linear velocity from
  141323. * @returns linear velocity
  141324. */
  141325. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141326. /**
  141327. * gets the angular velocity
  141328. * @param impostor imposter to get angular velocity from
  141329. * @returns angular velocity
  141330. */
  141331. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141332. /**
  141333. * Sets the mass of physics body
  141334. * @param impostor imposter to set the mass on
  141335. * @param mass mass to set
  141336. */
  141337. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141338. /**
  141339. * Gets the mass of the physics body
  141340. * @param impostor imposter to get the mass from
  141341. * @returns mass
  141342. */
  141343. getBodyMass(impostor: PhysicsImpostor): number;
  141344. /**
  141345. * Gets friction of the impostor
  141346. * @param impostor impostor to get friction from
  141347. * @returns friction value
  141348. */
  141349. getBodyFriction(impostor: PhysicsImpostor): number;
  141350. /**
  141351. * Sets friction of the impostor
  141352. * @param impostor impostor to set friction on
  141353. * @param friction friction value
  141354. */
  141355. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141356. /**
  141357. * Gets restitution of the impostor
  141358. * @param impostor impostor to get restitution from
  141359. * @returns restitution value
  141360. */
  141361. getBodyRestitution(impostor: PhysicsImpostor): number;
  141362. /**
  141363. * Sets resitution of the impostor
  141364. * @param impostor impostor to set resitution on
  141365. * @param restitution resitution value
  141366. */
  141367. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141368. /**
  141369. * Gets pressure inside the impostor
  141370. * @param impostor impostor to get pressure from
  141371. * @returns pressure value
  141372. */
  141373. getBodyPressure(impostor: PhysicsImpostor): number;
  141374. /**
  141375. * Sets pressure inside a soft body impostor
  141376. * Cloth and rope must remain 0 pressure
  141377. * @param impostor impostor to set pressure on
  141378. * @param pressure pressure value
  141379. */
  141380. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  141381. /**
  141382. * Gets stiffness of the impostor
  141383. * @param impostor impostor to get stiffness from
  141384. * @returns pressure value
  141385. */
  141386. getBodyStiffness(impostor: PhysicsImpostor): number;
  141387. /**
  141388. * Sets stiffness of the impostor
  141389. * @param impostor impostor to set stiffness on
  141390. * @param stiffness stiffness value from 0 to 1
  141391. */
  141392. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  141393. /**
  141394. * Gets velocityIterations of the impostor
  141395. * @param impostor impostor to get velocity iterations from
  141396. * @returns velocityIterations value
  141397. */
  141398. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  141399. /**
  141400. * Sets velocityIterations of the impostor
  141401. * @param impostor impostor to set velocity iterations on
  141402. * @param velocityIterations velocityIterations value
  141403. */
  141404. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  141405. /**
  141406. * Gets positionIterations of the impostor
  141407. * @param impostor impostor to get position iterations from
  141408. * @returns positionIterations value
  141409. */
  141410. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  141411. /**
  141412. * Sets positionIterations of the impostor
  141413. * @param impostor impostor to set position on
  141414. * @param positionIterations positionIterations value
  141415. */
  141416. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  141417. /**
  141418. * Append an anchor to a cloth object
  141419. * @param impostor is the cloth impostor to add anchor to
  141420. * @param otherImpostor is the rigid impostor to anchor to
  141421. * @param width ratio across width from 0 to 1
  141422. * @param height ratio up height from 0 to 1
  141423. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  141424. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141425. */
  141426. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141427. /**
  141428. * Append an hook to a rope object
  141429. * @param impostor is the rope impostor to add hook to
  141430. * @param otherImpostor is the rigid impostor to hook to
  141431. * @param length ratio along the rope from 0 to 1
  141432. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  141433. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141434. */
  141435. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141436. /**
  141437. * Sleeps the physics body and stops it from being active
  141438. * @param impostor impostor to sleep
  141439. */
  141440. sleepBody(impostor: PhysicsImpostor): void;
  141441. /**
  141442. * Activates the physics body
  141443. * @param impostor impostor to activate
  141444. */
  141445. wakeUpBody(impostor: PhysicsImpostor): void;
  141446. /**
  141447. * Updates the distance parameters of the joint
  141448. * @param joint joint to update
  141449. * @param maxDistance maximum distance of the joint
  141450. * @param minDistance minimum distance of the joint
  141451. */
  141452. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141453. /**
  141454. * Sets a motor on the joint
  141455. * @param joint joint to set motor on
  141456. * @param speed speed of the motor
  141457. * @param maxForce maximum force of the motor
  141458. * @param motorIndex index of the motor
  141459. */
  141460. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141461. /**
  141462. * Sets the motors limit
  141463. * @param joint joint to set limit on
  141464. * @param upperLimit upper limit
  141465. * @param lowerLimit lower limit
  141466. */
  141467. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141468. /**
  141469. * Syncs the position and rotation of a mesh with the impostor
  141470. * @param mesh mesh to sync
  141471. * @param impostor impostor to update the mesh with
  141472. */
  141473. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141474. /**
  141475. * Gets the radius of the impostor
  141476. * @param impostor impostor to get radius from
  141477. * @returns the radius
  141478. */
  141479. getRadius(impostor: PhysicsImpostor): number;
  141480. /**
  141481. * Gets the box size of the impostor
  141482. * @param impostor impostor to get box size from
  141483. * @param result the resulting box size
  141484. */
  141485. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141486. /**
  141487. * Disposes of the impostor
  141488. */
  141489. dispose(): void;
  141490. /**
  141491. * Does a raycast in the physics world
  141492. * @param from when should the ray start?
  141493. * @param to when should the ray end?
  141494. * @returns PhysicsRaycastResult
  141495. */
  141496. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141497. }
  141498. }
  141499. declare module BABYLON {
  141500. interface AbstractScene {
  141501. /**
  141502. * The list of reflection probes added to the scene
  141503. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141504. */
  141505. reflectionProbes: Array<ReflectionProbe>;
  141506. /**
  141507. * Removes the given reflection probe from this scene.
  141508. * @param toRemove The reflection probe to remove
  141509. * @returns The index of the removed reflection probe
  141510. */
  141511. removeReflectionProbe(toRemove: ReflectionProbe): number;
  141512. /**
  141513. * Adds the given reflection probe to this scene.
  141514. * @param newReflectionProbe The reflection probe to add
  141515. */
  141516. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  141517. }
  141518. /**
  141519. * Class used to generate realtime reflection / refraction cube textures
  141520. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141521. */
  141522. export class ReflectionProbe {
  141523. /** defines the name of the probe */
  141524. name: string;
  141525. private _scene;
  141526. private _renderTargetTexture;
  141527. private _projectionMatrix;
  141528. private _viewMatrix;
  141529. private _target;
  141530. private _add;
  141531. private _attachedMesh;
  141532. private _invertYAxis;
  141533. /** Gets or sets probe position (center of the cube map) */
  141534. position: Vector3;
  141535. /**
  141536. * Creates a new reflection probe
  141537. * @param name defines the name of the probe
  141538. * @param size defines the texture resolution (for each face)
  141539. * @param scene defines the hosting scene
  141540. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  141541. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  141542. */
  141543. constructor(
  141544. /** defines the name of the probe */
  141545. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  141546. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  141547. get samples(): number;
  141548. set samples(value: number);
  141549. /** Gets or sets the refresh rate to use (on every frame by default) */
  141550. get refreshRate(): number;
  141551. set refreshRate(value: number);
  141552. /**
  141553. * Gets the hosting scene
  141554. * @returns a Scene
  141555. */
  141556. getScene(): Scene;
  141557. /** Gets the internal CubeTexture used to render to */
  141558. get cubeTexture(): RenderTargetTexture;
  141559. /** Gets the list of meshes to render */
  141560. get renderList(): Nullable<AbstractMesh[]>;
  141561. /**
  141562. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  141563. * @param mesh defines the mesh to attach to
  141564. */
  141565. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  141566. /**
  141567. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  141568. * @param renderingGroupId The rendering group id corresponding to its index
  141569. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  141570. */
  141571. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  141572. /**
  141573. * Clean all associated resources
  141574. */
  141575. dispose(): void;
  141576. /**
  141577. * Converts the reflection probe information to a readable string for debug purpose.
  141578. * @param fullDetails Supports for multiple levels of logging within scene loading
  141579. * @returns the human readable reflection probe info
  141580. */
  141581. toString(fullDetails?: boolean): string;
  141582. /**
  141583. * Get the class name of the relfection probe.
  141584. * @returns "ReflectionProbe"
  141585. */
  141586. getClassName(): string;
  141587. /**
  141588. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  141589. * @returns The JSON representation of the texture
  141590. */
  141591. serialize(): any;
  141592. /**
  141593. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  141594. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  141595. * @param scene Define the scene the parsed reflection probe should be instantiated in
  141596. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  141597. * @returns The parsed reflection probe if successful
  141598. */
  141599. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  141600. }
  141601. }
  141602. declare module BABYLON {
  141603. /** @hidden */
  141604. export var _BabylonLoaderRegistered: boolean;
  141605. /**
  141606. * Helps setting up some configuration for the babylon file loader.
  141607. */
  141608. export class BabylonFileLoaderConfiguration {
  141609. /**
  141610. * The loader does not allow injecting custom physix engine into the plugins.
  141611. * Unfortunately in ES6, we need to manually inject them into the plugin.
  141612. * So you could set this variable to your engine import to make it work.
  141613. */
  141614. static LoaderInjectedPhysicsEngine: any;
  141615. }
  141616. }
  141617. declare module BABYLON {
  141618. /**
  141619. * The Physically based simple base material of BJS.
  141620. *
  141621. * This enables better naming and convention enforcements on top of the pbrMaterial.
  141622. * It is used as the base class for both the specGloss and metalRough conventions.
  141623. */
  141624. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  141625. /**
  141626. * Number of Simultaneous lights allowed on the material.
  141627. */
  141628. maxSimultaneousLights: number;
  141629. /**
  141630. * If sets to true, disables all the lights affecting the material.
  141631. */
  141632. disableLighting: boolean;
  141633. /**
  141634. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  141635. */
  141636. environmentTexture: BaseTexture;
  141637. /**
  141638. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  141639. */
  141640. invertNormalMapX: boolean;
  141641. /**
  141642. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  141643. */
  141644. invertNormalMapY: boolean;
  141645. /**
  141646. * Normal map used in the model.
  141647. */
  141648. normalTexture: BaseTexture;
  141649. /**
  141650. * Emissivie color used to self-illuminate the model.
  141651. */
  141652. emissiveColor: Color3;
  141653. /**
  141654. * Emissivie texture used to self-illuminate the model.
  141655. */
  141656. emissiveTexture: BaseTexture;
  141657. /**
  141658. * Occlusion Channel Strenght.
  141659. */
  141660. occlusionStrength: number;
  141661. /**
  141662. * Occlusion Texture of the material (adding extra occlusion effects).
  141663. */
  141664. occlusionTexture: BaseTexture;
  141665. /**
  141666. * Defines the alpha limits in alpha test mode.
  141667. */
  141668. alphaCutOff: number;
  141669. /**
  141670. * Gets the current double sided mode.
  141671. */
  141672. get doubleSided(): boolean;
  141673. /**
  141674. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  141675. */
  141676. set doubleSided(value: boolean);
  141677. /**
  141678. * Stores the pre-calculated light information of a mesh in a texture.
  141679. */
  141680. lightmapTexture: BaseTexture;
  141681. /**
  141682. * If true, the light map contains occlusion information instead of lighting info.
  141683. */
  141684. useLightmapAsShadowmap: boolean;
  141685. /**
  141686. * Instantiates a new PBRMaterial instance.
  141687. *
  141688. * @param name The material name
  141689. * @param scene The scene the material will be use in.
  141690. */
  141691. constructor(name: string, scene: Scene);
  141692. getClassName(): string;
  141693. }
  141694. }
  141695. declare module BABYLON {
  141696. /**
  141697. * The PBR material of BJS following the metal roughness convention.
  141698. *
  141699. * This fits to the PBR convention in the GLTF definition:
  141700. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  141701. */
  141702. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  141703. /**
  141704. * The base color has two different interpretations depending on the value of metalness.
  141705. * When the material is a metal, the base color is the specific measured reflectance value
  141706. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  141707. * of the material.
  141708. */
  141709. baseColor: Color3;
  141710. /**
  141711. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  141712. * well as opacity information in the alpha channel.
  141713. */
  141714. baseTexture: BaseTexture;
  141715. /**
  141716. * Specifies the metallic scalar value of the material.
  141717. * Can also be used to scale the metalness values of the metallic texture.
  141718. */
  141719. metallic: number;
  141720. /**
  141721. * Specifies the roughness scalar value of the material.
  141722. * Can also be used to scale the roughness values of the metallic texture.
  141723. */
  141724. roughness: number;
  141725. /**
  141726. * Texture containing both the metallic value in the B channel and the
  141727. * roughness value in the G channel to keep better precision.
  141728. */
  141729. metallicRoughnessTexture: BaseTexture;
  141730. /**
  141731. * Instantiates a new PBRMetalRoughnessMaterial instance.
  141732. *
  141733. * @param name The material name
  141734. * @param scene The scene the material will be use in.
  141735. */
  141736. constructor(name: string, scene: Scene);
  141737. /**
  141738. * Return the currrent class name of the material.
  141739. */
  141740. getClassName(): string;
  141741. /**
  141742. * Makes a duplicate of the current material.
  141743. * @param name - name to use for the new material.
  141744. */
  141745. clone(name: string): PBRMetallicRoughnessMaterial;
  141746. /**
  141747. * Serialize the material to a parsable JSON object.
  141748. */
  141749. serialize(): any;
  141750. /**
  141751. * Parses a JSON object correponding to the serialize function.
  141752. */
  141753. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  141754. }
  141755. }
  141756. declare module BABYLON {
  141757. /**
  141758. * The PBR material of BJS following the specular glossiness convention.
  141759. *
  141760. * This fits to the PBR convention in the GLTF definition:
  141761. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  141762. */
  141763. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  141764. /**
  141765. * Specifies the diffuse color of the material.
  141766. */
  141767. diffuseColor: Color3;
  141768. /**
  141769. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  141770. * channel.
  141771. */
  141772. diffuseTexture: BaseTexture;
  141773. /**
  141774. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  141775. */
  141776. specularColor: Color3;
  141777. /**
  141778. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  141779. */
  141780. glossiness: number;
  141781. /**
  141782. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  141783. */
  141784. specularGlossinessTexture: BaseTexture;
  141785. /**
  141786. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  141787. *
  141788. * @param name The material name
  141789. * @param scene The scene the material will be use in.
  141790. */
  141791. constructor(name: string, scene: Scene);
  141792. /**
  141793. * Return the currrent class name of the material.
  141794. */
  141795. getClassName(): string;
  141796. /**
  141797. * Makes a duplicate of the current material.
  141798. * @param name - name to use for the new material.
  141799. */
  141800. clone(name: string): PBRSpecularGlossinessMaterial;
  141801. /**
  141802. * Serialize the material to a parsable JSON object.
  141803. */
  141804. serialize(): any;
  141805. /**
  141806. * Parses a JSON object correponding to the serialize function.
  141807. */
  141808. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  141809. }
  141810. }
  141811. declare module BABYLON {
  141812. /**
  141813. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  141814. * It can help converting any input color in a desired output one. This can then be used to create effects
  141815. * from sepia, black and white to sixties or futuristic rendering...
  141816. *
  141817. * The only supported format is currently 3dl.
  141818. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  141819. */
  141820. export class ColorGradingTexture extends BaseTexture {
  141821. /**
  141822. * The texture URL.
  141823. */
  141824. url: string;
  141825. /**
  141826. * Empty line regex stored for GC.
  141827. */
  141828. private static _noneEmptyLineRegex;
  141829. private _textureMatrix;
  141830. private _onLoad;
  141831. /**
  141832. * Instantiates a ColorGradingTexture from the following parameters.
  141833. *
  141834. * @param url The location of the color gradind data (currently only supporting 3dl)
  141835. * @param sceneOrEngine The scene or engine the texture will be used in
  141836. * @param onLoad defines a callback triggered when the texture has been loaded
  141837. */
  141838. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  141839. /**
  141840. * Fires the onload event from the constructor if requested.
  141841. */
  141842. private _triggerOnLoad;
  141843. /**
  141844. * Returns the texture matrix used in most of the material.
  141845. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  141846. */
  141847. getTextureMatrix(): Matrix;
  141848. /**
  141849. * Occurs when the file being loaded is a .3dl LUT file.
  141850. */
  141851. private load3dlTexture;
  141852. /**
  141853. * Starts the loading process of the texture.
  141854. */
  141855. private loadTexture;
  141856. /**
  141857. * Clones the color gradind texture.
  141858. */
  141859. clone(): ColorGradingTexture;
  141860. /**
  141861. * Called during delayed load for textures.
  141862. */
  141863. delayLoad(): void;
  141864. /**
  141865. * Parses a color grading texture serialized by Babylon.
  141866. * @param parsedTexture The texture information being parsedTexture
  141867. * @param scene The scene to load the texture in
  141868. * @param rootUrl The root url of the data assets to load
  141869. * @return A color gradind texture
  141870. */
  141871. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  141872. /**
  141873. * Serializes the LUT texture to json format.
  141874. */
  141875. serialize(): any;
  141876. }
  141877. }
  141878. declare module BABYLON {
  141879. /**
  141880. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  141881. */
  141882. export class EquiRectangularCubeTexture extends BaseTexture {
  141883. /** The six faces of the cube. */
  141884. private static _FacesMapping;
  141885. private _noMipmap;
  141886. private _onLoad;
  141887. private _onError;
  141888. /** The size of the cubemap. */
  141889. private _size;
  141890. /** The buffer of the image. */
  141891. private _buffer;
  141892. /** The width of the input image. */
  141893. private _width;
  141894. /** The height of the input image. */
  141895. private _height;
  141896. /** The URL to the image. */
  141897. url: string;
  141898. /**
  141899. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  141900. * @param url The location of the image
  141901. * @param scene The scene the texture will be used in
  141902. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141903. * @param noMipmap Forces to not generate the mipmap if true
  141904. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141905. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141906. * @param onLoad — defines a callback called when texture is loaded
  141907. * @param onError — defines a callback called if there is an error
  141908. */
  141909. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  141910. /**
  141911. * Load the image data, by putting the image on a canvas and extracting its buffer.
  141912. */
  141913. private loadImage;
  141914. /**
  141915. * Convert the image buffer into a cubemap and create a CubeTexture.
  141916. */
  141917. private loadTexture;
  141918. /**
  141919. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  141920. * @param buffer The ArrayBuffer that should be converted.
  141921. * @returns The buffer as Float32Array.
  141922. */
  141923. private getFloat32ArrayFromArrayBuffer;
  141924. /**
  141925. * Get the current class name of the texture useful for serialization or dynamic coding.
  141926. * @returns "EquiRectangularCubeTexture"
  141927. */
  141928. getClassName(): string;
  141929. /**
  141930. * Create a clone of the current EquiRectangularCubeTexture and return it.
  141931. * @returns A clone of the current EquiRectangularCubeTexture.
  141932. */
  141933. clone(): EquiRectangularCubeTexture;
  141934. }
  141935. }
  141936. declare module BABYLON {
  141937. /**
  141938. * Defines the options related to the creation of an HtmlElementTexture
  141939. */
  141940. export interface IHtmlElementTextureOptions {
  141941. /**
  141942. * Defines wether mip maps should be created or not.
  141943. */
  141944. generateMipMaps?: boolean;
  141945. /**
  141946. * Defines the sampling mode of the texture.
  141947. */
  141948. samplingMode?: number;
  141949. /**
  141950. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  141951. */
  141952. engine: Nullable<ThinEngine>;
  141953. /**
  141954. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  141955. */
  141956. scene: Nullable<Scene>;
  141957. }
  141958. /**
  141959. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  141960. * To be as efficient as possible depending on your constraints nothing aside the first upload
  141961. * is automatically managed.
  141962. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  141963. * in your application.
  141964. *
  141965. * As the update is not automatic, you need to call them manually.
  141966. */
  141967. export class HtmlElementTexture extends BaseTexture {
  141968. /**
  141969. * The texture URL.
  141970. */
  141971. element: HTMLVideoElement | HTMLCanvasElement;
  141972. private static readonly DefaultOptions;
  141973. private _textureMatrix;
  141974. private _isVideo;
  141975. private _generateMipMaps;
  141976. private _samplingMode;
  141977. /**
  141978. * Instantiates a HtmlElementTexture from the following parameters.
  141979. *
  141980. * @param name Defines the name of the texture
  141981. * @param element Defines the video or canvas the texture is filled with
  141982. * @param options Defines the other none mandatory texture creation options
  141983. */
  141984. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  141985. private _createInternalTexture;
  141986. /**
  141987. * Returns the texture matrix used in most of the material.
  141988. */
  141989. getTextureMatrix(): Matrix;
  141990. /**
  141991. * Updates the content of the texture.
  141992. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  141993. */
  141994. update(invertY?: Nullable<boolean>): void;
  141995. }
  141996. }
  141997. declare module BABYLON {
  141998. /**
  141999. * Based on jsTGALoader - Javascript loader for TGA file
  142000. * By Vincent Thibault
  142001. * @see http://blog.robrowser.com/javascript-tga-loader.html
  142002. */
  142003. export class TGATools {
  142004. private static _TYPE_INDEXED;
  142005. private static _TYPE_RGB;
  142006. private static _TYPE_GREY;
  142007. private static _TYPE_RLE_INDEXED;
  142008. private static _TYPE_RLE_RGB;
  142009. private static _TYPE_RLE_GREY;
  142010. private static _ORIGIN_MASK;
  142011. private static _ORIGIN_SHIFT;
  142012. private static _ORIGIN_BL;
  142013. private static _ORIGIN_BR;
  142014. private static _ORIGIN_UL;
  142015. private static _ORIGIN_UR;
  142016. /**
  142017. * Gets the header of a TGA file
  142018. * @param data defines the TGA data
  142019. * @returns the header
  142020. */
  142021. static GetTGAHeader(data: Uint8Array): any;
  142022. /**
  142023. * Uploads TGA content to a Babylon Texture
  142024. * @hidden
  142025. */
  142026. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  142027. /** @hidden */
  142028. 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;
  142029. /** @hidden */
  142030. 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;
  142031. /** @hidden */
  142032. 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;
  142033. /** @hidden */
  142034. 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;
  142035. /** @hidden */
  142036. 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;
  142037. /** @hidden */
  142038. 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;
  142039. }
  142040. }
  142041. declare module BABYLON {
  142042. /**
  142043. * Implementation of the TGA Texture Loader.
  142044. * @hidden
  142045. */
  142046. export class _TGATextureLoader implements IInternalTextureLoader {
  142047. /**
  142048. * Defines wether the loader supports cascade loading the different faces.
  142049. */
  142050. readonly supportCascades: boolean;
  142051. /**
  142052. * This returns if the loader support the current file information.
  142053. * @param extension defines the file extension of the file being loaded
  142054. * @returns true if the loader can load the specified file
  142055. */
  142056. canLoad(extension: string): boolean;
  142057. /**
  142058. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142059. * @param data contains the texture data
  142060. * @param texture defines the BabylonJS internal texture
  142061. * @param createPolynomials will be true if polynomials have been requested
  142062. * @param onLoad defines the callback to trigger once the texture is ready
  142063. * @param onError defines the callback to trigger in case of error
  142064. */
  142065. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142066. /**
  142067. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142068. * @param data contains the texture data
  142069. * @param texture defines the BabylonJS internal texture
  142070. * @param callback defines the method to call once ready to upload
  142071. */
  142072. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142073. }
  142074. }
  142075. declare module BABYLON {
  142076. /**
  142077. * Info about the .basis files
  142078. */
  142079. class BasisFileInfo {
  142080. /**
  142081. * If the file has alpha
  142082. */
  142083. hasAlpha: boolean;
  142084. /**
  142085. * Info about each image of the basis file
  142086. */
  142087. images: Array<{
  142088. levels: Array<{
  142089. width: number;
  142090. height: number;
  142091. transcodedPixels: ArrayBufferView;
  142092. }>;
  142093. }>;
  142094. }
  142095. /**
  142096. * Result of transcoding a basis file
  142097. */
  142098. class TranscodeResult {
  142099. /**
  142100. * Info about the .basis file
  142101. */
  142102. fileInfo: BasisFileInfo;
  142103. /**
  142104. * Format to use when loading the file
  142105. */
  142106. format: number;
  142107. }
  142108. /**
  142109. * Configuration options for the Basis transcoder
  142110. */
  142111. export class BasisTranscodeConfiguration {
  142112. /**
  142113. * Supported compression formats used to determine the supported output format of the transcoder
  142114. */
  142115. supportedCompressionFormats?: {
  142116. /**
  142117. * etc1 compression format
  142118. */
  142119. etc1?: boolean;
  142120. /**
  142121. * s3tc compression format
  142122. */
  142123. s3tc?: boolean;
  142124. /**
  142125. * pvrtc compression format
  142126. */
  142127. pvrtc?: boolean;
  142128. /**
  142129. * etc2 compression format
  142130. */
  142131. etc2?: boolean;
  142132. };
  142133. /**
  142134. * If mipmap levels should be loaded for transcoded images (Default: true)
  142135. */
  142136. loadMipmapLevels?: boolean;
  142137. /**
  142138. * Index of a single image to load (Default: all images)
  142139. */
  142140. loadSingleImage?: number;
  142141. }
  142142. /**
  142143. * Used to load .Basis files
  142144. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  142145. */
  142146. export class BasisTools {
  142147. private static _IgnoreSupportedFormats;
  142148. /**
  142149. * URL to use when loading the basis transcoder
  142150. */
  142151. static JSModuleURL: string;
  142152. /**
  142153. * URL to use when loading the wasm module for the transcoder
  142154. */
  142155. static WasmModuleURL: string;
  142156. /**
  142157. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  142158. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  142159. * @returns internal format corresponding to the Basis format
  142160. */
  142161. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  142162. private static _WorkerPromise;
  142163. private static _Worker;
  142164. private static _actionId;
  142165. private static _CreateWorkerAsync;
  142166. /**
  142167. * Transcodes a loaded image file to compressed pixel data
  142168. * @param data image data to transcode
  142169. * @param config configuration options for the transcoding
  142170. * @returns a promise resulting in the transcoded image
  142171. */
  142172. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  142173. /**
  142174. * Loads a texture from the transcode result
  142175. * @param texture texture load to
  142176. * @param transcodeResult the result of transcoding the basis file to load from
  142177. */
  142178. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  142179. }
  142180. }
  142181. declare module BABYLON {
  142182. /**
  142183. * Loader for .basis file format
  142184. */
  142185. export class _BasisTextureLoader implements IInternalTextureLoader {
  142186. /**
  142187. * Defines whether the loader supports cascade loading the different faces.
  142188. */
  142189. readonly supportCascades: boolean;
  142190. /**
  142191. * This returns if the loader support the current file information.
  142192. * @param extension defines the file extension of the file being loaded
  142193. * @returns true if the loader can load the specified file
  142194. */
  142195. canLoad(extension: string): boolean;
  142196. /**
  142197. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142198. * @param data contains the texture data
  142199. * @param texture defines the BabylonJS internal texture
  142200. * @param createPolynomials will be true if polynomials have been requested
  142201. * @param onLoad defines the callback to trigger once the texture is ready
  142202. * @param onError defines the callback to trigger in case of error
  142203. */
  142204. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142205. /**
  142206. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142207. * @param data contains the texture data
  142208. * @param texture defines the BabylonJS internal texture
  142209. * @param callback defines the method to call once ready to upload
  142210. */
  142211. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142212. }
  142213. }
  142214. declare module BABYLON {
  142215. /**
  142216. * Defines the basic options interface of a TexturePacker Frame
  142217. */
  142218. export interface ITexturePackerFrame {
  142219. /**
  142220. * The frame ID
  142221. */
  142222. id: number;
  142223. /**
  142224. * The frames Scale
  142225. */
  142226. scale: Vector2;
  142227. /**
  142228. * The Frames offset
  142229. */
  142230. offset: Vector2;
  142231. }
  142232. /**
  142233. * This is a support class for frame Data on texture packer sets.
  142234. */
  142235. export class TexturePackerFrame implements ITexturePackerFrame {
  142236. /**
  142237. * The frame ID
  142238. */
  142239. id: number;
  142240. /**
  142241. * The frames Scale
  142242. */
  142243. scale: Vector2;
  142244. /**
  142245. * The Frames offset
  142246. */
  142247. offset: Vector2;
  142248. /**
  142249. * Initializes a texture package frame.
  142250. * @param id The numerical frame identifier
  142251. * @param scale Scalar Vector2 for UV frame
  142252. * @param offset Vector2 for the frame position in UV units.
  142253. * @returns TexturePackerFrame
  142254. */
  142255. constructor(id: number, scale: Vector2, offset: Vector2);
  142256. }
  142257. }
  142258. declare module BABYLON {
  142259. /**
  142260. * Defines the basic options interface of a TexturePacker
  142261. */
  142262. export interface ITexturePackerOptions {
  142263. /**
  142264. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  142265. */
  142266. map?: string[];
  142267. /**
  142268. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142269. */
  142270. uvsIn?: string;
  142271. /**
  142272. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142273. */
  142274. uvsOut?: string;
  142275. /**
  142276. * number representing the layout style. Defaults to LAYOUT_STRIP
  142277. */
  142278. layout?: number;
  142279. /**
  142280. * number of columns if using custom column count layout(2). This defaults to 4.
  142281. */
  142282. colnum?: number;
  142283. /**
  142284. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  142285. */
  142286. updateInputMeshes?: boolean;
  142287. /**
  142288. * boolean flag to dispose all the source textures. Defaults to true.
  142289. */
  142290. disposeSources?: boolean;
  142291. /**
  142292. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  142293. */
  142294. fillBlanks?: boolean;
  142295. /**
  142296. * string value representing the context fill style color. Defaults to 'black'.
  142297. */
  142298. customFillColor?: string;
  142299. /**
  142300. * Width and Height Value of each Frame in the TexturePacker Sets
  142301. */
  142302. frameSize?: number;
  142303. /**
  142304. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  142305. */
  142306. paddingRatio?: number;
  142307. /**
  142308. * Number that declares the fill method for the padding gutter.
  142309. */
  142310. paddingMode?: number;
  142311. /**
  142312. * If in SUBUV_COLOR padding mode what color to use.
  142313. */
  142314. paddingColor?: Color3 | Color4;
  142315. }
  142316. /**
  142317. * Defines the basic interface of a TexturePacker JSON File
  142318. */
  142319. export interface ITexturePackerJSON {
  142320. /**
  142321. * The frame ID
  142322. */
  142323. name: string;
  142324. /**
  142325. * The base64 channel data
  142326. */
  142327. sets: any;
  142328. /**
  142329. * The options of the Packer
  142330. */
  142331. options: ITexturePackerOptions;
  142332. /**
  142333. * The frame data of the Packer
  142334. */
  142335. frames: Array<number>;
  142336. }
  142337. /**
  142338. * This is a support class that generates a series of packed texture sets.
  142339. * @see https://doc.babylonjs.com/babylon101/materials
  142340. */
  142341. export class TexturePacker {
  142342. /** Packer Layout Constant 0 */
  142343. static readonly LAYOUT_STRIP: number;
  142344. /** Packer Layout Constant 1 */
  142345. static readonly LAYOUT_POWER2: number;
  142346. /** Packer Layout Constant 2 */
  142347. static readonly LAYOUT_COLNUM: number;
  142348. /** Packer Layout Constant 0 */
  142349. static readonly SUBUV_WRAP: number;
  142350. /** Packer Layout Constant 1 */
  142351. static readonly SUBUV_EXTEND: number;
  142352. /** Packer Layout Constant 2 */
  142353. static readonly SUBUV_COLOR: number;
  142354. /** The Name of the Texture Package */
  142355. name: string;
  142356. /** The scene scope of the TexturePacker */
  142357. scene: Scene;
  142358. /** The Meshes to target */
  142359. meshes: AbstractMesh[];
  142360. /** Arguments passed with the Constructor */
  142361. options: ITexturePackerOptions;
  142362. /** The promise that is started upon initialization */
  142363. promise: Nullable<Promise<TexturePacker | string>>;
  142364. /** The Container object for the channel sets that are generated */
  142365. sets: object;
  142366. /** The Container array for the frames that are generated */
  142367. frames: TexturePackerFrame[];
  142368. /** The expected number of textures the system is parsing. */
  142369. private _expecting;
  142370. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  142371. private _paddingValue;
  142372. /**
  142373. * Initializes a texture package series from an array of meshes or a single mesh.
  142374. * @param name The name of the package
  142375. * @param meshes The target meshes to compose the package from
  142376. * @param options The arguments that texture packer should follow while building.
  142377. * @param scene The scene which the textures are scoped to.
  142378. * @returns TexturePacker
  142379. */
  142380. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  142381. /**
  142382. * Starts the package process
  142383. * @param resolve The promises resolution function
  142384. * @returns TexturePacker
  142385. */
  142386. private _createFrames;
  142387. /**
  142388. * Calculates the Size of the Channel Sets
  142389. * @returns Vector2
  142390. */
  142391. private _calculateSize;
  142392. /**
  142393. * Calculates the UV data for the frames.
  142394. * @param baseSize the base frameSize
  142395. * @param padding the base frame padding
  142396. * @param dtSize size of the Dynamic Texture for that channel
  142397. * @param dtUnits is 1/dtSize
  142398. * @param update flag to update the input meshes
  142399. */
  142400. private _calculateMeshUVFrames;
  142401. /**
  142402. * Calculates the frames Offset.
  142403. * @param index of the frame
  142404. * @returns Vector2
  142405. */
  142406. private _getFrameOffset;
  142407. /**
  142408. * Updates a Mesh to the frame data
  142409. * @param mesh that is the target
  142410. * @param frameID or the frame index
  142411. */
  142412. private _updateMeshUV;
  142413. /**
  142414. * Updates a Meshes materials to use the texture packer channels
  142415. * @param m is the mesh to target
  142416. * @param force all channels on the packer to be set.
  142417. */
  142418. private _updateTextureReferences;
  142419. /**
  142420. * Public method to set a Mesh to a frame
  142421. * @param m that is the target
  142422. * @param frameID or the frame index
  142423. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  142424. */
  142425. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  142426. /**
  142427. * Starts the async promise to compile the texture packer.
  142428. * @returns Promise<void>
  142429. */
  142430. processAsync(): Promise<void>;
  142431. /**
  142432. * Disposes all textures associated with this packer
  142433. */
  142434. dispose(): void;
  142435. /**
  142436. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  142437. * @param imageType is the image type to use.
  142438. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  142439. */
  142440. download(imageType?: string, quality?: number): void;
  142441. /**
  142442. * Public method to load a texturePacker JSON file.
  142443. * @param data of the JSON file in string format.
  142444. */
  142445. updateFromJSON(data: string): void;
  142446. }
  142447. }
  142448. declare module BABYLON {
  142449. /**
  142450. * 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.
  142451. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142452. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142453. */
  142454. export class CustomProceduralTexture extends ProceduralTexture {
  142455. private _animate;
  142456. private _time;
  142457. private _config;
  142458. private _texturePath;
  142459. /**
  142460. * Instantiates a new Custom Procedural Texture.
  142461. * 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.
  142462. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142463. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142464. * @param name Define the name of the texture
  142465. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  142466. * @param size Define the size of the texture to create
  142467. * @param scene Define the scene the texture belongs to
  142468. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  142469. * @param generateMipMaps Define if the texture should creates mip maps or not
  142470. */
  142471. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142472. private _loadJson;
  142473. /**
  142474. * Is the texture ready to be used ? (rendered at least once)
  142475. * @returns true if ready, otherwise, false.
  142476. */
  142477. isReady(): boolean;
  142478. /**
  142479. * Render the texture to its associated render target.
  142480. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  142481. */
  142482. render(useCameraPostProcess?: boolean): void;
  142483. /**
  142484. * Update the list of dependant textures samplers in the shader.
  142485. */
  142486. updateTextures(): void;
  142487. /**
  142488. * Update the uniform values of the procedural texture in the shader.
  142489. */
  142490. updateShaderUniforms(): void;
  142491. /**
  142492. * Define if the texture animates or not.
  142493. */
  142494. get animate(): boolean;
  142495. set animate(value: boolean);
  142496. }
  142497. }
  142498. declare module BABYLON {
  142499. /** @hidden */
  142500. export var noisePixelShader: {
  142501. name: string;
  142502. shader: string;
  142503. };
  142504. }
  142505. declare module BABYLON {
  142506. /**
  142507. * Class used to generate noise procedural textures
  142508. */
  142509. export class NoiseProceduralTexture extends ProceduralTexture {
  142510. /** Gets or sets the start time (default is 0) */
  142511. time: number;
  142512. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  142513. brightness: number;
  142514. /** Defines the number of octaves to process */
  142515. octaves: number;
  142516. /** Defines the level of persistence (0.8 by default) */
  142517. persistence: number;
  142518. /** Gets or sets animation speed factor (default is 1) */
  142519. animationSpeedFactor: number;
  142520. /**
  142521. * Creates a new NoiseProceduralTexture
  142522. * @param name defines the name fo the texture
  142523. * @param size defines the size of the texture (default is 256)
  142524. * @param scene defines the hosting scene
  142525. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  142526. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  142527. */
  142528. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142529. private _updateShaderUniforms;
  142530. protected _getDefines(): string;
  142531. /** Generate the current state of the procedural texture */
  142532. render(useCameraPostProcess?: boolean): void;
  142533. /**
  142534. * Serializes this noise procedural texture
  142535. * @returns a serialized noise procedural texture object
  142536. */
  142537. serialize(): any;
  142538. /**
  142539. * Clone the texture.
  142540. * @returns the cloned texture
  142541. */
  142542. clone(): NoiseProceduralTexture;
  142543. /**
  142544. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  142545. * @param parsedTexture defines parsed texture data
  142546. * @param scene defines the current scene
  142547. * @param rootUrl defines the root URL containing noise procedural texture information
  142548. * @returns a parsed NoiseProceduralTexture
  142549. */
  142550. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  142551. }
  142552. }
  142553. declare module BABYLON {
  142554. /**
  142555. * Raw cube texture where the raw buffers are passed in
  142556. */
  142557. export class RawCubeTexture extends CubeTexture {
  142558. /**
  142559. * Creates a cube texture where the raw buffers are passed in.
  142560. * @param scene defines the scene the texture is attached to
  142561. * @param data defines the array of data to use to create each face
  142562. * @param size defines the size of the textures
  142563. * @param format defines the format of the data
  142564. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  142565. * @param generateMipMaps defines if the engine should generate the mip levels
  142566. * @param invertY defines if data must be stored with Y axis inverted
  142567. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  142568. * @param compression defines the compression used (null by default)
  142569. */
  142570. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  142571. /**
  142572. * Updates the raw cube texture.
  142573. * @param data defines the data to store
  142574. * @param format defines the data format
  142575. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  142576. * @param invertY defines if data must be stored with Y axis inverted
  142577. * @param compression defines the compression used (null by default)
  142578. * @param level defines which level of the texture to update
  142579. */
  142580. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  142581. /**
  142582. * Updates a raw cube texture with RGBD encoded data.
  142583. * @param data defines the array of data [mipmap][face] to use to create each face
  142584. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  142585. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  142586. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  142587. * @returns a promsie that resolves when the operation is complete
  142588. */
  142589. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  142590. /**
  142591. * Clones the raw cube texture.
  142592. * @return a new cube texture
  142593. */
  142594. clone(): CubeTexture;
  142595. /** @hidden */
  142596. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  142597. }
  142598. }
  142599. declare module BABYLON {
  142600. /**
  142601. * Class used to store 2D array textures containing user data
  142602. */
  142603. export class RawTexture2DArray extends Texture {
  142604. /** Gets or sets the texture format to use */
  142605. format: number;
  142606. /**
  142607. * Create a new RawTexture2DArray
  142608. * @param data defines the data of the texture
  142609. * @param width defines the width of the texture
  142610. * @param height defines the height of the texture
  142611. * @param depth defines the number of layers of the texture
  142612. * @param format defines the texture format to use
  142613. * @param scene defines the hosting scene
  142614. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142615. * @param invertY defines if texture must be stored with Y axis inverted
  142616. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142617. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142618. */
  142619. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142620. /** Gets or sets the texture format to use */
  142621. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142622. /**
  142623. * Update the texture with new data
  142624. * @param data defines the data to store in the texture
  142625. */
  142626. update(data: ArrayBufferView): void;
  142627. }
  142628. }
  142629. declare module BABYLON {
  142630. /**
  142631. * Class used to store 3D textures containing user data
  142632. */
  142633. export class RawTexture3D extends Texture {
  142634. /** Gets or sets the texture format to use */
  142635. format: number;
  142636. /**
  142637. * Create a new RawTexture3D
  142638. * @param data defines the data of the texture
  142639. * @param width defines the width of the texture
  142640. * @param height defines the height of the texture
  142641. * @param depth defines the depth of the texture
  142642. * @param format defines the texture format to use
  142643. * @param scene defines the hosting scene
  142644. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142645. * @param invertY defines if texture must be stored with Y axis inverted
  142646. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142647. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142648. */
  142649. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142650. /** Gets or sets the texture format to use */
  142651. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142652. /**
  142653. * Update the texture with new data
  142654. * @param data defines the data to store in the texture
  142655. */
  142656. update(data: ArrayBufferView): void;
  142657. }
  142658. }
  142659. declare module BABYLON {
  142660. /**
  142661. * Creates a refraction texture used by refraction channel of the standard material.
  142662. * It is like a mirror but to see through a material.
  142663. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142664. */
  142665. export class RefractionTexture extends RenderTargetTexture {
  142666. /**
  142667. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  142668. * 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.
  142669. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142670. */
  142671. refractionPlane: Plane;
  142672. /**
  142673. * Define how deep under the surface we should see.
  142674. */
  142675. depth: number;
  142676. /**
  142677. * Creates a refraction texture used by refraction channel of the standard material.
  142678. * It is like a mirror but to see through a material.
  142679. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142680. * @param name Define the texture name
  142681. * @param size Define the size of the underlying texture
  142682. * @param scene Define the scene the refraction belongs to
  142683. * @param generateMipMaps Define if we need to generate mips level for the refraction
  142684. */
  142685. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  142686. /**
  142687. * Clone the refraction texture.
  142688. * @returns the cloned texture
  142689. */
  142690. clone(): RefractionTexture;
  142691. /**
  142692. * Serialize the texture to a JSON representation you could use in Parse later on
  142693. * @returns the serialized JSON representation
  142694. */
  142695. serialize(): any;
  142696. }
  142697. }
  142698. declare module BABYLON {
  142699. /**
  142700. * Block used to add support for vertex skinning (bones)
  142701. */
  142702. export class BonesBlock extends NodeMaterialBlock {
  142703. /**
  142704. * Creates a new BonesBlock
  142705. * @param name defines the block name
  142706. */
  142707. constructor(name: string);
  142708. /**
  142709. * Initialize the block and prepare the context for build
  142710. * @param state defines the state that will be used for the build
  142711. */
  142712. initialize(state: NodeMaterialBuildState): void;
  142713. /**
  142714. * Gets the current class name
  142715. * @returns the class name
  142716. */
  142717. getClassName(): string;
  142718. /**
  142719. * Gets the matrix indices input component
  142720. */
  142721. get matricesIndices(): NodeMaterialConnectionPoint;
  142722. /**
  142723. * Gets the matrix weights input component
  142724. */
  142725. get matricesWeights(): NodeMaterialConnectionPoint;
  142726. /**
  142727. * Gets the extra matrix indices input component
  142728. */
  142729. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  142730. /**
  142731. * Gets the extra matrix weights input component
  142732. */
  142733. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  142734. /**
  142735. * Gets the world input component
  142736. */
  142737. get world(): NodeMaterialConnectionPoint;
  142738. /**
  142739. * Gets the output component
  142740. */
  142741. get output(): NodeMaterialConnectionPoint;
  142742. autoConfigure(material: NodeMaterial): void;
  142743. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  142744. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142745. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142746. protected _buildBlock(state: NodeMaterialBuildState): this;
  142747. }
  142748. }
  142749. declare module BABYLON {
  142750. /**
  142751. * Block used to add support for instances
  142752. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  142753. */
  142754. export class InstancesBlock extends NodeMaterialBlock {
  142755. /**
  142756. * Creates a new InstancesBlock
  142757. * @param name defines the block name
  142758. */
  142759. constructor(name: string);
  142760. /**
  142761. * Gets the current class name
  142762. * @returns the class name
  142763. */
  142764. getClassName(): string;
  142765. /**
  142766. * Gets the first world row input component
  142767. */
  142768. get world0(): NodeMaterialConnectionPoint;
  142769. /**
  142770. * Gets the second world row input component
  142771. */
  142772. get world1(): NodeMaterialConnectionPoint;
  142773. /**
  142774. * Gets the third world row input component
  142775. */
  142776. get world2(): NodeMaterialConnectionPoint;
  142777. /**
  142778. * Gets the forth world row input component
  142779. */
  142780. get world3(): NodeMaterialConnectionPoint;
  142781. /**
  142782. * Gets the world input component
  142783. */
  142784. get world(): NodeMaterialConnectionPoint;
  142785. /**
  142786. * Gets the output component
  142787. */
  142788. get output(): NodeMaterialConnectionPoint;
  142789. /**
  142790. * Gets the isntanceID component
  142791. */
  142792. get instanceID(): NodeMaterialConnectionPoint;
  142793. autoConfigure(material: NodeMaterial): void;
  142794. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  142795. protected _buildBlock(state: NodeMaterialBuildState): this;
  142796. }
  142797. }
  142798. declare module BABYLON {
  142799. /**
  142800. * Block used to add morph targets support to vertex shader
  142801. */
  142802. export class MorphTargetsBlock extends NodeMaterialBlock {
  142803. private _repeatableContentAnchor;
  142804. /**
  142805. * Create a new MorphTargetsBlock
  142806. * @param name defines the block name
  142807. */
  142808. constructor(name: string);
  142809. /**
  142810. * Gets the current class name
  142811. * @returns the class name
  142812. */
  142813. getClassName(): string;
  142814. /**
  142815. * Gets the position input component
  142816. */
  142817. get position(): NodeMaterialConnectionPoint;
  142818. /**
  142819. * Gets the normal input component
  142820. */
  142821. get normal(): NodeMaterialConnectionPoint;
  142822. /**
  142823. * Gets the tangent input component
  142824. */
  142825. get tangent(): NodeMaterialConnectionPoint;
  142826. /**
  142827. * Gets the tangent input component
  142828. */
  142829. get uv(): NodeMaterialConnectionPoint;
  142830. /**
  142831. * Gets the position output component
  142832. */
  142833. get positionOutput(): NodeMaterialConnectionPoint;
  142834. /**
  142835. * Gets the normal output component
  142836. */
  142837. get normalOutput(): NodeMaterialConnectionPoint;
  142838. /**
  142839. * Gets the tangent output component
  142840. */
  142841. get tangentOutput(): NodeMaterialConnectionPoint;
  142842. /**
  142843. * Gets the tangent output component
  142844. */
  142845. get uvOutput(): NodeMaterialConnectionPoint;
  142846. initialize(state: NodeMaterialBuildState): void;
  142847. autoConfigure(material: NodeMaterial): void;
  142848. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142850. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  142851. protected _buildBlock(state: NodeMaterialBuildState): this;
  142852. }
  142853. }
  142854. declare module BABYLON {
  142855. /**
  142856. * Block used to get data information from a light
  142857. */
  142858. export class LightInformationBlock extends NodeMaterialBlock {
  142859. private _lightDataUniformName;
  142860. private _lightColorUniformName;
  142861. private _lightTypeDefineName;
  142862. /**
  142863. * Gets or sets the light associated with this block
  142864. */
  142865. light: Nullable<Light>;
  142866. /**
  142867. * Creates a new LightInformationBlock
  142868. * @param name defines the block name
  142869. */
  142870. constructor(name: string);
  142871. /**
  142872. * Gets the current class name
  142873. * @returns the class name
  142874. */
  142875. getClassName(): string;
  142876. /**
  142877. * Gets the world position input component
  142878. */
  142879. get worldPosition(): NodeMaterialConnectionPoint;
  142880. /**
  142881. * Gets the direction output component
  142882. */
  142883. get direction(): NodeMaterialConnectionPoint;
  142884. /**
  142885. * Gets the direction output component
  142886. */
  142887. get color(): NodeMaterialConnectionPoint;
  142888. /**
  142889. * Gets the direction output component
  142890. */
  142891. get intensity(): NodeMaterialConnectionPoint;
  142892. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142893. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142894. protected _buildBlock(state: NodeMaterialBuildState): this;
  142895. serialize(): any;
  142896. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142897. }
  142898. }
  142899. declare module BABYLON {
  142900. /**
  142901. * Block used to add image processing support to fragment shader
  142902. */
  142903. export class ImageProcessingBlock extends NodeMaterialBlock {
  142904. /**
  142905. * Create a new ImageProcessingBlock
  142906. * @param name defines the block name
  142907. */
  142908. constructor(name: string);
  142909. /**
  142910. * Gets the current class name
  142911. * @returns the class name
  142912. */
  142913. getClassName(): string;
  142914. /**
  142915. * Gets the color input component
  142916. */
  142917. get color(): NodeMaterialConnectionPoint;
  142918. /**
  142919. * Gets the output component
  142920. */
  142921. get output(): NodeMaterialConnectionPoint;
  142922. /**
  142923. * Initialize the block and prepare the context for build
  142924. * @param state defines the state that will be used for the build
  142925. */
  142926. initialize(state: NodeMaterialBuildState): void;
  142927. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  142928. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142929. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142930. protected _buildBlock(state: NodeMaterialBuildState): this;
  142931. }
  142932. }
  142933. declare module BABYLON {
  142934. /**
  142935. * Block used to pertub normals based on a normal map
  142936. */
  142937. export class PerturbNormalBlock extends NodeMaterialBlock {
  142938. private _tangentSpaceParameterName;
  142939. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142940. invertX: boolean;
  142941. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  142942. invertY: boolean;
  142943. /**
  142944. * Create a new PerturbNormalBlock
  142945. * @param name defines the block name
  142946. */
  142947. constructor(name: string);
  142948. /**
  142949. * Gets the current class name
  142950. * @returns the class name
  142951. */
  142952. getClassName(): string;
  142953. /**
  142954. * Gets the world position input component
  142955. */
  142956. get worldPosition(): NodeMaterialConnectionPoint;
  142957. /**
  142958. * Gets the world normal input component
  142959. */
  142960. get worldNormal(): NodeMaterialConnectionPoint;
  142961. /**
  142962. * Gets the world tangent input component
  142963. */
  142964. get worldTangent(): NodeMaterialConnectionPoint;
  142965. /**
  142966. * Gets the uv input component
  142967. */
  142968. get uv(): NodeMaterialConnectionPoint;
  142969. /**
  142970. * Gets the normal map color input component
  142971. */
  142972. get normalMapColor(): NodeMaterialConnectionPoint;
  142973. /**
  142974. * Gets the strength input component
  142975. */
  142976. get strength(): NodeMaterialConnectionPoint;
  142977. /**
  142978. * Gets the output component
  142979. */
  142980. get output(): NodeMaterialConnectionPoint;
  142981. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142982. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142983. autoConfigure(material: NodeMaterial): void;
  142984. protected _buildBlock(state: NodeMaterialBuildState): this;
  142985. protected _dumpPropertiesCode(): string;
  142986. serialize(): any;
  142987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142988. }
  142989. }
  142990. declare module BABYLON {
  142991. /**
  142992. * Block used to discard a pixel if a value is smaller than a cutoff
  142993. */
  142994. export class DiscardBlock extends NodeMaterialBlock {
  142995. /**
  142996. * Create a new DiscardBlock
  142997. * @param name defines the block name
  142998. */
  142999. constructor(name: string);
  143000. /**
  143001. * Gets the current class name
  143002. * @returns the class name
  143003. */
  143004. getClassName(): string;
  143005. /**
  143006. * Gets the color input component
  143007. */
  143008. get value(): NodeMaterialConnectionPoint;
  143009. /**
  143010. * Gets the cutoff input component
  143011. */
  143012. get cutoff(): NodeMaterialConnectionPoint;
  143013. protected _buildBlock(state: NodeMaterialBuildState): this;
  143014. }
  143015. }
  143016. declare module BABYLON {
  143017. /**
  143018. * Block used to test if the fragment shader is front facing
  143019. */
  143020. export class FrontFacingBlock extends NodeMaterialBlock {
  143021. /**
  143022. * Creates a new FrontFacingBlock
  143023. * @param name defines the block name
  143024. */
  143025. constructor(name: string);
  143026. /**
  143027. * Gets the current class name
  143028. * @returns the class name
  143029. */
  143030. getClassName(): string;
  143031. /**
  143032. * Gets the output component
  143033. */
  143034. get output(): NodeMaterialConnectionPoint;
  143035. protected _buildBlock(state: NodeMaterialBuildState): this;
  143036. }
  143037. }
  143038. declare module BABYLON {
  143039. /**
  143040. * Block used to get the derivative value on x and y of a given input
  143041. */
  143042. export class DerivativeBlock extends NodeMaterialBlock {
  143043. /**
  143044. * Create a new DerivativeBlock
  143045. * @param name defines the block name
  143046. */
  143047. constructor(name: string);
  143048. /**
  143049. * Gets the current class name
  143050. * @returns the class name
  143051. */
  143052. getClassName(): string;
  143053. /**
  143054. * Gets the input component
  143055. */
  143056. get input(): NodeMaterialConnectionPoint;
  143057. /**
  143058. * Gets the derivative output on x
  143059. */
  143060. get dx(): NodeMaterialConnectionPoint;
  143061. /**
  143062. * Gets the derivative output on y
  143063. */
  143064. get dy(): NodeMaterialConnectionPoint;
  143065. protected _buildBlock(state: NodeMaterialBuildState): this;
  143066. }
  143067. }
  143068. declare module BABYLON {
  143069. /**
  143070. * Block used to make gl_FragCoord available
  143071. */
  143072. export class FragCoordBlock extends NodeMaterialBlock {
  143073. /**
  143074. * Creates a new FragCoordBlock
  143075. * @param name defines the block name
  143076. */
  143077. constructor(name: string);
  143078. /**
  143079. * Gets the current class name
  143080. * @returns the class name
  143081. */
  143082. getClassName(): string;
  143083. /**
  143084. * Gets the xy component
  143085. */
  143086. get xy(): NodeMaterialConnectionPoint;
  143087. /**
  143088. * Gets the xyz component
  143089. */
  143090. get xyz(): NodeMaterialConnectionPoint;
  143091. /**
  143092. * Gets the xyzw component
  143093. */
  143094. get xyzw(): NodeMaterialConnectionPoint;
  143095. /**
  143096. * Gets the x component
  143097. */
  143098. get x(): NodeMaterialConnectionPoint;
  143099. /**
  143100. * Gets the y component
  143101. */
  143102. get y(): NodeMaterialConnectionPoint;
  143103. /**
  143104. * Gets the z component
  143105. */
  143106. get z(): NodeMaterialConnectionPoint;
  143107. /**
  143108. * Gets the w component
  143109. */
  143110. get output(): NodeMaterialConnectionPoint;
  143111. protected writeOutputs(state: NodeMaterialBuildState): string;
  143112. protected _buildBlock(state: NodeMaterialBuildState): this;
  143113. }
  143114. }
  143115. declare module BABYLON {
  143116. /**
  143117. * Block used to get the screen sizes
  143118. */
  143119. export class ScreenSizeBlock extends NodeMaterialBlock {
  143120. private _varName;
  143121. private _scene;
  143122. /**
  143123. * Creates a new ScreenSizeBlock
  143124. * @param name defines the block name
  143125. */
  143126. constructor(name: string);
  143127. /**
  143128. * Gets the current class name
  143129. * @returns the class name
  143130. */
  143131. getClassName(): string;
  143132. /**
  143133. * Gets the xy component
  143134. */
  143135. get xy(): NodeMaterialConnectionPoint;
  143136. /**
  143137. * Gets the x component
  143138. */
  143139. get x(): NodeMaterialConnectionPoint;
  143140. /**
  143141. * Gets the y component
  143142. */
  143143. get y(): NodeMaterialConnectionPoint;
  143144. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143145. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  143146. protected _buildBlock(state: NodeMaterialBuildState): this;
  143147. }
  143148. }
  143149. declare module BABYLON {
  143150. /**
  143151. * Block used to add support for scene fog
  143152. */
  143153. export class FogBlock extends NodeMaterialBlock {
  143154. private _fogDistanceName;
  143155. private _fogParameters;
  143156. /**
  143157. * Create a new FogBlock
  143158. * @param name defines the block name
  143159. */
  143160. constructor(name: string);
  143161. /**
  143162. * Gets the current class name
  143163. * @returns the class name
  143164. */
  143165. getClassName(): string;
  143166. /**
  143167. * Gets the world position input component
  143168. */
  143169. get worldPosition(): NodeMaterialConnectionPoint;
  143170. /**
  143171. * Gets the view input component
  143172. */
  143173. get view(): NodeMaterialConnectionPoint;
  143174. /**
  143175. * Gets the color input component
  143176. */
  143177. get input(): NodeMaterialConnectionPoint;
  143178. /**
  143179. * Gets the fog color input component
  143180. */
  143181. get fogColor(): NodeMaterialConnectionPoint;
  143182. /**
  143183. * Gets the output component
  143184. */
  143185. get output(): NodeMaterialConnectionPoint;
  143186. autoConfigure(material: NodeMaterial): void;
  143187. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143188. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143189. protected _buildBlock(state: NodeMaterialBuildState): this;
  143190. }
  143191. }
  143192. declare module BABYLON {
  143193. /**
  143194. * Block used to add light in the fragment shader
  143195. */
  143196. export class LightBlock extends NodeMaterialBlock {
  143197. private _lightId;
  143198. /**
  143199. * Gets or sets the light associated with this block
  143200. */
  143201. light: Nullable<Light>;
  143202. /**
  143203. * Create a new LightBlock
  143204. * @param name defines the block name
  143205. */
  143206. constructor(name: string);
  143207. /**
  143208. * Gets the current class name
  143209. * @returns the class name
  143210. */
  143211. getClassName(): string;
  143212. /**
  143213. * Gets the world position input component
  143214. */
  143215. get worldPosition(): NodeMaterialConnectionPoint;
  143216. /**
  143217. * Gets the world normal input component
  143218. */
  143219. get worldNormal(): NodeMaterialConnectionPoint;
  143220. /**
  143221. * Gets the camera (or eye) position component
  143222. */
  143223. get cameraPosition(): NodeMaterialConnectionPoint;
  143224. /**
  143225. * Gets the glossiness component
  143226. */
  143227. get glossiness(): NodeMaterialConnectionPoint;
  143228. /**
  143229. * Gets the glossinness power component
  143230. */
  143231. get glossPower(): NodeMaterialConnectionPoint;
  143232. /**
  143233. * Gets the diffuse color component
  143234. */
  143235. get diffuseColor(): NodeMaterialConnectionPoint;
  143236. /**
  143237. * Gets the specular color component
  143238. */
  143239. get specularColor(): NodeMaterialConnectionPoint;
  143240. /**
  143241. * Gets the diffuse output component
  143242. */
  143243. get diffuseOutput(): NodeMaterialConnectionPoint;
  143244. /**
  143245. * Gets the specular output component
  143246. */
  143247. get specularOutput(): NodeMaterialConnectionPoint;
  143248. /**
  143249. * Gets the shadow output component
  143250. */
  143251. get shadow(): NodeMaterialConnectionPoint;
  143252. autoConfigure(material: NodeMaterial): void;
  143253. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143254. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143255. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143256. private _injectVertexCode;
  143257. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143258. serialize(): any;
  143259. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143260. }
  143261. }
  143262. declare module BABYLON {
  143263. /**
  143264. * Block used to read a reflection texture from a sampler
  143265. */
  143266. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  143267. /**
  143268. * Create a new ReflectionTextureBlock
  143269. * @param name defines the block name
  143270. */
  143271. constructor(name: string);
  143272. /**
  143273. * Gets the current class name
  143274. * @returns the class name
  143275. */
  143276. getClassName(): string;
  143277. /**
  143278. * Gets the world position input component
  143279. */
  143280. get position(): NodeMaterialConnectionPoint;
  143281. /**
  143282. * Gets the world position input component
  143283. */
  143284. get worldPosition(): NodeMaterialConnectionPoint;
  143285. /**
  143286. * Gets the world normal input component
  143287. */
  143288. get worldNormal(): NodeMaterialConnectionPoint;
  143289. /**
  143290. * Gets the world input component
  143291. */
  143292. get world(): NodeMaterialConnectionPoint;
  143293. /**
  143294. * Gets the camera (or eye) position component
  143295. */
  143296. get cameraPosition(): NodeMaterialConnectionPoint;
  143297. /**
  143298. * Gets the view input component
  143299. */
  143300. get view(): NodeMaterialConnectionPoint;
  143301. /**
  143302. * Gets the rgb output component
  143303. */
  143304. get rgb(): NodeMaterialConnectionPoint;
  143305. /**
  143306. * Gets the rgba output component
  143307. */
  143308. get rgba(): NodeMaterialConnectionPoint;
  143309. /**
  143310. * Gets the r output component
  143311. */
  143312. get r(): NodeMaterialConnectionPoint;
  143313. /**
  143314. * Gets the g output component
  143315. */
  143316. get g(): NodeMaterialConnectionPoint;
  143317. /**
  143318. * Gets the b output component
  143319. */
  143320. get b(): NodeMaterialConnectionPoint;
  143321. /**
  143322. * Gets the a output component
  143323. */
  143324. get a(): NodeMaterialConnectionPoint;
  143325. autoConfigure(material: NodeMaterial): void;
  143326. protected _buildBlock(state: NodeMaterialBuildState): this;
  143327. }
  143328. }
  143329. declare module BABYLON {
  143330. /**
  143331. * Block used to add 2 vectors
  143332. */
  143333. export class AddBlock extends NodeMaterialBlock {
  143334. /**
  143335. * Creates a new AddBlock
  143336. * @param name defines the block name
  143337. */
  143338. constructor(name: string);
  143339. /**
  143340. * Gets the current class name
  143341. * @returns the class name
  143342. */
  143343. getClassName(): string;
  143344. /**
  143345. * Gets the left operand input component
  143346. */
  143347. get left(): NodeMaterialConnectionPoint;
  143348. /**
  143349. * Gets the right operand input component
  143350. */
  143351. get right(): NodeMaterialConnectionPoint;
  143352. /**
  143353. * Gets the output component
  143354. */
  143355. get output(): NodeMaterialConnectionPoint;
  143356. protected _buildBlock(state: NodeMaterialBuildState): this;
  143357. }
  143358. }
  143359. declare module BABYLON {
  143360. /**
  143361. * Block used to scale a vector by a float
  143362. */
  143363. export class ScaleBlock extends NodeMaterialBlock {
  143364. /**
  143365. * Creates a new ScaleBlock
  143366. * @param name defines the block name
  143367. */
  143368. constructor(name: string);
  143369. /**
  143370. * Gets the current class name
  143371. * @returns the class name
  143372. */
  143373. getClassName(): string;
  143374. /**
  143375. * Gets the input component
  143376. */
  143377. get input(): NodeMaterialConnectionPoint;
  143378. /**
  143379. * Gets the factor input component
  143380. */
  143381. get factor(): NodeMaterialConnectionPoint;
  143382. /**
  143383. * Gets the output component
  143384. */
  143385. get output(): NodeMaterialConnectionPoint;
  143386. protected _buildBlock(state: NodeMaterialBuildState): this;
  143387. }
  143388. }
  143389. declare module BABYLON {
  143390. /**
  143391. * Block used to clamp a float
  143392. */
  143393. export class ClampBlock extends NodeMaterialBlock {
  143394. /** Gets or sets the minimum range */
  143395. minimum: number;
  143396. /** Gets or sets the maximum range */
  143397. maximum: number;
  143398. /**
  143399. * Creates a new ClampBlock
  143400. * @param name defines the block name
  143401. */
  143402. constructor(name: string);
  143403. /**
  143404. * Gets the current class name
  143405. * @returns the class name
  143406. */
  143407. getClassName(): string;
  143408. /**
  143409. * Gets the value input component
  143410. */
  143411. get value(): NodeMaterialConnectionPoint;
  143412. /**
  143413. * Gets the output component
  143414. */
  143415. get output(): NodeMaterialConnectionPoint;
  143416. protected _buildBlock(state: NodeMaterialBuildState): this;
  143417. protected _dumpPropertiesCode(): string;
  143418. serialize(): any;
  143419. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143420. }
  143421. }
  143422. declare module BABYLON {
  143423. /**
  143424. * Block used to apply a cross product between 2 vectors
  143425. */
  143426. export class CrossBlock extends NodeMaterialBlock {
  143427. /**
  143428. * Creates a new CrossBlock
  143429. * @param name defines the block name
  143430. */
  143431. constructor(name: string);
  143432. /**
  143433. * Gets the current class name
  143434. * @returns the class name
  143435. */
  143436. getClassName(): string;
  143437. /**
  143438. * Gets the left operand input component
  143439. */
  143440. get left(): NodeMaterialConnectionPoint;
  143441. /**
  143442. * Gets the right operand input component
  143443. */
  143444. get right(): NodeMaterialConnectionPoint;
  143445. /**
  143446. * Gets the output component
  143447. */
  143448. get output(): NodeMaterialConnectionPoint;
  143449. protected _buildBlock(state: NodeMaterialBuildState): this;
  143450. }
  143451. }
  143452. declare module BABYLON {
  143453. /**
  143454. * Block used to apply a dot product between 2 vectors
  143455. */
  143456. export class DotBlock extends NodeMaterialBlock {
  143457. /**
  143458. * Creates a new DotBlock
  143459. * @param name defines the block name
  143460. */
  143461. constructor(name: string);
  143462. /**
  143463. * Gets the current class name
  143464. * @returns the class name
  143465. */
  143466. getClassName(): string;
  143467. /**
  143468. * Gets the left operand input component
  143469. */
  143470. get left(): NodeMaterialConnectionPoint;
  143471. /**
  143472. * Gets the right operand input component
  143473. */
  143474. get right(): NodeMaterialConnectionPoint;
  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 normalize a vector
  143485. */
  143486. export class NormalizeBlock extends NodeMaterialBlock {
  143487. /**
  143488. * Creates a new NormalizeBlock
  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 output component
  143503. */
  143504. get output(): NodeMaterialConnectionPoint;
  143505. protected _buildBlock(state: NodeMaterialBuildState): this;
  143506. }
  143507. }
  143508. declare module BABYLON {
  143509. /**
  143510. * Block used to create a Color3/4 out of individual inputs (one for each component)
  143511. */
  143512. export class ColorMergerBlock extends NodeMaterialBlock {
  143513. /**
  143514. * Create a new ColorMergerBlock
  143515. * @param name defines the block name
  143516. */
  143517. constructor(name: string);
  143518. /**
  143519. * Gets the current class name
  143520. * @returns the class name
  143521. */
  143522. getClassName(): string;
  143523. /**
  143524. * Gets the rgb component (input)
  143525. */
  143526. get rgbIn(): NodeMaterialConnectionPoint;
  143527. /**
  143528. * Gets the r component (input)
  143529. */
  143530. get r(): NodeMaterialConnectionPoint;
  143531. /**
  143532. * Gets the g component (input)
  143533. */
  143534. get g(): NodeMaterialConnectionPoint;
  143535. /**
  143536. * Gets the b component (input)
  143537. */
  143538. get b(): NodeMaterialConnectionPoint;
  143539. /**
  143540. * Gets the a component (input)
  143541. */
  143542. get a(): NodeMaterialConnectionPoint;
  143543. /**
  143544. * Gets the rgba component (output)
  143545. */
  143546. get rgba(): NodeMaterialConnectionPoint;
  143547. /**
  143548. * Gets the rgb component (output)
  143549. */
  143550. get rgbOut(): NodeMaterialConnectionPoint;
  143551. /**
  143552. * Gets the rgb component (output)
  143553. * @deprecated Please use rgbOut instead.
  143554. */
  143555. get rgb(): NodeMaterialConnectionPoint;
  143556. protected _buildBlock(state: NodeMaterialBuildState): this;
  143557. }
  143558. }
  143559. declare module BABYLON {
  143560. /**
  143561. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  143562. */
  143563. export class VectorSplitterBlock extends NodeMaterialBlock {
  143564. /**
  143565. * Create a new VectorSplitterBlock
  143566. * @param name defines the block name
  143567. */
  143568. constructor(name: string);
  143569. /**
  143570. * Gets the current class name
  143571. * @returns the class name
  143572. */
  143573. getClassName(): string;
  143574. /**
  143575. * Gets the xyzw component (input)
  143576. */
  143577. get xyzw(): NodeMaterialConnectionPoint;
  143578. /**
  143579. * Gets the xyz component (input)
  143580. */
  143581. get xyzIn(): NodeMaterialConnectionPoint;
  143582. /**
  143583. * Gets the xy component (input)
  143584. */
  143585. get xyIn(): NodeMaterialConnectionPoint;
  143586. /**
  143587. * Gets the xyz component (output)
  143588. */
  143589. get xyzOut(): NodeMaterialConnectionPoint;
  143590. /**
  143591. * Gets the xy component (output)
  143592. */
  143593. get xyOut(): NodeMaterialConnectionPoint;
  143594. /**
  143595. * Gets the x component (output)
  143596. */
  143597. get x(): NodeMaterialConnectionPoint;
  143598. /**
  143599. * Gets the y component (output)
  143600. */
  143601. get y(): NodeMaterialConnectionPoint;
  143602. /**
  143603. * Gets the z component (output)
  143604. */
  143605. get z(): NodeMaterialConnectionPoint;
  143606. /**
  143607. * Gets the w component (output)
  143608. */
  143609. get w(): NodeMaterialConnectionPoint;
  143610. protected _inputRename(name: string): string;
  143611. protected _outputRename(name: string): string;
  143612. protected _buildBlock(state: NodeMaterialBuildState): this;
  143613. }
  143614. }
  143615. declare module BABYLON {
  143616. /**
  143617. * Block used to lerp between 2 values
  143618. */
  143619. export class LerpBlock extends NodeMaterialBlock {
  143620. /**
  143621. * Creates a new LerpBlock
  143622. * @param name defines the block name
  143623. */
  143624. constructor(name: string);
  143625. /**
  143626. * Gets the current class name
  143627. * @returns the class name
  143628. */
  143629. getClassName(): string;
  143630. /**
  143631. * Gets the left operand input component
  143632. */
  143633. get left(): NodeMaterialConnectionPoint;
  143634. /**
  143635. * Gets the right operand input component
  143636. */
  143637. get right(): NodeMaterialConnectionPoint;
  143638. /**
  143639. * Gets the gradient operand input component
  143640. */
  143641. get gradient(): NodeMaterialConnectionPoint;
  143642. /**
  143643. * Gets the output component
  143644. */
  143645. get output(): NodeMaterialConnectionPoint;
  143646. protected _buildBlock(state: NodeMaterialBuildState): this;
  143647. }
  143648. }
  143649. declare module BABYLON {
  143650. /**
  143651. * Block used to divide 2 vectors
  143652. */
  143653. export class DivideBlock extends NodeMaterialBlock {
  143654. /**
  143655. * Creates a new DivideBlock
  143656. * @param name defines the block name
  143657. */
  143658. constructor(name: string);
  143659. /**
  143660. * Gets the current class name
  143661. * @returns the class name
  143662. */
  143663. getClassName(): string;
  143664. /**
  143665. * Gets the left operand input component
  143666. */
  143667. get left(): NodeMaterialConnectionPoint;
  143668. /**
  143669. * Gets the right operand input component
  143670. */
  143671. get right(): NodeMaterialConnectionPoint;
  143672. /**
  143673. * Gets the output component
  143674. */
  143675. get output(): NodeMaterialConnectionPoint;
  143676. protected _buildBlock(state: NodeMaterialBuildState): this;
  143677. }
  143678. }
  143679. declare module BABYLON {
  143680. /**
  143681. * Block used to subtract 2 vectors
  143682. */
  143683. export class SubtractBlock extends NodeMaterialBlock {
  143684. /**
  143685. * Creates a new SubtractBlock
  143686. * @param name defines the block name
  143687. */
  143688. constructor(name: string);
  143689. /**
  143690. * Gets the current class name
  143691. * @returns the class name
  143692. */
  143693. getClassName(): string;
  143694. /**
  143695. * Gets the left operand input component
  143696. */
  143697. get left(): NodeMaterialConnectionPoint;
  143698. /**
  143699. * Gets the right operand input component
  143700. */
  143701. get right(): NodeMaterialConnectionPoint;
  143702. /**
  143703. * Gets the output component
  143704. */
  143705. get output(): NodeMaterialConnectionPoint;
  143706. protected _buildBlock(state: NodeMaterialBuildState): this;
  143707. }
  143708. }
  143709. declare module BABYLON {
  143710. /**
  143711. * Block used to step a value
  143712. */
  143713. export class StepBlock extends NodeMaterialBlock {
  143714. /**
  143715. * Creates a new StepBlock
  143716. * @param name defines the block name
  143717. */
  143718. constructor(name: string);
  143719. /**
  143720. * Gets the current class name
  143721. * @returns the class name
  143722. */
  143723. getClassName(): string;
  143724. /**
  143725. * Gets the value operand input component
  143726. */
  143727. get value(): NodeMaterialConnectionPoint;
  143728. /**
  143729. * Gets the edge operand input component
  143730. */
  143731. get edge(): NodeMaterialConnectionPoint;
  143732. /**
  143733. * Gets the output component
  143734. */
  143735. get output(): NodeMaterialConnectionPoint;
  143736. protected _buildBlock(state: NodeMaterialBuildState): this;
  143737. }
  143738. }
  143739. declare module BABYLON {
  143740. /**
  143741. * Block used to get the opposite (1 - x) of a value
  143742. */
  143743. export class OneMinusBlock extends NodeMaterialBlock {
  143744. /**
  143745. * Creates a new OneMinusBlock
  143746. * @param name defines the block name
  143747. */
  143748. constructor(name: string);
  143749. /**
  143750. * Gets the current class name
  143751. * @returns the class name
  143752. */
  143753. getClassName(): string;
  143754. /**
  143755. * Gets the input component
  143756. */
  143757. get input(): NodeMaterialConnectionPoint;
  143758. /**
  143759. * Gets the output component
  143760. */
  143761. get output(): NodeMaterialConnectionPoint;
  143762. protected _buildBlock(state: NodeMaterialBuildState): this;
  143763. }
  143764. }
  143765. declare module BABYLON {
  143766. /**
  143767. * Block used to get the view direction
  143768. */
  143769. export class ViewDirectionBlock extends NodeMaterialBlock {
  143770. /**
  143771. * Creates a new ViewDirectionBlock
  143772. * @param name defines the block name
  143773. */
  143774. constructor(name: string);
  143775. /**
  143776. * Gets the current class name
  143777. * @returns the class name
  143778. */
  143779. getClassName(): string;
  143780. /**
  143781. * Gets the world position component
  143782. */
  143783. get worldPosition(): NodeMaterialConnectionPoint;
  143784. /**
  143785. * Gets the camera position component
  143786. */
  143787. get cameraPosition(): NodeMaterialConnectionPoint;
  143788. /**
  143789. * Gets the output component
  143790. */
  143791. get output(): NodeMaterialConnectionPoint;
  143792. autoConfigure(material: NodeMaterial): void;
  143793. protected _buildBlock(state: NodeMaterialBuildState): this;
  143794. }
  143795. }
  143796. declare module BABYLON {
  143797. /**
  143798. * Block used to compute fresnel value
  143799. */
  143800. export class FresnelBlock extends NodeMaterialBlock {
  143801. /**
  143802. * Create a new FresnelBlock
  143803. * @param name defines the block name
  143804. */
  143805. constructor(name: string);
  143806. /**
  143807. * Gets the current class name
  143808. * @returns the class name
  143809. */
  143810. getClassName(): string;
  143811. /**
  143812. * Gets the world normal input component
  143813. */
  143814. get worldNormal(): NodeMaterialConnectionPoint;
  143815. /**
  143816. * Gets the view direction input component
  143817. */
  143818. get viewDirection(): NodeMaterialConnectionPoint;
  143819. /**
  143820. * Gets the bias input component
  143821. */
  143822. get bias(): NodeMaterialConnectionPoint;
  143823. /**
  143824. * Gets the camera (or eye) position component
  143825. */
  143826. get power(): NodeMaterialConnectionPoint;
  143827. /**
  143828. * Gets the fresnel output component
  143829. */
  143830. get fresnel(): NodeMaterialConnectionPoint;
  143831. autoConfigure(material: NodeMaterial): void;
  143832. protected _buildBlock(state: NodeMaterialBuildState): this;
  143833. }
  143834. }
  143835. declare module BABYLON {
  143836. /**
  143837. * Block used to get the max of 2 values
  143838. */
  143839. export class MaxBlock extends NodeMaterialBlock {
  143840. /**
  143841. * Creates a new MaxBlock
  143842. * @param name defines the block name
  143843. */
  143844. constructor(name: string);
  143845. /**
  143846. * Gets the current class name
  143847. * @returns the class name
  143848. */
  143849. getClassName(): string;
  143850. /**
  143851. * Gets the left operand input component
  143852. */
  143853. get left(): NodeMaterialConnectionPoint;
  143854. /**
  143855. * Gets the right operand input component
  143856. */
  143857. get right(): NodeMaterialConnectionPoint;
  143858. /**
  143859. * Gets the output component
  143860. */
  143861. get output(): NodeMaterialConnectionPoint;
  143862. protected _buildBlock(state: NodeMaterialBuildState): this;
  143863. }
  143864. }
  143865. declare module BABYLON {
  143866. /**
  143867. * Block used to get the min of 2 values
  143868. */
  143869. export class MinBlock extends NodeMaterialBlock {
  143870. /**
  143871. * Creates a new MinBlock
  143872. * @param name defines the block name
  143873. */
  143874. constructor(name: string);
  143875. /**
  143876. * Gets the current class name
  143877. * @returns the class name
  143878. */
  143879. getClassName(): string;
  143880. /**
  143881. * Gets the left operand input component
  143882. */
  143883. get left(): NodeMaterialConnectionPoint;
  143884. /**
  143885. * Gets the right operand input component
  143886. */
  143887. get right(): NodeMaterialConnectionPoint;
  143888. /**
  143889. * Gets the output component
  143890. */
  143891. get output(): NodeMaterialConnectionPoint;
  143892. protected _buildBlock(state: NodeMaterialBuildState): this;
  143893. }
  143894. }
  143895. declare module BABYLON {
  143896. /**
  143897. * Block used to get the distance between 2 values
  143898. */
  143899. export class DistanceBlock extends NodeMaterialBlock {
  143900. /**
  143901. * Creates a new DistanceBlock
  143902. * @param name defines the block name
  143903. */
  143904. constructor(name: string);
  143905. /**
  143906. * Gets the current class name
  143907. * @returns the class name
  143908. */
  143909. getClassName(): string;
  143910. /**
  143911. * Gets the left operand input component
  143912. */
  143913. get left(): NodeMaterialConnectionPoint;
  143914. /**
  143915. * Gets the right operand input component
  143916. */
  143917. get right(): NodeMaterialConnectionPoint;
  143918. /**
  143919. * Gets the output component
  143920. */
  143921. get output(): NodeMaterialConnectionPoint;
  143922. protected _buildBlock(state: NodeMaterialBuildState): this;
  143923. }
  143924. }
  143925. declare module BABYLON {
  143926. /**
  143927. * Block used to get the length of a vector
  143928. */
  143929. export class LengthBlock extends NodeMaterialBlock {
  143930. /**
  143931. * Creates a new LengthBlock
  143932. * @param name defines the block name
  143933. */
  143934. constructor(name: string);
  143935. /**
  143936. * Gets the current class name
  143937. * @returns the class name
  143938. */
  143939. getClassName(): string;
  143940. /**
  143941. * Gets the value input component
  143942. */
  143943. get value(): NodeMaterialConnectionPoint;
  143944. /**
  143945. * Gets the output component
  143946. */
  143947. get output(): NodeMaterialConnectionPoint;
  143948. protected _buildBlock(state: NodeMaterialBuildState): this;
  143949. }
  143950. }
  143951. declare module BABYLON {
  143952. /**
  143953. * Block used to get negative version of a value (i.e. x * -1)
  143954. */
  143955. export class NegateBlock extends NodeMaterialBlock {
  143956. /**
  143957. * Creates a new NegateBlock
  143958. * @param name defines the block name
  143959. */
  143960. constructor(name: string);
  143961. /**
  143962. * Gets the current class name
  143963. * @returns the class name
  143964. */
  143965. getClassName(): string;
  143966. /**
  143967. * Gets the value input component
  143968. */
  143969. get value(): NodeMaterialConnectionPoint;
  143970. /**
  143971. * Gets the output component
  143972. */
  143973. get output(): NodeMaterialConnectionPoint;
  143974. protected _buildBlock(state: NodeMaterialBuildState): this;
  143975. }
  143976. }
  143977. declare module BABYLON {
  143978. /**
  143979. * Block used to get the value of the first parameter raised to the power of the second
  143980. */
  143981. export class PowBlock extends NodeMaterialBlock {
  143982. /**
  143983. * Creates a new PowBlock
  143984. * @param name defines the block name
  143985. */
  143986. constructor(name: string);
  143987. /**
  143988. * Gets the current class name
  143989. * @returns the class name
  143990. */
  143991. getClassName(): string;
  143992. /**
  143993. * Gets the value operand input component
  143994. */
  143995. get value(): NodeMaterialConnectionPoint;
  143996. /**
  143997. * Gets the power operand input component
  143998. */
  143999. get power(): NodeMaterialConnectionPoint;
  144000. /**
  144001. * Gets the output component
  144002. */
  144003. get output(): NodeMaterialConnectionPoint;
  144004. protected _buildBlock(state: NodeMaterialBuildState): this;
  144005. }
  144006. }
  144007. declare module BABYLON {
  144008. /**
  144009. * Block used to get a random number
  144010. */
  144011. export class RandomNumberBlock extends NodeMaterialBlock {
  144012. /**
  144013. * Creates a new RandomNumberBlock
  144014. * @param name defines the block name
  144015. */
  144016. constructor(name: string);
  144017. /**
  144018. * Gets the current class name
  144019. * @returns the class name
  144020. */
  144021. getClassName(): string;
  144022. /**
  144023. * Gets the seed input component
  144024. */
  144025. get seed(): NodeMaterialConnectionPoint;
  144026. /**
  144027. * Gets the output component
  144028. */
  144029. get output(): NodeMaterialConnectionPoint;
  144030. protected _buildBlock(state: NodeMaterialBuildState): this;
  144031. }
  144032. }
  144033. declare module BABYLON {
  144034. /**
  144035. * Block used to compute arc tangent of 2 values
  144036. */
  144037. export class ArcTan2Block extends NodeMaterialBlock {
  144038. /**
  144039. * Creates a new ArcTan2Block
  144040. * @param name defines the block name
  144041. */
  144042. constructor(name: string);
  144043. /**
  144044. * Gets the current class name
  144045. * @returns the class name
  144046. */
  144047. getClassName(): string;
  144048. /**
  144049. * Gets the x operand input component
  144050. */
  144051. get x(): NodeMaterialConnectionPoint;
  144052. /**
  144053. * Gets the y operand input component
  144054. */
  144055. get y(): NodeMaterialConnectionPoint;
  144056. /**
  144057. * Gets the output component
  144058. */
  144059. get output(): NodeMaterialConnectionPoint;
  144060. protected _buildBlock(state: NodeMaterialBuildState): this;
  144061. }
  144062. }
  144063. declare module BABYLON {
  144064. /**
  144065. * Block used to smooth step a value
  144066. */
  144067. export class SmoothStepBlock extends NodeMaterialBlock {
  144068. /**
  144069. * Creates a new SmoothStepBlock
  144070. * @param name defines the block name
  144071. */
  144072. constructor(name: string);
  144073. /**
  144074. * Gets the current class name
  144075. * @returns the class name
  144076. */
  144077. getClassName(): string;
  144078. /**
  144079. * Gets the value operand input component
  144080. */
  144081. get value(): NodeMaterialConnectionPoint;
  144082. /**
  144083. * Gets the first edge operand input component
  144084. */
  144085. get edge0(): NodeMaterialConnectionPoint;
  144086. /**
  144087. * Gets the second edge operand input component
  144088. */
  144089. get edge1(): NodeMaterialConnectionPoint;
  144090. /**
  144091. * Gets the output component
  144092. */
  144093. get output(): NodeMaterialConnectionPoint;
  144094. protected _buildBlock(state: NodeMaterialBuildState): this;
  144095. }
  144096. }
  144097. declare module BABYLON {
  144098. /**
  144099. * Block used to get the reciprocal (1 / x) of a value
  144100. */
  144101. export class ReciprocalBlock extends NodeMaterialBlock {
  144102. /**
  144103. * Creates a new ReciprocalBlock
  144104. * @param name defines the block name
  144105. */
  144106. constructor(name: string);
  144107. /**
  144108. * Gets the current class name
  144109. * @returns the class name
  144110. */
  144111. getClassName(): string;
  144112. /**
  144113. * Gets the input component
  144114. */
  144115. get input(): 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 replace a color by another one
  144126. */
  144127. export class ReplaceColorBlock extends NodeMaterialBlock {
  144128. /**
  144129. * Creates a new ReplaceColorBlock
  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 value input component
  144140. */
  144141. get value(): NodeMaterialConnectionPoint;
  144142. /**
  144143. * Gets the reference input component
  144144. */
  144145. get reference(): NodeMaterialConnectionPoint;
  144146. /**
  144147. * Gets the distance input component
  144148. */
  144149. get distance(): NodeMaterialConnectionPoint;
  144150. /**
  144151. * Gets the replacement input component
  144152. */
  144153. get replacement(): NodeMaterialConnectionPoint;
  144154. /**
  144155. * Gets the output component
  144156. */
  144157. get output(): NodeMaterialConnectionPoint;
  144158. protected _buildBlock(state: NodeMaterialBuildState): this;
  144159. }
  144160. }
  144161. declare module BABYLON {
  144162. /**
  144163. * Block used to posterize a value
  144164. * @see https://en.wikipedia.org/wiki/Posterization
  144165. */
  144166. export class PosterizeBlock extends NodeMaterialBlock {
  144167. /**
  144168. * Creates a new PosterizeBlock
  144169. * @param name defines the block name
  144170. */
  144171. constructor(name: string);
  144172. /**
  144173. * Gets the current class name
  144174. * @returns the class name
  144175. */
  144176. getClassName(): string;
  144177. /**
  144178. * Gets the value input component
  144179. */
  144180. get value(): NodeMaterialConnectionPoint;
  144181. /**
  144182. * Gets the steps input component
  144183. */
  144184. get steps(): NodeMaterialConnectionPoint;
  144185. /**
  144186. * Gets the output component
  144187. */
  144188. get output(): NodeMaterialConnectionPoint;
  144189. protected _buildBlock(state: NodeMaterialBuildState): this;
  144190. }
  144191. }
  144192. declare module BABYLON {
  144193. /**
  144194. * Operations supported by the Wave block
  144195. */
  144196. export enum WaveBlockKind {
  144197. /** SawTooth */
  144198. SawTooth = 0,
  144199. /** Square */
  144200. Square = 1,
  144201. /** Triangle */
  144202. Triangle = 2
  144203. }
  144204. /**
  144205. * Block used to apply wave operation to floats
  144206. */
  144207. export class WaveBlock extends NodeMaterialBlock {
  144208. /**
  144209. * Gets or sets the kibnd of wave to be applied by the block
  144210. */
  144211. kind: WaveBlockKind;
  144212. /**
  144213. * Creates a new WaveBlock
  144214. * @param name defines the block name
  144215. */
  144216. constructor(name: string);
  144217. /**
  144218. * Gets the current class name
  144219. * @returns the class name
  144220. */
  144221. getClassName(): string;
  144222. /**
  144223. * Gets the input component
  144224. */
  144225. get input(): NodeMaterialConnectionPoint;
  144226. /**
  144227. * Gets the output component
  144228. */
  144229. get output(): NodeMaterialConnectionPoint;
  144230. protected _buildBlock(state: NodeMaterialBuildState): this;
  144231. serialize(): any;
  144232. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144233. }
  144234. }
  144235. declare module BABYLON {
  144236. /**
  144237. * Class used to store a color step for the GradientBlock
  144238. */
  144239. export class GradientBlockColorStep {
  144240. private _step;
  144241. /**
  144242. * Gets value indicating which step this color is associated with (between 0 and 1)
  144243. */
  144244. get step(): number;
  144245. /**
  144246. * Sets a value indicating which step this color is associated with (between 0 and 1)
  144247. */
  144248. set step(val: number);
  144249. private _color;
  144250. /**
  144251. * Gets the color associated with this step
  144252. */
  144253. get color(): Color3;
  144254. /**
  144255. * Sets the color associated with this step
  144256. */
  144257. set color(val: Color3);
  144258. /**
  144259. * Creates a new GradientBlockColorStep
  144260. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  144261. * @param color defines the color associated with this step
  144262. */
  144263. constructor(step: number, color: Color3);
  144264. }
  144265. /**
  144266. * Block used to return a color from a gradient based on an input value between 0 and 1
  144267. */
  144268. export class GradientBlock extends NodeMaterialBlock {
  144269. /**
  144270. * Gets or sets the list of color steps
  144271. */
  144272. colorSteps: GradientBlockColorStep[];
  144273. /** Gets an observable raised when the value is changed */
  144274. onValueChangedObservable: Observable<GradientBlock>;
  144275. /** calls observable when the value is changed*/
  144276. colorStepsUpdated(): void;
  144277. /**
  144278. * Creates a new GradientBlock
  144279. * @param name defines the block name
  144280. */
  144281. constructor(name: string);
  144282. /**
  144283. * Gets the current class name
  144284. * @returns the class name
  144285. */
  144286. getClassName(): string;
  144287. /**
  144288. * Gets the gradient input component
  144289. */
  144290. get gradient(): NodeMaterialConnectionPoint;
  144291. /**
  144292. * Gets the output component
  144293. */
  144294. get output(): NodeMaterialConnectionPoint;
  144295. private _writeColorConstant;
  144296. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144297. serialize(): any;
  144298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144299. protected _dumpPropertiesCode(): string;
  144300. }
  144301. }
  144302. declare module BABYLON {
  144303. /**
  144304. * Block used to normalize lerp between 2 values
  144305. */
  144306. export class NLerpBlock extends NodeMaterialBlock {
  144307. /**
  144308. * Creates a new NLerpBlock
  144309. * @param name defines the block name
  144310. */
  144311. constructor(name: string);
  144312. /**
  144313. * Gets the current class name
  144314. * @returns the class name
  144315. */
  144316. getClassName(): string;
  144317. /**
  144318. * Gets the left operand input component
  144319. */
  144320. get left(): NodeMaterialConnectionPoint;
  144321. /**
  144322. * Gets the right operand input component
  144323. */
  144324. get right(): NodeMaterialConnectionPoint;
  144325. /**
  144326. * Gets the gradient operand input component
  144327. */
  144328. get gradient(): NodeMaterialConnectionPoint;
  144329. /**
  144330. * Gets the output component
  144331. */
  144332. get output(): NodeMaterialConnectionPoint;
  144333. protected _buildBlock(state: NodeMaterialBuildState): this;
  144334. }
  144335. }
  144336. declare module BABYLON {
  144337. /**
  144338. * block used to Generate a Worley Noise 3D Noise Pattern
  144339. */
  144340. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  144341. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144342. manhattanDistance: boolean;
  144343. /**
  144344. * Creates a new WorleyNoise3DBlock
  144345. * @param name defines the block name
  144346. */
  144347. constructor(name: string);
  144348. /**
  144349. * Gets the current class name
  144350. * @returns the class name
  144351. */
  144352. getClassName(): string;
  144353. /**
  144354. * Gets the seed input component
  144355. */
  144356. get seed(): NodeMaterialConnectionPoint;
  144357. /**
  144358. * Gets the jitter input component
  144359. */
  144360. get jitter(): NodeMaterialConnectionPoint;
  144361. /**
  144362. * Gets the output component
  144363. */
  144364. get output(): NodeMaterialConnectionPoint;
  144365. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144366. /**
  144367. * Exposes the properties to the UI?
  144368. */
  144369. protected _dumpPropertiesCode(): string;
  144370. /**
  144371. * Exposes the properties to the Seralize?
  144372. */
  144373. serialize(): any;
  144374. /**
  144375. * Exposes the properties to the deseralize?
  144376. */
  144377. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144378. }
  144379. }
  144380. declare module BABYLON {
  144381. /**
  144382. * block used to Generate a Simplex Perlin 3d Noise Pattern
  144383. */
  144384. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  144385. /**
  144386. * Creates a new SimplexPerlin3DBlock
  144387. * @param name defines the block name
  144388. */
  144389. constructor(name: string);
  144390. /**
  144391. * Gets the current class name
  144392. * @returns the class name
  144393. */
  144394. getClassName(): string;
  144395. /**
  144396. * Gets the seed operand input component
  144397. */
  144398. get seed(): NodeMaterialConnectionPoint;
  144399. /**
  144400. * Gets the output component
  144401. */
  144402. get output(): NodeMaterialConnectionPoint;
  144403. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144404. }
  144405. }
  144406. declare module BABYLON {
  144407. /**
  144408. * Block used to blend normals
  144409. */
  144410. export class NormalBlendBlock extends NodeMaterialBlock {
  144411. /**
  144412. * Creates a new NormalBlendBlock
  144413. * @param name defines the block name
  144414. */
  144415. constructor(name: string);
  144416. /**
  144417. * Gets the current class name
  144418. * @returns the class name
  144419. */
  144420. getClassName(): string;
  144421. /**
  144422. * Gets the first input component
  144423. */
  144424. get normalMap0(): NodeMaterialConnectionPoint;
  144425. /**
  144426. * Gets the second input component
  144427. */
  144428. get normalMap1(): NodeMaterialConnectionPoint;
  144429. /**
  144430. * Gets the output component
  144431. */
  144432. get output(): NodeMaterialConnectionPoint;
  144433. protected _buildBlock(state: NodeMaterialBuildState): this;
  144434. }
  144435. }
  144436. declare module BABYLON {
  144437. /**
  144438. * Block used to rotate a 2d vector by a given angle
  144439. */
  144440. export class Rotate2dBlock extends NodeMaterialBlock {
  144441. /**
  144442. * Creates a new Rotate2dBlock
  144443. * @param name defines the block name
  144444. */
  144445. constructor(name: string);
  144446. /**
  144447. * Gets the current class name
  144448. * @returns the class name
  144449. */
  144450. getClassName(): string;
  144451. /**
  144452. * Gets the input vector
  144453. */
  144454. get input(): NodeMaterialConnectionPoint;
  144455. /**
  144456. * Gets the input angle
  144457. */
  144458. get angle(): NodeMaterialConnectionPoint;
  144459. /**
  144460. * Gets the output component
  144461. */
  144462. get output(): NodeMaterialConnectionPoint;
  144463. autoConfigure(material: NodeMaterial): void;
  144464. protected _buildBlock(state: NodeMaterialBuildState): this;
  144465. }
  144466. }
  144467. declare module BABYLON {
  144468. /**
  144469. * Block used to get the reflected vector from a direction and a normal
  144470. */
  144471. export class ReflectBlock extends NodeMaterialBlock {
  144472. /**
  144473. * Creates a new ReflectBlock
  144474. * @param name defines the block name
  144475. */
  144476. constructor(name: string);
  144477. /**
  144478. * Gets the current class name
  144479. * @returns the class name
  144480. */
  144481. getClassName(): string;
  144482. /**
  144483. * Gets the incident component
  144484. */
  144485. get incident(): NodeMaterialConnectionPoint;
  144486. /**
  144487. * Gets the normal component
  144488. */
  144489. get normal(): NodeMaterialConnectionPoint;
  144490. /**
  144491. * Gets the output component
  144492. */
  144493. get output(): NodeMaterialConnectionPoint;
  144494. protected _buildBlock(state: NodeMaterialBuildState): this;
  144495. }
  144496. }
  144497. declare module BABYLON {
  144498. /**
  144499. * Block used to get the refracted vector from a direction and a normal
  144500. */
  144501. export class RefractBlock extends NodeMaterialBlock {
  144502. /**
  144503. * Creates a new RefractBlock
  144504. * @param name defines the block name
  144505. */
  144506. constructor(name: string);
  144507. /**
  144508. * Gets the current class name
  144509. * @returns the class name
  144510. */
  144511. getClassName(): string;
  144512. /**
  144513. * Gets the incident component
  144514. */
  144515. get incident(): NodeMaterialConnectionPoint;
  144516. /**
  144517. * Gets the normal component
  144518. */
  144519. get normal(): NodeMaterialConnectionPoint;
  144520. /**
  144521. * Gets the index of refraction component
  144522. */
  144523. get ior(): NodeMaterialConnectionPoint;
  144524. /**
  144525. * Gets the output component
  144526. */
  144527. get output(): NodeMaterialConnectionPoint;
  144528. protected _buildBlock(state: NodeMaterialBuildState): this;
  144529. }
  144530. }
  144531. declare module BABYLON {
  144532. /**
  144533. * Block used to desaturate a color
  144534. */
  144535. export class DesaturateBlock extends NodeMaterialBlock {
  144536. /**
  144537. * Creates a new DesaturateBlock
  144538. * @param name defines the block name
  144539. */
  144540. constructor(name: string);
  144541. /**
  144542. * Gets the current class name
  144543. * @returns the class name
  144544. */
  144545. getClassName(): string;
  144546. /**
  144547. * Gets the color operand input component
  144548. */
  144549. get color(): NodeMaterialConnectionPoint;
  144550. /**
  144551. * Gets the level operand input component
  144552. */
  144553. get level(): NodeMaterialConnectionPoint;
  144554. /**
  144555. * Gets the output component
  144556. */
  144557. get output(): NodeMaterialConnectionPoint;
  144558. protected _buildBlock(state: NodeMaterialBuildState): this;
  144559. }
  144560. }
  144561. declare module BABYLON {
  144562. /**
  144563. * Block used to implement the ambient occlusion module of the PBR material
  144564. */
  144565. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  144566. /**
  144567. * Create a new AmbientOcclusionBlock
  144568. * @param name defines the block name
  144569. */
  144570. constructor(name: string);
  144571. /**
  144572. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  144573. */
  144574. useAmbientInGrayScale: boolean;
  144575. /**
  144576. * Initialize the block and prepare the context for build
  144577. * @param state defines the state that will be used for the build
  144578. */
  144579. initialize(state: NodeMaterialBuildState): void;
  144580. /**
  144581. * Gets the current class name
  144582. * @returns the class name
  144583. */
  144584. getClassName(): string;
  144585. /**
  144586. * Gets the texture input component
  144587. */
  144588. get texture(): NodeMaterialConnectionPoint;
  144589. /**
  144590. * Gets the texture intensity component
  144591. */
  144592. get intensity(): NodeMaterialConnectionPoint;
  144593. /**
  144594. * Gets the direct light intensity input component
  144595. */
  144596. get directLightIntensity(): NodeMaterialConnectionPoint;
  144597. /**
  144598. * Gets the ambient occlusion object output component
  144599. */
  144600. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144601. /**
  144602. * Gets the main code of the block (fragment side)
  144603. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  144604. * @returns the shader code
  144605. */
  144606. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  144607. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144608. protected _buildBlock(state: NodeMaterialBuildState): this;
  144609. protected _dumpPropertiesCode(): string;
  144610. serialize(): any;
  144611. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144612. }
  144613. }
  144614. declare module BABYLON {
  144615. /**
  144616. * Block used to implement the reflection module of the PBR material
  144617. */
  144618. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  144619. /** @hidden */
  144620. _defineLODReflectionAlpha: string;
  144621. /** @hidden */
  144622. _defineLinearSpecularReflection: string;
  144623. private _vEnvironmentIrradianceName;
  144624. /** @hidden */
  144625. _vReflectionMicrosurfaceInfosName: string;
  144626. /** @hidden */
  144627. _vReflectionInfosName: string;
  144628. /** @hidden */
  144629. _vReflectionFilteringInfoName: string;
  144630. private _scene;
  144631. /**
  144632. * The three properties below are set by the main PBR block prior to calling methods of this class.
  144633. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144634. * It's less burden on the user side in the editor part.
  144635. */
  144636. /** @hidden */
  144637. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144638. /** @hidden */
  144639. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144640. /** @hidden */
  144641. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  144642. /**
  144643. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  144644. * diffuse part of the IBL.
  144645. */
  144646. useSphericalHarmonics: boolean;
  144647. /**
  144648. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  144649. */
  144650. forceIrradianceInFragment: boolean;
  144651. /**
  144652. * Create a new ReflectionBlock
  144653. * @param name defines the block name
  144654. */
  144655. constructor(name: string);
  144656. /**
  144657. * Gets the current class name
  144658. * @returns the class name
  144659. */
  144660. getClassName(): string;
  144661. /**
  144662. * Gets the position input component
  144663. */
  144664. get position(): NodeMaterialConnectionPoint;
  144665. /**
  144666. * Gets the world position input component
  144667. */
  144668. get worldPosition(): NodeMaterialConnectionPoint;
  144669. /**
  144670. * Gets the world normal input component
  144671. */
  144672. get worldNormal(): NodeMaterialConnectionPoint;
  144673. /**
  144674. * Gets the world input component
  144675. */
  144676. get world(): NodeMaterialConnectionPoint;
  144677. /**
  144678. * Gets the camera (or eye) position component
  144679. */
  144680. get cameraPosition(): NodeMaterialConnectionPoint;
  144681. /**
  144682. * Gets the view input component
  144683. */
  144684. get view(): NodeMaterialConnectionPoint;
  144685. /**
  144686. * Gets the color input component
  144687. */
  144688. get color(): NodeMaterialConnectionPoint;
  144689. /**
  144690. * Gets the reflection object output component
  144691. */
  144692. get reflection(): NodeMaterialConnectionPoint;
  144693. /**
  144694. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  144695. */
  144696. get hasTexture(): boolean;
  144697. /**
  144698. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  144699. */
  144700. get reflectionColor(): string;
  144701. protected _getTexture(): Nullable<BaseTexture>;
  144702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144704. /**
  144705. * Gets the code to inject in the vertex shader
  144706. * @param state current state of the node material building
  144707. * @returns the shader code
  144708. */
  144709. handleVertexSide(state: NodeMaterialBuildState): string;
  144710. /**
  144711. * Gets the main code of the block (fragment side)
  144712. * @param state current state of the node material building
  144713. * @param normalVarName name of the existing variable corresponding to the normal
  144714. * @returns the shader code
  144715. */
  144716. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  144717. protected _buildBlock(state: NodeMaterialBuildState): this;
  144718. protected _dumpPropertiesCode(): string;
  144719. serialize(): any;
  144720. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144721. }
  144722. }
  144723. declare module BABYLON {
  144724. /**
  144725. * Block used to implement the sheen module of the PBR material
  144726. */
  144727. export class SheenBlock extends NodeMaterialBlock {
  144728. /**
  144729. * Create a new SheenBlock
  144730. * @param name defines the block name
  144731. */
  144732. constructor(name: string);
  144733. /**
  144734. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  144735. * It allows the strength of the sheen effect to not depend on the base color of the material,
  144736. * making it easier to setup and tweak the effect
  144737. */
  144738. albedoScaling: boolean;
  144739. /**
  144740. * Defines if the sheen is linked to the sheen color.
  144741. */
  144742. linkSheenWithAlbedo: boolean;
  144743. /**
  144744. * Initialize the block and prepare the context for build
  144745. * @param state defines the state that will be used for the build
  144746. */
  144747. initialize(state: NodeMaterialBuildState): void;
  144748. /**
  144749. * Gets the current class name
  144750. * @returns the class name
  144751. */
  144752. getClassName(): string;
  144753. /**
  144754. * Gets the intensity input component
  144755. */
  144756. get intensity(): NodeMaterialConnectionPoint;
  144757. /**
  144758. * Gets the color input component
  144759. */
  144760. get color(): NodeMaterialConnectionPoint;
  144761. /**
  144762. * Gets the roughness input component
  144763. */
  144764. get roughness(): NodeMaterialConnectionPoint;
  144765. /**
  144766. * Gets the sheen object output component
  144767. */
  144768. get sheen(): NodeMaterialConnectionPoint;
  144769. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144770. /**
  144771. * Gets the main code of the block (fragment side)
  144772. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144773. * @returns the shader code
  144774. */
  144775. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  144776. protected _buildBlock(state: NodeMaterialBuildState): this;
  144777. protected _dumpPropertiesCode(): string;
  144778. serialize(): any;
  144779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144780. }
  144781. }
  144782. declare module BABYLON {
  144783. /**
  144784. * Block used to implement the reflectivity module of the PBR material
  144785. */
  144786. export class ReflectivityBlock extends NodeMaterialBlock {
  144787. private _metallicReflectanceColor;
  144788. private _metallicF0Factor;
  144789. /** @hidden */
  144790. _vMetallicReflectanceFactorsName: string;
  144791. /**
  144792. * The property below is set by the main PBR block prior to calling methods of this class.
  144793. */
  144794. /** @hidden */
  144795. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  144796. /**
  144797. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  144798. */
  144799. useAmbientOcclusionFromMetallicTextureRed: boolean;
  144800. /**
  144801. * Specifies if the metallic texture contains the metallness information in its blue channel.
  144802. */
  144803. useMetallnessFromMetallicTextureBlue: boolean;
  144804. /**
  144805. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  144806. */
  144807. useRoughnessFromMetallicTextureAlpha: boolean;
  144808. /**
  144809. * Specifies if the metallic texture contains the roughness information in its green channel.
  144810. */
  144811. useRoughnessFromMetallicTextureGreen: boolean;
  144812. /**
  144813. * Create a new ReflectivityBlock
  144814. * @param name defines the block name
  144815. */
  144816. constructor(name: string);
  144817. /**
  144818. * Initialize the block and prepare the context for build
  144819. * @param state defines the state that will be used for the build
  144820. */
  144821. initialize(state: NodeMaterialBuildState): void;
  144822. /**
  144823. * Gets the current class name
  144824. * @returns the class name
  144825. */
  144826. getClassName(): string;
  144827. /**
  144828. * Gets the metallic input component
  144829. */
  144830. get metallic(): NodeMaterialConnectionPoint;
  144831. /**
  144832. * Gets the roughness input component
  144833. */
  144834. get roughness(): NodeMaterialConnectionPoint;
  144835. /**
  144836. * Gets the texture input component
  144837. */
  144838. get texture(): NodeMaterialConnectionPoint;
  144839. /**
  144840. * Gets the reflectivity object output component
  144841. */
  144842. get reflectivity(): NodeMaterialConnectionPoint;
  144843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144844. /**
  144845. * Gets the main code of the block (fragment side)
  144846. * @param state current state of the node material building
  144847. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  144848. * @returns the shader code
  144849. */
  144850. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  144851. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144852. protected _buildBlock(state: NodeMaterialBuildState): this;
  144853. protected _dumpPropertiesCode(): string;
  144854. serialize(): any;
  144855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144856. }
  144857. }
  144858. declare module BABYLON {
  144859. /**
  144860. * Block used to implement the anisotropy module of the PBR material
  144861. */
  144862. export class AnisotropyBlock extends NodeMaterialBlock {
  144863. /**
  144864. * The two properties below are set by the main PBR block prior to calling methods of this class.
  144865. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144866. * It's less burden on the user side in the editor part.
  144867. */
  144868. /** @hidden */
  144869. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144870. /** @hidden */
  144871. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144872. /**
  144873. * Create a new AnisotropyBlock
  144874. * @param name defines the block name
  144875. */
  144876. constructor(name: string);
  144877. /**
  144878. * Initialize the block and prepare the context for build
  144879. * @param state defines the state that will be used for the build
  144880. */
  144881. initialize(state: NodeMaterialBuildState): void;
  144882. /**
  144883. * Gets the current class name
  144884. * @returns the class name
  144885. */
  144886. getClassName(): string;
  144887. /**
  144888. * Gets the intensity input component
  144889. */
  144890. get intensity(): NodeMaterialConnectionPoint;
  144891. /**
  144892. * Gets the direction input component
  144893. */
  144894. get direction(): NodeMaterialConnectionPoint;
  144895. /**
  144896. * Gets the texture input component
  144897. */
  144898. get texture(): NodeMaterialConnectionPoint;
  144899. /**
  144900. * Gets the uv input component
  144901. */
  144902. get uv(): NodeMaterialConnectionPoint;
  144903. /**
  144904. * Gets the worldTangent input component
  144905. */
  144906. get worldTangent(): NodeMaterialConnectionPoint;
  144907. /**
  144908. * Gets the anisotropy object output component
  144909. */
  144910. get anisotropy(): NodeMaterialConnectionPoint;
  144911. private _generateTBNSpace;
  144912. /**
  144913. * Gets the main code of the block (fragment side)
  144914. * @param state current state of the node material building
  144915. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144916. * @returns the shader code
  144917. */
  144918. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  144919. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144920. protected _buildBlock(state: NodeMaterialBuildState): this;
  144921. }
  144922. }
  144923. declare module BABYLON {
  144924. /**
  144925. * Block used to implement the clear coat module of the PBR material
  144926. */
  144927. export class ClearCoatBlock extends NodeMaterialBlock {
  144928. private _scene;
  144929. /**
  144930. * Create a new ClearCoatBlock
  144931. * @param name defines the block name
  144932. */
  144933. constructor(name: string);
  144934. /**
  144935. * Initialize the block and prepare the context for build
  144936. * @param state defines the state that will be used for the build
  144937. */
  144938. initialize(state: NodeMaterialBuildState): void;
  144939. /**
  144940. * Gets the current class name
  144941. * @returns the class name
  144942. */
  144943. getClassName(): string;
  144944. /**
  144945. * Gets the intensity input component
  144946. */
  144947. get intensity(): NodeMaterialConnectionPoint;
  144948. /**
  144949. * Gets the roughness input component
  144950. */
  144951. get roughness(): NodeMaterialConnectionPoint;
  144952. /**
  144953. * Gets the ior input component
  144954. */
  144955. get ior(): NodeMaterialConnectionPoint;
  144956. /**
  144957. * Gets the texture input component
  144958. */
  144959. get texture(): NodeMaterialConnectionPoint;
  144960. /**
  144961. * Gets the bump texture input component
  144962. */
  144963. get bumpTexture(): NodeMaterialConnectionPoint;
  144964. /**
  144965. * Gets the uv input component
  144966. */
  144967. get uv(): NodeMaterialConnectionPoint;
  144968. /**
  144969. * Gets the tint color input component
  144970. */
  144971. get tintColor(): NodeMaterialConnectionPoint;
  144972. /**
  144973. * Gets the tint "at distance" input component
  144974. */
  144975. get tintAtDistance(): NodeMaterialConnectionPoint;
  144976. /**
  144977. * Gets the tint thickness input component
  144978. */
  144979. get tintThickness(): NodeMaterialConnectionPoint;
  144980. /**
  144981. * Gets the world tangent input component
  144982. */
  144983. get worldTangent(): NodeMaterialConnectionPoint;
  144984. /**
  144985. * Gets the clear coat object output component
  144986. */
  144987. get clearcoat(): NodeMaterialConnectionPoint;
  144988. autoConfigure(material: NodeMaterial): void;
  144989. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144990. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144991. private _generateTBNSpace;
  144992. /**
  144993. * Gets the main code of the block (fragment side)
  144994. * @param state current state of the node material building
  144995. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  144996. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144997. * @param worldPosVarName name of the variable holding the world position
  144998. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144999. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  145000. * @param worldNormalVarName name of the variable holding the world normal
  145001. * @returns the shader code
  145002. */
  145003. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  145004. protected _buildBlock(state: NodeMaterialBuildState): this;
  145005. }
  145006. }
  145007. declare module BABYLON {
  145008. /**
  145009. * Block used to implement the sub surface module of the PBR material
  145010. */
  145011. export class SubSurfaceBlock extends NodeMaterialBlock {
  145012. /**
  145013. * Create a new SubSurfaceBlock
  145014. * @param name defines the block name
  145015. */
  145016. constructor(name: string);
  145017. /**
  145018. * Stores the intensity of the different subsurface effects in the thickness texture.
  145019. * * the green channel is the translucency intensity.
  145020. * * the blue channel is the scattering intensity.
  145021. * * the alpha channel is the refraction intensity.
  145022. */
  145023. useMaskFromThicknessTexture: boolean;
  145024. /**
  145025. * Initialize the block and prepare the context for build
  145026. * @param state defines the state that will be used for the build
  145027. */
  145028. initialize(state: NodeMaterialBuildState): void;
  145029. /**
  145030. * Gets the current class name
  145031. * @returns the class name
  145032. */
  145033. getClassName(): string;
  145034. /**
  145035. * Gets the min thickness input component
  145036. */
  145037. get minThickness(): NodeMaterialConnectionPoint;
  145038. /**
  145039. * Gets the max thickness input component
  145040. */
  145041. get maxThickness(): NodeMaterialConnectionPoint;
  145042. /**
  145043. * Gets the thickness texture component
  145044. */
  145045. get thicknessTexture(): NodeMaterialConnectionPoint;
  145046. /**
  145047. * Gets the tint color input component
  145048. */
  145049. get tintColor(): NodeMaterialConnectionPoint;
  145050. /**
  145051. * Gets the translucency intensity input component
  145052. */
  145053. get translucencyIntensity(): NodeMaterialConnectionPoint;
  145054. /**
  145055. * Gets the translucency diffusion distance input component
  145056. */
  145057. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  145058. /**
  145059. * Gets the refraction object parameters
  145060. */
  145061. get refraction(): NodeMaterialConnectionPoint;
  145062. /**
  145063. * Gets the sub surface object output component
  145064. */
  145065. get subsurface(): NodeMaterialConnectionPoint;
  145066. autoConfigure(material: NodeMaterial): void;
  145067. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145068. /**
  145069. * Gets the main code of the block (fragment side)
  145070. * @param state current state of the node material building
  145071. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  145072. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145073. * @param worldPosVarName name of the variable holding the world position
  145074. * @returns the shader code
  145075. */
  145076. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  145077. protected _buildBlock(state: NodeMaterialBuildState): this;
  145078. }
  145079. }
  145080. declare module BABYLON {
  145081. /**
  145082. * Block used to implement the PBR metallic/roughness model
  145083. */
  145084. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  145085. /**
  145086. * Gets or sets the light associated with this block
  145087. */
  145088. light: Nullable<Light>;
  145089. private _lightId;
  145090. private _scene;
  145091. private _environmentBRDFTexture;
  145092. private _environmentBrdfSamplerName;
  145093. private _vNormalWName;
  145094. private _invertNormalName;
  145095. /**
  145096. * Create a new ReflectionBlock
  145097. * @param name defines the block name
  145098. */
  145099. constructor(name: string);
  145100. /**
  145101. * Intensity of the direct lights e.g. the four lights available in your scene.
  145102. * This impacts both the direct diffuse and specular highlights.
  145103. */
  145104. directIntensity: number;
  145105. /**
  145106. * Intensity of the environment e.g. how much the environment will light the object
  145107. * either through harmonics for rough material or through the refelction for shiny ones.
  145108. */
  145109. environmentIntensity: number;
  145110. /**
  145111. * This is a special control allowing the reduction of the specular highlights coming from the
  145112. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  145113. */
  145114. specularIntensity: number;
  145115. /**
  145116. * Defines the falloff type used in this material.
  145117. * It by default is Physical.
  145118. */
  145119. lightFalloff: number;
  145120. /**
  145121. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  145122. */
  145123. useAlphaFromAlbedoTexture: boolean;
  145124. /**
  145125. * Specifies that alpha test should be used
  145126. */
  145127. useAlphaTest: boolean;
  145128. /**
  145129. * Defines the alpha limits in alpha test mode.
  145130. */
  145131. alphaTestCutoff: number;
  145132. /**
  145133. * Specifies that alpha blending should be used
  145134. */
  145135. useAlphaBlending: boolean;
  145136. /**
  145137. * Defines if the alpha value should be determined via the rgb values.
  145138. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  145139. */
  145140. opacityRGB: boolean;
  145141. /**
  145142. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  145143. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  145144. */
  145145. useRadianceOverAlpha: boolean;
  145146. /**
  145147. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  145148. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  145149. */
  145150. useSpecularOverAlpha: boolean;
  145151. /**
  145152. * Enables specular anti aliasing in the PBR shader.
  145153. * It will both interacts on the Geometry for analytical and IBL lighting.
  145154. * It also prefilter the roughness map based on the bump values.
  145155. */
  145156. enableSpecularAntiAliasing: boolean;
  145157. /**
  145158. * Enables realtime filtering on the texture.
  145159. */
  145160. realTimeFiltering: boolean;
  145161. /**
  145162. * Quality switch for realtime filtering
  145163. */
  145164. realTimeFilteringQuality: number;
  145165. /**
  145166. * Defines if the material uses energy conservation.
  145167. */
  145168. useEnergyConservation: boolean;
  145169. /**
  145170. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  145171. * too much the area relying on ambient texture to define their ambient occlusion.
  145172. */
  145173. useRadianceOcclusion: boolean;
  145174. /**
  145175. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  145176. * makes the reflect vector face the model (under horizon).
  145177. */
  145178. useHorizonOcclusion: boolean;
  145179. /**
  145180. * If set to true, no lighting calculations will be applied.
  145181. */
  145182. unlit: boolean;
  145183. /**
  145184. * Force normal to face away from face.
  145185. */
  145186. forceNormalForward: boolean;
  145187. /**
  145188. * Defines the material debug mode.
  145189. * It helps seeing only some components of the material while troubleshooting.
  145190. */
  145191. debugMode: number;
  145192. /**
  145193. * Specify from where on screen the debug mode should start.
  145194. * The value goes from -1 (full screen) to 1 (not visible)
  145195. * It helps with side by side comparison against the final render
  145196. * This defaults to 0
  145197. */
  145198. debugLimit: number;
  145199. /**
  145200. * As the default viewing range might not be enough (if the ambient is really small for instance)
  145201. * You can use the factor to better multiply the final value.
  145202. */
  145203. debugFactor: number;
  145204. /**
  145205. * Initialize the block and prepare the context for build
  145206. * @param state defines the state that will be used for the build
  145207. */
  145208. initialize(state: NodeMaterialBuildState): void;
  145209. /**
  145210. * Gets the current class name
  145211. * @returns the class name
  145212. */
  145213. getClassName(): string;
  145214. /**
  145215. * Gets the world position input component
  145216. */
  145217. get worldPosition(): NodeMaterialConnectionPoint;
  145218. /**
  145219. * Gets the world normal input component
  145220. */
  145221. get worldNormal(): NodeMaterialConnectionPoint;
  145222. /**
  145223. * Gets the perturbed normal input component
  145224. */
  145225. get perturbedNormal(): NodeMaterialConnectionPoint;
  145226. /**
  145227. * Gets the camera position input component
  145228. */
  145229. get cameraPosition(): NodeMaterialConnectionPoint;
  145230. /**
  145231. * Gets the base color input component
  145232. */
  145233. get baseColor(): NodeMaterialConnectionPoint;
  145234. /**
  145235. * Gets the opacity texture input component
  145236. */
  145237. get opacityTexture(): NodeMaterialConnectionPoint;
  145238. /**
  145239. * Gets the ambient color input component
  145240. */
  145241. get ambientColor(): NodeMaterialConnectionPoint;
  145242. /**
  145243. * Gets the reflectivity object parameters
  145244. */
  145245. get reflectivity(): NodeMaterialConnectionPoint;
  145246. /**
  145247. * Gets the ambient occlusion object parameters
  145248. */
  145249. get ambientOcclusion(): NodeMaterialConnectionPoint;
  145250. /**
  145251. * Gets the reflection object parameters
  145252. */
  145253. get reflection(): NodeMaterialConnectionPoint;
  145254. /**
  145255. * Gets the sheen object parameters
  145256. */
  145257. get sheen(): NodeMaterialConnectionPoint;
  145258. /**
  145259. * Gets the clear coat object parameters
  145260. */
  145261. get clearcoat(): NodeMaterialConnectionPoint;
  145262. /**
  145263. * Gets the sub surface object parameters
  145264. */
  145265. get subsurface(): NodeMaterialConnectionPoint;
  145266. /**
  145267. * Gets the anisotropy object parameters
  145268. */
  145269. get anisotropy(): NodeMaterialConnectionPoint;
  145270. /**
  145271. * Gets the ambient output component
  145272. */
  145273. get ambient(): NodeMaterialConnectionPoint;
  145274. /**
  145275. * Gets the diffuse output component
  145276. */
  145277. get diffuse(): NodeMaterialConnectionPoint;
  145278. /**
  145279. * Gets the specular output component
  145280. */
  145281. get specular(): NodeMaterialConnectionPoint;
  145282. /**
  145283. * Gets the sheen output component
  145284. */
  145285. get sheenDir(): NodeMaterialConnectionPoint;
  145286. /**
  145287. * Gets the clear coat output component
  145288. */
  145289. get clearcoatDir(): NodeMaterialConnectionPoint;
  145290. /**
  145291. * Gets the indirect diffuse output component
  145292. */
  145293. get diffuseIndirect(): NodeMaterialConnectionPoint;
  145294. /**
  145295. * Gets the indirect specular output component
  145296. */
  145297. get specularIndirect(): NodeMaterialConnectionPoint;
  145298. /**
  145299. * Gets the indirect sheen output component
  145300. */
  145301. get sheenIndirect(): NodeMaterialConnectionPoint;
  145302. /**
  145303. * Gets the indirect clear coat output component
  145304. */
  145305. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  145306. /**
  145307. * Gets the refraction output component
  145308. */
  145309. get refraction(): NodeMaterialConnectionPoint;
  145310. /**
  145311. * Gets the global lighting output component
  145312. */
  145313. get lighting(): NodeMaterialConnectionPoint;
  145314. /**
  145315. * Gets the shadow output component
  145316. */
  145317. get shadow(): NodeMaterialConnectionPoint;
  145318. /**
  145319. * Gets the alpha output component
  145320. */
  145321. get alpha(): NodeMaterialConnectionPoint;
  145322. autoConfigure(material: NodeMaterial): void;
  145323. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145324. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145326. private _injectVertexCode;
  145327. /**
  145328. * Gets the code corresponding to the albedo/opacity module
  145329. * @returns the shader code
  145330. */
  145331. getAlbedoOpacityCode(): string;
  145332. protected _buildBlock(state: NodeMaterialBuildState): this;
  145333. protected _dumpPropertiesCode(): string;
  145334. serialize(): any;
  145335. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145336. }
  145337. }
  145338. declare module BABYLON {
  145339. /**
  145340. * Block used to compute value of one parameter modulo another
  145341. */
  145342. export class ModBlock extends NodeMaterialBlock {
  145343. /**
  145344. * Creates a new ModBlock
  145345. * @param name defines the block name
  145346. */
  145347. constructor(name: string);
  145348. /**
  145349. * Gets the current class name
  145350. * @returns the class name
  145351. */
  145352. getClassName(): string;
  145353. /**
  145354. * Gets the left operand input component
  145355. */
  145356. get left(): NodeMaterialConnectionPoint;
  145357. /**
  145358. * Gets the right operand input component
  145359. */
  145360. get right(): NodeMaterialConnectionPoint;
  145361. /**
  145362. * Gets the output component
  145363. */
  145364. get output(): NodeMaterialConnectionPoint;
  145365. protected _buildBlock(state: NodeMaterialBuildState): this;
  145366. }
  145367. }
  145368. declare module BABYLON {
  145369. /**
  145370. * Configuration for Draco compression
  145371. */
  145372. export interface IDracoCompressionConfiguration {
  145373. /**
  145374. * Configuration for the decoder.
  145375. */
  145376. decoder: {
  145377. /**
  145378. * The url to the WebAssembly module.
  145379. */
  145380. wasmUrl?: string;
  145381. /**
  145382. * The url to the WebAssembly binary.
  145383. */
  145384. wasmBinaryUrl?: string;
  145385. /**
  145386. * The url to the fallback JavaScript module.
  145387. */
  145388. fallbackUrl?: string;
  145389. };
  145390. }
  145391. /**
  145392. * Draco compression (https://google.github.io/draco/)
  145393. *
  145394. * This class wraps the Draco module.
  145395. *
  145396. * **Encoder**
  145397. *
  145398. * The encoder is not currently implemented.
  145399. *
  145400. * **Decoder**
  145401. *
  145402. * 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.
  145403. *
  145404. * To update the configuration, use the following code:
  145405. * ```javascript
  145406. * DracoCompression.Configuration = {
  145407. * decoder: {
  145408. * wasmUrl: "<url to the WebAssembly library>",
  145409. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  145410. * fallbackUrl: "<url to the fallback JavaScript library>",
  145411. * }
  145412. * };
  145413. * ```
  145414. *
  145415. * 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.
  145416. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  145417. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  145418. *
  145419. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  145420. * ```javascript
  145421. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  145422. * ```
  145423. *
  145424. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  145425. */
  145426. export class DracoCompression implements IDisposable {
  145427. private _workerPoolPromise?;
  145428. private _decoderModulePromise?;
  145429. /**
  145430. * The configuration. Defaults to the following urls:
  145431. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  145432. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  145433. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  145434. */
  145435. static Configuration: IDracoCompressionConfiguration;
  145436. /**
  145437. * Returns true if the decoder configuration is available.
  145438. */
  145439. static get DecoderAvailable(): boolean;
  145440. /**
  145441. * Default number of workers to create when creating the draco compression object.
  145442. */
  145443. static DefaultNumWorkers: number;
  145444. private static GetDefaultNumWorkers;
  145445. private static _Default;
  145446. /**
  145447. * Default instance for the draco compression object.
  145448. */
  145449. static get Default(): DracoCompression;
  145450. /**
  145451. * Constructor
  145452. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  145453. */
  145454. constructor(numWorkers?: number);
  145455. /**
  145456. * Stop all async operations and release resources.
  145457. */
  145458. dispose(): void;
  145459. /**
  145460. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  145461. * @returns a promise that resolves when ready
  145462. */
  145463. whenReadyAsync(): Promise<void>;
  145464. /**
  145465. * Decode Draco compressed mesh data to vertex data.
  145466. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  145467. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  145468. * @returns A promise that resolves with the decoded vertex data
  145469. */
  145470. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  145471. [kind: string]: number;
  145472. }): Promise<VertexData>;
  145473. }
  145474. }
  145475. declare module BABYLON {
  145476. /**
  145477. * Class for building Constructive Solid Geometry
  145478. */
  145479. export class CSG {
  145480. private polygons;
  145481. /**
  145482. * The world matrix
  145483. */
  145484. matrix: Matrix;
  145485. /**
  145486. * Stores the position
  145487. */
  145488. position: Vector3;
  145489. /**
  145490. * Stores the rotation
  145491. */
  145492. rotation: Vector3;
  145493. /**
  145494. * Stores the rotation quaternion
  145495. */
  145496. rotationQuaternion: Nullable<Quaternion>;
  145497. /**
  145498. * Stores the scaling vector
  145499. */
  145500. scaling: Vector3;
  145501. /**
  145502. * Convert the Mesh to CSG
  145503. * @param mesh The Mesh to convert to CSG
  145504. * @returns A new CSG from the Mesh
  145505. */
  145506. static FromMesh(mesh: Mesh): CSG;
  145507. /**
  145508. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  145509. * @param polygons Polygons used to construct a CSG solid
  145510. */
  145511. private static FromPolygons;
  145512. /**
  145513. * Clones, or makes a deep copy, of the CSG
  145514. * @returns A new CSG
  145515. */
  145516. clone(): CSG;
  145517. /**
  145518. * Unions this CSG with another CSG
  145519. * @param csg The CSG to union against this CSG
  145520. * @returns The unioned CSG
  145521. */
  145522. union(csg: CSG): CSG;
  145523. /**
  145524. * Unions this CSG with another CSG in place
  145525. * @param csg The CSG to union against this CSG
  145526. */
  145527. unionInPlace(csg: CSG): void;
  145528. /**
  145529. * Subtracts this CSG with another CSG
  145530. * @param csg The CSG to subtract against this CSG
  145531. * @returns A new CSG
  145532. */
  145533. subtract(csg: CSG): CSG;
  145534. /**
  145535. * Subtracts this CSG with another CSG in place
  145536. * @param csg The CSG to subtact against this CSG
  145537. */
  145538. subtractInPlace(csg: CSG): void;
  145539. /**
  145540. * Intersect this CSG with another CSG
  145541. * @param csg The CSG to intersect against this CSG
  145542. * @returns A new CSG
  145543. */
  145544. intersect(csg: CSG): CSG;
  145545. /**
  145546. * Intersects this CSG with another CSG in place
  145547. * @param csg The CSG to intersect against this CSG
  145548. */
  145549. intersectInPlace(csg: CSG): void;
  145550. /**
  145551. * Return a new CSG solid with solid and empty space switched. This solid is
  145552. * not modified.
  145553. * @returns A new CSG solid with solid and empty space switched
  145554. */
  145555. inverse(): CSG;
  145556. /**
  145557. * Inverses the CSG in place
  145558. */
  145559. inverseInPlace(): void;
  145560. /**
  145561. * This is used to keep meshes transformations so they can be restored
  145562. * when we build back a Babylon Mesh
  145563. * NB : All CSG operations are performed in world coordinates
  145564. * @param csg The CSG to copy the transform attributes from
  145565. * @returns This CSG
  145566. */
  145567. copyTransformAttributes(csg: CSG): CSG;
  145568. /**
  145569. * Build Raw mesh from CSG
  145570. * Coordinates here are in world space
  145571. * @param name The name of the mesh geometry
  145572. * @param scene The Scene
  145573. * @param keepSubMeshes Specifies if the submeshes should be kept
  145574. * @returns A new Mesh
  145575. */
  145576. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145577. /**
  145578. * Build Mesh from CSG taking material and transforms into account
  145579. * @param name The name of the Mesh
  145580. * @param material The material of the Mesh
  145581. * @param scene The Scene
  145582. * @param keepSubMeshes Specifies if submeshes should be kept
  145583. * @returns The new Mesh
  145584. */
  145585. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145586. }
  145587. }
  145588. declare module BABYLON {
  145589. /**
  145590. * Class used to create a trail following a mesh
  145591. */
  145592. export class TrailMesh extends Mesh {
  145593. private _generator;
  145594. private _autoStart;
  145595. private _running;
  145596. private _diameter;
  145597. private _length;
  145598. private _sectionPolygonPointsCount;
  145599. private _sectionVectors;
  145600. private _sectionNormalVectors;
  145601. private _beforeRenderObserver;
  145602. /**
  145603. * @constructor
  145604. * @param name The value used by scene.getMeshByName() to do a lookup.
  145605. * @param generator The mesh or transform node to generate a trail.
  145606. * @param scene The scene to add this mesh to.
  145607. * @param diameter Diameter of trailing mesh. Default is 1.
  145608. * @param length Length of trailing mesh. Default is 60.
  145609. * @param autoStart Automatically start trailing mesh. Default true.
  145610. */
  145611. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  145612. /**
  145613. * "TrailMesh"
  145614. * @returns "TrailMesh"
  145615. */
  145616. getClassName(): string;
  145617. private _createMesh;
  145618. /**
  145619. * Start trailing mesh.
  145620. */
  145621. start(): void;
  145622. /**
  145623. * Stop trailing mesh.
  145624. */
  145625. stop(): void;
  145626. /**
  145627. * Update trailing mesh geometry.
  145628. */
  145629. update(): void;
  145630. /**
  145631. * Returns a new TrailMesh object.
  145632. * @param name is a string, the name given to the new mesh
  145633. * @param newGenerator use new generator object for cloned trail mesh
  145634. * @returns a new mesh
  145635. */
  145636. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  145637. /**
  145638. * Serializes this trail mesh
  145639. * @param serializationObject object to write serialization to
  145640. */
  145641. serialize(serializationObject: any): void;
  145642. /**
  145643. * Parses a serialized trail mesh
  145644. * @param parsedMesh the serialized mesh
  145645. * @param scene the scene to create the trail mesh in
  145646. * @returns the created trail mesh
  145647. */
  145648. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  145649. }
  145650. }
  145651. declare module BABYLON {
  145652. /**
  145653. * Class containing static functions to help procedurally build meshes
  145654. */
  145655. export class TiledBoxBuilder {
  145656. /**
  145657. * Creates a box mesh
  145658. * 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)
  145659. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145663. * @param name defines the name of the mesh
  145664. * @param options defines the options used to create the mesh
  145665. * @param scene defines the hosting scene
  145666. * @returns the box mesh
  145667. */
  145668. static CreateTiledBox(name: string, options: {
  145669. pattern?: number;
  145670. width?: number;
  145671. height?: number;
  145672. depth?: number;
  145673. tileSize?: number;
  145674. tileWidth?: number;
  145675. tileHeight?: number;
  145676. alignHorizontal?: number;
  145677. alignVertical?: number;
  145678. faceUV?: Vector4[];
  145679. faceColors?: Color4[];
  145680. sideOrientation?: number;
  145681. updatable?: boolean;
  145682. }, scene?: Nullable<Scene>): Mesh;
  145683. }
  145684. }
  145685. declare module BABYLON {
  145686. /**
  145687. * Class containing static functions to help procedurally build meshes
  145688. */
  145689. export class TorusKnotBuilder {
  145690. /**
  145691. * Creates a torus knot mesh
  145692. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145693. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145694. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145695. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145699. * @param name defines the name of the mesh
  145700. * @param options defines the options used to create the mesh
  145701. * @param scene defines the hosting scene
  145702. * @returns the torus knot mesh
  145703. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145704. */
  145705. static CreateTorusKnot(name: string, options: {
  145706. radius?: number;
  145707. tube?: number;
  145708. radialSegments?: number;
  145709. tubularSegments?: number;
  145710. p?: number;
  145711. q?: number;
  145712. updatable?: boolean;
  145713. sideOrientation?: number;
  145714. frontUVs?: Vector4;
  145715. backUVs?: Vector4;
  145716. }, scene: any): Mesh;
  145717. }
  145718. }
  145719. declare module BABYLON {
  145720. /**
  145721. * Polygon
  145722. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  145723. */
  145724. export class Polygon {
  145725. /**
  145726. * Creates a rectangle
  145727. * @param xmin bottom X coord
  145728. * @param ymin bottom Y coord
  145729. * @param xmax top X coord
  145730. * @param ymax top Y coord
  145731. * @returns points that make the resulting rectation
  145732. */
  145733. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  145734. /**
  145735. * Creates a circle
  145736. * @param radius radius of circle
  145737. * @param cx scale in x
  145738. * @param cy scale in y
  145739. * @param numberOfSides number of sides that make up the circle
  145740. * @returns points that make the resulting circle
  145741. */
  145742. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  145743. /**
  145744. * Creates a polygon from input string
  145745. * @param input Input polygon data
  145746. * @returns the parsed points
  145747. */
  145748. static Parse(input: string): Vector2[];
  145749. /**
  145750. * Starts building a polygon from x and y coordinates
  145751. * @param x x coordinate
  145752. * @param y y coordinate
  145753. * @returns the started path2
  145754. */
  145755. static StartingAt(x: number, y: number): Path2;
  145756. }
  145757. /**
  145758. * Builds a polygon
  145759. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  145760. */
  145761. export class PolygonMeshBuilder {
  145762. private _points;
  145763. private _outlinepoints;
  145764. private _holes;
  145765. private _name;
  145766. private _scene;
  145767. private _epoints;
  145768. private _eholes;
  145769. private _addToepoint;
  145770. /**
  145771. * Babylon reference to the earcut plugin.
  145772. */
  145773. bjsEarcut: any;
  145774. /**
  145775. * Creates a PolygonMeshBuilder
  145776. * @param name name of the builder
  145777. * @param contours Path of the polygon
  145778. * @param scene scene to add to when creating the mesh
  145779. * @param earcutInjection can be used to inject your own earcut reference
  145780. */
  145781. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  145782. /**
  145783. * Adds a whole within the polygon
  145784. * @param hole Array of points defining the hole
  145785. * @returns this
  145786. */
  145787. addHole(hole: Vector2[]): PolygonMeshBuilder;
  145788. /**
  145789. * Creates the polygon
  145790. * @param updatable If the mesh should be updatable
  145791. * @param depth The depth of the mesh created
  145792. * @returns the created mesh
  145793. */
  145794. build(updatable?: boolean, depth?: number): Mesh;
  145795. /**
  145796. * Creates the polygon
  145797. * @param depth The depth of the mesh created
  145798. * @returns the created VertexData
  145799. */
  145800. buildVertexData(depth?: number): VertexData;
  145801. /**
  145802. * Adds a side to the polygon
  145803. * @param positions points that make the polygon
  145804. * @param normals normals of the polygon
  145805. * @param uvs uvs of the polygon
  145806. * @param indices indices of the polygon
  145807. * @param bounds bounds of the polygon
  145808. * @param points points of the polygon
  145809. * @param depth depth of the polygon
  145810. * @param flip flip of the polygon
  145811. */
  145812. private addSide;
  145813. }
  145814. }
  145815. declare module BABYLON {
  145816. /**
  145817. * Class containing static functions to help procedurally build meshes
  145818. */
  145819. export class PolygonBuilder {
  145820. /**
  145821. * Creates a polygon mesh
  145822. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145823. * * 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
  145824. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145827. * * Remember you can only change the shape positions, not their number when updating a polygon
  145828. * @param name defines the name of the mesh
  145829. * @param options defines the options used to create the mesh
  145830. * @param scene defines the hosting scene
  145831. * @param earcutInjection can be used to inject your own earcut reference
  145832. * @returns the polygon mesh
  145833. */
  145834. static CreatePolygon(name: string, options: {
  145835. shape: Vector3[];
  145836. holes?: Vector3[][];
  145837. depth?: number;
  145838. faceUV?: Vector4[];
  145839. faceColors?: Color4[];
  145840. updatable?: boolean;
  145841. sideOrientation?: number;
  145842. frontUVs?: Vector4;
  145843. backUVs?: Vector4;
  145844. wrap?: boolean;
  145845. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145846. /**
  145847. * Creates an extruded polygon mesh, with depth in the Y direction.
  145848. * * 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)
  145849. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145850. * @param name defines the name of the mesh
  145851. * @param options defines the options used to create the mesh
  145852. * @param scene defines the hosting scene
  145853. * @param earcutInjection can be used to inject your own earcut reference
  145854. * @returns the polygon mesh
  145855. */
  145856. static ExtrudePolygon(name: string, options: {
  145857. shape: Vector3[];
  145858. holes?: Vector3[][];
  145859. depth?: number;
  145860. faceUV?: Vector4[];
  145861. faceColors?: Color4[];
  145862. updatable?: boolean;
  145863. sideOrientation?: number;
  145864. frontUVs?: Vector4;
  145865. backUVs?: Vector4;
  145866. wrap?: boolean;
  145867. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145868. }
  145869. }
  145870. declare module BABYLON {
  145871. /**
  145872. * Class containing static functions to help procedurally build meshes
  145873. */
  145874. export class LatheBuilder {
  145875. /**
  145876. * Creates lathe mesh.
  145877. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145878. * * 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
  145879. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145880. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145881. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145882. * * 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
  145883. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145884. * * 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
  145885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145887. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145889. * @param name defines the name of the mesh
  145890. * @param options defines the options used to create the mesh
  145891. * @param scene defines the hosting scene
  145892. * @returns the lathe mesh
  145893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145894. */
  145895. static CreateLathe(name: string, options: {
  145896. shape: Vector3[];
  145897. radius?: number;
  145898. tessellation?: number;
  145899. clip?: number;
  145900. arc?: number;
  145901. closed?: boolean;
  145902. updatable?: boolean;
  145903. sideOrientation?: number;
  145904. frontUVs?: Vector4;
  145905. backUVs?: Vector4;
  145906. cap?: number;
  145907. invertUV?: boolean;
  145908. }, scene?: Nullable<Scene>): Mesh;
  145909. }
  145910. }
  145911. declare module BABYLON {
  145912. /**
  145913. * Class containing static functions to help procedurally build meshes
  145914. */
  145915. export class TiledPlaneBuilder {
  145916. /**
  145917. * Creates a tiled plane mesh
  145918. * * The parameter `pattern` will, depending on value, do nothing or
  145919. * * * flip (reflect about central vertical) alternate tiles across and up
  145920. * * * flip every tile on alternate rows
  145921. * * * rotate (180 degs) alternate tiles across and up
  145922. * * * rotate every tile on alternate rows
  145923. * * * flip and rotate alternate tiles across and up
  145924. * * * flip and rotate every tile on alternate rows
  145925. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  145926. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  145927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145928. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145929. * * 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)
  145930. * * 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)
  145931. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145932. * @param name defines the name of the mesh
  145933. * @param options defines the options used to create the mesh
  145934. * @param scene defines the hosting scene
  145935. * @returns the box mesh
  145936. */
  145937. static CreateTiledPlane(name: string, options: {
  145938. pattern?: number;
  145939. tileSize?: number;
  145940. tileWidth?: number;
  145941. tileHeight?: number;
  145942. size?: number;
  145943. width?: number;
  145944. height?: number;
  145945. alignHorizontal?: number;
  145946. alignVertical?: number;
  145947. sideOrientation?: number;
  145948. frontUVs?: Vector4;
  145949. backUVs?: Vector4;
  145950. updatable?: boolean;
  145951. }, scene?: Nullable<Scene>): Mesh;
  145952. }
  145953. }
  145954. declare module BABYLON {
  145955. /**
  145956. * Class containing static functions to help procedurally build meshes
  145957. */
  145958. export class TubeBuilder {
  145959. /**
  145960. * Creates a tube mesh.
  145961. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145962. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145963. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145964. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145965. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145966. * * 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)
  145967. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145968. * * 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
  145969. * * 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
  145970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145972. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145974. * @param name defines the name of the mesh
  145975. * @param options defines the options used to create the mesh
  145976. * @param scene defines the hosting scene
  145977. * @returns the tube mesh
  145978. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145979. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145980. */
  145981. static CreateTube(name: string, options: {
  145982. path: Vector3[];
  145983. radius?: number;
  145984. tessellation?: number;
  145985. radiusFunction?: {
  145986. (i: number, distance: number): number;
  145987. };
  145988. cap?: number;
  145989. arc?: number;
  145990. updatable?: boolean;
  145991. sideOrientation?: number;
  145992. frontUVs?: Vector4;
  145993. backUVs?: Vector4;
  145994. instance?: Mesh;
  145995. invertUV?: boolean;
  145996. }, scene?: Nullable<Scene>): Mesh;
  145997. }
  145998. }
  145999. declare module BABYLON {
  146000. /**
  146001. * Class containing static functions to help procedurally build meshes
  146002. */
  146003. export class IcoSphereBuilder {
  146004. /**
  146005. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146006. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146007. * * 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`)
  146008. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146009. * * 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
  146010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146013. * @param name defines the name of the mesh
  146014. * @param options defines the options used to create the mesh
  146015. * @param scene defines the hosting scene
  146016. * @returns the icosahedron mesh
  146017. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146018. */
  146019. static CreateIcoSphere(name: string, options: {
  146020. radius?: number;
  146021. radiusX?: number;
  146022. radiusY?: number;
  146023. radiusZ?: number;
  146024. flat?: boolean;
  146025. subdivisions?: number;
  146026. sideOrientation?: number;
  146027. frontUVs?: Vector4;
  146028. backUVs?: Vector4;
  146029. updatable?: boolean;
  146030. }, scene?: Nullable<Scene>): Mesh;
  146031. }
  146032. }
  146033. declare module BABYLON {
  146034. /**
  146035. * Class containing static functions to help procedurally build meshes
  146036. */
  146037. export class DecalBuilder {
  146038. /**
  146039. * Creates a decal mesh.
  146040. * 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
  146041. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146042. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146043. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146044. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146045. * @param name defines the name of the mesh
  146046. * @param sourceMesh defines the mesh where the decal must be applied
  146047. * @param options defines the options used to create the mesh
  146048. * @param scene defines the hosting scene
  146049. * @returns the decal mesh
  146050. * @see https://doc.babylonjs.com/how_to/decals
  146051. */
  146052. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146053. position?: Vector3;
  146054. normal?: Vector3;
  146055. size?: Vector3;
  146056. angle?: number;
  146057. }): Mesh;
  146058. }
  146059. }
  146060. declare module BABYLON {
  146061. /**
  146062. * Class containing static functions to help procedurally build meshes
  146063. */
  146064. export class MeshBuilder {
  146065. /**
  146066. * Creates a box mesh
  146067. * * The parameter `size` sets the size (float) of each box side (default 1)
  146068. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  146069. * * 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)
  146070. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146074. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146075. * @param name defines the name of the mesh
  146076. * @param options defines the options used to create the mesh
  146077. * @param scene defines the hosting scene
  146078. * @returns the box mesh
  146079. */
  146080. static CreateBox(name: string, options: {
  146081. size?: number;
  146082. width?: number;
  146083. height?: number;
  146084. depth?: number;
  146085. faceUV?: Vector4[];
  146086. faceColors?: Color4[];
  146087. sideOrientation?: number;
  146088. frontUVs?: Vector4;
  146089. backUVs?: Vector4;
  146090. wrap?: boolean;
  146091. topBaseAt?: number;
  146092. bottomBaseAt?: number;
  146093. updatable?: boolean;
  146094. }, scene?: Nullable<Scene>): Mesh;
  146095. /**
  146096. * Creates a tiled box mesh
  146097. * * faceTiles sets the pattern, tile size and number of tiles for a face
  146098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146099. * @param name defines the name of the mesh
  146100. * @param options defines the options used to create the mesh
  146101. * @param scene defines the hosting scene
  146102. * @returns the tiled box mesh
  146103. */
  146104. static CreateTiledBox(name: string, options: {
  146105. pattern?: number;
  146106. size?: number;
  146107. width?: number;
  146108. height?: number;
  146109. depth: number;
  146110. tileSize?: number;
  146111. tileWidth?: number;
  146112. tileHeight?: number;
  146113. faceUV?: Vector4[];
  146114. faceColors?: Color4[];
  146115. alignHorizontal?: number;
  146116. alignVertical?: number;
  146117. sideOrientation?: number;
  146118. updatable?: boolean;
  146119. }, scene?: Nullable<Scene>): Mesh;
  146120. /**
  146121. * Creates a sphere mesh
  146122. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  146123. * * 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`)
  146124. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  146125. * * 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
  146126. * * 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)
  146127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146130. * @param name defines the name of the mesh
  146131. * @param options defines the options used to create the mesh
  146132. * @param scene defines the hosting scene
  146133. * @returns the sphere mesh
  146134. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  146135. */
  146136. static CreateSphere(name: string, options: {
  146137. segments?: number;
  146138. diameter?: number;
  146139. diameterX?: number;
  146140. diameterY?: number;
  146141. diameterZ?: number;
  146142. arc?: number;
  146143. slice?: number;
  146144. sideOrientation?: number;
  146145. frontUVs?: Vector4;
  146146. backUVs?: Vector4;
  146147. updatable?: boolean;
  146148. }, scene?: Nullable<Scene>): Mesh;
  146149. /**
  146150. * Creates a plane polygonal mesh. By default, this is a disc
  146151. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  146152. * * 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
  146153. * * 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
  146154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146157. * @param name defines the name of the mesh
  146158. * @param options defines the options used to create the mesh
  146159. * @param scene defines the hosting scene
  146160. * @returns the plane polygonal mesh
  146161. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  146162. */
  146163. static CreateDisc(name: string, options: {
  146164. radius?: number;
  146165. tessellation?: number;
  146166. arc?: number;
  146167. updatable?: boolean;
  146168. sideOrientation?: number;
  146169. frontUVs?: Vector4;
  146170. backUVs?: Vector4;
  146171. }, scene?: Nullable<Scene>): Mesh;
  146172. /**
  146173. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146174. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146175. * * 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`)
  146176. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146177. * * 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
  146178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146181. * @param name defines the name of the mesh
  146182. * @param options defines the options used to create the mesh
  146183. * @param scene defines the hosting scene
  146184. * @returns the icosahedron mesh
  146185. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146186. */
  146187. static CreateIcoSphere(name: string, options: {
  146188. radius?: number;
  146189. radiusX?: number;
  146190. radiusY?: number;
  146191. radiusZ?: number;
  146192. flat?: boolean;
  146193. subdivisions?: number;
  146194. sideOrientation?: number;
  146195. frontUVs?: Vector4;
  146196. backUVs?: Vector4;
  146197. updatable?: boolean;
  146198. }, scene?: Nullable<Scene>): Mesh;
  146199. /**
  146200. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146201. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  146202. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  146203. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  146204. * * 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
  146205. * * 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
  146206. * * 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
  146207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146210. * * 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
  146211. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  146212. * * 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
  146213. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  146214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146215. * @param name defines the name of the mesh
  146216. * @param options defines the options used to create the mesh
  146217. * @param scene defines the hosting scene
  146218. * @returns the ribbon mesh
  146219. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  146220. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146221. */
  146222. static CreateRibbon(name: string, options: {
  146223. pathArray: Vector3[][];
  146224. closeArray?: boolean;
  146225. closePath?: boolean;
  146226. offset?: number;
  146227. updatable?: boolean;
  146228. sideOrientation?: number;
  146229. frontUVs?: Vector4;
  146230. backUVs?: Vector4;
  146231. instance?: Mesh;
  146232. invertUV?: boolean;
  146233. uvs?: Vector2[];
  146234. colors?: Color4[];
  146235. }, scene?: Nullable<Scene>): Mesh;
  146236. /**
  146237. * Creates a cylinder or a cone mesh
  146238. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  146239. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  146240. * * 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.
  146241. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  146242. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  146243. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  146244. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  146245. * * 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).
  146246. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  146247. * * 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).
  146248. * * 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
  146249. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  146250. * * 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
  146251. * * 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.
  146252. * * If `enclose` is false, a ring surface is one element.
  146253. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  146254. * * 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
  146255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146258. * @param name defines the name of the mesh
  146259. * @param options defines the options used to create the mesh
  146260. * @param scene defines the hosting scene
  146261. * @returns the cylinder mesh
  146262. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  146263. */
  146264. static CreateCylinder(name: string, options: {
  146265. height?: number;
  146266. diameterTop?: number;
  146267. diameterBottom?: number;
  146268. diameter?: number;
  146269. tessellation?: number;
  146270. subdivisions?: number;
  146271. arc?: number;
  146272. faceColors?: Color4[];
  146273. faceUV?: Vector4[];
  146274. updatable?: boolean;
  146275. hasRings?: boolean;
  146276. enclose?: boolean;
  146277. cap?: number;
  146278. sideOrientation?: number;
  146279. frontUVs?: Vector4;
  146280. backUVs?: Vector4;
  146281. }, scene?: Nullable<Scene>): Mesh;
  146282. /**
  146283. * Creates a torus mesh
  146284. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  146285. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  146286. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  146287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146290. * @param name defines the name of the mesh
  146291. * @param options defines the options used to create the mesh
  146292. * @param scene defines the hosting scene
  146293. * @returns the torus mesh
  146294. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  146295. */
  146296. static CreateTorus(name: string, options: {
  146297. diameter?: number;
  146298. thickness?: number;
  146299. tessellation?: number;
  146300. updatable?: boolean;
  146301. sideOrientation?: number;
  146302. frontUVs?: Vector4;
  146303. backUVs?: Vector4;
  146304. }, scene?: Nullable<Scene>): Mesh;
  146305. /**
  146306. * Creates a torus knot mesh
  146307. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146308. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146309. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146310. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146312. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146314. * @param name defines the name of the mesh
  146315. * @param options defines the options used to create the mesh
  146316. * @param scene defines the hosting scene
  146317. * @returns the torus knot mesh
  146318. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146319. */
  146320. static CreateTorusKnot(name: string, options: {
  146321. radius?: number;
  146322. tube?: number;
  146323. radialSegments?: number;
  146324. tubularSegments?: number;
  146325. p?: number;
  146326. q?: number;
  146327. updatable?: boolean;
  146328. sideOrientation?: number;
  146329. frontUVs?: Vector4;
  146330. backUVs?: Vector4;
  146331. }, scene?: Nullable<Scene>): Mesh;
  146332. /**
  146333. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  146334. * * 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
  146335. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  146336. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  146337. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  146338. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  146339. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  146340. * * 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
  146341. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  146342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  146344. * @param name defines the name of the new line system
  146345. * @param options defines the options used to create the line system
  146346. * @param scene defines the hosting scene
  146347. * @returns a new line system mesh
  146348. */
  146349. static CreateLineSystem(name: string, options: {
  146350. lines: Vector3[][];
  146351. updatable?: boolean;
  146352. instance?: Nullable<LinesMesh>;
  146353. colors?: Nullable<Color4[][]>;
  146354. useVertexAlpha?: boolean;
  146355. }, scene: Nullable<Scene>): LinesMesh;
  146356. /**
  146357. * Creates a line mesh
  146358. * 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
  146359. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146360. * * The parameter `points` is an array successive Vector3
  146361. * * 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
  146362. * * The optional parameter `colors` is an array of successive Color4, one per line point
  146363. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  146364. * * When updating an instance, remember that only point positions can change, not the number of points
  146365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146366. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  146367. * @param name defines the name of the new line system
  146368. * @param options defines the options used to create the line system
  146369. * @param scene defines the hosting scene
  146370. * @returns a new line mesh
  146371. */
  146372. static CreateLines(name: string, options: {
  146373. points: Vector3[];
  146374. updatable?: boolean;
  146375. instance?: Nullable<LinesMesh>;
  146376. colors?: Color4[];
  146377. useVertexAlpha?: boolean;
  146378. }, scene?: Nullable<Scene>): LinesMesh;
  146379. /**
  146380. * Creates a dashed line mesh
  146381. * * 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
  146382. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146383. * * The parameter `points` is an array successive Vector3
  146384. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  146385. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  146386. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  146387. * * 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
  146388. * * When updating an instance, remember that only point positions can change, not the number of points
  146389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146390. * @param name defines the name of the mesh
  146391. * @param options defines the options used to create the mesh
  146392. * @param scene defines the hosting scene
  146393. * @returns the dashed line mesh
  146394. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  146395. */
  146396. static CreateDashedLines(name: string, options: {
  146397. points: Vector3[];
  146398. dashSize?: number;
  146399. gapSize?: number;
  146400. dashNb?: number;
  146401. updatable?: boolean;
  146402. instance?: LinesMesh;
  146403. }, scene?: Nullable<Scene>): LinesMesh;
  146404. /**
  146405. * 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.
  146406. * * 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.
  146407. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146408. * * 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.
  146409. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  146410. * * 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
  146411. * * 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
  146412. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  146413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146415. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  146416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146417. * @param name defines the name of the mesh
  146418. * @param options defines the options used to create the mesh
  146419. * @param scene defines the hosting scene
  146420. * @returns the extruded shape mesh
  146421. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146423. */
  146424. static ExtrudeShape(name: string, options: {
  146425. shape: Vector3[];
  146426. path: Vector3[];
  146427. scale?: number;
  146428. rotation?: number;
  146429. cap?: number;
  146430. updatable?: boolean;
  146431. sideOrientation?: number;
  146432. frontUVs?: Vector4;
  146433. backUVs?: Vector4;
  146434. instance?: Mesh;
  146435. invertUV?: boolean;
  146436. }, scene?: Nullable<Scene>): Mesh;
  146437. /**
  146438. * Creates an custom extruded shape mesh.
  146439. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  146440. * * 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.
  146441. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146442. * * 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
  146443. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  146444. * * 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
  146445. * * It must returns a float value that will be the scale value applied to the shape on each path point
  146446. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  146447. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  146448. * * 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
  146449. * * 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
  146450. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  146451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146453. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146455. * @param name defines the name of the mesh
  146456. * @param options defines the options used to create the mesh
  146457. * @param scene defines the hosting scene
  146458. * @returns the custom extruded shape mesh
  146459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  146460. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146462. */
  146463. static ExtrudeShapeCustom(name: string, options: {
  146464. shape: Vector3[];
  146465. path: Vector3[];
  146466. scaleFunction?: any;
  146467. rotationFunction?: any;
  146468. ribbonCloseArray?: boolean;
  146469. ribbonClosePath?: boolean;
  146470. cap?: number;
  146471. updatable?: boolean;
  146472. sideOrientation?: number;
  146473. frontUVs?: Vector4;
  146474. backUVs?: Vector4;
  146475. instance?: Mesh;
  146476. invertUV?: boolean;
  146477. }, scene?: Nullable<Scene>): Mesh;
  146478. /**
  146479. * Creates lathe mesh.
  146480. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146481. * * 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
  146482. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146483. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146484. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146485. * * 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
  146486. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146487. * * 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
  146488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146490. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146492. * @param name defines the name of the mesh
  146493. * @param options defines the options used to create the mesh
  146494. * @param scene defines the hosting scene
  146495. * @returns the lathe mesh
  146496. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146497. */
  146498. static CreateLathe(name: string, options: {
  146499. shape: Vector3[];
  146500. radius?: number;
  146501. tessellation?: number;
  146502. clip?: number;
  146503. arc?: number;
  146504. closed?: boolean;
  146505. updatable?: boolean;
  146506. sideOrientation?: number;
  146507. frontUVs?: Vector4;
  146508. backUVs?: Vector4;
  146509. cap?: number;
  146510. invertUV?: boolean;
  146511. }, scene?: Nullable<Scene>): Mesh;
  146512. /**
  146513. * Creates a tiled plane mesh
  146514. * * You can set a limited pattern arrangement with the tiles
  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. * @param name defines the name of the mesh
  146519. * @param options defines the options used to create the mesh
  146520. * @param scene defines the hosting scene
  146521. * @returns the plane mesh
  146522. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146523. */
  146524. static CreateTiledPlane(name: string, options: {
  146525. pattern?: number;
  146526. tileSize?: number;
  146527. tileWidth?: number;
  146528. tileHeight?: number;
  146529. size?: number;
  146530. width?: number;
  146531. height?: number;
  146532. alignHorizontal?: number;
  146533. alignVertical?: number;
  146534. sideOrientation?: number;
  146535. frontUVs?: Vector4;
  146536. backUVs?: Vector4;
  146537. updatable?: boolean;
  146538. }, scene?: Nullable<Scene>): Mesh;
  146539. /**
  146540. * Creates a plane mesh
  146541. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146542. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146543. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146547. * @param name defines the name of the mesh
  146548. * @param options defines the options used to create the mesh
  146549. * @param scene defines the hosting scene
  146550. * @returns the plane mesh
  146551. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146552. */
  146553. static CreatePlane(name: string, options: {
  146554. size?: number;
  146555. width?: number;
  146556. height?: number;
  146557. sideOrientation?: number;
  146558. frontUVs?: Vector4;
  146559. backUVs?: Vector4;
  146560. updatable?: boolean;
  146561. sourcePlane?: Plane;
  146562. }, scene?: Nullable<Scene>): Mesh;
  146563. /**
  146564. * Creates a ground mesh
  146565. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  146566. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  146567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146568. * @param name defines the name of the mesh
  146569. * @param options defines the options used to create the mesh
  146570. * @param scene defines the hosting scene
  146571. * @returns the ground mesh
  146572. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  146573. */
  146574. static CreateGround(name: string, options: {
  146575. width?: number;
  146576. height?: number;
  146577. subdivisions?: number;
  146578. subdivisionsX?: number;
  146579. subdivisionsY?: number;
  146580. updatable?: boolean;
  146581. }, scene?: Nullable<Scene>): Mesh;
  146582. /**
  146583. * Creates a tiled ground mesh
  146584. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  146585. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  146586. * * 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
  146587. * * 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
  146588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146589. * @param name defines the name of the mesh
  146590. * @param options defines the options used to create the mesh
  146591. * @param scene defines the hosting scene
  146592. * @returns the tiled ground mesh
  146593. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  146594. */
  146595. static CreateTiledGround(name: string, options: {
  146596. xmin: number;
  146597. zmin: number;
  146598. xmax: number;
  146599. zmax: number;
  146600. subdivisions?: {
  146601. w: number;
  146602. h: number;
  146603. };
  146604. precision?: {
  146605. w: number;
  146606. h: number;
  146607. };
  146608. updatable?: boolean;
  146609. }, scene?: Nullable<Scene>): Mesh;
  146610. /**
  146611. * Creates a ground mesh from a height map
  146612. * * The parameter `url` sets the URL of the height map image resource.
  146613. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  146614. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  146615. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  146616. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  146617. * * 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.
  146618. * * 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).
  146619. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  146620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146621. * @param name defines the name of the mesh
  146622. * @param url defines the url to the height map
  146623. * @param options defines the options used to create the mesh
  146624. * @param scene defines the hosting scene
  146625. * @returns the ground mesh
  146626. * @see https://doc.babylonjs.com/babylon101/height_map
  146627. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  146628. */
  146629. static CreateGroundFromHeightMap(name: string, url: string, options: {
  146630. width?: number;
  146631. height?: number;
  146632. subdivisions?: number;
  146633. minHeight?: number;
  146634. maxHeight?: number;
  146635. colorFilter?: Color3;
  146636. alphaFilter?: number;
  146637. updatable?: boolean;
  146638. onReady?: (mesh: GroundMesh) => void;
  146639. }, scene?: Nullable<Scene>): GroundMesh;
  146640. /**
  146641. * Creates a polygon mesh
  146642. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146643. * * 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
  146644. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146646. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146647. * * Remember you can only change the shape positions, not their number when updating a polygon
  146648. * @param name defines the name of the mesh
  146649. * @param options defines the options used to create the mesh
  146650. * @param scene defines the hosting scene
  146651. * @param earcutInjection can be used to inject your own earcut reference
  146652. * @returns the polygon mesh
  146653. */
  146654. static CreatePolygon(name: string, options: {
  146655. shape: Vector3[];
  146656. holes?: Vector3[][];
  146657. depth?: number;
  146658. faceUV?: Vector4[];
  146659. faceColors?: Color4[];
  146660. updatable?: boolean;
  146661. sideOrientation?: number;
  146662. frontUVs?: Vector4;
  146663. backUVs?: Vector4;
  146664. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146665. /**
  146666. * Creates an extruded polygon mesh, with depth in the Y direction.
  146667. * * 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)
  146668. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146669. * @param name defines the name of the mesh
  146670. * @param options defines the options used to create the mesh
  146671. * @param scene defines the hosting scene
  146672. * @param earcutInjection can be used to inject your own earcut reference
  146673. * @returns the polygon mesh
  146674. */
  146675. static ExtrudePolygon(name: string, options: {
  146676. shape: Vector3[];
  146677. holes?: Vector3[][];
  146678. depth?: number;
  146679. faceUV?: Vector4[];
  146680. faceColors?: Color4[];
  146681. updatable?: boolean;
  146682. sideOrientation?: number;
  146683. frontUVs?: Vector4;
  146684. backUVs?: Vector4;
  146685. wrap?: boolean;
  146686. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146687. /**
  146688. * Creates a tube mesh.
  146689. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146690. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146691. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146692. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146693. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146694. * * 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)
  146695. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146696. * * 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
  146697. * * 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
  146698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146699. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146700. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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 tube mesh
  146706. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146707. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146708. */
  146709. static CreateTube(name: string, options: {
  146710. path: Vector3[];
  146711. radius?: number;
  146712. tessellation?: number;
  146713. radiusFunction?: {
  146714. (i: number, distance: number): number;
  146715. };
  146716. cap?: number;
  146717. arc?: number;
  146718. updatable?: boolean;
  146719. sideOrientation?: number;
  146720. frontUVs?: Vector4;
  146721. backUVs?: Vector4;
  146722. instance?: Mesh;
  146723. invertUV?: boolean;
  146724. }, scene?: Nullable<Scene>): Mesh;
  146725. /**
  146726. * Creates a polyhedron mesh
  146727. * * 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
  146728. * * The parameter `size` (positive float, default 1) sets the polygon size
  146729. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  146730. * * 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`
  146731. * * 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
  146732. * * 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)`)
  146733. * * 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
  146734. * * 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
  146735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146738. * @param name defines the name of the mesh
  146739. * @param options defines the options used to create the mesh
  146740. * @param scene defines the hosting scene
  146741. * @returns the polyhedron mesh
  146742. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  146743. */
  146744. static CreatePolyhedron(name: string, options: {
  146745. type?: number;
  146746. size?: number;
  146747. sizeX?: number;
  146748. sizeY?: number;
  146749. sizeZ?: number;
  146750. custom?: any;
  146751. faceUV?: Vector4[];
  146752. faceColors?: Color4[];
  146753. flat?: boolean;
  146754. updatable?: boolean;
  146755. sideOrientation?: number;
  146756. frontUVs?: Vector4;
  146757. backUVs?: Vector4;
  146758. }, scene?: Nullable<Scene>): Mesh;
  146759. /**
  146760. * Creates a decal mesh.
  146761. * 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
  146762. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146763. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146764. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146765. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146766. * @param name defines the name of the mesh
  146767. * @param sourceMesh defines the mesh where the decal must be applied
  146768. * @param options defines the options used to create the mesh
  146769. * @param scene defines the hosting scene
  146770. * @returns the decal mesh
  146771. * @see https://doc.babylonjs.com/how_to/decals
  146772. */
  146773. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146774. position?: Vector3;
  146775. normal?: Vector3;
  146776. size?: Vector3;
  146777. angle?: number;
  146778. }): Mesh;
  146779. /**
  146780. * Creates a Capsule Mesh
  146781. * @param name defines the name of the mesh.
  146782. * @param options the constructors options used to shape the mesh.
  146783. * @param scene defines the scene the mesh is scoped to.
  146784. * @returns the capsule mesh
  146785. * @see https://doc.babylonjs.com/how_to/capsule_shape
  146786. */
  146787. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  146788. }
  146789. }
  146790. declare module BABYLON {
  146791. /**
  146792. * A simplifier interface for future simplification implementations
  146793. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146794. */
  146795. export interface ISimplifier {
  146796. /**
  146797. * Simplification of a given mesh according to the given settings.
  146798. * Since this requires computation, it is assumed that the function runs async.
  146799. * @param settings The settings of the simplification, including quality and distance
  146800. * @param successCallback A callback that will be called after the mesh was simplified.
  146801. * @param errorCallback in case of an error, this callback will be called. optional.
  146802. */
  146803. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  146804. }
  146805. /**
  146806. * Expected simplification settings.
  146807. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  146808. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146809. */
  146810. export interface ISimplificationSettings {
  146811. /**
  146812. * Gets or sets the expected quality
  146813. */
  146814. quality: number;
  146815. /**
  146816. * Gets or sets the distance when this optimized version should be used
  146817. */
  146818. distance: number;
  146819. /**
  146820. * Gets an already optimized mesh
  146821. */
  146822. optimizeMesh?: boolean;
  146823. }
  146824. /**
  146825. * Class used to specify simplification options
  146826. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146827. */
  146828. export class SimplificationSettings implements ISimplificationSettings {
  146829. /** expected quality */
  146830. quality: number;
  146831. /** distance when this optimized version should be used */
  146832. distance: number;
  146833. /** already optimized mesh */
  146834. optimizeMesh?: boolean | undefined;
  146835. /**
  146836. * Creates a SimplificationSettings
  146837. * @param quality expected quality
  146838. * @param distance distance when this optimized version should be used
  146839. * @param optimizeMesh already optimized mesh
  146840. */
  146841. constructor(
  146842. /** expected quality */
  146843. quality: number,
  146844. /** distance when this optimized version should be used */
  146845. distance: number,
  146846. /** already optimized mesh */
  146847. optimizeMesh?: boolean | undefined);
  146848. }
  146849. /**
  146850. * Interface used to define a simplification task
  146851. */
  146852. export interface ISimplificationTask {
  146853. /**
  146854. * Array of settings
  146855. */
  146856. settings: Array<ISimplificationSettings>;
  146857. /**
  146858. * Simplification type
  146859. */
  146860. simplificationType: SimplificationType;
  146861. /**
  146862. * Mesh to simplify
  146863. */
  146864. mesh: Mesh;
  146865. /**
  146866. * Callback called on success
  146867. */
  146868. successCallback?: () => void;
  146869. /**
  146870. * Defines if parallel processing can be used
  146871. */
  146872. parallelProcessing: boolean;
  146873. }
  146874. /**
  146875. * Queue used to order the simplification tasks
  146876. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146877. */
  146878. export class SimplificationQueue {
  146879. private _simplificationArray;
  146880. /**
  146881. * Gets a boolean indicating that the process is still running
  146882. */
  146883. running: boolean;
  146884. /**
  146885. * Creates a new queue
  146886. */
  146887. constructor();
  146888. /**
  146889. * Adds a new simplification task
  146890. * @param task defines a task to add
  146891. */
  146892. addTask(task: ISimplificationTask): void;
  146893. /**
  146894. * Execute next task
  146895. */
  146896. executeNext(): void;
  146897. /**
  146898. * Execute a simplification task
  146899. * @param task defines the task to run
  146900. */
  146901. runSimplification(task: ISimplificationTask): void;
  146902. private getSimplifier;
  146903. }
  146904. /**
  146905. * The implemented types of simplification
  146906. * At the moment only Quadratic Error Decimation is implemented
  146907. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146908. */
  146909. export enum SimplificationType {
  146910. /** Quadratic error decimation */
  146911. QUADRATIC = 0
  146912. }
  146913. /**
  146914. * An implementation of the Quadratic Error simplification algorithm.
  146915. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  146916. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  146917. * @author RaananW
  146918. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146919. */
  146920. export class QuadraticErrorSimplification implements ISimplifier {
  146921. private _mesh;
  146922. private triangles;
  146923. private vertices;
  146924. private references;
  146925. private _reconstructedMesh;
  146926. /** Gets or sets the number pf sync interations */
  146927. syncIterations: number;
  146928. /** Gets or sets the aggressiveness of the simplifier */
  146929. aggressiveness: number;
  146930. /** Gets or sets the number of allowed iterations for decimation */
  146931. decimationIterations: number;
  146932. /** Gets or sets the espilon to use for bounding box computation */
  146933. boundingBoxEpsilon: number;
  146934. /**
  146935. * Creates a new QuadraticErrorSimplification
  146936. * @param _mesh defines the target mesh
  146937. */
  146938. constructor(_mesh: Mesh);
  146939. /**
  146940. * Simplification of a given mesh according to the given settings.
  146941. * Since this requires computation, it is assumed that the function runs async.
  146942. * @param settings The settings of the simplification, including quality and distance
  146943. * @param successCallback A callback that will be called after the mesh was simplified.
  146944. */
  146945. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  146946. private runDecimation;
  146947. private initWithMesh;
  146948. private init;
  146949. private reconstructMesh;
  146950. private initDecimatedMesh;
  146951. private isFlipped;
  146952. private updateTriangles;
  146953. private identifyBorder;
  146954. private updateMesh;
  146955. private vertexError;
  146956. private calculateError;
  146957. }
  146958. }
  146959. declare module BABYLON {
  146960. interface Scene {
  146961. /** @hidden (Backing field) */
  146962. _simplificationQueue: SimplificationQueue;
  146963. /**
  146964. * Gets or sets the simplification queue attached to the scene
  146965. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146966. */
  146967. simplificationQueue: SimplificationQueue;
  146968. }
  146969. interface Mesh {
  146970. /**
  146971. * Simplify the mesh according to the given array of settings.
  146972. * Function will return immediately and will simplify async
  146973. * @param settings a collection of simplification settings
  146974. * @param parallelProcessing should all levels calculate parallel or one after the other
  146975. * @param simplificationType the type of simplification to run
  146976. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  146977. * @returns the current mesh
  146978. */
  146979. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  146980. }
  146981. /**
  146982. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  146983. * created in a scene
  146984. */
  146985. export class SimplicationQueueSceneComponent implements ISceneComponent {
  146986. /**
  146987. * The component name helpfull to identify the component in the list of scene components.
  146988. */
  146989. readonly name: string;
  146990. /**
  146991. * The scene the component belongs to.
  146992. */
  146993. scene: Scene;
  146994. /**
  146995. * Creates a new instance of the component for the given scene
  146996. * @param scene Defines the scene to register the component in
  146997. */
  146998. constructor(scene: Scene);
  146999. /**
  147000. * Registers the component in a given scene
  147001. */
  147002. register(): void;
  147003. /**
  147004. * Rebuilds the elements related to this component in case of
  147005. * context lost for instance.
  147006. */
  147007. rebuild(): void;
  147008. /**
  147009. * Disposes the component and the associated ressources
  147010. */
  147011. dispose(): void;
  147012. private _beforeCameraUpdate;
  147013. }
  147014. }
  147015. declare module BABYLON {
  147016. interface Mesh {
  147017. /**
  147018. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  147019. */
  147020. thinInstanceEnablePicking: boolean;
  147021. /**
  147022. * Creates a new thin instance
  147023. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  147024. * @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
  147025. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  147026. */
  147027. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  147028. /**
  147029. * Adds the transformation (matrix) of the current mesh as a thin instance
  147030. * @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
  147031. * @returns the thin instance index number
  147032. */
  147033. thinInstanceAddSelf(refresh: boolean): number;
  147034. /**
  147035. * Registers a custom attribute to be used with thin instances
  147036. * @param kind name of the attribute
  147037. * @param stride size in floats of the attribute
  147038. */
  147039. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  147040. /**
  147041. * Sets the matrix of a thin instance
  147042. * @param index index of the thin instance
  147043. * @param matrix matrix to set
  147044. * @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
  147045. */
  147046. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  147047. /**
  147048. * Sets the value of a custom attribute for a thin instance
  147049. * @param kind name of the attribute
  147050. * @param index index of the thin instance
  147051. * @param value value to set
  147052. * @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
  147053. */
  147054. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  147055. /**
  147056. * 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.
  147057. */
  147058. thinInstanceCount: number;
  147059. /**
  147060. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  147061. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  147062. * @param buffer buffer to set
  147063. * @param stride size in floats of each value of the buffer
  147064. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  147065. */
  147066. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  147067. /**
  147068. * Gets the list of world matrices
  147069. * @return an array containing all the world matrices from the thin instances
  147070. */
  147071. thinInstanceGetWorldMatrices(): Matrix[];
  147072. /**
  147073. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  147074. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147075. */
  147076. thinInstanceBufferUpdated(kind: string): void;
  147077. /**
  147078. * Applies a partial update to a buffer directly on the GPU
  147079. * 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
  147080. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147081. * @param data the data to set in the GPU buffer
  147082. * @param offset the offset in the GPU buffer where to update the data
  147083. */
  147084. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  147085. /**
  147086. * Refreshes the bounding info, taking into account all the thin instances defined
  147087. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  147088. */
  147089. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  147090. /** @hidden */
  147091. _thinInstanceInitializeUserStorage(): void;
  147092. /** @hidden */
  147093. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  147094. /** @hidden */
  147095. _userThinInstanceBuffersStorage: {
  147096. data: {
  147097. [key: string]: Float32Array;
  147098. };
  147099. sizes: {
  147100. [key: string]: number;
  147101. };
  147102. vertexBuffers: {
  147103. [key: string]: Nullable<VertexBuffer>;
  147104. };
  147105. strides: {
  147106. [key: string]: number;
  147107. };
  147108. };
  147109. }
  147110. }
  147111. declare module BABYLON {
  147112. /**
  147113. * Navigation plugin interface to add navigation constrained by a navigation mesh
  147114. */
  147115. export interface INavigationEnginePlugin {
  147116. /**
  147117. * plugin name
  147118. */
  147119. name: string;
  147120. /**
  147121. * Creates a navigation mesh
  147122. * @param meshes array of all the geometry used to compute the navigatio mesh
  147123. * @param parameters bunch of parameters used to filter geometry
  147124. */
  147125. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147126. /**
  147127. * Create a navigation mesh debug mesh
  147128. * @param scene is where the mesh will be added
  147129. * @returns debug display mesh
  147130. */
  147131. createDebugNavMesh(scene: Scene): Mesh;
  147132. /**
  147133. * Get a navigation mesh constrained position, closest to the parameter position
  147134. * @param position world position
  147135. * @returns the closest point to position constrained by the navigation mesh
  147136. */
  147137. getClosestPoint(position: Vector3): Vector3;
  147138. /**
  147139. * Get a navigation mesh constrained position, closest to the parameter position
  147140. * @param position world position
  147141. * @param result output the closest point to position constrained by the navigation mesh
  147142. */
  147143. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147144. /**
  147145. * Get a navigation mesh constrained position, within a particular radius
  147146. * @param position world position
  147147. * @param maxRadius the maximum distance to the constrained world position
  147148. * @returns the closest point to position constrained by the navigation mesh
  147149. */
  147150. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147151. /**
  147152. * Get a navigation mesh constrained position, within a particular radius
  147153. * @param position world position
  147154. * @param maxRadius the maximum distance to the constrained world position
  147155. * @param result output the closest point to position constrained by the navigation mesh
  147156. */
  147157. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147158. /**
  147159. * Compute the final position from a segment made of destination-position
  147160. * @param position world position
  147161. * @param destination world position
  147162. * @returns the resulting point along the navmesh
  147163. */
  147164. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147165. /**
  147166. * Compute the final position from a segment made of destination-position
  147167. * @param position world position
  147168. * @param destination world position
  147169. * @param result output the resulting point along the navmesh
  147170. */
  147171. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147172. /**
  147173. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147174. * @param start world position
  147175. * @param end world position
  147176. * @returns array containing world position composing the path
  147177. */
  147178. computePath(start: Vector3, end: Vector3): Vector3[];
  147179. /**
  147180. * If this plugin is supported
  147181. * @returns true if plugin is supported
  147182. */
  147183. isSupported(): boolean;
  147184. /**
  147185. * Create a new Crowd so you can add agents
  147186. * @param maxAgents the maximum agent count in the crowd
  147187. * @param maxAgentRadius the maximum radius an agent can have
  147188. * @param scene to attach the crowd to
  147189. * @returns the crowd you can add agents to
  147190. */
  147191. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147192. /**
  147193. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147194. * The queries will try to find a solution within those bounds
  147195. * default is (1,1,1)
  147196. * @param extent x,y,z value that define the extent around the queries point of reference
  147197. */
  147198. setDefaultQueryExtent(extent: Vector3): void;
  147199. /**
  147200. * Get the Bounding box extent specified by setDefaultQueryExtent
  147201. * @returns the box extent values
  147202. */
  147203. getDefaultQueryExtent(): Vector3;
  147204. /**
  147205. * build the navmesh from a previously saved state using getNavmeshData
  147206. * @param data the Uint8Array returned by getNavmeshData
  147207. */
  147208. buildFromNavmeshData(data: Uint8Array): void;
  147209. /**
  147210. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147211. * @returns data the Uint8Array that can be saved and reused
  147212. */
  147213. getNavmeshData(): Uint8Array;
  147214. /**
  147215. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147216. * @param result output the box extent values
  147217. */
  147218. getDefaultQueryExtentToRef(result: Vector3): void;
  147219. /**
  147220. * Release all resources
  147221. */
  147222. dispose(): void;
  147223. }
  147224. /**
  147225. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  147226. */
  147227. export interface ICrowd {
  147228. /**
  147229. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147230. * You can attach anything to that node. The node position is updated in the scene update tick.
  147231. * @param pos world position that will be constrained by the navigation mesh
  147232. * @param parameters agent parameters
  147233. * @param transform hooked to the agent that will be update by the scene
  147234. * @returns agent index
  147235. */
  147236. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147237. /**
  147238. * Returns the agent position in world space
  147239. * @param index agent index returned by addAgent
  147240. * @returns world space position
  147241. */
  147242. getAgentPosition(index: number): Vector3;
  147243. /**
  147244. * Gets the agent position result in world space
  147245. * @param index agent index returned by addAgent
  147246. * @param result output world space position
  147247. */
  147248. getAgentPositionToRef(index: number, result: Vector3): void;
  147249. /**
  147250. * Gets the agent velocity in world space
  147251. * @param index agent index returned by addAgent
  147252. * @returns world space velocity
  147253. */
  147254. getAgentVelocity(index: number): Vector3;
  147255. /**
  147256. * Gets the agent velocity result in world space
  147257. * @param index agent index returned by addAgent
  147258. * @param result output world space velocity
  147259. */
  147260. getAgentVelocityToRef(index: number, result: Vector3): void;
  147261. /**
  147262. * remove a particular agent previously created
  147263. * @param index agent index returned by addAgent
  147264. */
  147265. removeAgent(index: number): void;
  147266. /**
  147267. * get the list of all agents attached to this crowd
  147268. * @returns list of agent indices
  147269. */
  147270. getAgents(): number[];
  147271. /**
  147272. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147273. * @param deltaTime in seconds
  147274. */
  147275. update(deltaTime: number): void;
  147276. /**
  147277. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147278. * @param index agent index returned by addAgent
  147279. * @param destination targeted world position
  147280. */
  147281. agentGoto(index: number, destination: Vector3): void;
  147282. /**
  147283. * Teleport the agent to a new position
  147284. * @param index agent index returned by addAgent
  147285. * @param destination targeted world position
  147286. */
  147287. agentTeleport(index: number, destination: Vector3): void;
  147288. /**
  147289. * Update agent parameters
  147290. * @param index agent index returned by addAgent
  147291. * @param parameters agent parameters
  147292. */
  147293. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147294. /**
  147295. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147296. * The queries will try to find a solution within those bounds
  147297. * default is (1,1,1)
  147298. * @param extent x,y,z value that define the extent around the queries point of reference
  147299. */
  147300. setDefaultQueryExtent(extent: Vector3): void;
  147301. /**
  147302. * Get the Bounding box extent specified by setDefaultQueryExtent
  147303. * @returns the box extent values
  147304. */
  147305. getDefaultQueryExtent(): Vector3;
  147306. /**
  147307. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147308. * @param result output the box extent values
  147309. */
  147310. getDefaultQueryExtentToRef(result: Vector3): void;
  147311. /**
  147312. * Release all resources
  147313. */
  147314. dispose(): void;
  147315. }
  147316. /**
  147317. * Configures an agent
  147318. */
  147319. export interface IAgentParameters {
  147320. /**
  147321. * Agent radius. [Limit: >= 0]
  147322. */
  147323. radius: number;
  147324. /**
  147325. * Agent height. [Limit: > 0]
  147326. */
  147327. height: number;
  147328. /**
  147329. * Maximum allowed acceleration. [Limit: >= 0]
  147330. */
  147331. maxAcceleration: number;
  147332. /**
  147333. * Maximum allowed speed. [Limit: >= 0]
  147334. */
  147335. maxSpeed: number;
  147336. /**
  147337. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  147338. */
  147339. collisionQueryRange: number;
  147340. /**
  147341. * The path visibility optimization range. [Limit: > 0]
  147342. */
  147343. pathOptimizationRange: number;
  147344. /**
  147345. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  147346. */
  147347. separationWeight: number;
  147348. }
  147349. /**
  147350. * Configures the navigation mesh creation
  147351. */
  147352. export interface INavMeshParameters {
  147353. /**
  147354. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  147355. */
  147356. cs: number;
  147357. /**
  147358. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  147359. */
  147360. ch: number;
  147361. /**
  147362. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  147363. */
  147364. walkableSlopeAngle: number;
  147365. /**
  147366. * Minimum floor to 'ceiling' height that will still allow the floor area to
  147367. * be considered walkable. [Limit: >= 3] [Units: vx]
  147368. */
  147369. walkableHeight: number;
  147370. /**
  147371. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  147372. */
  147373. walkableClimb: number;
  147374. /**
  147375. * The distance to erode/shrink the walkable area of the heightfield away from
  147376. * obstructions. [Limit: >=0] [Units: vx]
  147377. */
  147378. walkableRadius: number;
  147379. /**
  147380. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  147381. */
  147382. maxEdgeLen: number;
  147383. /**
  147384. * The maximum distance a simplfied contour's border edges should deviate
  147385. * the original raw contour. [Limit: >=0] [Units: vx]
  147386. */
  147387. maxSimplificationError: number;
  147388. /**
  147389. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  147390. */
  147391. minRegionArea: number;
  147392. /**
  147393. * Any regions with a span count smaller than this value will, if possible,
  147394. * be merged with larger regions. [Limit: >=0] [Units: vx]
  147395. */
  147396. mergeRegionArea: number;
  147397. /**
  147398. * The maximum number of vertices allowed for polygons generated during the
  147399. * contour to polygon conversion process. [Limit: >= 3]
  147400. */
  147401. maxVertsPerPoly: number;
  147402. /**
  147403. * Sets the sampling distance to use when generating the detail mesh.
  147404. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  147405. */
  147406. detailSampleDist: number;
  147407. /**
  147408. * The maximum distance the detail mesh surface should deviate from heightfield
  147409. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  147410. */
  147411. detailSampleMaxError: number;
  147412. }
  147413. }
  147414. declare module BABYLON {
  147415. /**
  147416. * RecastJS navigation plugin
  147417. */
  147418. export class RecastJSPlugin implements INavigationEnginePlugin {
  147419. /**
  147420. * Reference to the Recast library
  147421. */
  147422. bjsRECAST: any;
  147423. /**
  147424. * plugin name
  147425. */
  147426. name: string;
  147427. /**
  147428. * the first navmesh created. We might extend this to support multiple navmeshes
  147429. */
  147430. navMesh: any;
  147431. /**
  147432. * Initializes the recastJS plugin
  147433. * @param recastInjection can be used to inject your own recast reference
  147434. */
  147435. constructor(recastInjection?: any);
  147436. /**
  147437. * Creates a navigation mesh
  147438. * @param meshes array of all the geometry used to compute the navigatio mesh
  147439. * @param parameters bunch of parameters used to filter geometry
  147440. */
  147441. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147442. /**
  147443. * Create a navigation mesh debug mesh
  147444. * @param scene is where the mesh will be added
  147445. * @returns debug display mesh
  147446. */
  147447. createDebugNavMesh(scene: Scene): Mesh;
  147448. /**
  147449. * Get a navigation mesh constrained position, closest to the parameter position
  147450. * @param position world position
  147451. * @returns the closest point to position constrained by the navigation mesh
  147452. */
  147453. getClosestPoint(position: Vector3): Vector3;
  147454. /**
  147455. * Get a navigation mesh constrained position, closest to the parameter position
  147456. * @param position world position
  147457. * @param result output the closest point to position constrained by the navigation mesh
  147458. */
  147459. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147460. /**
  147461. * Get a navigation mesh constrained position, within a particular radius
  147462. * @param position world position
  147463. * @param maxRadius the maximum distance to the constrained world position
  147464. * @returns the closest point to position constrained by the navigation mesh
  147465. */
  147466. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147467. /**
  147468. * Get a navigation mesh constrained position, within a particular radius
  147469. * @param position world position
  147470. * @param maxRadius the maximum distance to the constrained world position
  147471. * @param result output the closest point to position constrained by the navigation mesh
  147472. */
  147473. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147474. /**
  147475. * Compute the final position from a segment made of destination-position
  147476. * @param position world position
  147477. * @param destination world position
  147478. * @returns the resulting point along the navmesh
  147479. */
  147480. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147481. /**
  147482. * Compute the final position from a segment made of destination-position
  147483. * @param position world position
  147484. * @param destination world position
  147485. * @param result output the resulting point along the navmesh
  147486. */
  147487. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147488. /**
  147489. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147490. * @param start world position
  147491. * @param end world position
  147492. * @returns array containing world position composing the path
  147493. */
  147494. computePath(start: Vector3, end: Vector3): Vector3[];
  147495. /**
  147496. * Create a new Crowd so you can add agents
  147497. * @param maxAgents the maximum agent count in the crowd
  147498. * @param maxAgentRadius the maximum radius an agent can have
  147499. * @param scene to attach the crowd to
  147500. * @returns the crowd you can add agents to
  147501. */
  147502. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147503. /**
  147504. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147505. * The queries will try to find a solution within those bounds
  147506. * default is (1,1,1)
  147507. * @param extent x,y,z value that define the extent around the queries point of reference
  147508. */
  147509. setDefaultQueryExtent(extent: Vector3): void;
  147510. /**
  147511. * Get the Bounding box extent specified by setDefaultQueryExtent
  147512. * @returns the box extent values
  147513. */
  147514. getDefaultQueryExtent(): Vector3;
  147515. /**
  147516. * build the navmesh from a previously saved state using getNavmeshData
  147517. * @param data the Uint8Array returned by getNavmeshData
  147518. */
  147519. buildFromNavmeshData(data: Uint8Array): void;
  147520. /**
  147521. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147522. * @returns data the Uint8Array that can be saved and reused
  147523. */
  147524. getNavmeshData(): Uint8Array;
  147525. /**
  147526. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147527. * @param result output the box extent values
  147528. */
  147529. getDefaultQueryExtentToRef(result: Vector3): void;
  147530. /**
  147531. * Disposes
  147532. */
  147533. dispose(): void;
  147534. /**
  147535. * If this plugin is supported
  147536. * @returns true if plugin is supported
  147537. */
  147538. isSupported(): boolean;
  147539. }
  147540. /**
  147541. * Recast detour crowd implementation
  147542. */
  147543. export class RecastJSCrowd implements ICrowd {
  147544. /**
  147545. * Recast/detour plugin
  147546. */
  147547. bjsRECASTPlugin: RecastJSPlugin;
  147548. /**
  147549. * Link to the detour crowd
  147550. */
  147551. recastCrowd: any;
  147552. /**
  147553. * One transform per agent
  147554. */
  147555. transforms: TransformNode[];
  147556. /**
  147557. * All agents created
  147558. */
  147559. agents: number[];
  147560. /**
  147561. * Link to the scene is kept to unregister the crowd from the scene
  147562. */
  147563. private _scene;
  147564. /**
  147565. * Observer for crowd updates
  147566. */
  147567. private _onBeforeAnimationsObserver;
  147568. /**
  147569. * Constructor
  147570. * @param plugin recastJS plugin
  147571. * @param maxAgents the maximum agent count in the crowd
  147572. * @param maxAgentRadius the maximum radius an agent can have
  147573. * @param scene to attach the crowd to
  147574. * @returns the crowd you can add agents to
  147575. */
  147576. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  147577. /**
  147578. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147579. * You can attach anything to that node. The node position is updated in the scene update tick.
  147580. * @param pos world position that will be constrained by the navigation mesh
  147581. * @param parameters agent parameters
  147582. * @param transform hooked to the agent that will be update by the scene
  147583. * @returns agent index
  147584. */
  147585. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147586. /**
  147587. * Returns the agent position in world space
  147588. * @param index agent index returned by addAgent
  147589. * @returns world space position
  147590. */
  147591. getAgentPosition(index: number): Vector3;
  147592. /**
  147593. * Returns the agent position result in world space
  147594. * @param index agent index returned by addAgent
  147595. * @param result output world space position
  147596. */
  147597. getAgentPositionToRef(index: number, result: Vector3): void;
  147598. /**
  147599. * Returns the agent velocity in world space
  147600. * @param index agent index returned by addAgent
  147601. * @returns world space velocity
  147602. */
  147603. getAgentVelocity(index: number): Vector3;
  147604. /**
  147605. * Returns the agent velocity result in world space
  147606. * @param index agent index returned by addAgent
  147607. * @param result output world space velocity
  147608. */
  147609. getAgentVelocityToRef(index: number, result: Vector3): void;
  147610. /**
  147611. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147612. * @param index agent index returned by addAgent
  147613. * @param destination targeted world position
  147614. */
  147615. agentGoto(index: number, destination: Vector3): void;
  147616. /**
  147617. * Teleport the agent to a new position
  147618. * @param index agent index returned by addAgent
  147619. * @param destination targeted world position
  147620. */
  147621. agentTeleport(index: number, destination: Vector3): void;
  147622. /**
  147623. * Update agent parameters
  147624. * @param index agent index returned by addAgent
  147625. * @param parameters agent parameters
  147626. */
  147627. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147628. /**
  147629. * remove a particular agent previously created
  147630. * @param index agent index returned by addAgent
  147631. */
  147632. removeAgent(index: number): void;
  147633. /**
  147634. * get the list of all agents attached to this crowd
  147635. * @returns list of agent indices
  147636. */
  147637. getAgents(): number[];
  147638. /**
  147639. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147640. * @param deltaTime in seconds
  147641. */
  147642. update(deltaTime: number): void;
  147643. /**
  147644. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147645. * The queries will try to find a solution within those bounds
  147646. * default is (1,1,1)
  147647. * @param extent x,y,z value that define the extent around the queries point of reference
  147648. */
  147649. setDefaultQueryExtent(extent: Vector3): void;
  147650. /**
  147651. * Get the Bounding box extent specified by setDefaultQueryExtent
  147652. * @returns the box extent values
  147653. */
  147654. getDefaultQueryExtent(): Vector3;
  147655. /**
  147656. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147657. * @param result output the box extent values
  147658. */
  147659. getDefaultQueryExtentToRef(result: Vector3): void;
  147660. /**
  147661. * Release all resources
  147662. */
  147663. dispose(): void;
  147664. }
  147665. }
  147666. declare module BABYLON {
  147667. /**
  147668. * Class used to enable access to IndexedDB
  147669. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  147670. */
  147671. export class Database implements IOfflineProvider {
  147672. private _callbackManifestChecked;
  147673. private _currentSceneUrl;
  147674. private _db;
  147675. private _enableSceneOffline;
  147676. private _enableTexturesOffline;
  147677. private _manifestVersionFound;
  147678. private _mustUpdateRessources;
  147679. private _hasReachedQuota;
  147680. private _isSupported;
  147681. private _idbFactory;
  147682. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  147683. private static IsUASupportingBlobStorage;
  147684. /**
  147685. * Gets a boolean indicating if Database storate is enabled (off by default)
  147686. */
  147687. static IDBStorageEnabled: boolean;
  147688. /**
  147689. * Gets a boolean indicating if scene must be saved in the database
  147690. */
  147691. get enableSceneOffline(): boolean;
  147692. /**
  147693. * Gets a boolean indicating if textures must be saved in the database
  147694. */
  147695. get enableTexturesOffline(): boolean;
  147696. /**
  147697. * Creates a new Database
  147698. * @param urlToScene defines the url to load the scene
  147699. * @param callbackManifestChecked defines the callback to use when manifest is checked
  147700. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  147701. */
  147702. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  147703. private static _ParseURL;
  147704. private static _ReturnFullUrlLocation;
  147705. private _checkManifestFile;
  147706. /**
  147707. * Open the database and make it available
  147708. * @param successCallback defines the callback to call on success
  147709. * @param errorCallback defines the callback to call on error
  147710. */
  147711. open(successCallback: () => void, errorCallback: () => void): void;
  147712. /**
  147713. * Loads an image from the database
  147714. * @param url defines the url to load from
  147715. * @param image defines the target DOM image
  147716. */
  147717. loadImage(url: string, image: HTMLImageElement): void;
  147718. private _loadImageFromDBAsync;
  147719. private _saveImageIntoDBAsync;
  147720. private _checkVersionFromDB;
  147721. private _loadVersionFromDBAsync;
  147722. private _saveVersionIntoDBAsync;
  147723. /**
  147724. * Loads a file from database
  147725. * @param url defines the URL to load from
  147726. * @param sceneLoaded defines a callback to call on success
  147727. * @param progressCallBack defines a callback to call when progress changed
  147728. * @param errorCallback defines a callback to call on error
  147729. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  147730. */
  147731. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  147732. private _loadFileAsync;
  147733. private _saveFileAsync;
  147734. /**
  147735. * Validates if xhr data is correct
  147736. * @param xhr defines the request to validate
  147737. * @param dataType defines the expected data type
  147738. * @returns true if data is correct
  147739. */
  147740. private static _ValidateXHRData;
  147741. }
  147742. }
  147743. declare module BABYLON {
  147744. /** @hidden */
  147745. export var gpuUpdateParticlesPixelShader: {
  147746. name: string;
  147747. shader: string;
  147748. };
  147749. }
  147750. declare module BABYLON {
  147751. /** @hidden */
  147752. export var gpuUpdateParticlesVertexShader: {
  147753. name: string;
  147754. shader: string;
  147755. };
  147756. }
  147757. declare module BABYLON {
  147758. /** @hidden */
  147759. export var clipPlaneFragmentDeclaration2: {
  147760. name: string;
  147761. shader: string;
  147762. };
  147763. }
  147764. declare module BABYLON {
  147765. /** @hidden */
  147766. export var gpuRenderParticlesPixelShader: {
  147767. name: string;
  147768. shader: string;
  147769. };
  147770. }
  147771. declare module BABYLON {
  147772. /** @hidden */
  147773. export var clipPlaneVertexDeclaration2: {
  147774. name: string;
  147775. shader: string;
  147776. };
  147777. }
  147778. declare module BABYLON {
  147779. /** @hidden */
  147780. export var gpuRenderParticlesVertexShader: {
  147781. name: string;
  147782. shader: string;
  147783. };
  147784. }
  147785. declare module BABYLON {
  147786. /**
  147787. * This represents a GPU particle system in Babylon
  147788. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  147789. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  147790. */
  147791. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  147792. /**
  147793. * The layer mask we are rendering the particles through.
  147794. */
  147795. layerMask: number;
  147796. private _capacity;
  147797. private _activeCount;
  147798. private _currentActiveCount;
  147799. private _accumulatedCount;
  147800. private _renderEffect;
  147801. private _updateEffect;
  147802. private _buffer0;
  147803. private _buffer1;
  147804. private _spriteBuffer;
  147805. private _updateVAO;
  147806. private _renderVAO;
  147807. private _targetIndex;
  147808. private _sourceBuffer;
  147809. private _targetBuffer;
  147810. private _currentRenderId;
  147811. private _started;
  147812. private _stopped;
  147813. private _timeDelta;
  147814. private _randomTexture;
  147815. private _randomTexture2;
  147816. private _attributesStrideSize;
  147817. private _updateEffectOptions;
  147818. private _randomTextureSize;
  147819. private _actualFrame;
  147820. private _customEffect;
  147821. private readonly _rawTextureWidth;
  147822. /**
  147823. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  147824. */
  147825. static get IsSupported(): boolean;
  147826. /**
  147827. * An event triggered when the system is disposed.
  147828. */
  147829. onDisposeObservable: Observable<IParticleSystem>;
  147830. /**
  147831. * Gets the maximum number of particles active at the same time.
  147832. * @returns The max number of active particles.
  147833. */
  147834. getCapacity(): number;
  147835. /**
  147836. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  147837. * to override the particles.
  147838. */
  147839. forceDepthWrite: boolean;
  147840. /**
  147841. * Gets or set the number of active particles
  147842. */
  147843. get activeParticleCount(): number;
  147844. set activeParticleCount(value: number);
  147845. private _preWarmDone;
  147846. /**
  147847. * Specifies if the particles are updated in emitter local space or world space.
  147848. */
  147849. isLocal: boolean;
  147850. /** Gets or sets a matrix to use to compute projection */
  147851. defaultProjectionMatrix: Matrix;
  147852. /**
  147853. * Is this system ready to be used/rendered
  147854. * @return true if the system is ready
  147855. */
  147856. isReady(): boolean;
  147857. /**
  147858. * Gets if the system has been started. (Note: this will still be true after stop is called)
  147859. * @returns True if it has been started, otherwise false.
  147860. */
  147861. isStarted(): boolean;
  147862. /**
  147863. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  147864. * @returns True if it has been stopped, otherwise false.
  147865. */
  147866. isStopped(): boolean;
  147867. /**
  147868. * Gets a boolean indicating that the system is stopping
  147869. * @returns true if the system is currently stopping
  147870. */
  147871. isStopping(): boolean;
  147872. /**
  147873. * Gets the number of particles active at the same time.
  147874. * @returns The number of active particles.
  147875. */
  147876. getActiveCount(): number;
  147877. /**
  147878. * Starts the particle system and begins to emit
  147879. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  147880. */
  147881. start(delay?: number): void;
  147882. /**
  147883. * Stops the particle system.
  147884. */
  147885. stop(): void;
  147886. /**
  147887. * Remove all active particles
  147888. */
  147889. reset(): void;
  147890. /**
  147891. * Returns the string "GPUParticleSystem"
  147892. * @returns a string containing the class name
  147893. */
  147894. getClassName(): string;
  147895. /**
  147896. * Gets the custom effect used to render the particles
  147897. * @param blendMode Blend mode for which the effect should be retrieved
  147898. * @returns The effect
  147899. */
  147900. getCustomEffect(blendMode?: number): Nullable<Effect>;
  147901. /**
  147902. * Sets the custom effect used to render the particles
  147903. * @param effect The effect to set
  147904. * @param blendMode Blend mode for which the effect should be set
  147905. */
  147906. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  147907. /** @hidden */
  147908. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  147909. /**
  147910. * Observable that will be called just before the particles are drawn
  147911. */
  147912. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  147913. /**
  147914. * Gets the name of the particle vertex shader
  147915. */
  147916. get vertexShaderName(): string;
  147917. private _colorGradientsTexture;
  147918. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  147919. /**
  147920. * Adds a new color gradient
  147921. * @param gradient defines the gradient to use (between 0 and 1)
  147922. * @param color1 defines the color to affect to the specified gradient
  147923. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  147924. * @returns the current particle system
  147925. */
  147926. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  147927. private _refreshColorGradient;
  147928. /** Force the system to rebuild all gradients that need to be resync */
  147929. forceRefreshGradients(): void;
  147930. /**
  147931. * Remove a specific color gradient
  147932. * @param gradient defines the gradient to remove
  147933. * @returns the current particle system
  147934. */
  147935. removeColorGradient(gradient: number): GPUParticleSystem;
  147936. private _angularSpeedGradientsTexture;
  147937. private _sizeGradientsTexture;
  147938. private _velocityGradientsTexture;
  147939. private _limitVelocityGradientsTexture;
  147940. private _dragGradientsTexture;
  147941. private _addFactorGradient;
  147942. /**
  147943. * Adds a new size gradient
  147944. * @param gradient defines the gradient to use (between 0 and 1)
  147945. * @param factor defines the size factor to affect to the specified gradient
  147946. * @returns the current particle system
  147947. */
  147948. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  147949. /**
  147950. * Remove a specific size gradient
  147951. * @param gradient defines the gradient to remove
  147952. * @returns the current particle system
  147953. */
  147954. removeSizeGradient(gradient: number): GPUParticleSystem;
  147955. private _refreshFactorGradient;
  147956. /**
  147957. * Adds a new angular speed gradient
  147958. * @param gradient defines the gradient to use (between 0 and 1)
  147959. * @param factor defines the angular speed to affect to the specified gradient
  147960. * @returns the current particle system
  147961. */
  147962. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  147963. /**
  147964. * Remove a specific angular speed gradient
  147965. * @param gradient defines the gradient to remove
  147966. * @returns the current particle system
  147967. */
  147968. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  147969. /**
  147970. * Adds a new velocity gradient
  147971. * @param gradient defines the gradient to use (between 0 and 1)
  147972. * @param factor defines the velocity to affect to the specified gradient
  147973. * @returns the current particle system
  147974. */
  147975. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147976. /**
  147977. * Remove a specific velocity gradient
  147978. * @param gradient defines the gradient to remove
  147979. * @returns the current particle system
  147980. */
  147981. removeVelocityGradient(gradient: number): GPUParticleSystem;
  147982. /**
  147983. * Adds a new limit velocity gradient
  147984. * @param gradient defines the gradient to use (between 0 and 1)
  147985. * @param factor defines the limit velocity value to affect to the specified gradient
  147986. * @returns the current particle system
  147987. */
  147988. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147989. /**
  147990. * Remove a specific limit velocity gradient
  147991. * @param gradient defines the gradient to remove
  147992. * @returns the current particle system
  147993. */
  147994. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  147995. /**
  147996. * Adds a new drag gradient
  147997. * @param gradient defines the gradient to use (between 0 and 1)
  147998. * @param factor defines the drag value to affect to the specified gradient
  147999. * @returns the current particle system
  148000. */
  148001. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  148002. /**
  148003. * Remove a specific drag gradient
  148004. * @param gradient defines the gradient to remove
  148005. * @returns the current particle system
  148006. */
  148007. removeDragGradient(gradient: number): GPUParticleSystem;
  148008. /**
  148009. * Not supported by GPUParticleSystem
  148010. * @param gradient defines the gradient to use (between 0 and 1)
  148011. * @param factor defines the emit rate value to affect to the specified gradient
  148012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148013. * @returns the current particle system
  148014. */
  148015. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148016. /**
  148017. * Not supported by GPUParticleSystem
  148018. * @param gradient defines the gradient to remove
  148019. * @returns the current particle system
  148020. */
  148021. removeEmitRateGradient(gradient: number): IParticleSystem;
  148022. /**
  148023. * Not supported by GPUParticleSystem
  148024. * @param gradient defines the gradient to use (between 0 and 1)
  148025. * @param factor defines the start size value to affect to the specified gradient
  148026. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148027. * @returns the current particle system
  148028. */
  148029. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148030. /**
  148031. * Not supported by GPUParticleSystem
  148032. * @param gradient defines the gradient to remove
  148033. * @returns the current particle system
  148034. */
  148035. removeStartSizeGradient(gradient: number): IParticleSystem;
  148036. /**
  148037. * Not supported by GPUParticleSystem
  148038. * @param gradient defines the gradient to use (between 0 and 1)
  148039. * @param min defines the color remap minimal range
  148040. * @param max defines the color remap maximal range
  148041. * @returns the current particle system
  148042. */
  148043. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148044. /**
  148045. * Not supported by GPUParticleSystem
  148046. * @param gradient defines the gradient to remove
  148047. * @returns the current particle system
  148048. */
  148049. removeColorRemapGradient(): IParticleSystem;
  148050. /**
  148051. * Not supported by GPUParticleSystem
  148052. * @param gradient defines the gradient to use (between 0 and 1)
  148053. * @param min defines the alpha remap minimal range
  148054. * @param max defines the alpha remap maximal range
  148055. * @returns the current particle system
  148056. */
  148057. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148058. /**
  148059. * Not supported by GPUParticleSystem
  148060. * @param gradient defines the gradient to remove
  148061. * @returns the current particle system
  148062. */
  148063. removeAlphaRemapGradient(): IParticleSystem;
  148064. /**
  148065. * Not supported by GPUParticleSystem
  148066. * @param gradient defines the gradient to use (between 0 and 1)
  148067. * @param color defines the color to affect to the specified gradient
  148068. * @returns the current particle system
  148069. */
  148070. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  148071. /**
  148072. * Not supported by GPUParticleSystem
  148073. * @param gradient defines the gradient to remove
  148074. * @returns the current particle system
  148075. */
  148076. removeRampGradient(): IParticleSystem;
  148077. /**
  148078. * Not supported by GPUParticleSystem
  148079. * @returns the list of ramp gradients
  148080. */
  148081. getRampGradients(): Nullable<Array<Color3Gradient>>;
  148082. /**
  148083. * Not supported by GPUParticleSystem
  148084. * Gets or sets a boolean indicating that ramp gradients must be used
  148085. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  148086. */
  148087. get useRampGradients(): boolean;
  148088. set useRampGradients(value: boolean);
  148089. /**
  148090. * Not supported by GPUParticleSystem
  148091. * @param gradient defines the gradient to use (between 0 and 1)
  148092. * @param factor defines the life time factor to affect to the specified gradient
  148093. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148094. * @returns the current particle system
  148095. */
  148096. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148097. /**
  148098. * Not supported by GPUParticleSystem
  148099. * @param gradient defines the gradient to remove
  148100. * @returns the current particle system
  148101. */
  148102. removeLifeTimeGradient(gradient: number): IParticleSystem;
  148103. /**
  148104. * Instantiates a GPU particle system.
  148105. * 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.
  148106. * @param name The name of the particle system
  148107. * @param options The options used to create the system
  148108. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  148109. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  148110. * @param customEffect a custom effect used to change the way particles are rendered by default
  148111. */
  148112. constructor(name: string, options: Partial<{
  148113. capacity: number;
  148114. randomTextureSize: number;
  148115. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  148116. protected _reset(): void;
  148117. private _createUpdateVAO;
  148118. private _createRenderVAO;
  148119. private _initialize;
  148120. /** @hidden */
  148121. _recreateUpdateEffect(): void;
  148122. private _getEffect;
  148123. /**
  148124. * Fill the defines array according to the current settings of the particle system
  148125. * @param defines Array to be updated
  148126. * @param blendMode blend mode to take into account when updating the array
  148127. */
  148128. fillDefines(defines: Array<string>, blendMode?: number): void;
  148129. /**
  148130. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  148131. * @param uniforms Uniforms array to fill
  148132. * @param attributes Attributes array to fill
  148133. * @param samplers Samplers array to fill
  148134. */
  148135. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  148136. /** @hidden */
  148137. _recreateRenderEffect(): Effect;
  148138. /**
  148139. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  148140. * @param preWarm defines if we are in the pre-warmimg phase
  148141. */
  148142. animate(preWarm?: boolean): void;
  148143. private _createFactorGradientTexture;
  148144. private _createSizeGradientTexture;
  148145. private _createAngularSpeedGradientTexture;
  148146. private _createVelocityGradientTexture;
  148147. private _createLimitVelocityGradientTexture;
  148148. private _createDragGradientTexture;
  148149. private _createColorGradientTexture;
  148150. /**
  148151. * Renders the particle system in its current state
  148152. * @param preWarm defines if the system should only update the particles but not render them
  148153. * @returns the current number of particles
  148154. */
  148155. render(preWarm?: boolean): number;
  148156. /**
  148157. * Rebuilds the particle system
  148158. */
  148159. rebuild(): void;
  148160. private _releaseBuffers;
  148161. private _releaseVAOs;
  148162. /**
  148163. * Disposes the particle system and free the associated resources
  148164. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  148165. */
  148166. dispose(disposeTexture?: boolean): void;
  148167. /**
  148168. * Clones the particle system.
  148169. * @param name The name of the cloned object
  148170. * @param newEmitter The new emitter to use
  148171. * @returns the cloned particle system
  148172. */
  148173. clone(name: string, newEmitter: any): GPUParticleSystem;
  148174. /**
  148175. * Serializes the particle system to a JSON object
  148176. * @param serializeTexture defines if the texture must be serialized as well
  148177. * @returns the JSON object
  148178. */
  148179. serialize(serializeTexture?: boolean): any;
  148180. /**
  148181. * Parses a JSON object to create a GPU particle system.
  148182. * @param parsedParticleSystem The JSON object to parse
  148183. * @param sceneOrEngine The scene or the engine to create the particle system in
  148184. * @param rootUrl The root url to use to load external dependencies like texture
  148185. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  148186. * @returns the parsed GPU particle system
  148187. */
  148188. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  148189. }
  148190. }
  148191. declare module BABYLON {
  148192. /**
  148193. * Represents a set of particle systems working together to create a specific effect
  148194. */
  148195. export class ParticleSystemSet implements IDisposable {
  148196. /**
  148197. * Gets or sets base Assets URL
  148198. */
  148199. static BaseAssetsUrl: string;
  148200. private _emitterCreationOptions;
  148201. private _emitterNode;
  148202. /**
  148203. * Gets the particle system list
  148204. */
  148205. systems: IParticleSystem[];
  148206. /**
  148207. * Gets the emitter node used with this set
  148208. */
  148209. get emitterNode(): Nullable<TransformNode>;
  148210. /**
  148211. * Creates a new emitter mesh as a sphere
  148212. * @param options defines the options used to create the sphere
  148213. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  148214. * @param scene defines the hosting scene
  148215. */
  148216. setEmitterAsSphere(options: {
  148217. diameter: number;
  148218. segments: number;
  148219. color: Color3;
  148220. }, renderingGroupId: number, scene: Scene): void;
  148221. /**
  148222. * Starts all particle systems of the set
  148223. * @param emitter defines an optional mesh to use as emitter for the particle systems
  148224. */
  148225. start(emitter?: AbstractMesh): void;
  148226. /**
  148227. * Release all associated resources
  148228. */
  148229. dispose(): void;
  148230. /**
  148231. * Serialize the set into a JSON compatible object
  148232. * @param serializeTexture defines if the texture must be serialized as well
  148233. * @returns a JSON compatible representation of the set
  148234. */
  148235. serialize(serializeTexture?: boolean): any;
  148236. /**
  148237. * Parse a new ParticleSystemSet from a serialized source
  148238. * @param data defines a JSON compatible representation of the set
  148239. * @param scene defines the hosting scene
  148240. * @param gpu defines if we want GPU particles or CPU particles
  148241. * @returns a new ParticleSystemSet
  148242. */
  148243. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  148244. }
  148245. }
  148246. declare module BABYLON {
  148247. /**
  148248. * This class is made for on one-liner static method to help creating particle system set.
  148249. */
  148250. export class ParticleHelper {
  148251. /**
  148252. * Gets or sets base Assets URL
  148253. */
  148254. static BaseAssetsUrl: string;
  148255. /** Define the Url to load snippets */
  148256. static SnippetUrl: string;
  148257. /**
  148258. * Create a default particle system that you can tweak
  148259. * @param emitter defines the emitter to use
  148260. * @param capacity defines the system capacity (default is 500 particles)
  148261. * @param scene defines the hosting scene
  148262. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  148263. * @returns the new Particle system
  148264. */
  148265. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  148266. /**
  148267. * This is the main static method (one-liner) of this helper to create different particle systems
  148268. * @param type This string represents the type to the particle system to create
  148269. * @param scene The scene where the particle system should live
  148270. * @param gpu If the system will use gpu
  148271. * @returns the ParticleSystemSet created
  148272. */
  148273. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  148274. /**
  148275. * Static function used to export a particle system to a ParticleSystemSet variable.
  148276. * Please note that the emitter shape is not exported
  148277. * @param systems defines the particle systems to export
  148278. * @returns the created particle system set
  148279. */
  148280. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  148281. /**
  148282. * Creates a particle system from a snippet saved in a remote file
  148283. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  148284. * @param url defines the url to load from
  148285. * @param scene defines the hosting scene
  148286. * @param gpu If the system will use gpu
  148287. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148288. * @returns a promise that will resolve to the new particle system
  148289. */
  148290. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148291. /**
  148292. * Creates a particle system from a snippet saved by the particle system editor
  148293. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  148294. * @param scene defines the hosting scene
  148295. * @param gpu If the system will use gpu
  148296. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148297. * @returns a promise that will resolve to the new particle system
  148298. */
  148299. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148300. }
  148301. }
  148302. declare module BABYLON {
  148303. interface Engine {
  148304. /**
  148305. * Create an effect to use with particle systems.
  148306. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  148307. * the particle system for which you want to create a custom effect in the last parameter
  148308. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  148309. * @param uniformsNames defines a list of attribute names
  148310. * @param samplers defines an array of string used to represent textures
  148311. * @param defines defines the string containing the defines to use to compile the shaders
  148312. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  148313. * @param onCompiled defines a function to call when the effect creation is successful
  148314. * @param onError defines a function to call when the effect creation has failed
  148315. * @param particleSystem the particle system you want to create the effect for
  148316. * @returns the new Effect
  148317. */
  148318. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  148319. }
  148320. interface Mesh {
  148321. /**
  148322. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  148323. * @returns an array of IParticleSystem
  148324. */
  148325. getEmittedParticleSystems(): IParticleSystem[];
  148326. /**
  148327. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  148328. * @returns an array of IParticleSystem
  148329. */
  148330. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  148331. }
  148332. }
  148333. declare module BABYLON {
  148334. /** Defines the 4 color options */
  148335. export enum PointColor {
  148336. /** color value */
  148337. Color = 2,
  148338. /** uv value */
  148339. UV = 1,
  148340. /** random value */
  148341. Random = 0,
  148342. /** stated value */
  148343. Stated = 3
  148344. }
  148345. /**
  148346. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  148347. * 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.
  148348. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  148349. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  148350. *
  148351. * Full documentation here : TO BE ENTERED
  148352. */
  148353. export class PointsCloudSystem implements IDisposable {
  148354. /**
  148355. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  148356. * Example : var p = SPS.particles[i];
  148357. */
  148358. particles: CloudPoint[];
  148359. /**
  148360. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  148361. */
  148362. nbParticles: number;
  148363. /**
  148364. * This a counter for your own usage. It's not set by any SPS functions.
  148365. */
  148366. counter: number;
  148367. /**
  148368. * The PCS name. This name is also given to the underlying mesh.
  148369. */
  148370. name: string;
  148371. /**
  148372. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  148373. */
  148374. mesh: Mesh;
  148375. /**
  148376. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  148377. * Please read :
  148378. */
  148379. vars: any;
  148380. /**
  148381. * @hidden
  148382. */
  148383. _size: number;
  148384. private _scene;
  148385. private _promises;
  148386. private _positions;
  148387. private _indices;
  148388. private _normals;
  148389. private _colors;
  148390. private _uvs;
  148391. private _indices32;
  148392. private _positions32;
  148393. private _colors32;
  148394. private _uvs32;
  148395. private _updatable;
  148396. private _isVisibilityBoxLocked;
  148397. private _alwaysVisible;
  148398. private _groups;
  148399. private _groupCounter;
  148400. private _computeParticleColor;
  148401. private _computeParticleTexture;
  148402. private _computeParticleRotation;
  148403. private _computeBoundingBox;
  148404. private _isReady;
  148405. /**
  148406. * Creates a PCS (Points Cloud System) object
  148407. * @param name (String) is the PCS name, this will be the underlying mesh name
  148408. * @param pointSize (number) is the size for each point
  148409. * @param scene (Scene) is the scene in which the PCS is added
  148410. * @param options defines the options of the PCS e.g.
  148411. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  148412. */
  148413. constructor(name: string, pointSize: number, scene: Scene, options?: {
  148414. updatable?: boolean;
  148415. });
  148416. /**
  148417. * Builds the PCS underlying mesh. Returns a standard Mesh.
  148418. * If no points were added to the PCS, the returned mesh is just a single point.
  148419. * @returns a promise for the created mesh
  148420. */
  148421. buildMeshAsync(): Promise<Mesh>;
  148422. /**
  148423. * @hidden
  148424. */
  148425. private _buildMesh;
  148426. private _addParticle;
  148427. private _randomUnitVector;
  148428. private _getColorIndicesForCoord;
  148429. private _setPointsColorOrUV;
  148430. private _colorFromTexture;
  148431. private _calculateDensity;
  148432. /**
  148433. * Adds points to the PCS in random positions within a unit sphere
  148434. * @param nb (positive integer) the number of particles to be created from this model
  148435. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  148436. * @returns the number of groups in the system
  148437. */
  148438. addPoints(nb: number, pointFunction?: any): number;
  148439. /**
  148440. * Adds points to the PCS from the surface of the model shape
  148441. * @param mesh is any Mesh object that will be used as a surface model for the points
  148442. * @param nb (positive integer) the number of particles to be created from this model
  148443. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148444. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148445. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148446. * @returns the number of groups in the system
  148447. */
  148448. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148449. /**
  148450. * Adds points to the PCS inside the model shape
  148451. * @param mesh is any Mesh object that will be used as a surface model for the points
  148452. * @param nb (positive integer) the number of particles to be created from this model
  148453. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148454. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148455. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148456. * @returns the number of groups in the system
  148457. */
  148458. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148459. /**
  148460. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  148461. * This method calls `updateParticle()` for each particle of the SPS.
  148462. * For an animated SPS, it is usually called within the render loop.
  148463. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  148464. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  148465. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  148466. * @returns the PCS.
  148467. */
  148468. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  148469. /**
  148470. * Disposes the PCS.
  148471. */
  148472. dispose(): void;
  148473. /**
  148474. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  148475. * doc :
  148476. * @returns the PCS.
  148477. */
  148478. refreshVisibleSize(): PointsCloudSystem;
  148479. /**
  148480. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  148481. * @param size the size (float) of the visibility box
  148482. * note : this doesn't lock the PCS mesh bounding box.
  148483. * doc :
  148484. */
  148485. setVisibilityBox(size: number): void;
  148486. /**
  148487. * Gets whether the PCS is always visible or not
  148488. * doc :
  148489. */
  148490. get isAlwaysVisible(): boolean;
  148491. /**
  148492. * Sets the PCS as always visible or not
  148493. * doc :
  148494. */
  148495. set isAlwaysVisible(val: boolean);
  148496. /**
  148497. * Tells to `setParticles()` to compute the particle rotations or not
  148498. * Default value : false. The PCS is faster when it's set to false
  148499. * Note : particle rotations are only applied to parent particles
  148500. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  148501. */
  148502. set computeParticleRotation(val: boolean);
  148503. /**
  148504. * Tells to `setParticles()` to compute the particle colors or not.
  148505. * Default value : true. The PCS is faster when it's set to false.
  148506. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148507. */
  148508. set computeParticleColor(val: boolean);
  148509. set computeParticleTexture(val: boolean);
  148510. /**
  148511. * Gets if `setParticles()` computes the particle colors or not.
  148512. * Default value : false. The PCS is faster when it's set to false.
  148513. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148514. */
  148515. get computeParticleColor(): boolean;
  148516. /**
  148517. * Gets if `setParticles()` computes the particle textures or not.
  148518. * Default value : false. The PCS is faster when it's set to false.
  148519. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  148520. */
  148521. get computeParticleTexture(): boolean;
  148522. /**
  148523. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  148524. */
  148525. set computeBoundingBox(val: boolean);
  148526. /**
  148527. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  148528. */
  148529. get computeBoundingBox(): boolean;
  148530. /**
  148531. * This function does nothing. It may be overwritten to set all the particle first values.
  148532. * The PCS doesn't call this function, you may have to call it by your own.
  148533. * doc :
  148534. */
  148535. initParticles(): void;
  148536. /**
  148537. * This function does nothing. It may be overwritten to recycle a particle
  148538. * The PCS doesn't call this function, you can to call it
  148539. * doc :
  148540. * @param particle The particle to recycle
  148541. * @returns the recycled particle
  148542. */
  148543. recycleParticle(particle: CloudPoint): CloudPoint;
  148544. /**
  148545. * Updates a particle : this function should be overwritten by the user.
  148546. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148547. * doc :
  148548. * @example : just set a particle position or velocity and recycle conditions
  148549. * @param particle The particle to update
  148550. * @returns the updated particle
  148551. */
  148552. updateParticle(particle: CloudPoint): CloudPoint;
  148553. /**
  148554. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  148555. * This does nothing and may be overwritten by the user.
  148556. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148557. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148558. * @param update the boolean update value actually passed to setParticles()
  148559. */
  148560. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148561. /**
  148562. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  148563. * This will be passed three parameters.
  148564. * This does nothing and may be overwritten by the user.
  148565. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148566. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148567. * @param update the boolean update value actually passed to setParticles()
  148568. */
  148569. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148570. }
  148571. }
  148572. declare module BABYLON {
  148573. /**
  148574. * Represents one particle of a points cloud system.
  148575. */
  148576. export class CloudPoint {
  148577. /**
  148578. * particle global index
  148579. */
  148580. idx: number;
  148581. /**
  148582. * The color of the particle
  148583. */
  148584. color: Nullable<Color4>;
  148585. /**
  148586. * The world space position of the particle.
  148587. */
  148588. position: Vector3;
  148589. /**
  148590. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  148591. */
  148592. rotation: Vector3;
  148593. /**
  148594. * The world space rotation quaternion of the particle.
  148595. */
  148596. rotationQuaternion: Nullable<Quaternion>;
  148597. /**
  148598. * The uv of the particle.
  148599. */
  148600. uv: Nullable<Vector2>;
  148601. /**
  148602. * The current speed of the particle.
  148603. */
  148604. velocity: Vector3;
  148605. /**
  148606. * The pivot point in the particle local space.
  148607. */
  148608. pivot: Vector3;
  148609. /**
  148610. * Must the particle be translated from its pivot point in its local space ?
  148611. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  148612. * Default : false
  148613. */
  148614. translateFromPivot: boolean;
  148615. /**
  148616. * Index of this particle in the global "positions" array (Internal use)
  148617. * @hidden
  148618. */
  148619. _pos: number;
  148620. /**
  148621. * @hidden Index of this particle in the global "indices" array (Internal use)
  148622. */
  148623. _ind: number;
  148624. /**
  148625. * Group this particle belongs to
  148626. */
  148627. _group: PointsGroup;
  148628. /**
  148629. * Group id of this particle
  148630. */
  148631. groupId: number;
  148632. /**
  148633. * Index of the particle in its group id (Internal use)
  148634. */
  148635. idxInGroup: number;
  148636. /**
  148637. * @hidden Particle BoundingInfo object (Internal use)
  148638. */
  148639. _boundingInfo: BoundingInfo;
  148640. /**
  148641. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  148642. */
  148643. _pcs: PointsCloudSystem;
  148644. /**
  148645. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  148646. */
  148647. _stillInvisible: boolean;
  148648. /**
  148649. * @hidden Last computed particle rotation matrix
  148650. */
  148651. _rotationMatrix: number[];
  148652. /**
  148653. * Parent particle Id, if any.
  148654. * Default null.
  148655. */
  148656. parentId: Nullable<number>;
  148657. /**
  148658. * @hidden Internal global position in the PCS.
  148659. */
  148660. _globalPosition: Vector3;
  148661. /**
  148662. * Creates a Point Cloud object.
  148663. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  148664. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  148665. * @param group (PointsGroup) is the group the particle belongs to
  148666. * @param groupId (integer) is the group identifier in the PCS.
  148667. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  148668. * @param pcs defines the PCS it is associated to
  148669. */
  148670. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  148671. /**
  148672. * get point size
  148673. */
  148674. get size(): Vector3;
  148675. /**
  148676. * Set point size
  148677. */
  148678. set size(scale: Vector3);
  148679. /**
  148680. * Legacy support, changed quaternion to rotationQuaternion
  148681. */
  148682. get quaternion(): Nullable<Quaternion>;
  148683. /**
  148684. * Legacy support, changed quaternion to rotationQuaternion
  148685. */
  148686. set quaternion(q: Nullable<Quaternion>);
  148687. /**
  148688. * Returns a boolean. True if the particle intersects a mesh, else false
  148689. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  148690. * @param target is the object (point or mesh) what the intersection is computed against
  148691. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  148692. * @returns true if it intersects
  148693. */
  148694. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  148695. /**
  148696. * get the rotation matrix of the particle
  148697. * @hidden
  148698. */
  148699. getRotationMatrix(m: Matrix): void;
  148700. }
  148701. /**
  148702. * Represents a group of points in a points cloud system
  148703. * * PCS internal tool, don't use it manually.
  148704. */
  148705. export class PointsGroup {
  148706. /**
  148707. * The group id
  148708. * @hidden
  148709. */
  148710. groupID: number;
  148711. /**
  148712. * image data for group (internal use)
  148713. * @hidden
  148714. */
  148715. _groupImageData: Nullable<ArrayBufferView>;
  148716. /**
  148717. * Image Width (internal use)
  148718. * @hidden
  148719. */
  148720. _groupImgWidth: number;
  148721. /**
  148722. * Image Height (internal use)
  148723. * @hidden
  148724. */
  148725. _groupImgHeight: number;
  148726. /**
  148727. * Custom position function (internal use)
  148728. * @hidden
  148729. */
  148730. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  148731. /**
  148732. * density per facet for surface points
  148733. * @hidden
  148734. */
  148735. _groupDensity: number[];
  148736. /**
  148737. * Only when points are colored by texture carries pointer to texture list array
  148738. * @hidden
  148739. */
  148740. _textureNb: number;
  148741. /**
  148742. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  148743. * PCS internal tool, don't use it manually.
  148744. * @hidden
  148745. */
  148746. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  148747. }
  148748. }
  148749. declare module BABYLON {
  148750. interface Scene {
  148751. /** @hidden (Backing field) */
  148752. _physicsEngine: Nullable<IPhysicsEngine>;
  148753. /** @hidden */
  148754. _physicsTimeAccumulator: number;
  148755. /**
  148756. * Gets the current physics engine
  148757. * @returns a IPhysicsEngine or null if none attached
  148758. */
  148759. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  148760. /**
  148761. * Enables physics to the current scene
  148762. * @param gravity defines the scene's gravity for the physics engine
  148763. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  148764. * @return a boolean indicating if the physics engine was initialized
  148765. */
  148766. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  148767. /**
  148768. * Disables and disposes the physics engine associated with the scene
  148769. */
  148770. disablePhysicsEngine(): void;
  148771. /**
  148772. * Gets a boolean indicating if there is an active physics engine
  148773. * @returns a boolean indicating if there is an active physics engine
  148774. */
  148775. isPhysicsEnabled(): boolean;
  148776. /**
  148777. * Deletes a physics compound impostor
  148778. * @param compound defines the compound to delete
  148779. */
  148780. deleteCompoundImpostor(compound: any): void;
  148781. /**
  148782. * An event triggered when physic simulation is about to be run
  148783. */
  148784. onBeforePhysicsObservable: Observable<Scene>;
  148785. /**
  148786. * An event triggered when physic simulation has been done
  148787. */
  148788. onAfterPhysicsObservable: Observable<Scene>;
  148789. }
  148790. interface AbstractMesh {
  148791. /** @hidden */
  148792. _physicsImpostor: Nullable<PhysicsImpostor>;
  148793. /**
  148794. * Gets or sets impostor used for physic simulation
  148795. * @see https://doc.babylonjs.com/features/physics_engine
  148796. */
  148797. physicsImpostor: Nullable<PhysicsImpostor>;
  148798. /**
  148799. * Gets the current physics impostor
  148800. * @see https://doc.babylonjs.com/features/physics_engine
  148801. * @returns a physics impostor or null
  148802. */
  148803. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  148804. /** Apply a physic impulse to the mesh
  148805. * @param force defines the force to apply
  148806. * @param contactPoint defines where to apply the force
  148807. * @returns the current mesh
  148808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  148809. */
  148810. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  148811. /**
  148812. * Creates a physic joint between two meshes
  148813. * @param otherMesh defines the other mesh to use
  148814. * @param pivot1 defines the pivot to use on this mesh
  148815. * @param pivot2 defines the pivot to use on the other mesh
  148816. * @param options defines additional options (can be plugin dependent)
  148817. * @returns the current mesh
  148818. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  148819. */
  148820. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  148821. /** @hidden */
  148822. _disposePhysicsObserver: Nullable<Observer<Node>>;
  148823. }
  148824. /**
  148825. * Defines the physics engine scene component responsible to manage a physics engine
  148826. */
  148827. export class PhysicsEngineSceneComponent implements ISceneComponent {
  148828. /**
  148829. * The component name helpful to identify the component in the list of scene components.
  148830. */
  148831. readonly name: string;
  148832. /**
  148833. * The scene the component belongs to.
  148834. */
  148835. scene: Scene;
  148836. /**
  148837. * Creates a new instance of the component for the given scene
  148838. * @param scene Defines the scene to register the component in
  148839. */
  148840. constructor(scene: Scene);
  148841. /**
  148842. * Registers the component in a given scene
  148843. */
  148844. register(): void;
  148845. /**
  148846. * Rebuilds the elements related to this component in case of
  148847. * context lost for instance.
  148848. */
  148849. rebuild(): void;
  148850. /**
  148851. * Disposes the component and the associated ressources
  148852. */
  148853. dispose(): void;
  148854. }
  148855. }
  148856. declare module BABYLON {
  148857. /**
  148858. * A helper for physics simulations
  148859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148860. */
  148861. export class PhysicsHelper {
  148862. private _scene;
  148863. private _physicsEngine;
  148864. /**
  148865. * Initializes the Physics helper
  148866. * @param scene Babylon.js scene
  148867. */
  148868. constructor(scene: Scene);
  148869. /**
  148870. * Applies a radial explosion impulse
  148871. * @param origin the origin of the explosion
  148872. * @param radiusOrEventOptions the radius or the options of radial explosion
  148873. * @param strength the explosion strength
  148874. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148875. * @returns A physics radial explosion event, or null
  148876. */
  148877. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148878. /**
  148879. * Applies a radial explosion force
  148880. * @param origin the origin of the explosion
  148881. * @param radiusOrEventOptions the radius or the options of radial explosion
  148882. * @param strength the explosion strength
  148883. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148884. * @returns A physics radial explosion event, or null
  148885. */
  148886. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148887. /**
  148888. * Creates a gravitational field
  148889. * @param origin the origin of the explosion
  148890. * @param radiusOrEventOptions the radius or the options of radial explosion
  148891. * @param strength the explosion strength
  148892. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148893. * @returns A physics gravitational field event, or null
  148894. */
  148895. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  148896. /**
  148897. * Creates a physics updraft event
  148898. * @param origin the origin of the updraft
  148899. * @param radiusOrEventOptions the radius or the options of the updraft
  148900. * @param strength the strength of the updraft
  148901. * @param height the height of the updraft
  148902. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  148903. * @returns A physics updraft event, or null
  148904. */
  148905. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  148906. /**
  148907. * Creates a physics vortex event
  148908. * @param origin the of the vortex
  148909. * @param radiusOrEventOptions the radius or the options of the vortex
  148910. * @param strength the strength of the vortex
  148911. * @param height the height of the vortex
  148912. * @returns a Physics vortex event, or null
  148913. * A physics vortex event or null
  148914. */
  148915. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  148916. }
  148917. /**
  148918. * Represents a physics radial explosion event
  148919. */
  148920. class PhysicsRadialExplosionEvent {
  148921. private _scene;
  148922. private _options;
  148923. private _sphere;
  148924. private _dataFetched;
  148925. /**
  148926. * Initializes a radial explosioin event
  148927. * @param _scene BabylonJS scene
  148928. * @param _options The options for the vortex event
  148929. */
  148930. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  148931. /**
  148932. * Returns the data related to the radial explosion event (sphere).
  148933. * @returns The radial explosion event data
  148934. */
  148935. getData(): PhysicsRadialExplosionEventData;
  148936. /**
  148937. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  148938. * @param impostor A physics imposter
  148939. * @param origin the origin of the explosion
  148940. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  148941. */
  148942. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  148943. /**
  148944. * Triggers affecterd impostors callbacks
  148945. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  148946. */
  148947. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  148948. /**
  148949. * Disposes the sphere.
  148950. * @param force Specifies if the sphere should be disposed by force
  148951. */
  148952. dispose(force?: boolean): void;
  148953. /*** Helpers ***/
  148954. private _prepareSphere;
  148955. private _intersectsWithSphere;
  148956. }
  148957. /**
  148958. * Represents a gravitational field event
  148959. */
  148960. class PhysicsGravitationalFieldEvent {
  148961. private _physicsHelper;
  148962. private _scene;
  148963. private _origin;
  148964. private _options;
  148965. private _tickCallback;
  148966. private _sphere;
  148967. private _dataFetched;
  148968. /**
  148969. * Initializes the physics gravitational field event
  148970. * @param _physicsHelper A physics helper
  148971. * @param _scene BabylonJS scene
  148972. * @param _origin The origin position of the gravitational field event
  148973. * @param _options The options for the vortex event
  148974. */
  148975. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  148976. /**
  148977. * Returns the data related to the gravitational field event (sphere).
  148978. * @returns A gravitational field event
  148979. */
  148980. getData(): PhysicsGravitationalFieldEventData;
  148981. /**
  148982. * Enables the gravitational field.
  148983. */
  148984. enable(): void;
  148985. /**
  148986. * Disables the gravitational field.
  148987. */
  148988. disable(): void;
  148989. /**
  148990. * Disposes the sphere.
  148991. * @param force The force to dispose from the gravitational field event
  148992. */
  148993. dispose(force?: boolean): void;
  148994. private _tick;
  148995. }
  148996. /**
  148997. * Represents a physics updraft event
  148998. */
  148999. class PhysicsUpdraftEvent {
  149000. private _scene;
  149001. private _origin;
  149002. private _options;
  149003. private _physicsEngine;
  149004. private _originTop;
  149005. private _originDirection;
  149006. private _tickCallback;
  149007. private _cylinder;
  149008. private _cylinderPosition;
  149009. private _dataFetched;
  149010. /**
  149011. * Initializes the physics updraft event
  149012. * @param _scene BabylonJS scene
  149013. * @param _origin The origin position of the updraft
  149014. * @param _options The options for the updraft event
  149015. */
  149016. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  149017. /**
  149018. * Returns the data related to the updraft event (cylinder).
  149019. * @returns A physics updraft event
  149020. */
  149021. getData(): PhysicsUpdraftEventData;
  149022. /**
  149023. * Enables the updraft.
  149024. */
  149025. enable(): void;
  149026. /**
  149027. * Disables the updraft.
  149028. */
  149029. disable(): void;
  149030. /**
  149031. * Disposes the cylinder.
  149032. * @param force Specifies if the updraft should be disposed by force
  149033. */
  149034. dispose(force?: boolean): void;
  149035. private getImpostorHitData;
  149036. private _tick;
  149037. /*** Helpers ***/
  149038. private _prepareCylinder;
  149039. private _intersectsWithCylinder;
  149040. }
  149041. /**
  149042. * Represents a physics vortex event
  149043. */
  149044. class PhysicsVortexEvent {
  149045. private _scene;
  149046. private _origin;
  149047. private _options;
  149048. private _physicsEngine;
  149049. private _originTop;
  149050. private _tickCallback;
  149051. private _cylinder;
  149052. private _cylinderPosition;
  149053. private _dataFetched;
  149054. /**
  149055. * Initializes the physics vortex event
  149056. * @param _scene The BabylonJS scene
  149057. * @param _origin The origin position of the vortex
  149058. * @param _options The options for the vortex event
  149059. */
  149060. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  149061. /**
  149062. * Returns the data related to the vortex event (cylinder).
  149063. * @returns The physics vortex event data
  149064. */
  149065. getData(): PhysicsVortexEventData;
  149066. /**
  149067. * Enables the vortex.
  149068. */
  149069. enable(): void;
  149070. /**
  149071. * Disables the cortex.
  149072. */
  149073. disable(): void;
  149074. /**
  149075. * Disposes the sphere.
  149076. * @param force
  149077. */
  149078. dispose(force?: boolean): void;
  149079. private getImpostorHitData;
  149080. private _tick;
  149081. /*** Helpers ***/
  149082. private _prepareCylinder;
  149083. private _intersectsWithCylinder;
  149084. }
  149085. /**
  149086. * Options fot the radial explosion event
  149087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149088. */
  149089. export class PhysicsRadialExplosionEventOptions {
  149090. /**
  149091. * The radius of the sphere for the radial explosion.
  149092. */
  149093. radius: number;
  149094. /**
  149095. * The strenth of the explosion.
  149096. */
  149097. strength: number;
  149098. /**
  149099. * The strenght of the force in correspondence to the distance of the affected object
  149100. */
  149101. falloff: PhysicsRadialImpulseFalloff;
  149102. /**
  149103. * Sphere options for the radial explosion.
  149104. */
  149105. sphere: {
  149106. segments: number;
  149107. diameter: number;
  149108. };
  149109. /**
  149110. * Sphere options for the radial explosion.
  149111. */
  149112. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  149113. }
  149114. /**
  149115. * Options fot the updraft event
  149116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149117. */
  149118. export class PhysicsUpdraftEventOptions {
  149119. /**
  149120. * The radius of the cylinder for the vortex
  149121. */
  149122. radius: number;
  149123. /**
  149124. * The strenth of the updraft.
  149125. */
  149126. strength: number;
  149127. /**
  149128. * The height of the cylinder for the updraft.
  149129. */
  149130. height: number;
  149131. /**
  149132. * The mode for the the updraft.
  149133. */
  149134. updraftMode: PhysicsUpdraftMode;
  149135. }
  149136. /**
  149137. * Options fot the vortex event
  149138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149139. */
  149140. export class PhysicsVortexEventOptions {
  149141. /**
  149142. * The radius of the cylinder for the vortex
  149143. */
  149144. radius: number;
  149145. /**
  149146. * The strenth of the vortex.
  149147. */
  149148. strength: number;
  149149. /**
  149150. * The height of the cylinder for the vortex.
  149151. */
  149152. height: number;
  149153. /**
  149154. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  149155. */
  149156. centripetalForceThreshold: number;
  149157. /**
  149158. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  149159. */
  149160. centripetalForceMultiplier: number;
  149161. /**
  149162. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  149163. */
  149164. centrifugalForceMultiplier: number;
  149165. /**
  149166. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  149167. */
  149168. updraftForceMultiplier: number;
  149169. }
  149170. /**
  149171. * The strenght of the force in correspondence to the distance of the affected object
  149172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149173. */
  149174. export enum PhysicsRadialImpulseFalloff {
  149175. /** Defines that impulse is constant in strength across it's whole radius */
  149176. Constant = 0,
  149177. /** Defines that impulse gets weaker if it's further from the origin */
  149178. Linear = 1
  149179. }
  149180. /**
  149181. * The strength of the force in correspondence to the distance of the affected object
  149182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149183. */
  149184. export enum PhysicsUpdraftMode {
  149185. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  149186. Center = 0,
  149187. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  149188. Perpendicular = 1
  149189. }
  149190. /**
  149191. * Interface for a physics hit data
  149192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149193. */
  149194. export interface PhysicsHitData {
  149195. /**
  149196. * The force applied at the contact point
  149197. */
  149198. force: Vector3;
  149199. /**
  149200. * The contact point
  149201. */
  149202. contactPoint: Vector3;
  149203. /**
  149204. * The distance from the origin to the contact point
  149205. */
  149206. distanceFromOrigin: number;
  149207. }
  149208. /**
  149209. * Interface for radial explosion event data
  149210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149211. */
  149212. export interface PhysicsRadialExplosionEventData {
  149213. /**
  149214. * A sphere used for the radial explosion event
  149215. */
  149216. sphere: Mesh;
  149217. }
  149218. /**
  149219. * Interface for gravitational field event data
  149220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149221. */
  149222. export interface PhysicsGravitationalFieldEventData {
  149223. /**
  149224. * A sphere mesh used for the gravitational field event
  149225. */
  149226. sphere: Mesh;
  149227. }
  149228. /**
  149229. * Interface for updraft event data
  149230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149231. */
  149232. export interface PhysicsUpdraftEventData {
  149233. /**
  149234. * A cylinder used for the updraft event
  149235. */
  149236. cylinder: Mesh;
  149237. }
  149238. /**
  149239. * Interface for vortex event data
  149240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149241. */
  149242. export interface PhysicsVortexEventData {
  149243. /**
  149244. * A cylinder used for the vortex event
  149245. */
  149246. cylinder: Mesh;
  149247. }
  149248. /**
  149249. * Interface for an affected physics impostor
  149250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149251. */
  149252. export interface PhysicsAffectedImpostorWithData {
  149253. /**
  149254. * The impostor affected by the effect
  149255. */
  149256. impostor: PhysicsImpostor;
  149257. /**
  149258. * The data about the hit/horce from the explosion
  149259. */
  149260. hitData: PhysicsHitData;
  149261. }
  149262. }
  149263. declare module BABYLON {
  149264. /** @hidden */
  149265. export var blackAndWhitePixelShader: {
  149266. name: string;
  149267. shader: string;
  149268. };
  149269. }
  149270. declare module BABYLON {
  149271. /**
  149272. * Post process used to render in black and white
  149273. */
  149274. export class BlackAndWhitePostProcess extends PostProcess {
  149275. /**
  149276. * Linear about to convert he result to black and white (default: 1)
  149277. */
  149278. degree: number;
  149279. /**
  149280. * Gets a string identifying the name of the class
  149281. * @returns "BlackAndWhitePostProcess" string
  149282. */
  149283. getClassName(): string;
  149284. /**
  149285. * Creates a black and white post process
  149286. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  149287. * @param name The name of the effect.
  149288. * @param options The required width/height ratio to downsize to before computing the render pass.
  149289. * @param camera The camera to apply the render pass to.
  149290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149291. * @param engine The engine which the post process will be applied. (default: current engine)
  149292. * @param reusable If the post process can be reused on the same frame. (default: false)
  149293. */
  149294. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149295. /** @hidden */
  149296. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  149297. }
  149298. }
  149299. declare module BABYLON {
  149300. /**
  149301. * This represents a set of one or more post processes in Babylon.
  149302. * A post process can be used to apply a shader to a texture after it is rendered.
  149303. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149304. */
  149305. export class PostProcessRenderEffect {
  149306. private _postProcesses;
  149307. private _getPostProcesses;
  149308. private _singleInstance;
  149309. private _cameras;
  149310. private _indicesForCamera;
  149311. /**
  149312. * Name of the effect
  149313. * @hidden
  149314. */
  149315. _name: string;
  149316. /**
  149317. * Instantiates a post process render effect.
  149318. * A post process can be used to apply a shader to a texture after it is rendered.
  149319. * @param engine The engine the effect is tied to
  149320. * @param name The name of the effect
  149321. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  149322. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  149323. */
  149324. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  149325. /**
  149326. * Checks if all the post processes in the effect are supported.
  149327. */
  149328. get isSupported(): boolean;
  149329. /**
  149330. * Updates the current state of the effect
  149331. * @hidden
  149332. */
  149333. _update(): void;
  149334. /**
  149335. * Attaches the effect on cameras
  149336. * @param cameras The camera to attach to.
  149337. * @hidden
  149338. */
  149339. _attachCameras(cameras: Camera): void;
  149340. /**
  149341. * Attaches the effect on cameras
  149342. * @param cameras The camera to attach to.
  149343. * @hidden
  149344. */
  149345. _attachCameras(cameras: Camera[]): void;
  149346. /**
  149347. * Detaches the effect on cameras
  149348. * @param cameras The camera to detatch from.
  149349. * @hidden
  149350. */
  149351. _detachCameras(cameras: Camera): void;
  149352. /**
  149353. * Detatches the effect on cameras
  149354. * @param cameras The camera to detatch from.
  149355. * @hidden
  149356. */
  149357. _detachCameras(cameras: Camera[]): void;
  149358. /**
  149359. * Enables the effect on given cameras
  149360. * @param cameras The camera to enable.
  149361. * @hidden
  149362. */
  149363. _enable(cameras: Camera): void;
  149364. /**
  149365. * Enables the effect on given cameras
  149366. * @param cameras The camera to enable.
  149367. * @hidden
  149368. */
  149369. _enable(cameras: Nullable<Camera[]>): void;
  149370. /**
  149371. * Disables the effect on the given cameras
  149372. * @param cameras The camera to disable.
  149373. * @hidden
  149374. */
  149375. _disable(cameras: Camera): void;
  149376. /**
  149377. * Disables the effect on the given cameras
  149378. * @param cameras The camera to disable.
  149379. * @hidden
  149380. */
  149381. _disable(cameras: Nullable<Camera[]>): void;
  149382. /**
  149383. * Gets a list of the post processes contained in the effect.
  149384. * @param camera The camera to get the post processes on.
  149385. * @returns The list of the post processes in the effect.
  149386. */
  149387. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  149388. }
  149389. }
  149390. declare module BABYLON {
  149391. /** @hidden */
  149392. export var extractHighlightsPixelShader: {
  149393. name: string;
  149394. shader: string;
  149395. };
  149396. }
  149397. declare module BABYLON {
  149398. /**
  149399. * 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.
  149400. */
  149401. export class ExtractHighlightsPostProcess extends PostProcess {
  149402. /**
  149403. * The luminance threshold, pixels below this value will be set to black.
  149404. */
  149405. threshold: number;
  149406. /** @hidden */
  149407. _exposure: number;
  149408. /**
  149409. * Post process which has the input texture to be used when performing highlight extraction
  149410. * @hidden
  149411. */
  149412. _inputPostProcess: Nullable<PostProcess>;
  149413. /**
  149414. * Gets a string identifying the name of the class
  149415. * @returns "ExtractHighlightsPostProcess" string
  149416. */
  149417. getClassName(): string;
  149418. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149419. }
  149420. }
  149421. declare module BABYLON {
  149422. /** @hidden */
  149423. export var bloomMergePixelShader: {
  149424. name: string;
  149425. shader: string;
  149426. };
  149427. }
  149428. declare module BABYLON {
  149429. /**
  149430. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149431. */
  149432. export class BloomMergePostProcess extends PostProcess {
  149433. /** Weight of the bloom to be added to the original input. */
  149434. weight: number;
  149435. /**
  149436. * Gets a string identifying the name of the class
  149437. * @returns "BloomMergePostProcess" string
  149438. */
  149439. getClassName(): string;
  149440. /**
  149441. * Creates a new instance of @see BloomMergePostProcess
  149442. * @param name The name of the effect.
  149443. * @param originalFromInput Post process which's input will be used for the merge.
  149444. * @param blurred Blurred highlights post process which's output will be used.
  149445. * @param weight Weight of the bloom to be added to the original input.
  149446. * @param options The required width/height ratio to downsize to before computing the render pass.
  149447. * @param camera The camera to apply the render pass to.
  149448. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149449. * @param engine The engine which the post process will be applied. (default: current engine)
  149450. * @param reusable If the post process can be reused on the same frame. (default: false)
  149451. * @param textureType Type of textures used when performing the post process. (default: 0)
  149452. * @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)
  149453. */
  149454. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  149455. /** Weight of the bloom to be added to the original input. */
  149456. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149457. }
  149458. }
  149459. declare module BABYLON {
  149460. /**
  149461. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  149462. */
  149463. export class BloomEffect extends PostProcessRenderEffect {
  149464. private bloomScale;
  149465. /**
  149466. * @hidden Internal
  149467. */
  149468. _effects: Array<PostProcess>;
  149469. /**
  149470. * @hidden Internal
  149471. */
  149472. _downscale: ExtractHighlightsPostProcess;
  149473. private _blurX;
  149474. private _blurY;
  149475. private _merge;
  149476. /**
  149477. * The luminance threshold to find bright areas of the image to bloom.
  149478. */
  149479. get threshold(): number;
  149480. set threshold(value: number);
  149481. /**
  149482. * The strength of the bloom.
  149483. */
  149484. get weight(): number;
  149485. set weight(value: number);
  149486. /**
  149487. * Specifies the size of the bloom blur kernel, relative to the final output size
  149488. */
  149489. get kernel(): number;
  149490. set kernel(value: number);
  149491. /**
  149492. * Creates a new instance of @see BloomEffect
  149493. * @param scene The scene the effect belongs to.
  149494. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  149495. * @param bloomKernel The size of the kernel to be used when applying the blur.
  149496. * @param bloomWeight The the strength of bloom.
  149497. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149498. * @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)
  149499. */
  149500. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  149501. /**
  149502. * Disposes each of the internal effects for a given camera.
  149503. * @param camera The camera to dispose the effect on.
  149504. */
  149505. disposeEffects(camera: Camera): void;
  149506. /**
  149507. * @hidden Internal
  149508. */
  149509. _updateEffects(): void;
  149510. /**
  149511. * Internal
  149512. * @returns if all the contained post processes are ready.
  149513. * @hidden
  149514. */
  149515. _isReady(): boolean;
  149516. }
  149517. }
  149518. declare module BABYLON {
  149519. /** @hidden */
  149520. export var chromaticAberrationPixelShader: {
  149521. name: string;
  149522. shader: string;
  149523. };
  149524. }
  149525. declare module BABYLON {
  149526. /**
  149527. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  149528. */
  149529. export class ChromaticAberrationPostProcess extends PostProcess {
  149530. /**
  149531. * The amount of seperation of rgb channels (default: 30)
  149532. */
  149533. aberrationAmount: number;
  149534. /**
  149535. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  149536. */
  149537. radialIntensity: number;
  149538. /**
  149539. * 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))
  149540. */
  149541. direction: Vector2;
  149542. /**
  149543. * 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))
  149544. */
  149545. centerPosition: Vector2;
  149546. /** The width of the screen to apply the effect on */
  149547. screenWidth: number;
  149548. /** The height of the screen to apply the effect on */
  149549. screenHeight: number;
  149550. /**
  149551. * Gets a string identifying the name of the class
  149552. * @returns "ChromaticAberrationPostProcess" string
  149553. */
  149554. getClassName(): string;
  149555. /**
  149556. * Creates a new instance ChromaticAberrationPostProcess
  149557. * @param name The name of the effect.
  149558. * @param screenWidth The width of the screen to apply the effect on.
  149559. * @param screenHeight The height of the screen to apply the effect on.
  149560. * @param options The required width/height ratio to downsize to before computing the render pass.
  149561. * @param camera The camera to apply the render pass to.
  149562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149563. * @param engine The engine which the post process will be applied. (default: current engine)
  149564. * @param reusable If the post process can be reused on the same frame. (default: false)
  149565. * @param textureType Type of textures used when performing the post process. (default: 0)
  149566. * @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)
  149567. */
  149568. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149569. /** @hidden */
  149570. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  149571. }
  149572. }
  149573. declare module BABYLON {
  149574. /** @hidden */
  149575. export var circleOfConfusionPixelShader: {
  149576. name: string;
  149577. shader: string;
  149578. };
  149579. }
  149580. declare module BABYLON {
  149581. /**
  149582. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  149583. */
  149584. export class CircleOfConfusionPostProcess extends PostProcess {
  149585. /**
  149586. * 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.
  149587. */
  149588. lensSize: number;
  149589. /**
  149590. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149591. */
  149592. fStop: number;
  149593. /**
  149594. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149595. */
  149596. focusDistance: number;
  149597. /**
  149598. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  149599. */
  149600. focalLength: number;
  149601. /**
  149602. * Gets a string identifying the name of the class
  149603. * @returns "CircleOfConfusionPostProcess" string
  149604. */
  149605. getClassName(): string;
  149606. private _depthTexture;
  149607. /**
  149608. * Creates a new instance CircleOfConfusionPostProcess
  149609. * @param name The name of the effect.
  149610. * @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.
  149611. * @param options The required width/height ratio to downsize to before computing the render pass.
  149612. * @param camera The camera to apply the render pass to.
  149613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149614. * @param engine The engine which the post process will be applied. (default: current engine)
  149615. * @param reusable If the post process can be reused on the same frame. (default: false)
  149616. * @param textureType Type of textures used when performing the post process. (default: 0)
  149617. * @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)
  149618. */
  149619. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149620. /**
  149621. * 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.
  149622. */
  149623. set depthTexture(value: RenderTargetTexture);
  149624. }
  149625. }
  149626. declare module BABYLON {
  149627. /** @hidden */
  149628. export var colorCorrectionPixelShader: {
  149629. name: string;
  149630. shader: string;
  149631. };
  149632. }
  149633. declare module BABYLON {
  149634. /**
  149635. *
  149636. * This post-process allows the modification of rendered colors by using
  149637. * a 'look-up table' (LUT). This effect is also called Color Grading.
  149638. *
  149639. * The object needs to be provided an url to a texture containing the color
  149640. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  149641. * Use an image editing software to tweak the LUT to match your needs.
  149642. *
  149643. * For an example of a color LUT, see here:
  149644. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  149645. * For explanations on color grading, see here:
  149646. * @see http://udn.epicgames.com/Three/ColorGrading.html
  149647. *
  149648. */
  149649. export class ColorCorrectionPostProcess extends PostProcess {
  149650. private _colorTableTexture;
  149651. /**
  149652. * Gets the color table url used to create the LUT texture
  149653. */
  149654. colorTableUrl: string;
  149655. /**
  149656. * Gets a string identifying the name of the class
  149657. * @returns "ColorCorrectionPostProcess" string
  149658. */
  149659. getClassName(): string;
  149660. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149661. /** @hidden */
  149662. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  149663. }
  149664. }
  149665. declare module BABYLON {
  149666. /** @hidden */
  149667. export var convolutionPixelShader: {
  149668. name: string;
  149669. shader: string;
  149670. };
  149671. }
  149672. declare module BABYLON {
  149673. /**
  149674. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  149675. * input texture to perform effects such as edge detection or sharpening
  149676. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149677. */
  149678. export class ConvolutionPostProcess extends PostProcess {
  149679. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  149680. kernel: number[];
  149681. /**
  149682. * Gets a string identifying the name of the class
  149683. * @returns "ConvolutionPostProcess" string
  149684. */
  149685. getClassName(): string;
  149686. /**
  149687. * Creates a new instance ConvolutionPostProcess
  149688. * @param name The name of the effect.
  149689. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  149690. * @param options The required width/height ratio to downsize to before computing the render pass.
  149691. * @param camera The camera to apply the render pass to.
  149692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149693. * @param engine The engine which the post process will be applied. (default: current engine)
  149694. * @param reusable If the post process can be reused on the same frame. (default: false)
  149695. * @param textureType Type of textures used when performing the post process. (default: 0)
  149696. */
  149697. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149698. /** @hidden */
  149699. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  149700. /**
  149701. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149702. */
  149703. static EdgeDetect0Kernel: number[];
  149704. /**
  149705. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149706. */
  149707. static EdgeDetect1Kernel: number[];
  149708. /**
  149709. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149710. */
  149711. static EdgeDetect2Kernel: number[];
  149712. /**
  149713. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149714. */
  149715. static SharpenKernel: number[];
  149716. /**
  149717. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149718. */
  149719. static EmbossKernel: number[];
  149720. /**
  149721. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149722. */
  149723. static GaussianKernel: number[];
  149724. }
  149725. }
  149726. declare module BABYLON {
  149727. /**
  149728. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  149729. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  149730. * based on samples that have a large difference in distance than the center pixel.
  149731. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  149732. */
  149733. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  149734. /**
  149735. * The direction the blur should be applied
  149736. */
  149737. direction: Vector2;
  149738. /**
  149739. * Gets a string identifying the name of the class
  149740. * @returns "DepthOfFieldBlurPostProcess" string
  149741. */
  149742. getClassName(): string;
  149743. /**
  149744. * Creates a new instance CircleOfConfusionPostProcess
  149745. * @param name The name of the effect.
  149746. * @param scene The scene the effect belongs to.
  149747. * @param direction The direction the blur should be applied.
  149748. * @param kernel The size of the kernel used to blur.
  149749. * @param options The required width/height ratio to downsize to before computing the render pass.
  149750. * @param camera The camera to apply the render pass to.
  149751. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  149752. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  149753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149754. * @param engine The engine which the post process will be applied. (default: current engine)
  149755. * @param reusable If the post process can be reused on the same frame. (default: false)
  149756. * @param textureType Type of textures used when performing the post process. (default: 0)
  149757. * @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)
  149758. */
  149759. 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);
  149760. }
  149761. }
  149762. declare module BABYLON {
  149763. /** @hidden */
  149764. export var depthOfFieldMergePixelShader: {
  149765. name: string;
  149766. shader: string;
  149767. };
  149768. }
  149769. declare module BABYLON {
  149770. /**
  149771. * Options to be set when merging outputs from the default pipeline.
  149772. */
  149773. export class DepthOfFieldMergePostProcessOptions {
  149774. /**
  149775. * The original image to merge on top of
  149776. */
  149777. originalFromInput: PostProcess;
  149778. /**
  149779. * Parameters to perform the merge of the depth of field effect
  149780. */
  149781. depthOfField?: {
  149782. circleOfConfusion: PostProcess;
  149783. blurSteps: Array<PostProcess>;
  149784. };
  149785. /**
  149786. * Parameters to perform the merge of bloom effect
  149787. */
  149788. bloom?: {
  149789. blurred: PostProcess;
  149790. weight: number;
  149791. };
  149792. }
  149793. /**
  149794. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149795. */
  149796. export class DepthOfFieldMergePostProcess extends PostProcess {
  149797. private blurSteps;
  149798. /**
  149799. * Gets a string identifying the name of the class
  149800. * @returns "DepthOfFieldMergePostProcess" string
  149801. */
  149802. getClassName(): string;
  149803. /**
  149804. * Creates a new instance of DepthOfFieldMergePostProcess
  149805. * @param name The name of the effect.
  149806. * @param originalFromInput Post process which's input will be used for the merge.
  149807. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  149808. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  149809. * @param options The required width/height ratio to downsize to before computing the render pass.
  149810. * @param camera The camera to apply the render pass to.
  149811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149812. * @param engine The engine which the post process will be applied. (default: current engine)
  149813. * @param reusable If the post process can be reused on the same frame. (default: false)
  149814. * @param textureType Type of textures used when performing the post process. (default: 0)
  149815. * @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)
  149816. */
  149817. 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);
  149818. /**
  149819. * Updates the effect with the current post process compile time values and recompiles the shader.
  149820. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  149821. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  149822. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  149823. * @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
  149824. * @param onCompiled Called when the shader has been compiled.
  149825. * @param onError Called if there is an error when compiling a shader.
  149826. */
  149827. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  149828. }
  149829. }
  149830. declare module BABYLON {
  149831. /**
  149832. * Specifies the level of max blur that should be applied when using the depth of field effect
  149833. */
  149834. export enum DepthOfFieldEffectBlurLevel {
  149835. /**
  149836. * Subtle blur
  149837. */
  149838. Low = 0,
  149839. /**
  149840. * Medium blur
  149841. */
  149842. Medium = 1,
  149843. /**
  149844. * Large blur
  149845. */
  149846. High = 2
  149847. }
  149848. /**
  149849. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  149850. */
  149851. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  149852. private _circleOfConfusion;
  149853. /**
  149854. * @hidden Internal, blurs from high to low
  149855. */
  149856. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  149857. private _depthOfFieldBlurY;
  149858. private _dofMerge;
  149859. /**
  149860. * @hidden Internal post processes in depth of field effect
  149861. */
  149862. _effects: Array<PostProcess>;
  149863. /**
  149864. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  149865. */
  149866. set focalLength(value: number);
  149867. get focalLength(): number;
  149868. /**
  149869. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149870. */
  149871. set fStop(value: number);
  149872. get fStop(): number;
  149873. /**
  149874. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149875. */
  149876. set focusDistance(value: number);
  149877. get focusDistance(): number;
  149878. /**
  149879. * 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.
  149880. */
  149881. set lensSize(value: number);
  149882. get lensSize(): number;
  149883. /**
  149884. * Creates a new instance DepthOfFieldEffect
  149885. * @param scene The scene the effect belongs to.
  149886. * @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.
  149887. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149888. * @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)
  149889. */
  149890. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  149891. /**
  149892. * Get the current class name of the current effet
  149893. * @returns "DepthOfFieldEffect"
  149894. */
  149895. getClassName(): string;
  149896. /**
  149897. * 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.
  149898. */
  149899. set depthTexture(value: RenderTargetTexture);
  149900. /**
  149901. * Disposes each of the internal effects for a given camera.
  149902. * @param camera The camera to dispose the effect on.
  149903. */
  149904. disposeEffects(camera: Camera): void;
  149905. /**
  149906. * @hidden Internal
  149907. */
  149908. _updateEffects(): void;
  149909. /**
  149910. * Internal
  149911. * @returns if all the contained post processes are ready.
  149912. * @hidden
  149913. */
  149914. _isReady(): boolean;
  149915. }
  149916. }
  149917. declare module BABYLON {
  149918. /** @hidden */
  149919. export var displayPassPixelShader: {
  149920. name: string;
  149921. shader: string;
  149922. };
  149923. }
  149924. declare module BABYLON {
  149925. /**
  149926. * DisplayPassPostProcess which produces an output the same as it's input
  149927. */
  149928. export class DisplayPassPostProcess extends PostProcess {
  149929. /**
  149930. * Gets a string identifying the name of the class
  149931. * @returns "DisplayPassPostProcess" string
  149932. */
  149933. getClassName(): string;
  149934. /**
  149935. * Creates the DisplayPassPostProcess
  149936. * @param name The name of the effect.
  149937. * @param options The required width/height ratio to downsize to before computing the render pass.
  149938. * @param camera The camera to apply the render pass to.
  149939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149940. * @param engine The engine which the post process will be applied. (default: current engine)
  149941. * @param reusable If the post process can be reused on the same frame. (default: false)
  149942. */
  149943. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149944. /** @hidden */
  149945. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  149946. }
  149947. }
  149948. declare module BABYLON {
  149949. /** @hidden */
  149950. export var filterPixelShader: {
  149951. name: string;
  149952. shader: string;
  149953. };
  149954. }
  149955. declare module BABYLON {
  149956. /**
  149957. * Applies a kernel filter to the image
  149958. */
  149959. export class FilterPostProcess extends PostProcess {
  149960. /** The matrix to be applied to the image */
  149961. kernelMatrix: Matrix;
  149962. /**
  149963. * Gets a string identifying the name of the class
  149964. * @returns "FilterPostProcess" string
  149965. */
  149966. getClassName(): string;
  149967. /**
  149968. *
  149969. * @param name The name of the effect.
  149970. * @param kernelMatrix The matrix to be applied to the image
  149971. * @param options The required width/height ratio to downsize to before computing the render pass.
  149972. * @param camera The camera to apply the render pass to.
  149973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149974. * @param engine The engine which the post process will be applied. (default: current engine)
  149975. * @param reusable If the post process can be reused on the same frame. (default: false)
  149976. */
  149977. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149978. /** @hidden */
  149979. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  149980. }
  149981. }
  149982. declare module BABYLON {
  149983. /** @hidden */
  149984. export var fxaaPixelShader: {
  149985. name: string;
  149986. shader: string;
  149987. };
  149988. }
  149989. declare module BABYLON {
  149990. /** @hidden */
  149991. export var fxaaVertexShader: {
  149992. name: string;
  149993. shader: string;
  149994. };
  149995. }
  149996. declare module BABYLON {
  149997. /**
  149998. * Fxaa post process
  149999. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  150000. */
  150001. export class FxaaPostProcess extends PostProcess {
  150002. /**
  150003. * Gets a string identifying the name of the class
  150004. * @returns "FxaaPostProcess" string
  150005. */
  150006. getClassName(): string;
  150007. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150008. private _getDefines;
  150009. /** @hidden */
  150010. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  150011. }
  150012. }
  150013. declare module BABYLON {
  150014. /** @hidden */
  150015. export var grainPixelShader: {
  150016. name: string;
  150017. shader: string;
  150018. };
  150019. }
  150020. declare module BABYLON {
  150021. /**
  150022. * The GrainPostProcess adds noise to the image at mid luminance levels
  150023. */
  150024. export class GrainPostProcess extends PostProcess {
  150025. /**
  150026. * The intensity of the grain added (default: 30)
  150027. */
  150028. intensity: number;
  150029. /**
  150030. * If the grain should be randomized on every frame
  150031. */
  150032. animated: boolean;
  150033. /**
  150034. * Gets a string identifying the name of the class
  150035. * @returns "GrainPostProcess" string
  150036. */
  150037. getClassName(): string;
  150038. /**
  150039. * Creates a new instance of @see GrainPostProcess
  150040. * @param name The name of the effect.
  150041. * @param options The required width/height ratio to downsize to before computing the render pass.
  150042. * @param camera The camera to apply the render pass to.
  150043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150044. * @param engine The engine which the post process will be applied. (default: current engine)
  150045. * @param reusable If the post process can be reused on the same frame. (default: false)
  150046. * @param textureType Type of textures used when performing the post process. (default: 0)
  150047. * @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)
  150048. */
  150049. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150050. /** @hidden */
  150051. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  150052. }
  150053. }
  150054. declare module BABYLON {
  150055. /** @hidden */
  150056. export var highlightsPixelShader: {
  150057. name: string;
  150058. shader: string;
  150059. };
  150060. }
  150061. declare module BABYLON {
  150062. /**
  150063. * Extracts highlights from the image
  150064. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150065. */
  150066. export class HighlightsPostProcess extends PostProcess {
  150067. /**
  150068. * Gets a string identifying the name of the class
  150069. * @returns "HighlightsPostProcess" string
  150070. */
  150071. getClassName(): string;
  150072. /**
  150073. * Extracts highlights from the image
  150074. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150075. * @param name The name of the effect.
  150076. * @param options The required width/height ratio to downsize to before computing the render pass.
  150077. * @param camera The camera to apply the render pass to.
  150078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150079. * @param engine The engine which the post process will be applied. (default: current engine)
  150080. * @param reusable If the post process can be reused on the same frame. (default: false)
  150081. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  150082. */
  150083. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150084. }
  150085. }
  150086. declare module BABYLON {
  150087. /** @hidden */
  150088. export var mrtFragmentDeclaration: {
  150089. name: string;
  150090. shader: string;
  150091. };
  150092. }
  150093. declare module BABYLON {
  150094. /** @hidden */
  150095. export var geometryPixelShader: {
  150096. name: string;
  150097. shader: string;
  150098. };
  150099. }
  150100. declare module BABYLON {
  150101. /** @hidden */
  150102. export var geometryVertexShader: {
  150103. name: string;
  150104. shader: string;
  150105. };
  150106. }
  150107. declare module BABYLON {
  150108. /** @hidden */
  150109. interface ISavedTransformationMatrix {
  150110. world: Matrix;
  150111. viewProjection: Matrix;
  150112. }
  150113. /**
  150114. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  150115. */
  150116. export class GeometryBufferRenderer {
  150117. /**
  150118. * Constant used to retrieve the position texture index in the G-Buffer textures array
  150119. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  150120. */
  150121. static readonly POSITION_TEXTURE_TYPE: number;
  150122. /**
  150123. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  150124. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  150125. */
  150126. static readonly VELOCITY_TEXTURE_TYPE: number;
  150127. /**
  150128. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  150129. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  150130. */
  150131. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  150132. /**
  150133. * Dictionary used to store the previous transformation matrices of each rendered mesh
  150134. * in order to compute objects velocities when enableVelocity is set to "true"
  150135. * @hidden
  150136. */
  150137. _previousTransformationMatrices: {
  150138. [index: number]: ISavedTransformationMatrix;
  150139. };
  150140. /**
  150141. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  150142. * in order to compute objects velocities when enableVelocity is set to "true"
  150143. * @hidden
  150144. */
  150145. _previousBonesTransformationMatrices: {
  150146. [index: number]: Float32Array;
  150147. };
  150148. /**
  150149. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  150150. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  150151. */
  150152. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  150153. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  150154. renderTransparentMeshes: boolean;
  150155. private _scene;
  150156. private _resizeObserver;
  150157. private _multiRenderTarget;
  150158. private _ratio;
  150159. private _enablePosition;
  150160. private _enableVelocity;
  150161. private _enableReflectivity;
  150162. private _positionIndex;
  150163. private _velocityIndex;
  150164. private _reflectivityIndex;
  150165. protected _effect: Effect;
  150166. protected _cachedDefines: string;
  150167. /**
  150168. * Set the render list (meshes to be rendered) used in the G buffer.
  150169. */
  150170. set renderList(meshes: Mesh[]);
  150171. /**
  150172. * Gets wether or not G buffer are supported by the running hardware.
  150173. * This requires draw buffer supports
  150174. */
  150175. get isSupported(): boolean;
  150176. /**
  150177. * Returns the index of the given texture type in the G-Buffer textures array
  150178. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  150179. * @returns the index of the given texture type in the G-Buffer textures array
  150180. */
  150181. getTextureIndex(textureType: number): number;
  150182. /**
  150183. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  150184. */
  150185. get enablePosition(): boolean;
  150186. /**
  150187. * Sets whether or not objects positions are enabled for the G buffer.
  150188. */
  150189. set enablePosition(enable: boolean);
  150190. /**
  150191. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  150192. */
  150193. get enableVelocity(): boolean;
  150194. /**
  150195. * Sets wether or not objects velocities are enabled for the G buffer.
  150196. */
  150197. set enableVelocity(enable: boolean);
  150198. /**
  150199. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  150200. */
  150201. get enableReflectivity(): boolean;
  150202. /**
  150203. * Sets wether or not objects roughness are enabled for the G buffer.
  150204. */
  150205. set enableReflectivity(enable: boolean);
  150206. /**
  150207. * Gets the scene associated with the buffer.
  150208. */
  150209. get scene(): Scene;
  150210. /**
  150211. * Gets the ratio used by the buffer during its creation.
  150212. * How big is the buffer related to the main canvas.
  150213. */
  150214. get ratio(): number;
  150215. /** @hidden */
  150216. static _SceneComponentInitialization: (scene: Scene) => void;
  150217. /**
  150218. * Creates a new G Buffer for the scene
  150219. * @param scene The scene the buffer belongs to
  150220. * @param ratio How big is the buffer related to the main canvas.
  150221. */
  150222. constructor(scene: Scene, ratio?: number);
  150223. /**
  150224. * Checks wether everything is ready to render a submesh to the G buffer.
  150225. * @param subMesh the submesh to check readiness for
  150226. * @param useInstances is the mesh drawn using instance or not
  150227. * @returns true if ready otherwise false
  150228. */
  150229. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150230. /**
  150231. * Gets the current underlying G Buffer.
  150232. * @returns the buffer
  150233. */
  150234. getGBuffer(): MultiRenderTarget;
  150235. /**
  150236. * Gets the number of samples used to render the buffer (anti aliasing).
  150237. */
  150238. get samples(): number;
  150239. /**
  150240. * Sets the number of samples used to render the buffer (anti aliasing).
  150241. */
  150242. set samples(value: number);
  150243. /**
  150244. * Disposes the renderer and frees up associated resources.
  150245. */
  150246. dispose(): void;
  150247. protected _createRenderTargets(): void;
  150248. private _copyBonesTransformationMatrices;
  150249. }
  150250. }
  150251. declare module BABYLON {
  150252. interface Scene {
  150253. /** @hidden (Backing field) */
  150254. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150255. /**
  150256. * Gets or Sets the current geometry buffer associated to the scene.
  150257. */
  150258. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150259. /**
  150260. * Enables a GeometryBufferRender and associates it with the scene
  150261. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  150262. * @returns the GeometryBufferRenderer
  150263. */
  150264. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  150265. /**
  150266. * Disables the GeometryBufferRender associated with the scene
  150267. */
  150268. disableGeometryBufferRenderer(): void;
  150269. }
  150270. /**
  150271. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150272. * in several rendering techniques.
  150273. */
  150274. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  150275. /**
  150276. * The component name helpful to identify the component in the list of scene components.
  150277. */
  150278. readonly name: string;
  150279. /**
  150280. * The scene the component belongs to.
  150281. */
  150282. scene: Scene;
  150283. /**
  150284. * Creates a new instance of the component for the given scene
  150285. * @param scene Defines the scene to register the component in
  150286. */
  150287. constructor(scene: Scene);
  150288. /**
  150289. * Registers the component in a given scene
  150290. */
  150291. register(): void;
  150292. /**
  150293. * Rebuilds the elements related to this component in case of
  150294. * context lost for instance.
  150295. */
  150296. rebuild(): void;
  150297. /**
  150298. * Disposes the component and the associated ressources
  150299. */
  150300. dispose(): void;
  150301. private _gatherRenderTargets;
  150302. }
  150303. }
  150304. declare module BABYLON {
  150305. /** @hidden */
  150306. export var motionBlurPixelShader: {
  150307. name: string;
  150308. shader: string;
  150309. };
  150310. }
  150311. declare module BABYLON {
  150312. /**
  150313. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  150314. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  150315. * As an example, all you have to do is to create the post-process:
  150316. * var mb = new BABYLON.MotionBlurPostProcess(
  150317. * 'mb', // The name of the effect.
  150318. * scene, // The scene containing the objects to blur according to their velocity.
  150319. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  150320. * camera // The camera to apply the render pass to.
  150321. * );
  150322. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  150323. */
  150324. export class MotionBlurPostProcess extends PostProcess {
  150325. /**
  150326. * Defines how much the image is blurred by the movement. Default value is equal to 1
  150327. */
  150328. motionStrength: number;
  150329. /**
  150330. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  150331. */
  150332. get motionBlurSamples(): number;
  150333. /**
  150334. * Sets the number of iterations to be used for motion blur quality
  150335. */
  150336. set motionBlurSamples(samples: number);
  150337. private _motionBlurSamples;
  150338. private _geometryBufferRenderer;
  150339. /**
  150340. * Gets a string identifying the name of the class
  150341. * @returns "MotionBlurPostProcess" string
  150342. */
  150343. getClassName(): string;
  150344. /**
  150345. * Creates a new instance MotionBlurPostProcess
  150346. * @param name The name of the effect.
  150347. * @param scene The scene containing the objects to blur according to their velocity.
  150348. * @param options The required width/height ratio to downsize to before computing the render pass.
  150349. * @param camera The camera to apply the render pass to.
  150350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150351. * @param engine The engine which the post process will be applied. (default: current engine)
  150352. * @param reusable If the post process can be reused on the same frame. (default: false)
  150353. * @param textureType Type of textures used when performing the post process. (default: 0)
  150354. * @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)
  150355. */
  150356. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150357. /**
  150358. * Excludes the given skinned mesh from computing bones velocities.
  150359. * 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.
  150360. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  150361. */
  150362. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150363. /**
  150364. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  150365. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  150366. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  150367. */
  150368. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150369. /**
  150370. * Disposes the post process.
  150371. * @param camera The camera to dispose the post process on.
  150372. */
  150373. dispose(camera?: Camera): void;
  150374. /** @hidden */
  150375. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  150376. }
  150377. }
  150378. declare module BABYLON {
  150379. /** @hidden */
  150380. export var refractionPixelShader: {
  150381. name: string;
  150382. shader: string;
  150383. };
  150384. }
  150385. declare module BABYLON {
  150386. /**
  150387. * Post process which applies a refractin texture
  150388. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150389. */
  150390. export class RefractionPostProcess extends PostProcess {
  150391. private _refTexture;
  150392. private _ownRefractionTexture;
  150393. /** the base color of the refraction (used to taint the rendering) */
  150394. color: Color3;
  150395. /** simulated refraction depth */
  150396. depth: number;
  150397. /** the coefficient of the base color (0 to remove base color tainting) */
  150398. colorLevel: number;
  150399. /** Gets the url used to load the refraction texture */
  150400. refractionTextureUrl: string;
  150401. /**
  150402. * Gets or sets the refraction texture
  150403. * Please note that you are responsible for disposing the texture if you set it manually
  150404. */
  150405. get refractionTexture(): Texture;
  150406. set refractionTexture(value: Texture);
  150407. /**
  150408. * Gets a string identifying the name of the class
  150409. * @returns "RefractionPostProcess" string
  150410. */
  150411. getClassName(): string;
  150412. /**
  150413. * Initializes the RefractionPostProcess
  150414. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150415. * @param name The name of the effect.
  150416. * @param refractionTextureUrl Url of the refraction texture to use
  150417. * @param color the base color of the refraction (used to taint the rendering)
  150418. * @param depth simulated refraction depth
  150419. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  150420. * @param camera The camera to apply the render pass to.
  150421. * @param options The required width/height ratio to downsize to before computing the render pass.
  150422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150423. * @param engine The engine which the post process will be applied. (default: current engine)
  150424. * @param reusable If the post process can be reused on the same frame. (default: false)
  150425. */
  150426. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150427. /**
  150428. * Disposes of the post process
  150429. * @param camera Camera to dispose post process on
  150430. */
  150431. dispose(camera: Camera): void;
  150432. /** @hidden */
  150433. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  150434. }
  150435. }
  150436. declare module BABYLON {
  150437. /** @hidden */
  150438. export var sharpenPixelShader: {
  150439. name: string;
  150440. shader: string;
  150441. };
  150442. }
  150443. declare module BABYLON {
  150444. /**
  150445. * The SharpenPostProcess applies a sharpen kernel to every pixel
  150446. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150447. */
  150448. export class SharpenPostProcess extends PostProcess {
  150449. /**
  150450. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  150451. */
  150452. colorAmount: number;
  150453. /**
  150454. * How much sharpness should be applied (default: 0.3)
  150455. */
  150456. edgeAmount: number;
  150457. /**
  150458. * Gets a string identifying the name of the class
  150459. * @returns "SharpenPostProcess" string
  150460. */
  150461. getClassName(): string;
  150462. /**
  150463. * Creates a new instance ConvolutionPostProcess
  150464. * @param name The name of the effect.
  150465. * @param options The required width/height ratio to downsize to before computing the render pass.
  150466. * @param camera The camera to apply the render pass to.
  150467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150468. * @param engine The engine which the post process will be applied. (default: current engine)
  150469. * @param reusable If the post process can be reused on the same frame. (default: false)
  150470. * @param textureType Type of textures used when performing the post process. (default: 0)
  150471. * @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)
  150472. */
  150473. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150474. /** @hidden */
  150475. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  150476. }
  150477. }
  150478. declare module BABYLON {
  150479. /**
  150480. * PostProcessRenderPipeline
  150481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150482. */
  150483. export class PostProcessRenderPipeline {
  150484. private engine;
  150485. private _renderEffects;
  150486. private _renderEffectsForIsolatedPass;
  150487. /**
  150488. * List of inspectable custom properties (used by the Inspector)
  150489. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  150490. */
  150491. inspectableCustomProperties: IInspectable[];
  150492. /**
  150493. * @hidden
  150494. */
  150495. protected _cameras: Camera[];
  150496. /** @hidden */
  150497. _name: string;
  150498. /**
  150499. * Gets pipeline name
  150500. */
  150501. get name(): string;
  150502. /** Gets the list of attached cameras */
  150503. get cameras(): Camera[];
  150504. /**
  150505. * Initializes a PostProcessRenderPipeline
  150506. * @param engine engine to add the pipeline to
  150507. * @param name name of the pipeline
  150508. */
  150509. constructor(engine: Engine, name: string);
  150510. /**
  150511. * Gets the class name
  150512. * @returns "PostProcessRenderPipeline"
  150513. */
  150514. getClassName(): string;
  150515. /**
  150516. * If all the render effects in the pipeline are supported
  150517. */
  150518. get isSupported(): boolean;
  150519. /**
  150520. * Adds an effect to the pipeline
  150521. * @param renderEffect the effect to add
  150522. */
  150523. addEffect(renderEffect: PostProcessRenderEffect): void;
  150524. /** @hidden */
  150525. _rebuild(): void;
  150526. /** @hidden */
  150527. _enableEffect(renderEffectName: string, cameras: Camera): void;
  150528. /** @hidden */
  150529. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  150530. /** @hidden */
  150531. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150532. /** @hidden */
  150533. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150534. /** @hidden */
  150535. _attachCameras(cameras: Camera, unique: boolean): void;
  150536. /** @hidden */
  150537. _attachCameras(cameras: Camera[], unique: boolean): void;
  150538. /** @hidden */
  150539. _detachCameras(cameras: Camera): void;
  150540. /** @hidden */
  150541. _detachCameras(cameras: Nullable<Camera[]>): void;
  150542. /** @hidden */
  150543. _update(): void;
  150544. /** @hidden */
  150545. _reset(): void;
  150546. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  150547. /**
  150548. * Sets the required values to the prepass renderer.
  150549. * @param prePassRenderer defines the prepass renderer to setup.
  150550. * @returns true if the pre pass is needed.
  150551. */
  150552. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150553. /**
  150554. * Disposes of the pipeline
  150555. */
  150556. dispose(): void;
  150557. }
  150558. }
  150559. declare module BABYLON {
  150560. /**
  150561. * PostProcessRenderPipelineManager class
  150562. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150563. */
  150564. export class PostProcessRenderPipelineManager {
  150565. private _renderPipelines;
  150566. /**
  150567. * Initializes a PostProcessRenderPipelineManager
  150568. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150569. */
  150570. constructor();
  150571. /**
  150572. * Gets the list of supported render pipelines
  150573. */
  150574. get supportedPipelines(): PostProcessRenderPipeline[];
  150575. /**
  150576. * Adds a pipeline to the manager
  150577. * @param renderPipeline The pipeline to add
  150578. */
  150579. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  150580. /**
  150581. * Attaches a camera to the pipeline
  150582. * @param renderPipelineName The name of the pipeline to attach to
  150583. * @param cameras the camera to attach
  150584. * @param unique if the camera can be attached multiple times to the pipeline
  150585. */
  150586. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  150587. /**
  150588. * Detaches a camera from the pipeline
  150589. * @param renderPipelineName The name of the pipeline to detach from
  150590. * @param cameras the camera to detach
  150591. */
  150592. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  150593. /**
  150594. * Enables an effect by name on a pipeline
  150595. * @param renderPipelineName the name of the pipeline to enable the effect in
  150596. * @param renderEffectName the name of the effect to enable
  150597. * @param cameras the cameras that the effect should be enabled on
  150598. */
  150599. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150600. /**
  150601. * Disables an effect by name on a pipeline
  150602. * @param renderPipelineName the name of the pipeline to disable the effect in
  150603. * @param renderEffectName the name of the effect to disable
  150604. * @param cameras the cameras that the effect should be disabled on
  150605. */
  150606. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150607. /**
  150608. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  150609. */
  150610. update(): void;
  150611. /** @hidden */
  150612. _rebuild(): void;
  150613. /**
  150614. * Disposes of the manager and pipelines
  150615. */
  150616. dispose(): void;
  150617. }
  150618. }
  150619. declare module BABYLON {
  150620. interface Scene {
  150621. /** @hidden (Backing field) */
  150622. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150623. /**
  150624. * Gets the postprocess render pipeline manager
  150625. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150626. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150627. */
  150628. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150629. }
  150630. /**
  150631. * Defines the Render Pipeline scene component responsible to rendering pipelines
  150632. */
  150633. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  150634. /**
  150635. * The component name helpfull to identify the component in the list of scene components.
  150636. */
  150637. readonly name: string;
  150638. /**
  150639. * The scene the component belongs to.
  150640. */
  150641. scene: Scene;
  150642. /**
  150643. * Creates a new instance of the component for the given scene
  150644. * @param scene Defines the scene to register the component in
  150645. */
  150646. constructor(scene: Scene);
  150647. /**
  150648. * Registers the component in a given scene
  150649. */
  150650. register(): void;
  150651. /**
  150652. * Rebuilds the elements related to this component in case of
  150653. * context lost for instance.
  150654. */
  150655. rebuild(): void;
  150656. /**
  150657. * Disposes the component and the associated ressources
  150658. */
  150659. dispose(): void;
  150660. private _gatherRenderTargets;
  150661. }
  150662. }
  150663. declare module BABYLON {
  150664. /**
  150665. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  150666. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150667. */
  150668. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150669. private _scene;
  150670. private _camerasToBeAttached;
  150671. /**
  150672. * ID of the sharpen post process,
  150673. */
  150674. private readonly SharpenPostProcessId;
  150675. /**
  150676. * @ignore
  150677. * ID of the image processing post process;
  150678. */
  150679. readonly ImageProcessingPostProcessId: string;
  150680. /**
  150681. * @ignore
  150682. * ID of the Fast Approximate Anti-Aliasing post process;
  150683. */
  150684. readonly FxaaPostProcessId: string;
  150685. /**
  150686. * ID of the chromatic aberration post process,
  150687. */
  150688. private readonly ChromaticAberrationPostProcessId;
  150689. /**
  150690. * ID of the grain post process
  150691. */
  150692. private readonly GrainPostProcessId;
  150693. /**
  150694. * Sharpen post process which will apply a sharpen convolution to enhance edges
  150695. */
  150696. sharpen: SharpenPostProcess;
  150697. private _sharpenEffect;
  150698. private bloom;
  150699. /**
  150700. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  150701. */
  150702. depthOfField: DepthOfFieldEffect;
  150703. /**
  150704. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150705. */
  150706. fxaa: FxaaPostProcess;
  150707. /**
  150708. * Image post processing pass used to perform operations such as tone mapping or color grading.
  150709. */
  150710. imageProcessing: ImageProcessingPostProcess;
  150711. /**
  150712. * Chromatic aberration post process which will shift rgb colors in the image
  150713. */
  150714. chromaticAberration: ChromaticAberrationPostProcess;
  150715. private _chromaticAberrationEffect;
  150716. /**
  150717. * Grain post process which add noise to the image
  150718. */
  150719. grain: GrainPostProcess;
  150720. private _grainEffect;
  150721. /**
  150722. * Glow post process which adds a glow to emissive areas of the image
  150723. */
  150724. private _glowLayer;
  150725. /**
  150726. * Animations which can be used to tweak settings over a period of time
  150727. */
  150728. animations: Animation[];
  150729. private _imageProcessingConfigurationObserver;
  150730. private _sharpenEnabled;
  150731. private _bloomEnabled;
  150732. private _depthOfFieldEnabled;
  150733. private _depthOfFieldBlurLevel;
  150734. private _fxaaEnabled;
  150735. private _imageProcessingEnabled;
  150736. private _defaultPipelineTextureType;
  150737. private _bloomScale;
  150738. private _chromaticAberrationEnabled;
  150739. private _grainEnabled;
  150740. private _buildAllowed;
  150741. /**
  150742. * Gets active scene
  150743. */
  150744. get scene(): Scene;
  150745. /**
  150746. * Enable or disable the sharpen process from the pipeline
  150747. */
  150748. set sharpenEnabled(enabled: boolean);
  150749. get sharpenEnabled(): boolean;
  150750. private _resizeObserver;
  150751. private _hardwareScaleLevel;
  150752. private _bloomKernel;
  150753. /**
  150754. * Specifies the size of the bloom blur kernel, relative to the final output size
  150755. */
  150756. get bloomKernel(): number;
  150757. set bloomKernel(value: number);
  150758. /**
  150759. * Specifies the weight of the bloom in the final rendering
  150760. */
  150761. private _bloomWeight;
  150762. /**
  150763. * Specifies the luma threshold for the area that will be blurred by the bloom
  150764. */
  150765. private _bloomThreshold;
  150766. private _hdr;
  150767. /**
  150768. * The strength of the bloom.
  150769. */
  150770. set bloomWeight(value: number);
  150771. get bloomWeight(): number;
  150772. /**
  150773. * The strength of the bloom.
  150774. */
  150775. set bloomThreshold(value: number);
  150776. get bloomThreshold(): number;
  150777. /**
  150778. * The scale of the bloom, lower value will provide better performance.
  150779. */
  150780. set bloomScale(value: number);
  150781. get bloomScale(): number;
  150782. /**
  150783. * Enable or disable the bloom from the pipeline
  150784. */
  150785. set bloomEnabled(enabled: boolean);
  150786. get bloomEnabled(): boolean;
  150787. private _rebuildBloom;
  150788. /**
  150789. * If the depth of field is enabled.
  150790. */
  150791. get depthOfFieldEnabled(): boolean;
  150792. set depthOfFieldEnabled(enabled: boolean);
  150793. /**
  150794. * Blur level of the depth of field effect. (Higher blur will effect performance)
  150795. */
  150796. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  150797. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  150798. /**
  150799. * If the anti aliasing is enabled.
  150800. */
  150801. set fxaaEnabled(enabled: boolean);
  150802. get fxaaEnabled(): boolean;
  150803. private _samples;
  150804. /**
  150805. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150806. */
  150807. set samples(sampleCount: number);
  150808. get samples(): number;
  150809. /**
  150810. * If image processing is enabled.
  150811. */
  150812. set imageProcessingEnabled(enabled: boolean);
  150813. get imageProcessingEnabled(): boolean;
  150814. /**
  150815. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  150816. */
  150817. set glowLayerEnabled(enabled: boolean);
  150818. get glowLayerEnabled(): boolean;
  150819. /**
  150820. * Gets the glow layer (or null if not defined)
  150821. */
  150822. get glowLayer(): Nullable<GlowLayer>;
  150823. /**
  150824. * Enable or disable the chromaticAberration process from the pipeline
  150825. */
  150826. set chromaticAberrationEnabled(enabled: boolean);
  150827. get chromaticAberrationEnabled(): boolean;
  150828. /**
  150829. * Enable or disable the grain process from the pipeline
  150830. */
  150831. set grainEnabled(enabled: boolean);
  150832. get grainEnabled(): boolean;
  150833. /**
  150834. * @constructor
  150835. * @param name - The rendering pipeline name (default: "")
  150836. * @param hdr - If high dynamic range textures should be used (default: true)
  150837. * @param scene - The scene linked to this pipeline (default: the last created scene)
  150838. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  150839. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  150840. */
  150841. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  150842. /**
  150843. * Get the class name
  150844. * @returns "DefaultRenderingPipeline"
  150845. */
  150846. getClassName(): string;
  150847. /**
  150848. * Force the compilation of the entire pipeline.
  150849. */
  150850. prepare(): void;
  150851. private _hasCleared;
  150852. private _prevPostProcess;
  150853. private _prevPrevPostProcess;
  150854. private _setAutoClearAndTextureSharing;
  150855. private _depthOfFieldSceneObserver;
  150856. private _buildPipeline;
  150857. private _disposePostProcesses;
  150858. /**
  150859. * Adds a camera to the pipeline
  150860. * @param camera the camera to be added
  150861. */
  150862. addCamera(camera: Camera): void;
  150863. /**
  150864. * Removes a camera from the pipeline
  150865. * @param camera the camera to remove
  150866. */
  150867. removeCamera(camera: Camera): void;
  150868. /**
  150869. * Dispose of the pipeline and stop all post processes
  150870. */
  150871. dispose(): void;
  150872. /**
  150873. * Serialize the rendering pipeline (Used when exporting)
  150874. * @returns the serialized object
  150875. */
  150876. serialize(): any;
  150877. /**
  150878. * Parse the serialized pipeline
  150879. * @param source Source pipeline.
  150880. * @param scene The scene to load the pipeline to.
  150881. * @param rootUrl The URL of the serialized pipeline.
  150882. * @returns An instantiated pipeline from the serialized object.
  150883. */
  150884. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  150885. }
  150886. }
  150887. declare module BABYLON {
  150888. /** @hidden */
  150889. export var lensHighlightsPixelShader: {
  150890. name: string;
  150891. shader: string;
  150892. };
  150893. }
  150894. declare module BABYLON {
  150895. /** @hidden */
  150896. export var depthOfFieldPixelShader: {
  150897. name: string;
  150898. shader: string;
  150899. };
  150900. }
  150901. declare module BABYLON {
  150902. /**
  150903. * BABYLON.JS Chromatic Aberration GLSL Shader
  150904. * Author: Olivier Guyot
  150905. * Separates very slightly R, G and B colors on the edges of the screen
  150906. * Inspired by Francois Tarlier & Martins Upitis
  150907. */
  150908. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  150909. /**
  150910. * @ignore
  150911. * The chromatic aberration PostProcess id in the pipeline
  150912. */
  150913. LensChromaticAberrationEffect: string;
  150914. /**
  150915. * @ignore
  150916. * The highlights enhancing PostProcess id in the pipeline
  150917. */
  150918. HighlightsEnhancingEffect: string;
  150919. /**
  150920. * @ignore
  150921. * The depth-of-field PostProcess id in the pipeline
  150922. */
  150923. LensDepthOfFieldEffect: string;
  150924. private _scene;
  150925. private _depthTexture;
  150926. private _grainTexture;
  150927. private _chromaticAberrationPostProcess;
  150928. private _highlightsPostProcess;
  150929. private _depthOfFieldPostProcess;
  150930. private _edgeBlur;
  150931. private _grainAmount;
  150932. private _chromaticAberration;
  150933. private _distortion;
  150934. private _highlightsGain;
  150935. private _highlightsThreshold;
  150936. private _dofDistance;
  150937. private _dofAperture;
  150938. private _dofDarken;
  150939. private _dofPentagon;
  150940. private _blurNoise;
  150941. /**
  150942. * @constructor
  150943. *
  150944. * Effect parameters are as follow:
  150945. * {
  150946. * chromatic_aberration: number; // from 0 to x (1 for realism)
  150947. * edge_blur: number; // from 0 to x (1 for realism)
  150948. * distortion: number; // from 0 to x (1 for realism)
  150949. * grain_amount: number; // from 0 to 1
  150950. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  150951. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  150952. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  150953. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  150954. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  150955. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  150956. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  150957. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  150958. * }
  150959. * Note: if an effect parameter is unset, effect is disabled
  150960. *
  150961. * @param name The rendering pipeline name
  150962. * @param parameters - An object containing all parameters (see above)
  150963. * @param scene The scene linked to this pipeline
  150964. * @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)
  150965. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150966. */
  150967. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  150968. /**
  150969. * Get the class name
  150970. * @returns "LensRenderingPipeline"
  150971. */
  150972. getClassName(): string;
  150973. /**
  150974. * Gets associated scene
  150975. */
  150976. get scene(): Scene;
  150977. /**
  150978. * Gets or sets the edge blur
  150979. */
  150980. get edgeBlur(): number;
  150981. set edgeBlur(value: number);
  150982. /**
  150983. * Gets or sets the grain amount
  150984. */
  150985. get grainAmount(): number;
  150986. set grainAmount(value: number);
  150987. /**
  150988. * Gets or sets the chromatic aberration amount
  150989. */
  150990. get chromaticAberration(): number;
  150991. set chromaticAberration(value: number);
  150992. /**
  150993. * Gets or sets the depth of field aperture
  150994. */
  150995. get dofAperture(): number;
  150996. set dofAperture(value: number);
  150997. /**
  150998. * Gets or sets the edge distortion
  150999. */
  151000. get edgeDistortion(): number;
  151001. set edgeDistortion(value: number);
  151002. /**
  151003. * Gets or sets the depth of field distortion
  151004. */
  151005. get dofDistortion(): number;
  151006. set dofDistortion(value: number);
  151007. /**
  151008. * Gets or sets the darken out of focus amount
  151009. */
  151010. get darkenOutOfFocus(): number;
  151011. set darkenOutOfFocus(value: number);
  151012. /**
  151013. * Gets or sets a boolean indicating if blur noise is enabled
  151014. */
  151015. get blurNoise(): boolean;
  151016. set blurNoise(value: boolean);
  151017. /**
  151018. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151019. */
  151020. get pentagonBokeh(): boolean;
  151021. set pentagonBokeh(value: boolean);
  151022. /**
  151023. * Gets or sets the highlight grain amount
  151024. */
  151025. get highlightsGain(): number;
  151026. set highlightsGain(value: number);
  151027. /**
  151028. * Gets or sets the highlight threshold
  151029. */
  151030. get highlightsThreshold(): number;
  151031. set highlightsThreshold(value: number);
  151032. /**
  151033. * Sets the amount of blur at the edges
  151034. * @param amount blur amount
  151035. */
  151036. setEdgeBlur(amount: number): void;
  151037. /**
  151038. * Sets edge blur to 0
  151039. */
  151040. disableEdgeBlur(): void;
  151041. /**
  151042. * Sets the amout of grain
  151043. * @param amount Amount of grain
  151044. */
  151045. setGrainAmount(amount: number): void;
  151046. /**
  151047. * Set grain amount to 0
  151048. */
  151049. disableGrain(): void;
  151050. /**
  151051. * Sets the chromatic aberration amount
  151052. * @param amount amount of chromatic aberration
  151053. */
  151054. setChromaticAberration(amount: number): void;
  151055. /**
  151056. * Sets chromatic aberration amount to 0
  151057. */
  151058. disableChromaticAberration(): void;
  151059. /**
  151060. * Sets the EdgeDistortion amount
  151061. * @param amount amount of EdgeDistortion
  151062. */
  151063. setEdgeDistortion(amount: number): void;
  151064. /**
  151065. * Sets edge distortion to 0
  151066. */
  151067. disableEdgeDistortion(): void;
  151068. /**
  151069. * Sets the FocusDistance amount
  151070. * @param amount amount of FocusDistance
  151071. */
  151072. setFocusDistance(amount: number): void;
  151073. /**
  151074. * Disables depth of field
  151075. */
  151076. disableDepthOfField(): void;
  151077. /**
  151078. * Sets the Aperture amount
  151079. * @param amount amount of Aperture
  151080. */
  151081. setAperture(amount: number): void;
  151082. /**
  151083. * Sets the DarkenOutOfFocus amount
  151084. * @param amount amount of DarkenOutOfFocus
  151085. */
  151086. setDarkenOutOfFocus(amount: number): void;
  151087. private _pentagonBokehIsEnabled;
  151088. /**
  151089. * Creates a pentagon bokeh effect
  151090. */
  151091. enablePentagonBokeh(): void;
  151092. /**
  151093. * Disables the pentagon bokeh effect
  151094. */
  151095. disablePentagonBokeh(): void;
  151096. /**
  151097. * Enables noise blur
  151098. */
  151099. enableNoiseBlur(): void;
  151100. /**
  151101. * Disables noise blur
  151102. */
  151103. disableNoiseBlur(): void;
  151104. /**
  151105. * Sets the HighlightsGain amount
  151106. * @param amount amount of HighlightsGain
  151107. */
  151108. setHighlightsGain(amount: number): void;
  151109. /**
  151110. * Sets the HighlightsThreshold amount
  151111. * @param amount amount of HighlightsThreshold
  151112. */
  151113. setHighlightsThreshold(amount: number): void;
  151114. /**
  151115. * Disables highlights
  151116. */
  151117. disableHighlights(): void;
  151118. /**
  151119. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  151120. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  151121. */
  151122. dispose(disableDepthRender?: boolean): void;
  151123. private _createChromaticAberrationPostProcess;
  151124. private _createHighlightsPostProcess;
  151125. private _createDepthOfFieldPostProcess;
  151126. private _createGrainTexture;
  151127. }
  151128. }
  151129. declare module BABYLON {
  151130. /**
  151131. * Contains all parameters needed for the prepass to perform
  151132. * screen space subsurface scattering
  151133. */
  151134. export class SSAO2Configuration implements PrePassEffectConfiguration {
  151135. /**
  151136. * Is subsurface enabled
  151137. */
  151138. enabled: boolean;
  151139. /**
  151140. * Name of the configuration
  151141. */
  151142. name: string;
  151143. /**
  151144. * Textures that should be present in the MRT for this effect to work
  151145. */
  151146. readonly texturesRequired: number[];
  151147. /**
  151148. * Builds a ssao2 configuration object
  151149. * @param scene The scene
  151150. */
  151151. constructor();
  151152. /**
  151153. * Disposes the configuration
  151154. */
  151155. dispose(): void;
  151156. }
  151157. }
  151158. declare module BABYLON {
  151159. /** @hidden */
  151160. export var ssao2PixelShader: {
  151161. name: string;
  151162. shader: string;
  151163. };
  151164. }
  151165. declare module BABYLON {
  151166. /** @hidden */
  151167. export var ssaoCombinePixelShader: {
  151168. name: string;
  151169. shader: string;
  151170. };
  151171. }
  151172. declare module BABYLON {
  151173. /**
  151174. * Render pipeline to produce ssao effect
  151175. */
  151176. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  151177. /**
  151178. * @ignore
  151179. * The PassPostProcess id in the pipeline that contains the original scene color
  151180. */
  151181. SSAOOriginalSceneColorEffect: string;
  151182. /**
  151183. * @ignore
  151184. * The SSAO PostProcess id in the pipeline
  151185. */
  151186. SSAORenderEffect: string;
  151187. /**
  151188. * @ignore
  151189. * The horizontal blur PostProcess id in the pipeline
  151190. */
  151191. SSAOBlurHRenderEffect: string;
  151192. /**
  151193. * @ignore
  151194. * The vertical blur PostProcess id in the pipeline
  151195. */
  151196. SSAOBlurVRenderEffect: string;
  151197. /**
  151198. * @ignore
  151199. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151200. */
  151201. SSAOCombineRenderEffect: string;
  151202. /**
  151203. * The output strength of the SSAO post-process. Default value is 1.0.
  151204. */
  151205. totalStrength: number;
  151206. /**
  151207. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  151208. */
  151209. maxZ: number;
  151210. /**
  151211. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  151212. */
  151213. minZAspect: number;
  151214. private _samples;
  151215. /**
  151216. * Number of samples used for the SSAO calculations. Default value is 8
  151217. */
  151218. set samples(n: number);
  151219. get samples(): number;
  151220. private _textureSamples;
  151221. /**
  151222. * Number of samples to use for antialiasing
  151223. */
  151224. set textureSamples(n: number);
  151225. get textureSamples(): number;
  151226. /**
  151227. * Force rendering the geometry through geometry buffer
  151228. */
  151229. private _forceGeometryBuffer;
  151230. /**
  151231. * Ratio object used for SSAO ratio and blur ratio
  151232. */
  151233. private _ratio;
  151234. /**
  151235. * Dynamically generated sphere sampler.
  151236. */
  151237. private _sampleSphere;
  151238. private _ssao2PrePassConfiguration;
  151239. /**
  151240. * Blur filter offsets
  151241. */
  151242. private _samplerOffsets;
  151243. private _expensiveBlur;
  151244. /**
  151245. * If bilateral blur should be used
  151246. */
  151247. set expensiveBlur(b: boolean);
  151248. get expensiveBlur(): boolean;
  151249. /**
  151250. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  151251. */
  151252. radius: number;
  151253. /**
  151254. * The base color of the SSAO post-process
  151255. * The final result is "base + ssao" between [0, 1]
  151256. */
  151257. base: number;
  151258. /**
  151259. * Support test.
  151260. */
  151261. static get IsSupported(): boolean;
  151262. private _scene;
  151263. private _randomTexture;
  151264. private _originalColorPostProcess;
  151265. private _ssaoPostProcess;
  151266. private _blurHPostProcess;
  151267. private _blurVPostProcess;
  151268. private _ssaoCombinePostProcess;
  151269. private _prePassRenderer;
  151270. /**
  151271. * Gets active scene
  151272. */
  151273. get scene(): Scene;
  151274. /**
  151275. * @constructor
  151276. * @param name The rendering pipeline name
  151277. * @param scene The scene linked to this pipeline
  151278. * @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 }
  151279. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151280. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  151281. */
  151282. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  151283. /**
  151284. * Get the class name
  151285. * @returns "SSAO2RenderingPipeline"
  151286. */
  151287. getClassName(): string;
  151288. /**
  151289. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151290. */
  151291. dispose(disableGeometryBufferRenderer?: boolean): void;
  151292. private _createBlurPostProcess;
  151293. /** @hidden */
  151294. _rebuild(): void;
  151295. private _bits;
  151296. private _radicalInverse_VdC;
  151297. private _hammersley;
  151298. private _hemisphereSample_uniform;
  151299. private _generateHemisphere;
  151300. private _getDefinesForSSAO;
  151301. private _createSSAOPostProcess;
  151302. private _createSSAOCombinePostProcess;
  151303. private _createRandomTexture;
  151304. /**
  151305. * Serialize the rendering pipeline (Used when exporting)
  151306. * @returns the serialized object
  151307. */
  151308. serialize(): any;
  151309. /**
  151310. * Parse the serialized pipeline
  151311. * @param source Source pipeline.
  151312. * @param scene The scene to load the pipeline to.
  151313. * @param rootUrl The URL of the serialized pipeline.
  151314. * @returns An instantiated pipeline from the serialized object.
  151315. */
  151316. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  151317. /**
  151318. * Sets the required values to the prepass renderer.
  151319. * @param prePassRenderer defines the prepass renderer to setup
  151320. * @returns true if the pre pass is needed.
  151321. */
  151322. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151323. }
  151324. }
  151325. declare module BABYLON {
  151326. /** @hidden */
  151327. export var ssaoPixelShader: {
  151328. name: string;
  151329. shader: string;
  151330. };
  151331. }
  151332. declare module BABYLON {
  151333. /**
  151334. * Render pipeline to produce ssao effect
  151335. */
  151336. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  151337. /**
  151338. * @ignore
  151339. * The PassPostProcess id in the pipeline that contains the original scene color
  151340. */
  151341. SSAOOriginalSceneColorEffect: string;
  151342. /**
  151343. * @ignore
  151344. * The SSAO PostProcess id in the pipeline
  151345. */
  151346. SSAORenderEffect: string;
  151347. /**
  151348. * @ignore
  151349. * The horizontal blur PostProcess id in the pipeline
  151350. */
  151351. SSAOBlurHRenderEffect: string;
  151352. /**
  151353. * @ignore
  151354. * The vertical blur PostProcess id in the pipeline
  151355. */
  151356. SSAOBlurVRenderEffect: string;
  151357. /**
  151358. * @ignore
  151359. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151360. */
  151361. SSAOCombineRenderEffect: string;
  151362. /**
  151363. * The output strength of the SSAO post-process. Default value is 1.0.
  151364. */
  151365. totalStrength: number;
  151366. /**
  151367. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  151368. */
  151369. radius: number;
  151370. /**
  151371. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  151372. * Must not be equal to fallOff and superior to fallOff.
  151373. * Default value is 0.0075
  151374. */
  151375. area: number;
  151376. /**
  151377. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  151378. * Must not be equal to area and inferior to area.
  151379. * Default value is 0.000001
  151380. */
  151381. fallOff: number;
  151382. /**
  151383. * The base color of the SSAO post-process
  151384. * The final result is "base + ssao" between [0, 1]
  151385. */
  151386. base: number;
  151387. private _scene;
  151388. private _depthTexture;
  151389. private _randomTexture;
  151390. private _originalColorPostProcess;
  151391. private _ssaoPostProcess;
  151392. private _blurHPostProcess;
  151393. private _blurVPostProcess;
  151394. private _ssaoCombinePostProcess;
  151395. private _firstUpdate;
  151396. /**
  151397. * Gets active scene
  151398. */
  151399. get scene(): Scene;
  151400. /**
  151401. * @constructor
  151402. * @param name - The rendering pipeline name
  151403. * @param scene - The scene linked to this pipeline
  151404. * @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 }
  151405. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  151406. */
  151407. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  151408. /**
  151409. * Get the class name
  151410. * @returns "SSAORenderingPipeline"
  151411. */
  151412. getClassName(): string;
  151413. /**
  151414. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151415. */
  151416. dispose(disableDepthRender?: boolean): void;
  151417. private _createBlurPostProcess;
  151418. /** @hidden */
  151419. _rebuild(): void;
  151420. private _createSSAOPostProcess;
  151421. private _createSSAOCombinePostProcess;
  151422. private _createRandomTexture;
  151423. }
  151424. }
  151425. declare module BABYLON {
  151426. /** @hidden */
  151427. export var screenSpaceReflectionPixelShader: {
  151428. name: string;
  151429. shader: string;
  151430. };
  151431. }
  151432. declare module BABYLON {
  151433. /**
  151434. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  151435. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  151436. */
  151437. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  151438. /**
  151439. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  151440. */
  151441. threshold: number;
  151442. /**
  151443. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  151444. */
  151445. strength: number;
  151446. /**
  151447. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  151448. */
  151449. reflectionSpecularFalloffExponent: number;
  151450. /**
  151451. * 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]
  151452. */
  151453. step: number;
  151454. /**
  151455. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  151456. */
  151457. roughnessFactor: number;
  151458. private _geometryBufferRenderer;
  151459. private _enableSmoothReflections;
  151460. private _reflectionSamples;
  151461. private _smoothSteps;
  151462. /**
  151463. * Gets a string identifying the name of the class
  151464. * @returns "ScreenSpaceReflectionPostProcess" string
  151465. */
  151466. getClassName(): string;
  151467. /**
  151468. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  151469. * @param name The name of the effect.
  151470. * @param scene The scene containing the objects to calculate reflections.
  151471. * @param options The required width/height ratio to downsize to before computing the render pass.
  151472. * @param camera The camera to apply the render pass to.
  151473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151474. * @param engine The engine which the post process will be applied. (default: current engine)
  151475. * @param reusable If the post process can be reused on the same frame. (default: false)
  151476. * @param textureType Type of textures used when performing the post process. (default: 0)
  151477. * @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)
  151478. */
  151479. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151480. /**
  151481. * Gets wether or not smoothing reflections is enabled.
  151482. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151483. */
  151484. get enableSmoothReflections(): boolean;
  151485. /**
  151486. * Sets wether or not smoothing reflections is enabled.
  151487. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151488. */
  151489. set enableSmoothReflections(enabled: boolean);
  151490. /**
  151491. * Gets the number of samples taken while computing reflections. More samples count is high,
  151492. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151493. */
  151494. get reflectionSamples(): number;
  151495. /**
  151496. * Sets the number of samples taken while computing reflections. More samples count is high,
  151497. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151498. */
  151499. set reflectionSamples(samples: number);
  151500. /**
  151501. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  151502. * more the post-process will require GPU power and can generate a drop in FPS.
  151503. * Default value (5.0) work pretty well in all cases but can be adjusted.
  151504. */
  151505. get smoothSteps(): number;
  151506. set smoothSteps(steps: number);
  151507. private _updateEffectDefines;
  151508. /** @hidden */
  151509. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  151510. }
  151511. }
  151512. declare module BABYLON {
  151513. /** @hidden */
  151514. export var standardPixelShader: {
  151515. name: string;
  151516. shader: string;
  151517. };
  151518. }
  151519. declare module BABYLON {
  151520. /**
  151521. * Standard rendering pipeline
  151522. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151523. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  151524. */
  151525. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151526. /**
  151527. * Public members
  151528. */
  151529. /**
  151530. * Post-process which contains the original scene color before the pipeline applies all the effects
  151531. */
  151532. originalPostProcess: Nullable<PostProcess>;
  151533. /**
  151534. * Post-process used to down scale an image x4
  151535. */
  151536. downSampleX4PostProcess: Nullable<PostProcess>;
  151537. /**
  151538. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  151539. */
  151540. brightPassPostProcess: Nullable<PostProcess>;
  151541. /**
  151542. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  151543. */
  151544. blurHPostProcesses: PostProcess[];
  151545. /**
  151546. * Post-process array storing all the vertical blur post-processes used by the pipeline
  151547. */
  151548. blurVPostProcesses: PostProcess[];
  151549. /**
  151550. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  151551. */
  151552. textureAdderPostProcess: Nullable<PostProcess>;
  151553. /**
  151554. * Post-process used to create volumetric lighting effect
  151555. */
  151556. volumetricLightPostProcess: Nullable<PostProcess>;
  151557. /**
  151558. * Post-process used to smooth the previous volumetric light post-process on the X axis
  151559. */
  151560. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  151561. /**
  151562. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  151563. */
  151564. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  151565. /**
  151566. * Post-process used to merge the volumetric light effect and the real scene color
  151567. */
  151568. volumetricLightMergePostProces: Nullable<PostProcess>;
  151569. /**
  151570. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  151571. */
  151572. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  151573. /**
  151574. * Base post-process used to calculate the average luminance of the final image for HDR
  151575. */
  151576. luminancePostProcess: Nullable<PostProcess>;
  151577. /**
  151578. * Post-processes used to create down sample post-processes in order to get
  151579. * the average luminance of the final image for HDR
  151580. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  151581. */
  151582. luminanceDownSamplePostProcesses: PostProcess[];
  151583. /**
  151584. * Post-process used to create a HDR effect (light adaptation)
  151585. */
  151586. hdrPostProcess: Nullable<PostProcess>;
  151587. /**
  151588. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  151589. */
  151590. textureAdderFinalPostProcess: Nullable<PostProcess>;
  151591. /**
  151592. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  151593. */
  151594. lensFlareFinalPostProcess: Nullable<PostProcess>;
  151595. /**
  151596. * Post-process used to merge the final HDR post-process and the real scene color
  151597. */
  151598. hdrFinalPostProcess: Nullable<PostProcess>;
  151599. /**
  151600. * Post-process used to create a lens flare effect
  151601. */
  151602. lensFlarePostProcess: Nullable<PostProcess>;
  151603. /**
  151604. * Post-process that merges the result of the lens flare post-process and the real scene color
  151605. */
  151606. lensFlareComposePostProcess: Nullable<PostProcess>;
  151607. /**
  151608. * Post-process used to create a motion blur effect
  151609. */
  151610. motionBlurPostProcess: Nullable<PostProcess>;
  151611. /**
  151612. * Post-process used to create a depth of field effect
  151613. */
  151614. depthOfFieldPostProcess: Nullable<PostProcess>;
  151615. /**
  151616. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151617. */
  151618. fxaaPostProcess: Nullable<FxaaPostProcess>;
  151619. /**
  151620. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  151621. */
  151622. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  151623. /**
  151624. * Represents the brightness threshold in order to configure the illuminated surfaces
  151625. */
  151626. brightThreshold: number;
  151627. /**
  151628. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  151629. */
  151630. blurWidth: number;
  151631. /**
  151632. * Sets if the blur for highlighted surfaces must be only horizontal
  151633. */
  151634. horizontalBlur: boolean;
  151635. /**
  151636. * Gets the overall exposure used by the pipeline
  151637. */
  151638. get exposure(): number;
  151639. /**
  151640. * Sets the overall exposure used by the pipeline
  151641. */
  151642. set exposure(value: number);
  151643. /**
  151644. * Texture used typically to simulate "dirty" on camera lens
  151645. */
  151646. lensTexture: Nullable<Texture>;
  151647. /**
  151648. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  151649. */
  151650. volumetricLightCoefficient: number;
  151651. /**
  151652. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  151653. */
  151654. volumetricLightPower: number;
  151655. /**
  151656. * Used the set the blur intensity to smooth the volumetric lights
  151657. */
  151658. volumetricLightBlurScale: number;
  151659. /**
  151660. * Light (spot or directional) used to generate the volumetric lights rays
  151661. * The source light must have a shadow generate so the pipeline can get its
  151662. * depth map
  151663. */
  151664. sourceLight: Nullable<SpotLight | DirectionalLight>;
  151665. /**
  151666. * For eye adaptation, represents the minimum luminance the eye can see
  151667. */
  151668. hdrMinimumLuminance: number;
  151669. /**
  151670. * For eye adaptation, represents the decrease luminance speed
  151671. */
  151672. hdrDecreaseRate: number;
  151673. /**
  151674. * For eye adaptation, represents the increase luminance speed
  151675. */
  151676. hdrIncreaseRate: number;
  151677. /**
  151678. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151679. */
  151680. get hdrAutoExposure(): boolean;
  151681. /**
  151682. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151683. */
  151684. set hdrAutoExposure(value: boolean);
  151685. /**
  151686. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  151687. */
  151688. lensColorTexture: Nullable<Texture>;
  151689. /**
  151690. * The overall strengh for the lens flare effect
  151691. */
  151692. lensFlareStrength: number;
  151693. /**
  151694. * Dispersion coefficient for lens flare ghosts
  151695. */
  151696. lensFlareGhostDispersal: number;
  151697. /**
  151698. * Main lens flare halo width
  151699. */
  151700. lensFlareHaloWidth: number;
  151701. /**
  151702. * Based on the lens distortion effect, defines how much the lens flare result
  151703. * is distorted
  151704. */
  151705. lensFlareDistortionStrength: number;
  151706. /**
  151707. * Configures the blur intensity used for for lens flare (halo)
  151708. */
  151709. lensFlareBlurWidth: number;
  151710. /**
  151711. * Lens star texture must be used to simulate rays on the flares and is available
  151712. * in the documentation
  151713. */
  151714. lensStarTexture: Nullable<Texture>;
  151715. /**
  151716. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  151717. * flare effect by taking account of the dirt texture
  151718. */
  151719. lensFlareDirtTexture: Nullable<Texture>;
  151720. /**
  151721. * Represents the focal length for the depth of field effect
  151722. */
  151723. depthOfFieldDistance: number;
  151724. /**
  151725. * Represents the blur intensity for the blurred part of the depth of field effect
  151726. */
  151727. depthOfFieldBlurWidth: number;
  151728. /**
  151729. * Gets how much the image is blurred by the movement while using the motion blur post-process
  151730. */
  151731. get motionStrength(): number;
  151732. /**
  151733. * Sets how much the image is blurred by the movement while using the motion blur post-process
  151734. */
  151735. set motionStrength(strength: number);
  151736. /**
  151737. * Gets wether or not the motion blur post-process is object based or screen based.
  151738. */
  151739. get objectBasedMotionBlur(): boolean;
  151740. /**
  151741. * Sets wether or not the motion blur post-process should be object based or screen based
  151742. */
  151743. set objectBasedMotionBlur(value: boolean);
  151744. /**
  151745. * List of animations for the pipeline (IAnimatable implementation)
  151746. */
  151747. animations: Animation[];
  151748. /**
  151749. * Private members
  151750. */
  151751. private _scene;
  151752. private _currentDepthOfFieldSource;
  151753. private _basePostProcess;
  151754. private _fixedExposure;
  151755. private _currentExposure;
  151756. private _hdrAutoExposure;
  151757. private _hdrCurrentLuminance;
  151758. private _motionStrength;
  151759. private _isObjectBasedMotionBlur;
  151760. private _floatTextureType;
  151761. private _camerasToBeAttached;
  151762. private _ratio;
  151763. private _bloomEnabled;
  151764. private _depthOfFieldEnabled;
  151765. private _vlsEnabled;
  151766. private _lensFlareEnabled;
  151767. private _hdrEnabled;
  151768. private _motionBlurEnabled;
  151769. private _fxaaEnabled;
  151770. private _screenSpaceReflectionsEnabled;
  151771. private _motionBlurSamples;
  151772. private _volumetricLightStepsCount;
  151773. private _samples;
  151774. /**
  151775. * @ignore
  151776. * Specifies if the bloom pipeline is enabled
  151777. */
  151778. get BloomEnabled(): boolean;
  151779. set BloomEnabled(enabled: boolean);
  151780. /**
  151781. * @ignore
  151782. * Specifies if the depth of field pipeline is enabed
  151783. */
  151784. get DepthOfFieldEnabled(): boolean;
  151785. set DepthOfFieldEnabled(enabled: boolean);
  151786. /**
  151787. * @ignore
  151788. * Specifies if the lens flare pipeline is enabed
  151789. */
  151790. get LensFlareEnabled(): boolean;
  151791. set LensFlareEnabled(enabled: boolean);
  151792. /**
  151793. * @ignore
  151794. * Specifies if the HDR pipeline is enabled
  151795. */
  151796. get HDREnabled(): boolean;
  151797. set HDREnabled(enabled: boolean);
  151798. /**
  151799. * @ignore
  151800. * Specifies if the volumetric lights scattering effect is enabled
  151801. */
  151802. get VLSEnabled(): boolean;
  151803. set VLSEnabled(enabled: boolean);
  151804. /**
  151805. * @ignore
  151806. * Specifies if the motion blur effect is enabled
  151807. */
  151808. get MotionBlurEnabled(): boolean;
  151809. set MotionBlurEnabled(enabled: boolean);
  151810. /**
  151811. * Specifies if anti-aliasing is enabled
  151812. */
  151813. get fxaaEnabled(): boolean;
  151814. set fxaaEnabled(enabled: boolean);
  151815. /**
  151816. * Specifies if screen space reflections are enabled.
  151817. */
  151818. get screenSpaceReflectionsEnabled(): boolean;
  151819. set screenSpaceReflectionsEnabled(enabled: boolean);
  151820. /**
  151821. * Specifies the number of steps used to calculate the volumetric lights
  151822. * Typically in interval [50, 200]
  151823. */
  151824. get volumetricLightStepsCount(): number;
  151825. set volumetricLightStepsCount(count: number);
  151826. /**
  151827. * Specifies the number of samples used for the motion blur effect
  151828. * Typically in interval [16, 64]
  151829. */
  151830. get motionBlurSamples(): number;
  151831. set motionBlurSamples(samples: number);
  151832. /**
  151833. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151834. */
  151835. get samples(): number;
  151836. set samples(sampleCount: number);
  151837. /**
  151838. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151839. * @constructor
  151840. * @param name The rendering pipeline name
  151841. * @param scene The scene linked to this pipeline
  151842. * @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)
  151843. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  151844. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151845. */
  151846. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  151847. private _buildPipeline;
  151848. private _createDownSampleX4PostProcess;
  151849. private _createBrightPassPostProcess;
  151850. private _createBlurPostProcesses;
  151851. private _createTextureAdderPostProcess;
  151852. private _createVolumetricLightPostProcess;
  151853. private _createLuminancePostProcesses;
  151854. private _createHdrPostProcess;
  151855. private _createLensFlarePostProcess;
  151856. private _createDepthOfFieldPostProcess;
  151857. private _createMotionBlurPostProcess;
  151858. private _getDepthTexture;
  151859. private _disposePostProcesses;
  151860. /**
  151861. * Dispose of the pipeline and stop all post processes
  151862. */
  151863. dispose(): void;
  151864. /**
  151865. * Serialize the rendering pipeline (Used when exporting)
  151866. * @returns the serialized object
  151867. */
  151868. serialize(): any;
  151869. /**
  151870. * Parse the serialized pipeline
  151871. * @param source Source pipeline.
  151872. * @param scene The scene to load the pipeline to.
  151873. * @param rootUrl The URL of the serialized pipeline.
  151874. * @returns An instantiated pipeline from the serialized object.
  151875. */
  151876. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  151877. /**
  151878. * Luminance steps
  151879. */
  151880. static LuminanceSteps: number;
  151881. }
  151882. }
  151883. declare module BABYLON {
  151884. /** @hidden */
  151885. export var stereoscopicInterlacePixelShader: {
  151886. name: string;
  151887. shader: string;
  151888. };
  151889. }
  151890. declare module BABYLON {
  151891. /**
  151892. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  151893. */
  151894. export class StereoscopicInterlacePostProcessI extends PostProcess {
  151895. private _stepSize;
  151896. private _passedProcess;
  151897. /**
  151898. * Gets a string identifying the name of the class
  151899. * @returns "StereoscopicInterlacePostProcessI" string
  151900. */
  151901. getClassName(): string;
  151902. /**
  151903. * Initializes a StereoscopicInterlacePostProcessI
  151904. * @param name The name of the effect.
  151905. * @param rigCameras The rig cameras to be appled to the post process
  151906. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  151907. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  151908. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151909. * @param engine The engine which the post process will be applied. (default: current engine)
  151910. * @param reusable If the post process can be reused on the same frame. (default: false)
  151911. */
  151912. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151913. }
  151914. /**
  151915. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  151916. */
  151917. export class StereoscopicInterlacePostProcess extends PostProcess {
  151918. private _stepSize;
  151919. private _passedProcess;
  151920. /**
  151921. * Gets a string identifying the name of the class
  151922. * @returns "StereoscopicInterlacePostProcess" string
  151923. */
  151924. getClassName(): string;
  151925. /**
  151926. * Initializes a StereoscopicInterlacePostProcess
  151927. * @param name The name of the effect.
  151928. * @param rigCameras The rig cameras to be appled to the post process
  151929. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  151930. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151931. * @param engine The engine which the post process will be applied. (default: current engine)
  151932. * @param reusable If the post process can be reused on the same frame. (default: false)
  151933. */
  151934. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151935. }
  151936. }
  151937. declare module BABYLON {
  151938. /** @hidden */
  151939. export var tonemapPixelShader: {
  151940. name: string;
  151941. shader: string;
  151942. };
  151943. }
  151944. declare module BABYLON {
  151945. /** Defines operator used for tonemapping */
  151946. export enum TonemappingOperator {
  151947. /** Hable */
  151948. Hable = 0,
  151949. /** Reinhard */
  151950. Reinhard = 1,
  151951. /** HejiDawson */
  151952. HejiDawson = 2,
  151953. /** Photographic */
  151954. Photographic = 3
  151955. }
  151956. /**
  151957. * Defines a post process to apply tone mapping
  151958. */
  151959. export class TonemapPostProcess extends PostProcess {
  151960. private _operator;
  151961. /** Defines the required exposure adjustement */
  151962. exposureAdjustment: number;
  151963. /**
  151964. * Gets a string identifying the name of the class
  151965. * @returns "TonemapPostProcess" string
  151966. */
  151967. getClassName(): string;
  151968. /**
  151969. * Creates a new TonemapPostProcess
  151970. * @param name defines the name of the postprocess
  151971. * @param _operator defines the operator to use
  151972. * @param exposureAdjustment defines the required exposure adjustement
  151973. * @param camera defines the camera to use (can be null)
  151974. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  151975. * @param engine defines the hosting engine (can be ignore if camera is set)
  151976. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  151977. */
  151978. constructor(name: string, _operator: TonemappingOperator,
  151979. /** Defines the required exposure adjustement */
  151980. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  151981. }
  151982. }
  151983. declare module BABYLON {
  151984. /** @hidden */
  151985. export var volumetricLightScatteringPixelShader: {
  151986. name: string;
  151987. shader: string;
  151988. };
  151989. }
  151990. declare module BABYLON {
  151991. /** @hidden */
  151992. export var volumetricLightScatteringPassVertexShader: {
  151993. name: string;
  151994. shader: string;
  151995. };
  151996. }
  151997. declare module BABYLON {
  151998. /** @hidden */
  151999. export var volumetricLightScatteringPassPixelShader: {
  152000. name: string;
  152001. shader: string;
  152002. };
  152003. }
  152004. declare module BABYLON {
  152005. /**
  152006. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152007. */
  152008. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152009. private _volumetricLightScatteringPass;
  152010. private _volumetricLightScatteringRTT;
  152011. private _viewPort;
  152012. private _screenCoordinates;
  152013. private _cachedDefines;
  152014. /**
  152015. * If not undefined, the mesh position is computed from the attached node position
  152016. */
  152017. attachedNode: {
  152018. position: Vector3;
  152019. };
  152020. /**
  152021. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152022. */
  152023. customMeshPosition: Vector3;
  152024. /**
  152025. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152026. */
  152027. useCustomMeshPosition: boolean;
  152028. /**
  152029. * If the post-process should inverse the light scattering direction
  152030. */
  152031. invert: boolean;
  152032. /**
  152033. * The internal mesh used by the post-process
  152034. */
  152035. mesh: Mesh;
  152036. /**
  152037. * @hidden
  152038. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152039. */
  152040. get useDiffuseColor(): boolean;
  152041. set useDiffuseColor(useDiffuseColor: boolean);
  152042. /**
  152043. * Array containing the excluded meshes not rendered in the internal pass
  152044. */
  152045. excludedMeshes: AbstractMesh[];
  152046. /**
  152047. * Controls the overall intensity of the post-process
  152048. */
  152049. exposure: number;
  152050. /**
  152051. * Dissipates each sample's contribution in range [0, 1]
  152052. */
  152053. decay: number;
  152054. /**
  152055. * Controls the overall intensity of each sample
  152056. */
  152057. weight: number;
  152058. /**
  152059. * Controls the density of each sample
  152060. */
  152061. density: number;
  152062. /**
  152063. * @constructor
  152064. * @param name The post-process name
  152065. * @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)
  152066. * @param camera The camera that the post-process will be attached to
  152067. * @param mesh The mesh used to create the light scattering
  152068. * @param samples The post-process quality, default 100
  152069. * @param samplingModeThe post-process filtering mode
  152070. * @param engine The babylon engine
  152071. * @param reusable If the post-process is reusable
  152072. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152073. */
  152074. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152075. /**
  152076. * Returns the string "VolumetricLightScatteringPostProcess"
  152077. * @returns "VolumetricLightScatteringPostProcess"
  152078. */
  152079. getClassName(): string;
  152080. private _isReady;
  152081. /**
  152082. * Sets the new light position for light scattering effect
  152083. * @param position The new custom light position
  152084. */
  152085. setCustomMeshPosition(position: Vector3): void;
  152086. /**
  152087. * Returns the light position for light scattering effect
  152088. * @return Vector3 The custom light position
  152089. */
  152090. getCustomMeshPosition(): Vector3;
  152091. /**
  152092. * Disposes the internal assets and detaches the post-process from the camera
  152093. */
  152094. dispose(camera: Camera): void;
  152095. /**
  152096. * Returns the render target texture used by the post-process
  152097. * @return the render target texture used by the post-process
  152098. */
  152099. getPass(): RenderTargetTexture;
  152100. private _meshExcluded;
  152101. private _createPass;
  152102. private _updateMeshScreenCoordinates;
  152103. /**
  152104. * Creates a default mesh for the Volumeric Light Scattering post-process
  152105. * @param name The mesh name
  152106. * @param scene The scene where to create the mesh
  152107. * @return the default mesh
  152108. */
  152109. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  152110. }
  152111. }
  152112. declare module BABYLON {
  152113. /** @hidden */
  152114. export var screenSpaceCurvaturePixelShader: {
  152115. name: string;
  152116. shader: string;
  152117. };
  152118. }
  152119. declare module BABYLON {
  152120. /**
  152121. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  152122. */
  152123. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  152124. /**
  152125. * Defines how much ridge the curvature effect displays.
  152126. */
  152127. ridge: number;
  152128. /**
  152129. * Defines how much valley the curvature effect displays.
  152130. */
  152131. valley: number;
  152132. private _geometryBufferRenderer;
  152133. /**
  152134. * Gets a string identifying the name of the class
  152135. * @returns "ScreenSpaceCurvaturePostProcess" string
  152136. */
  152137. getClassName(): string;
  152138. /**
  152139. * Creates a new instance ScreenSpaceCurvaturePostProcess
  152140. * @param name The name of the effect.
  152141. * @param scene The scene containing the objects to blur according to their velocity.
  152142. * @param options The required width/height ratio to downsize to before computing the render pass.
  152143. * @param camera The camera to apply the render pass to.
  152144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152145. * @param engine The engine which the post process will be applied. (default: current engine)
  152146. * @param reusable If the post process can be reused on the same frame. (default: false)
  152147. * @param textureType Type of textures used when performing the post process. (default: 0)
  152148. * @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)
  152149. */
  152150. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152151. /**
  152152. * Support test.
  152153. */
  152154. static get IsSupported(): boolean;
  152155. /** @hidden */
  152156. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  152157. }
  152158. }
  152159. declare module BABYLON {
  152160. interface Scene {
  152161. /** @hidden (Backing field) */
  152162. _boundingBoxRenderer: BoundingBoxRenderer;
  152163. /** @hidden (Backing field) */
  152164. _forceShowBoundingBoxes: boolean;
  152165. /**
  152166. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  152167. */
  152168. forceShowBoundingBoxes: boolean;
  152169. /**
  152170. * Gets the bounding box renderer associated with the scene
  152171. * @returns a BoundingBoxRenderer
  152172. */
  152173. getBoundingBoxRenderer(): BoundingBoxRenderer;
  152174. }
  152175. interface AbstractMesh {
  152176. /** @hidden (Backing field) */
  152177. _showBoundingBox: boolean;
  152178. /**
  152179. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  152180. */
  152181. showBoundingBox: boolean;
  152182. }
  152183. /**
  152184. * Component responsible of rendering the bounding box of the meshes in a scene.
  152185. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  152186. */
  152187. export class BoundingBoxRenderer implements ISceneComponent {
  152188. /**
  152189. * The component name helpfull to identify the component in the list of scene components.
  152190. */
  152191. readonly name: string;
  152192. /**
  152193. * The scene the component belongs to.
  152194. */
  152195. scene: Scene;
  152196. /**
  152197. * Color of the bounding box lines placed in front of an object
  152198. */
  152199. frontColor: Color3;
  152200. /**
  152201. * Color of the bounding box lines placed behind an object
  152202. */
  152203. backColor: Color3;
  152204. /**
  152205. * Defines if the renderer should show the back lines or not
  152206. */
  152207. showBackLines: boolean;
  152208. /**
  152209. * Observable raised before rendering a bounding box
  152210. */
  152211. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  152212. /**
  152213. * Observable raised after rendering a bounding box
  152214. */
  152215. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  152216. /**
  152217. * @hidden
  152218. */
  152219. renderList: SmartArray<BoundingBox>;
  152220. private _colorShader;
  152221. private _vertexBuffers;
  152222. private _indexBuffer;
  152223. private _fillIndexBuffer;
  152224. private _fillIndexData;
  152225. /**
  152226. * Instantiates a new bounding box renderer in a scene.
  152227. * @param scene the scene the renderer renders in
  152228. */
  152229. constructor(scene: Scene);
  152230. /**
  152231. * Registers the component in a given scene
  152232. */
  152233. register(): void;
  152234. private _evaluateSubMesh;
  152235. private _activeMesh;
  152236. private _prepareRessources;
  152237. private _createIndexBuffer;
  152238. /**
  152239. * Rebuilds the elements related to this component in case of
  152240. * context lost for instance.
  152241. */
  152242. rebuild(): void;
  152243. /**
  152244. * @hidden
  152245. */
  152246. reset(): void;
  152247. /**
  152248. * Render the bounding boxes of a specific rendering group
  152249. * @param renderingGroupId defines the rendering group to render
  152250. */
  152251. render(renderingGroupId: number): void;
  152252. /**
  152253. * In case of occlusion queries, we can render the occlusion bounding box through this method
  152254. * @param mesh Define the mesh to render the occlusion bounding box for
  152255. */
  152256. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  152257. /**
  152258. * Dispose and release the resources attached to this renderer.
  152259. */
  152260. dispose(): void;
  152261. }
  152262. }
  152263. declare module BABYLON {
  152264. interface Scene {
  152265. /** @hidden (Backing field) */
  152266. _depthRenderer: {
  152267. [id: string]: DepthRenderer;
  152268. };
  152269. /**
  152270. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  152271. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  152272. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  152273. * @returns the created depth renderer
  152274. */
  152275. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  152276. /**
  152277. * Disables a depth renderer for a given camera
  152278. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  152279. */
  152280. disableDepthRenderer(camera?: Nullable<Camera>): void;
  152281. }
  152282. /**
  152283. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  152284. * in several rendering techniques.
  152285. */
  152286. export class DepthRendererSceneComponent implements ISceneComponent {
  152287. /**
  152288. * The component name helpfull to identify the component in the list of scene components.
  152289. */
  152290. readonly name: string;
  152291. /**
  152292. * The scene the component belongs to.
  152293. */
  152294. scene: Scene;
  152295. /**
  152296. * Creates a new instance of the component for the given scene
  152297. * @param scene Defines the scene to register the component in
  152298. */
  152299. constructor(scene: Scene);
  152300. /**
  152301. * Registers the component in a given scene
  152302. */
  152303. register(): void;
  152304. /**
  152305. * Rebuilds the elements related to this component in case of
  152306. * context lost for instance.
  152307. */
  152308. rebuild(): void;
  152309. /**
  152310. * Disposes the component and the associated ressources
  152311. */
  152312. dispose(): void;
  152313. private _gatherRenderTargets;
  152314. private _gatherActiveCameraRenderTargets;
  152315. }
  152316. }
  152317. declare module BABYLON {
  152318. interface AbstractScene {
  152319. /** @hidden (Backing field) */
  152320. _prePassRenderer: Nullable<PrePassRenderer>;
  152321. /**
  152322. * Gets or Sets the current prepass renderer associated to the scene.
  152323. */
  152324. prePassRenderer: Nullable<PrePassRenderer>;
  152325. /**
  152326. * Enables the prepass and associates it with the scene
  152327. * @returns the PrePassRenderer
  152328. */
  152329. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  152330. /**
  152331. * Disables the prepass associated with the scene
  152332. */
  152333. disablePrePassRenderer(): void;
  152334. }
  152335. /**
  152336. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152337. * in several rendering techniques.
  152338. */
  152339. export class PrePassRendererSceneComponent implements ISceneComponent {
  152340. /**
  152341. * The component name helpful to identify the component in the list of scene components.
  152342. */
  152343. readonly name: string;
  152344. /**
  152345. * The scene the component belongs to.
  152346. */
  152347. scene: Scene;
  152348. /**
  152349. * Creates a new instance of the component for the given scene
  152350. * @param scene Defines the scene to register the component in
  152351. */
  152352. constructor(scene: Scene);
  152353. /**
  152354. * Registers the component in a given scene
  152355. */
  152356. register(): void;
  152357. private _beforeCameraDraw;
  152358. private _afterCameraDraw;
  152359. private _beforeClearStage;
  152360. /**
  152361. * Rebuilds the elements related to this component in case of
  152362. * context lost for instance.
  152363. */
  152364. rebuild(): void;
  152365. /**
  152366. * Disposes the component and the associated ressources
  152367. */
  152368. dispose(): void;
  152369. }
  152370. }
  152371. declare module BABYLON {
  152372. /** @hidden */
  152373. export var fibonacci: {
  152374. name: string;
  152375. shader: string;
  152376. };
  152377. }
  152378. declare module BABYLON {
  152379. /** @hidden */
  152380. export var diffusionProfile: {
  152381. name: string;
  152382. shader: string;
  152383. };
  152384. }
  152385. declare module BABYLON {
  152386. /** @hidden */
  152387. export var subSurfaceScatteringPixelShader: {
  152388. name: string;
  152389. shader: string;
  152390. };
  152391. }
  152392. declare module BABYLON {
  152393. /**
  152394. * Sub surface scattering post process
  152395. */
  152396. export class SubSurfaceScatteringPostProcess extends PostProcess {
  152397. /**
  152398. * Gets a string identifying the name of the class
  152399. * @returns "SubSurfaceScatteringPostProcess" string
  152400. */
  152401. getClassName(): string;
  152402. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152403. }
  152404. }
  152405. declare module BABYLON {
  152406. /**
  152407. * Contains all parameters needed for the prepass to perform
  152408. * screen space subsurface scattering
  152409. */
  152410. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  152411. /** @hidden */
  152412. static _SceneComponentInitialization: (scene: Scene) => void;
  152413. private _ssDiffusionS;
  152414. private _ssFilterRadii;
  152415. private _ssDiffusionD;
  152416. /**
  152417. * Post process to attach for screen space subsurface scattering
  152418. */
  152419. postProcess: SubSurfaceScatteringPostProcess;
  152420. /**
  152421. * Diffusion profile color for subsurface scattering
  152422. */
  152423. get ssDiffusionS(): number[];
  152424. /**
  152425. * Diffusion profile max color channel value for subsurface scattering
  152426. */
  152427. get ssDiffusionD(): number[];
  152428. /**
  152429. * Diffusion profile filter radius for subsurface scattering
  152430. */
  152431. get ssFilterRadii(): number[];
  152432. /**
  152433. * Is subsurface enabled
  152434. */
  152435. enabled: boolean;
  152436. /**
  152437. * Name of the configuration
  152438. */
  152439. name: string;
  152440. /**
  152441. * Diffusion profile colors for subsurface scattering
  152442. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  152443. * See ...
  152444. * Note that you can only store up to 5 of them
  152445. */
  152446. ssDiffusionProfileColors: Color3[];
  152447. /**
  152448. * Defines the ratio real world => scene units.
  152449. * Used for subsurface scattering
  152450. */
  152451. metersPerUnit: number;
  152452. /**
  152453. * Textures that should be present in the MRT for this effect to work
  152454. */
  152455. readonly texturesRequired: number[];
  152456. private _scene;
  152457. /**
  152458. * Builds a subsurface configuration object
  152459. * @param scene The scene
  152460. */
  152461. constructor(scene: Scene);
  152462. /**
  152463. * Adds a new diffusion profile.
  152464. * Useful for more realistic subsurface scattering on diverse materials.
  152465. * @param color The color of the diffusion profile. Should be the average color of the material.
  152466. * @return The index of the diffusion profile for the material subsurface configuration
  152467. */
  152468. addDiffusionProfile(color: Color3): number;
  152469. /**
  152470. * Creates the sss post process
  152471. * @return The created post process
  152472. */
  152473. createPostProcess(): SubSurfaceScatteringPostProcess;
  152474. /**
  152475. * Deletes all diffusion profiles.
  152476. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  152477. */
  152478. clearAllDiffusionProfiles(): void;
  152479. /**
  152480. * Disposes this object
  152481. */
  152482. dispose(): void;
  152483. /**
  152484. * @hidden
  152485. * https://zero-radiance.github.io/post/sampling-diffusion/
  152486. *
  152487. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  152488. * ------------------------------------------------------------------------------------
  152489. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  152490. * PDF[r, phi, s] = r * R[r, phi, s]
  152491. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  152492. * ------------------------------------------------------------------------------------
  152493. * We importance sample the color channel with the widest scattering distance.
  152494. */
  152495. getDiffusionProfileParameters(color: Color3): number;
  152496. /**
  152497. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  152498. * 'u' is the random number (the value of the CDF): [0, 1).
  152499. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  152500. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  152501. */
  152502. private _sampleBurleyDiffusionProfile;
  152503. }
  152504. }
  152505. declare module BABYLON {
  152506. interface AbstractScene {
  152507. /** @hidden (Backing field) */
  152508. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152509. /**
  152510. * Gets or Sets the current prepass renderer associated to the scene.
  152511. */
  152512. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152513. /**
  152514. * Enables the subsurface effect for prepass
  152515. * @returns the SubSurfaceConfiguration
  152516. */
  152517. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  152518. /**
  152519. * Disables the subsurface effect for prepass
  152520. */
  152521. disableSubSurfaceForPrePass(): void;
  152522. }
  152523. /**
  152524. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152525. * in several rendering techniques.
  152526. */
  152527. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  152528. /**
  152529. * The component name helpful to identify the component in the list of scene components.
  152530. */
  152531. readonly name: string;
  152532. /**
  152533. * The scene the component belongs to.
  152534. */
  152535. scene: Scene;
  152536. /**
  152537. * Creates a new instance of the component for the given scene
  152538. * @param scene Defines the scene to register the component in
  152539. */
  152540. constructor(scene: Scene);
  152541. /**
  152542. * Registers the component in a given scene
  152543. */
  152544. register(): void;
  152545. /**
  152546. * Serializes the component data to the specified json object
  152547. * @param serializationObject The object to serialize to
  152548. */
  152549. serialize(serializationObject: any): void;
  152550. /**
  152551. * Adds all the elements from the container to the scene
  152552. * @param container the container holding the elements
  152553. */
  152554. addFromContainer(container: AbstractScene): void;
  152555. /**
  152556. * Removes all the elements in the container from the scene
  152557. * @param container contains the elements to remove
  152558. * @param dispose if the removed element should be disposed (default: false)
  152559. */
  152560. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  152561. /**
  152562. * Rebuilds the elements related to this component in case of
  152563. * context lost for instance.
  152564. */
  152565. rebuild(): void;
  152566. /**
  152567. * Disposes the component and the associated ressources
  152568. */
  152569. dispose(): void;
  152570. }
  152571. }
  152572. declare module BABYLON {
  152573. /** @hidden */
  152574. export var outlinePixelShader: {
  152575. name: string;
  152576. shader: string;
  152577. };
  152578. }
  152579. declare module BABYLON {
  152580. /** @hidden */
  152581. export var outlineVertexShader: {
  152582. name: string;
  152583. shader: string;
  152584. };
  152585. }
  152586. declare module BABYLON {
  152587. interface Scene {
  152588. /** @hidden */
  152589. _outlineRenderer: OutlineRenderer;
  152590. /**
  152591. * Gets the outline renderer associated with the scene
  152592. * @returns a OutlineRenderer
  152593. */
  152594. getOutlineRenderer(): OutlineRenderer;
  152595. }
  152596. interface AbstractMesh {
  152597. /** @hidden (Backing field) */
  152598. _renderOutline: boolean;
  152599. /**
  152600. * Gets or sets a boolean indicating if the outline must be rendered as well
  152601. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  152602. */
  152603. renderOutline: boolean;
  152604. /** @hidden (Backing field) */
  152605. _renderOverlay: boolean;
  152606. /**
  152607. * Gets or sets a boolean indicating if the overlay must be rendered as well
  152608. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  152609. */
  152610. renderOverlay: boolean;
  152611. }
  152612. /**
  152613. * This class is responsible to draw bothe outline/overlay of meshes.
  152614. * It should not be used directly but through the available method on mesh.
  152615. */
  152616. export class OutlineRenderer implements ISceneComponent {
  152617. /**
  152618. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  152619. */
  152620. private static _StencilReference;
  152621. /**
  152622. * The name of the component. Each component must have a unique name.
  152623. */
  152624. name: string;
  152625. /**
  152626. * The scene the component belongs to.
  152627. */
  152628. scene: Scene;
  152629. /**
  152630. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  152631. */
  152632. zOffset: number;
  152633. private _engine;
  152634. private _effect;
  152635. private _cachedDefines;
  152636. private _savedDepthWrite;
  152637. /**
  152638. * Instantiates a new outline renderer. (There could be only one per scene).
  152639. * @param scene Defines the scene it belongs to
  152640. */
  152641. constructor(scene: Scene);
  152642. /**
  152643. * Register the component to one instance of a scene.
  152644. */
  152645. register(): void;
  152646. /**
  152647. * Rebuilds the elements related to this component in case of
  152648. * context lost for instance.
  152649. */
  152650. rebuild(): void;
  152651. /**
  152652. * Disposes the component and the associated ressources.
  152653. */
  152654. dispose(): void;
  152655. /**
  152656. * Renders the outline in the canvas.
  152657. * @param subMesh Defines the sumesh to render
  152658. * @param batch Defines the batch of meshes in case of instances
  152659. * @param useOverlay Defines if the rendering is for the overlay or the outline
  152660. */
  152661. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  152662. /**
  152663. * Returns whether or not the outline renderer is ready for a given submesh.
  152664. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  152665. * @param subMesh Defines the submesh to check readyness for
  152666. * @param useInstances Defines wheter wee are trying to render instances or not
  152667. * @returns true if ready otherwise false
  152668. */
  152669. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  152670. private _beforeRenderingMesh;
  152671. private _afterRenderingMesh;
  152672. }
  152673. }
  152674. declare module BABYLON {
  152675. /**
  152676. * Defines the basic options interface of a Sprite Frame Source Size.
  152677. */
  152678. export interface ISpriteJSONSpriteSourceSize {
  152679. /**
  152680. * number of the original width of the Frame
  152681. */
  152682. w: number;
  152683. /**
  152684. * number of the original height of the Frame
  152685. */
  152686. h: number;
  152687. }
  152688. /**
  152689. * Defines the basic options interface of a Sprite Frame Data.
  152690. */
  152691. export interface ISpriteJSONSpriteFrameData {
  152692. /**
  152693. * number of the x offset of the Frame
  152694. */
  152695. x: number;
  152696. /**
  152697. * number of the y offset of the Frame
  152698. */
  152699. y: number;
  152700. /**
  152701. * number of the width of the Frame
  152702. */
  152703. w: number;
  152704. /**
  152705. * number of the height of the Frame
  152706. */
  152707. h: number;
  152708. }
  152709. /**
  152710. * Defines the basic options interface of a JSON Sprite.
  152711. */
  152712. export interface ISpriteJSONSprite {
  152713. /**
  152714. * string name of the Frame
  152715. */
  152716. filename: string;
  152717. /**
  152718. * ISpriteJSONSpriteFrame basic object of the frame data
  152719. */
  152720. frame: ISpriteJSONSpriteFrameData;
  152721. /**
  152722. * boolean to flag is the frame was rotated.
  152723. */
  152724. rotated: boolean;
  152725. /**
  152726. * boolean to flag is the frame was trimmed.
  152727. */
  152728. trimmed: boolean;
  152729. /**
  152730. * ISpriteJSONSpriteFrame basic object of the source data
  152731. */
  152732. spriteSourceSize: ISpriteJSONSpriteFrameData;
  152733. /**
  152734. * ISpriteJSONSpriteFrame basic object of the source data
  152735. */
  152736. sourceSize: ISpriteJSONSpriteSourceSize;
  152737. }
  152738. /**
  152739. * Defines the basic options interface of a JSON atlas.
  152740. */
  152741. export interface ISpriteJSONAtlas {
  152742. /**
  152743. * Array of objects that contain the frame data.
  152744. */
  152745. frames: Array<ISpriteJSONSprite>;
  152746. /**
  152747. * object basic object containing the sprite meta data.
  152748. */
  152749. meta?: object;
  152750. }
  152751. }
  152752. declare module BABYLON {
  152753. /** @hidden */
  152754. export var spriteMapPixelShader: {
  152755. name: string;
  152756. shader: string;
  152757. };
  152758. }
  152759. declare module BABYLON {
  152760. /** @hidden */
  152761. export var spriteMapVertexShader: {
  152762. name: string;
  152763. shader: string;
  152764. };
  152765. }
  152766. declare module BABYLON {
  152767. /**
  152768. * Defines the basic options interface of a SpriteMap
  152769. */
  152770. export interface ISpriteMapOptions {
  152771. /**
  152772. * Vector2 of the number of cells in the grid.
  152773. */
  152774. stageSize?: Vector2;
  152775. /**
  152776. * Vector2 of the size of the output plane in World Units.
  152777. */
  152778. outputSize?: Vector2;
  152779. /**
  152780. * Vector3 of the position of the output plane in World Units.
  152781. */
  152782. outputPosition?: Vector3;
  152783. /**
  152784. * Vector3 of the rotation of the output plane.
  152785. */
  152786. outputRotation?: Vector3;
  152787. /**
  152788. * number of layers that the system will reserve in resources.
  152789. */
  152790. layerCount?: number;
  152791. /**
  152792. * number of max animation frames a single cell will reserve in resources.
  152793. */
  152794. maxAnimationFrames?: number;
  152795. /**
  152796. * number cell index of the base tile when the system compiles.
  152797. */
  152798. baseTile?: number;
  152799. /**
  152800. * boolean flip the sprite after its been repositioned by the framing data.
  152801. */
  152802. flipU?: boolean;
  152803. /**
  152804. * Vector3 scalar of the global RGB values of the SpriteMap.
  152805. */
  152806. colorMultiply?: Vector3;
  152807. }
  152808. /**
  152809. * Defines the IDisposable interface in order to be cleanable from resources.
  152810. */
  152811. export interface ISpriteMap extends IDisposable {
  152812. /**
  152813. * String name of the SpriteMap.
  152814. */
  152815. name: string;
  152816. /**
  152817. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  152818. */
  152819. atlasJSON: ISpriteJSONAtlas;
  152820. /**
  152821. * Texture of the SpriteMap.
  152822. */
  152823. spriteSheet: Texture;
  152824. /**
  152825. * The parameters to initialize the SpriteMap with.
  152826. */
  152827. options: ISpriteMapOptions;
  152828. }
  152829. /**
  152830. * Class used to manage a grid restricted sprite deployment on an Output plane.
  152831. */
  152832. export class SpriteMap implements ISpriteMap {
  152833. /** The Name of the spriteMap */
  152834. name: string;
  152835. /** The JSON file with the frame and meta data */
  152836. atlasJSON: ISpriteJSONAtlas;
  152837. /** The systems Sprite Sheet Texture */
  152838. spriteSheet: Texture;
  152839. /** Arguments passed with the Constructor */
  152840. options: ISpriteMapOptions;
  152841. /** Public Sprite Storage array, parsed from atlasJSON */
  152842. sprites: Array<ISpriteJSONSprite>;
  152843. /** Returns the Number of Sprites in the System */
  152844. get spriteCount(): number;
  152845. /** Returns the Position of Output Plane*/
  152846. get position(): Vector3;
  152847. /** Returns the Position of Output Plane*/
  152848. set position(v: Vector3);
  152849. /** Returns the Rotation of Output Plane*/
  152850. get rotation(): Vector3;
  152851. /** Returns the Rotation of Output Plane*/
  152852. set rotation(v: Vector3);
  152853. /** Sets the AnimationMap*/
  152854. get animationMap(): RawTexture;
  152855. /** Sets the AnimationMap*/
  152856. set animationMap(v: RawTexture);
  152857. /** Scene that the SpriteMap was created in */
  152858. private _scene;
  152859. /** Texture Buffer of Float32 that holds tile frame data*/
  152860. private _frameMap;
  152861. /** Texture Buffers of Float32 that holds tileMap data*/
  152862. private _tileMaps;
  152863. /** Texture Buffer of Float32 that holds Animation Data*/
  152864. private _animationMap;
  152865. /** Custom ShaderMaterial Central to the System*/
  152866. private _material;
  152867. /** Custom ShaderMaterial Central to the System*/
  152868. private _output;
  152869. /** Systems Time Ticker*/
  152870. private _time;
  152871. /**
  152872. * Creates a new SpriteMap
  152873. * @param name defines the SpriteMaps Name
  152874. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  152875. * @param spriteSheet is the Texture that the Sprites are on.
  152876. * @param options a basic deployment configuration
  152877. * @param scene The Scene that the map is deployed on
  152878. */
  152879. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  152880. /**
  152881. * Returns tileID location
  152882. * @returns Vector2 the cell position ID
  152883. */
  152884. getTileID(): Vector2;
  152885. /**
  152886. * Gets the UV location of the mouse over the SpriteMap.
  152887. * @returns Vector2 the UV position of the mouse interaction
  152888. */
  152889. getMousePosition(): Vector2;
  152890. /**
  152891. * Creates the "frame" texture Buffer
  152892. * -------------------------------------
  152893. * Structure of frames
  152894. * "filename": "Falling-Water-2.png",
  152895. * "frame": {"x":69,"y":103,"w":24,"h":32},
  152896. * "rotated": true,
  152897. * "trimmed": true,
  152898. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  152899. * "sourceSize": {"w":32,"h":32}
  152900. * @returns RawTexture of the frameMap
  152901. */
  152902. private _createFrameBuffer;
  152903. /**
  152904. * Creates the tileMap texture Buffer
  152905. * @param buffer normally and array of numbers, or a false to generate from scratch
  152906. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  152907. * @returns RawTexture of the tileMap
  152908. */
  152909. private _createTileBuffer;
  152910. /**
  152911. * Modifies the data of the tileMaps
  152912. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  152913. * @param pos is the iVector2 Coordinates of the Tile
  152914. * @param tile The SpriteIndex of the new Tile
  152915. */
  152916. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  152917. /**
  152918. * Creates the animationMap texture Buffer
  152919. * @param buffer normally and array of numbers, or a false to generate from scratch
  152920. * @returns RawTexture of the animationMap
  152921. */
  152922. private _createTileAnimationBuffer;
  152923. /**
  152924. * Modifies the data of the animationMap
  152925. * @param cellID is the Index of the Sprite
  152926. * @param _frame is the target Animation frame
  152927. * @param toCell is the Target Index of the next frame of the animation
  152928. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  152929. * @param speed is a global scalar of the time variable on the map.
  152930. */
  152931. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  152932. /**
  152933. * Exports the .tilemaps file
  152934. */
  152935. saveTileMaps(): void;
  152936. /**
  152937. * Imports the .tilemaps file
  152938. * @param url of the .tilemaps file
  152939. */
  152940. loadTileMaps(url: string): void;
  152941. /**
  152942. * Release associated resources
  152943. */
  152944. dispose(): void;
  152945. }
  152946. }
  152947. declare module BABYLON {
  152948. /**
  152949. * Class used to manage multiple sprites of different sizes on the same spritesheet
  152950. * @see https://doc.babylonjs.com/babylon101/sprites
  152951. */
  152952. export class SpritePackedManager extends SpriteManager {
  152953. /** defines the packed manager's name */
  152954. name: string;
  152955. /**
  152956. * Creates a new sprite manager from a packed sprite sheet
  152957. * @param name defines the manager's name
  152958. * @param imgUrl defines the sprite sheet url
  152959. * @param capacity defines the maximum allowed number of sprites
  152960. * @param scene defines the hosting scene
  152961. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  152962. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  152963. * @param samplingMode defines the smapling mode to use with spritesheet
  152964. * @param fromPacked set to true; do not alter
  152965. */
  152966. constructor(
  152967. /** defines the packed manager's name */
  152968. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  152969. }
  152970. }
  152971. declare module BABYLON {
  152972. /**
  152973. * Defines the list of states available for a task inside a AssetsManager
  152974. */
  152975. export enum AssetTaskState {
  152976. /**
  152977. * Initialization
  152978. */
  152979. INIT = 0,
  152980. /**
  152981. * Running
  152982. */
  152983. RUNNING = 1,
  152984. /**
  152985. * Done
  152986. */
  152987. DONE = 2,
  152988. /**
  152989. * Error
  152990. */
  152991. ERROR = 3
  152992. }
  152993. /**
  152994. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  152995. */
  152996. export abstract class AbstractAssetTask {
  152997. /**
  152998. * Task name
  152999. */ name: string;
  153000. /**
  153001. * Callback called when the task is successful
  153002. */
  153003. onSuccess: (task: any) => void;
  153004. /**
  153005. * Callback called when the task is not successful
  153006. */
  153007. onError: (task: any, message?: string, exception?: any) => void;
  153008. /**
  153009. * Creates a new AssetsManager
  153010. * @param name defines the name of the task
  153011. */
  153012. constructor(
  153013. /**
  153014. * Task name
  153015. */ name: string);
  153016. private _isCompleted;
  153017. private _taskState;
  153018. private _errorObject;
  153019. /**
  153020. * Get if the task is completed
  153021. */
  153022. get isCompleted(): boolean;
  153023. /**
  153024. * Gets the current state of the task
  153025. */
  153026. get taskState(): AssetTaskState;
  153027. /**
  153028. * Gets the current error object (if task is in error)
  153029. */
  153030. get errorObject(): {
  153031. message?: string;
  153032. exception?: any;
  153033. };
  153034. /**
  153035. * Internal only
  153036. * @hidden
  153037. */
  153038. _setErrorObject(message?: string, exception?: any): void;
  153039. /**
  153040. * Execute the current task
  153041. * @param scene defines the scene where you want your assets to be loaded
  153042. * @param onSuccess is a callback called when the task is successfully executed
  153043. * @param onError is a callback called if an error occurs
  153044. */
  153045. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153046. /**
  153047. * Execute the current task
  153048. * @param scene defines the scene where you want your assets to be loaded
  153049. * @param onSuccess is a callback called when the task is successfully executed
  153050. * @param onError is a callback called if an error occurs
  153051. */
  153052. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153053. /**
  153054. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153055. * This can be used with failed tasks that have the reason for failure fixed.
  153056. */
  153057. reset(): void;
  153058. private onErrorCallback;
  153059. private onDoneCallback;
  153060. }
  153061. /**
  153062. * Define the interface used by progress events raised during assets loading
  153063. */
  153064. export interface IAssetsProgressEvent {
  153065. /**
  153066. * Defines the number of remaining tasks to process
  153067. */
  153068. remainingCount: number;
  153069. /**
  153070. * Defines the total number of tasks
  153071. */
  153072. totalCount: number;
  153073. /**
  153074. * Defines the task that was just processed
  153075. */
  153076. task: AbstractAssetTask;
  153077. }
  153078. /**
  153079. * Class used to share progress information about assets loading
  153080. */
  153081. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153082. /**
  153083. * Defines the number of remaining tasks to process
  153084. */
  153085. remainingCount: number;
  153086. /**
  153087. * Defines the total number of tasks
  153088. */
  153089. totalCount: number;
  153090. /**
  153091. * Defines the task that was just processed
  153092. */
  153093. task: AbstractAssetTask;
  153094. /**
  153095. * Creates a AssetsProgressEvent
  153096. * @param remainingCount defines the number of remaining tasks to process
  153097. * @param totalCount defines the total number of tasks
  153098. * @param task defines the task that was just processed
  153099. */
  153100. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  153101. }
  153102. /**
  153103. * Define a task used by AssetsManager to load assets into a container
  153104. */
  153105. export class ContainerAssetTask extends AbstractAssetTask {
  153106. /**
  153107. * Defines the name of the task
  153108. */
  153109. name: string;
  153110. /**
  153111. * Defines the list of mesh's names you want to load
  153112. */
  153113. meshesNames: any;
  153114. /**
  153115. * Defines the root url to use as a base to load your meshes and associated resources
  153116. */
  153117. rootUrl: string;
  153118. /**
  153119. * Defines the filename or File of the scene to load from
  153120. */
  153121. sceneFilename: string | File;
  153122. /**
  153123. * Get the loaded asset container
  153124. */
  153125. loadedContainer: AssetContainer;
  153126. /**
  153127. * Gets the list of loaded meshes
  153128. */
  153129. loadedMeshes: Array<AbstractMesh>;
  153130. /**
  153131. * Gets the list of loaded particle systems
  153132. */
  153133. loadedParticleSystems: Array<IParticleSystem>;
  153134. /**
  153135. * Gets the list of loaded skeletons
  153136. */
  153137. loadedSkeletons: Array<Skeleton>;
  153138. /**
  153139. * Gets the list of loaded animation groups
  153140. */
  153141. loadedAnimationGroups: Array<AnimationGroup>;
  153142. /**
  153143. * Callback called when the task is successful
  153144. */
  153145. onSuccess: (task: ContainerAssetTask) => void;
  153146. /**
  153147. * Callback called when the task is successful
  153148. */
  153149. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  153150. /**
  153151. * Creates a new ContainerAssetTask
  153152. * @param name defines the name of the task
  153153. * @param meshesNames defines the list of mesh's names you want to load
  153154. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153155. * @param sceneFilename defines the filename or File of the scene to load from
  153156. */
  153157. constructor(
  153158. /**
  153159. * Defines the name of the task
  153160. */
  153161. name: string,
  153162. /**
  153163. * Defines the list of mesh's names you want to load
  153164. */
  153165. meshesNames: any,
  153166. /**
  153167. * Defines the root url to use as a base to load your meshes and associated resources
  153168. */
  153169. rootUrl: string,
  153170. /**
  153171. * Defines the filename or File of the scene to load from
  153172. */
  153173. sceneFilename: string | File);
  153174. /**
  153175. * Execute the current task
  153176. * @param scene defines the scene where you want your assets to be loaded
  153177. * @param onSuccess is a callback called when the task is successfully executed
  153178. * @param onError is a callback called if an error occurs
  153179. */
  153180. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153181. }
  153182. /**
  153183. * Define a task used by AssetsManager to load meshes
  153184. */
  153185. export class MeshAssetTask extends AbstractAssetTask {
  153186. /**
  153187. * Defines the name of the task
  153188. */
  153189. name: string;
  153190. /**
  153191. * Defines the list of mesh's names you want to load
  153192. */
  153193. meshesNames: any;
  153194. /**
  153195. * Defines the root url to use as a base to load your meshes and associated resources
  153196. */
  153197. rootUrl: string;
  153198. /**
  153199. * Defines the filename or File of the scene to load from
  153200. */
  153201. sceneFilename: string | File;
  153202. /**
  153203. * Gets the list of loaded meshes
  153204. */
  153205. loadedMeshes: Array<AbstractMesh>;
  153206. /**
  153207. * Gets the list of loaded particle systems
  153208. */
  153209. loadedParticleSystems: Array<IParticleSystem>;
  153210. /**
  153211. * Gets the list of loaded skeletons
  153212. */
  153213. loadedSkeletons: Array<Skeleton>;
  153214. /**
  153215. * Gets the list of loaded animation groups
  153216. */
  153217. loadedAnimationGroups: Array<AnimationGroup>;
  153218. /**
  153219. * Callback called when the task is successful
  153220. */
  153221. onSuccess: (task: MeshAssetTask) => void;
  153222. /**
  153223. * Callback called when the task is successful
  153224. */
  153225. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  153226. /**
  153227. * Creates a new MeshAssetTask
  153228. * @param name defines the name of the task
  153229. * @param meshesNames defines the list of mesh's names you want to load
  153230. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153231. * @param sceneFilename defines the filename or File of the scene to load from
  153232. */
  153233. constructor(
  153234. /**
  153235. * Defines the name of the task
  153236. */
  153237. name: string,
  153238. /**
  153239. * Defines the list of mesh's names you want to load
  153240. */
  153241. meshesNames: any,
  153242. /**
  153243. * Defines the root url to use as a base to load your meshes and associated resources
  153244. */
  153245. rootUrl: string,
  153246. /**
  153247. * Defines the filename or File of the scene to load from
  153248. */
  153249. sceneFilename: string | File);
  153250. /**
  153251. * Execute the current task
  153252. * @param scene defines the scene where you want your assets to be loaded
  153253. * @param onSuccess is a callback called when the task is successfully executed
  153254. * @param onError is a callback called if an error occurs
  153255. */
  153256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153257. }
  153258. /**
  153259. * Define a task used by AssetsManager to load text content
  153260. */
  153261. export class TextFileAssetTask extends AbstractAssetTask {
  153262. /**
  153263. * Defines the name of the task
  153264. */
  153265. name: string;
  153266. /**
  153267. * Defines the location of the file to load
  153268. */
  153269. url: string;
  153270. /**
  153271. * Gets the loaded text string
  153272. */
  153273. text: string;
  153274. /**
  153275. * Callback called when the task is successful
  153276. */
  153277. onSuccess: (task: TextFileAssetTask) => void;
  153278. /**
  153279. * Callback called when the task is successful
  153280. */
  153281. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  153282. /**
  153283. * Creates a new TextFileAssetTask object
  153284. * @param name defines the name of the task
  153285. * @param url defines the location of the file to load
  153286. */
  153287. constructor(
  153288. /**
  153289. * Defines the name of the task
  153290. */
  153291. name: string,
  153292. /**
  153293. * Defines the location of the file to load
  153294. */
  153295. url: string);
  153296. /**
  153297. * Execute the current task
  153298. * @param scene defines the scene where you want your assets to be loaded
  153299. * @param onSuccess is a callback called when the task is successfully executed
  153300. * @param onError is a callback called if an error occurs
  153301. */
  153302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153303. }
  153304. /**
  153305. * Define a task used by AssetsManager to load binary data
  153306. */
  153307. export class BinaryFileAssetTask extends AbstractAssetTask {
  153308. /**
  153309. * Defines the name of the task
  153310. */
  153311. name: string;
  153312. /**
  153313. * Defines the location of the file to load
  153314. */
  153315. url: string;
  153316. /**
  153317. * Gets the lodaded data (as an array buffer)
  153318. */
  153319. data: ArrayBuffer;
  153320. /**
  153321. * Callback called when the task is successful
  153322. */
  153323. onSuccess: (task: BinaryFileAssetTask) => void;
  153324. /**
  153325. * Callback called when the task is successful
  153326. */
  153327. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  153328. /**
  153329. * Creates a new BinaryFileAssetTask object
  153330. * @param name defines the name of the new task
  153331. * @param url defines the location of the file to load
  153332. */
  153333. constructor(
  153334. /**
  153335. * Defines the name of the task
  153336. */
  153337. name: string,
  153338. /**
  153339. * Defines the location of the file to load
  153340. */
  153341. url: string);
  153342. /**
  153343. * Execute the current task
  153344. * @param scene defines the scene where you want your assets to be loaded
  153345. * @param onSuccess is a callback called when the task is successfully executed
  153346. * @param onError is a callback called if an error occurs
  153347. */
  153348. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153349. }
  153350. /**
  153351. * Define a task used by AssetsManager to load images
  153352. */
  153353. export class ImageAssetTask extends AbstractAssetTask {
  153354. /**
  153355. * Defines the name of the task
  153356. */
  153357. name: string;
  153358. /**
  153359. * Defines the location of the image to load
  153360. */
  153361. url: string;
  153362. /**
  153363. * Gets the loaded images
  153364. */
  153365. image: HTMLImageElement;
  153366. /**
  153367. * Callback called when the task is successful
  153368. */
  153369. onSuccess: (task: ImageAssetTask) => void;
  153370. /**
  153371. * Callback called when the task is successful
  153372. */
  153373. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  153374. /**
  153375. * Creates a new ImageAssetTask
  153376. * @param name defines the name of the task
  153377. * @param url defines the location of the image to load
  153378. */
  153379. constructor(
  153380. /**
  153381. * Defines the name of the task
  153382. */
  153383. name: string,
  153384. /**
  153385. * Defines the location of the image to load
  153386. */
  153387. url: string);
  153388. /**
  153389. * Execute the current task
  153390. * @param scene defines the scene where you want your assets to be loaded
  153391. * @param onSuccess is a callback called when the task is successfully executed
  153392. * @param onError is a callback called if an error occurs
  153393. */
  153394. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153395. }
  153396. /**
  153397. * Defines the interface used by texture loading tasks
  153398. */
  153399. export interface ITextureAssetTask<TEX extends BaseTexture> {
  153400. /**
  153401. * Gets the loaded texture
  153402. */
  153403. texture: TEX;
  153404. }
  153405. /**
  153406. * Define a task used by AssetsManager to load 2D textures
  153407. */
  153408. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  153409. /**
  153410. * Defines the name of the task
  153411. */
  153412. name: string;
  153413. /**
  153414. * Defines the location of the file to load
  153415. */
  153416. url: string;
  153417. /**
  153418. * Defines if mipmap should not be generated (default is false)
  153419. */
  153420. noMipmap?: boolean | undefined;
  153421. /**
  153422. * Defines if texture must be inverted on Y axis (default is true)
  153423. */
  153424. invertY: boolean;
  153425. /**
  153426. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153427. */
  153428. samplingMode: number;
  153429. /**
  153430. * Gets the loaded texture
  153431. */
  153432. texture: Texture;
  153433. /**
  153434. * Callback called when the task is successful
  153435. */
  153436. onSuccess: (task: TextureAssetTask) => void;
  153437. /**
  153438. * Callback called when the task is successful
  153439. */
  153440. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  153441. /**
  153442. * Creates a new TextureAssetTask object
  153443. * @param name defines the name of the task
  153444. * @param url defines the location of the file to load
  153445. * @param noMipmap defines if mipmap should not be generated (default is false)
  153446. * @param invertY defines if texture must be inverted on Y axis (default is true)
  153447. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153448. */
  153449. constructor(
  153450. /**
  153451. * Defines the name of the task
  153452. */
  153453. name: string,
  153454. /**
  153455. * Defines the location of the file to load
  153456. */
  153457. url: string,
  153458. /**
  153459. * Defines if mipmap should not be generated (default is false)
  153460. */
  153461. noMipmap?: boolean | undefined,
  153462. /**
  153463. * Defines if texture must be inverted on Y axis (default is true)
  153464. */
  153465. invertY?: boolean,
  153466. /**
  153467. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153468. */
  153469. samplingMode?: number);
  153470. /**
  153471. * Execute the current task
  153472. * @param scene defines the scene where you want your assets to be loaded
  153473. * @param onSuccess is a callback called when the task is successfully executed
  153474. * @param onError is a callback called if an error occurs
  153475. */
  153476. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153477. }
  153478. /**
  153479. * Define a task used by AssetsManager to load cube textures
  153480. */
  153481. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  153482. /**
  153483. * Defines the name of the task
  153484. */
  153485. name: string;
  153486. /**
  153487. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153488. */
  153489. url: string;
  153490. /**
  153491. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153492. */
  153493. extensions?: string[] | undefined;
  153494. /**
  153495. * Defines if mipmaps should not be generated (default is false)
  153496. */
  153497. noMipmap?: boolean | undefined;
  153498. /**
  153499. * Defines the explicit list of files (undefined by default)
  153500. */
  153501. files?: string[] | undefined;
  153502. /**
  153503. * Gets the loaded texture
  153504. */
  153505. texture: CubeTexture;
  153506. /**
  153507. * Callback called when the task is successful
  153508. */
  153509. onSuccess: (task: CubeTextureAssetTask) => void;
  153510. /**
  153511. * Callback called when the task is successful
  153512. */
  153513. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  153514. /**
  153515. * Creates a new CubeTextureAssetTask
  153516. * @param name defines the name of the task
  153517. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153518. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153519. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153520. * @param files defines the explicit list of files (undefined by default)
  153521. */
  153522. constructor(
  153523. /**
  153524. * Defines the name of the task
  153525. */
  153526. name: string,
  153527. /**
  153528. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153529. */
  153530. url: string,
  153531. /**
  153532. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153533. */
  153534. extensions?: string[] | undefined,
  153535. /**
  153536. * Defines if mipmaps should not be generated (default is false)
  153537. */
  153538. noMipmap?: boolean | undefined,
  153539. /**
  153540. * Defines the explicit list of files (undefined by default)
  153541. */
  153542. files?: string[] | undefined);
  153543. /**
  153544. * Execute the current task
  153545. * @param scene defines the scene where you want your assets to be loaded
  153546. * @param onSuccess is a callback called when the task is successfully executed
  153547. * @param onError is a callback called if an error occurs
  153548. */
  153549. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153550. }
  153551. /**
  153552. * Define a task used by AssetsManager to load HDR cube textures
  153553. */
  153554. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  153555. /**
  153556. * Defines the name of the task
  153557. */
  153558. name: string;
  153559. /**
  153560. * Defines the location of the file to load
  153561. */
  153562. url: string;
  153563. /**
  153564. * Defines the desired size (the more it increases the longer the generation will be)
  153565. */
  153566. size: number;
  153567. /**
  153568. * Defines if mipmaps should not be generated (default is false)
  153569. */
  153570. noMipmap: boolean;
  153571. /**
  153572. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153573. */
  153574. generateHarmonics: boolean;
  153575. /**
  153576. * 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)
  153577. */
  153578. gammaSpace: boolean;
  153579. /**
  153580. * Internal Use Only
  153581. */
  153582. reserved: boolean;
  153583. /**
  153584. * Gets the loaded texture
  153585. */
  153586. texture: HDRCubeTexture;
  153587. /**
  153588. * Callback called when the task is successful
  153589. */
  153590. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  153591. /**
  153592. * Callback called when the task is successful
  153593. */
  153594. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  153595. /**
  153596. * Creates a new HDRCubeTextureAssetTask object
  153597. * @param name defines the name of the task
  153598. * @param url defines the location of the file to load
  153599. * @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.
  153600. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153601. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153602. * @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)
  153603. * @param reserved Internal use only
  153604. */
  153605. constructor(
  153606. /**
  153607. * Defines the name of the task
  153608. */
  153609. name: string,
  153610. /**
  153611. * Defines the location of the file to load
  153612. */
  153613. url: string,
  153614. /**
  153615. * Defines the desired size (the more it increases the longer the generation will be)
  153616. */
  153617. size: number,
  153618. /**
  153619. * Defines if mipmaps should not be generated (default is false)
  153620. */
  153621. noMipmap?: boolean,
  153622. /**
  153623. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153624. */
  153625. generateHarmonics?: boolean,
  153626. /**
  153627. * 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)
  153628. */
  153629. gammaSpace?: boolean,
  153630. /**
  153631. * Internal Use Only
  153632. */
  153633. reserved?: boolean);
  153634. /**
  153635. * Execute the current task
  153636. * @param scene defines the scene where you want your assets to be loaded
  153637. * @param onSuccess is a callback called when the task is successfully executed
  153638. * @param onError is a callback called if an error occurs
  153639. */
  153640. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153641. }
  153642. /**
  153643. * Define a task used by AssetsManager to load Equirectangular cube textures
  153644. */
  153645. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  153646. /**
  153647. * Defines the name of the task
  153648. */
  153649. name: string;
  153650. /**
  153651. * Defines the location of the file to load
  153652. */
  153653. url: string;
  153654. /**
  153655. * Defines the desired size (the more it increases the longer the generation will be)
  153656. */
  153657. size: number;
  153658. /**
  153659. * Defines if mipmaps should not be generated (default is false)
  153660. */
  153661. noMipmap: boolean;
  153662. /**
  153663. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153664. * but the standard material would require them in Gamma space) (default is true)
  153665. */
  153666. gammaSpace: boolean;
  153667. /**
  153668. * Gets the loaded texture
  153669. */
  153670. texture: EquiRectangularCubeTexture;
  153671. /**
  153672. * Callback called when the task is successful
  153673. */
  153674. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  153675. /**
  153676. * Callback called when the task is successful
  153677. */
  153678. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  153679. /**
  153680. * Creates a new EquiRectangularCubeTextureAssetTask object
  153681. * @param name defines the name of the task
  153682. * @param url defines the location of the file to load
  153683. * @param size defines the desired size (the more it increases the longer the generation will be)
  153684. * If the size is omitted this implies you are using a preprocessed cubemap.
  153685. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153686. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  153687. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  153688. * (default is true)
  153689. */
  153690. constructor(
  153691. /**
  153692. * Defines the name of the task
  153693. */
  153694. name: string,
  153695. /**
  153696. * Defines the location of the file to load
  153697. */
  153698. url: string,
  153699. /**
  153700. * Defines the desired size (the more it increases the longer the generation will be)
  153701. */
  153702. size: number,
  153703. /**
  153704. * Defines if mipmaps should not be generated (default is false)
  153705. */
  153706. noMipmap?: boolean,
  153707. /**
  153708. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153709. * but the standard material would require them in Gamma space) (default is true)
  153710. */
  153711. gammaSpace?: boolean);
  153712. /**
  153713. * Execute the current task
  153714. * @param scene defines the scene where you want your assets to be loaded
  153715. * @param onSuccess is a callback called when the task is successfully executed
  153716. * @param onError is a callback called if an error occurs
  153717. */
  153718. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153719. }
  153720. /**
  153721. * This class can be used to easily import assets into a scene
  153722. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  153723. */
  153724. export class AssetsManager {
  153725. private _scene;
  153726. private _isLoading;
  153727. protected _tasks: AbstractAssetTask[];
  153728. protected _waitingTasksCount: number;
  153729. protected _totalTasksCount: number;
  153730. /**
  153731. * Callback called when all tasks are processed
  153732. */
  153733. onFinish: (tasks: AbstractAssetTask[]) => void;
  153734. /**
  153735. * Callback called when a task is successful
  153736. */
  153737. onTaskSuccess: (task: AbstractAssetTask) => void;
  153738. /**
  153739. * Callback called when a task had an error
  153740. */
  153741. onTaskError: (task: AbstractAssetTask) => void;
  153742. /**
  153743. * Callback called when a task is done (whatever the result is)
  153744. */
  153745. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  153746. /**
  153747. * Observable called when all tasks are processed
  153748. */
  153749. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  153750. /**
  153751. * Observable called when a task had an error
  153752. */
  153753. onTaskErrorObservable: Observable<AbstractAssetTask>;
  153754. /**
  153755. * Observable called when all tasks were executed
  153756. */
  153757. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  153758. /**
  153759. * Observable called when a task is done (whatever the result is)
  153760. */
  153761. onProgressObservable: Observable<IAssetsProgressEvent>;
  153762. /**
  153763. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  153764. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  153765. */
  153766. useDefaultLoadingScreen: boolean;
  153767. /**
  153768. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  153769. * when all assets have been downloaded.
  153770. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  153771. */
  153772. autoHideLoadingUI: boolean;
  153773. /**
  153774. * Creates a new AssetsManager
  153775. * @param scene defines the scene to work on
  153776. */
  153777. constructor(scene: Scene);
  153778. /**
  153779. * Add a ContainerAssetTask to the list of active tasks
  153780. * @param taskName defines the name of the new task
  153781. * @param meshesNames defines the name of meshes to load
  153782. * @param rootUrl defines the root url to use to locate files
  153783. * @param sceneFilename defines the filename of the scene file
  153784. * @returns a new ContainerAssetTask object
  153785. */
  153786. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  153787. /**
  153788. * Add a MeshAssetTask to the list of active tasks
  153789. * @param taskName defines the name of the new task
  153790. * @param meshesNames defines the name of meshes to load
  153791. * @param rootUrl defines the root url to use to locate files
  153792. * @param sceneFilename defines the filename of the scene file
  153793. * @returns a new MeshAssetTask object
  153794. */
  153795. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  153796. /**
  153797. * Add a TextFileAssetTask to the list of active tasks
  153798. * @param taskName defines the name of the new task
  153799. * @param url defines the url of the file to load
  153800. * @returns a new TextFileAssetTask object
  153801. */
  153802. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  153803. /**
  153804. * Add a BinaryFileAssetTask to the list of active tasks
  153805. * @param taskName defines the name of the new task
  153806. * @param url defines the url of the file to load
  153807. * @returns a new BinaryFileAssetTask object
  153808. */
  153809. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  153810. /**
  153811. * Add a ImageAssetTask to the list of active tasks
  153812. * @param taskName defines the name of the new task
  153813. * @param url defines the url of the file to load
  153814. * @returns a new ImageAssetTask object
  153815. */
  153816. addImageTask(taskName: string, url: string): ImageAssetTask;
  153817. /**
  153818. * Add a TextureAssetTask to the list of active tasks
  153819. * @param taskName defines the name of the new task
  153820. * @param url defines the url of the file to load
  153821. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153822. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  153823. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  153824. * @returns a new TextureAssetTask object
  153825. */
  153826. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  153827. /**
  153828. * Add a CubeTextureAssetTask to the list of active tasks
  153829. * @param taskName defines the name of the new task
  153830. * @param url defines the url of the file to load
  153831. * @param extensions defines the extension to use to load the cube map (can be null)
  153832. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153833. * @param files defines the list of files to load (can be null)
  153834. * @returns a new CubeTextureAssetTask object
  153835. */
  153836. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  153837. /**
  153838. *
  153839. * Add a HDRCubeTextureAssetTask to the list of active tasks
  153840. * @param taskName defines the name of the new task
  153841. * @param url defines the url of the file to load
  153842. * @param size defines the size you want for the cubemap (can be null)
  153843. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153844. * @param generateHarmonics defines if you want to automatically generate (true by default)
  153845. * @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)
  153846. * @param reserved Internal use only
  153847. * @returns a new HDRCubeTextureAssetTask object
  153848. */
  153849. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  153850. /**
  153851. *
  153852. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  153853. * @param taskName defines the name of the new task
  153854. * @param url defines the url of the file to load
  153855. * @param size defines the size you want for the cubemap (can be null)
  153856. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153857. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  153858. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  153859. * @returns a new EquiRectangularCubeTextureAssetTask object
  153860. */
  153861. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  153862. /**
  153863. * Remove a task from the assets manager.
  153864. * @param task the task to remove
  153865. */
  153866. removeTask(task: AbstractAssetTask): void;
  153867. private _decreaseWaitingTasksCount;
  153868. private _runTask;
  153869. /**
  153870. * Reset the AssetsManager and remove all tasks
  153871. * @return the current instance of the AssetsManager
  153872. */
  153873. reset(): AssetsManager;
  153874. /**
  153875. * Start the loading process
  153876. * @return the current instance of the AssetsManager
  153877. */
  153878. load(): AssetsManager;
  153879. /**
  153880. * Start the loading process as an async operation
  153881. * @return a promise returning the list of failed tasks
  153882. */
  153883. loadAsync(): Promise<void>;
  153884. }
  153885. }
  153886. declare module BABYLON {
  153887. /**
  153888. * Wrapper class for promise with external resolve and reject.
  153889. */
  153890. export class Deferred<T> {
  153891. /**
  153892. * The promise associated with this deferred object.
  153893. */
  153894. readonly promise: Promise<T>;
  153895. private _resolve;
  153896. private _reject;
  153897. /**
  153898. * The resolve method of the promise associated with this deferred object.
  153899. */
  153900. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  153901. /**
  153902. * The reject method of the promise associated with this deferred object.
  153903. */
  153904. get reject(): (reason?: any) => void;
  153905. /**
  153906. * Constructor for this deferred object.
  153907. */
  153908. constructor();
  153909. }
  153910. }
  153911. declare module BABYLON {
  153912. /**
  153913. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  153914. */
  153915. export class MeshExploder {
  153916. private _centerMesh;
  153917. private _meshes;
  153918. private _meshesOrigins;
  153919. private _toCenterVectors;
  153920. private _scaledDirection;
  153921. private _newPosition;
  153922. private _centerPosition;
  153923. /**
  153924. * Explodes meshes from a center mesh.
  153925. * @param meshes The meshes to explode.
  153926. * @param centerMesh The mesh to be center of explosion.
  153927. */
  153928. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  153929. private _setCenterMesh;
  153930. /**
  153931. * Get class name
  153932. * @returns "MeshExploder"
  153933. */
  153934. getClassName(): string;
  153935. /**
  153936. * "Exploded meshes"
  153937. * @returns Array of meshes with the centerMesh at index 0.
  153938. */
  153939. getMeshes(): Array<Mesh>;
  153940. /**
  153941. * Explodes meshes giving a specific direction
  153942. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  153943. */
  153944. explode(direction?: number): void;
  153945. }
  153946. }
  153947. declare module BABYLON {
  153948. /**
  153949. * Class used to help managing file picking and drag'n'drop
  153950. */
  153951. export class FilesInput {
  153952. /**
  153953. * List of files ready to be loaded
  153954. */
  153955. static get FilesToLoad(): {
  153956. [key: string]: File;
  153957. };
  153958. /**
  153959. * Callback called when a file is processed
  153960. */
  153961. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  153962. private _engine;
  153963. private _currentScene;
  153964. private _sceneLoadedCallback;
  153965. private _progressCallback;
  153966. private _additionalRenderLoopLogicCallback;
  153967. private _textureLoadingCallback;
  153968. private _startingProcessingFilesCallback;
  153969. private _onReloadCallback;
  153970. private _errorCallback;
  153971. private _elementToMonitor;
  153972. private _sceneFileToLoad;
  153973. private _filesToLoad;
  153974. /**
  153975. * Creates a new FilesInput
  153976. * @param engine defines the rendering engine
  153977. * @param scene defines the hosting scene
  153978. * @param sceneLoadedCallback callback called when scene is loaded
  153979. * @param progressCallback callback called to track progress
  153980. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  153981. * @param textureLoadingCallback callback called when a texture is loading
  153982. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  153983. * @param onReloadCallback callback called when a reload is requested
  153984. * @param errorCallback callback call if an error occurs
  153985. */
  153986. 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>);
  153987. private _dragEnterHandler;
  153988. private _dragOverHandler;
  153989. private _dropHandler;
  153990. /**
  153991. * Calls this function to listen to drag'n'drop events on a specific DOM element
  153992. * @param elementToMonitor defines the DOM element to track
  153993. */
  153994. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  153995. /** Gets the current list of files to load */
  153996. get filesToLoad(): File[];
  153997. /**
  153998. * Release all associated resources
  153999. */
  154000. dispose(): void;
  154001. private renderFunction;
  154002. private drag;
  154003. private drop;
  154004. private _traverseFolder;
  154005. private _processFiles;
  154006. /**
  154007. * Load files from a drop event
  154008. * @param event defines the drop event to use as source
  154009. */
  154010. loadFiles(event: any): void;
  154011. private _processReload;
  154012. /**
  154013. * Reload the current scene from the loaded files
  154014. */
  154015. reload(): void;
  154016. }
  154017. }
  154018. declare module BABYLON {
  154019. /**
  154020. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154021. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154022. */
  154023. export class SceneOptimization {
  154024. /**
  154025. * Defines the priority of this optimization (0 by default which means first in the list)
  154026. */
  154027. priority: number;
  154028. /**
  154029. * Gets a string describing the action executed by the current optimization
  154030. * @returns description string
  154031. */
  154032. getDescription(): string;
  154033. /**
  154034. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154035. * @param scene defines the current scene where to apply this optimization
  154036. * @param optimizer defines the current optimizer
  154037. * @returns true if everything that can be done was applied
  154038. */
  154039. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154040. /**
  154041. * Creates the SceneOptimization object
  154042. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154043. * @param desc defines the description associated with the optimization
  154044. */
  154045. constructor(
  154046. /**
  154047. * Defines the priority of this optimization (0 by default which means first in the list)
  154048. */
  154049. priority?: number);
  154050. }
  154051. /**
  154052. * Defines an optimization used to reduce the size of render target textures
  154053. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154054. */
  154055. export class TextureOptimization extends SceneOptimization {
  154056. /**
  154057. * Defines the priority of this optimization (0 by default which means first in the list)
  154058. */
  154059. priority: number;
  154060. /**
  154061. * 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
  154062. */
  154063. maximumSize: number;
  154064. /**
  154065. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154066. */
  154067. step: number;
  154068. /**
  154069. * Gets a string describing the action executed by the current optimization
  154070. * @returns description string
  154071. */
  154072. getDescription(): string;
  154073. /**
  154074. * Creates the TextureOptimization object
  154075. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154076. * @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
  154077. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154078. */
  154079. constructor(
  154080. /**
  154081. * Defines the priority of this optimization (0 by default which means first in the list)
  154082. */
  154083. priority?: number,
  154084. /**
  154085. * 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
  154086. */
  154087. maximumSize?: number,
  154088. /**
  154089. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154090. */
  154091. step?: number);
  154092. /**
  154093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154094. * @param scene defines the current scene where to apply this optimization
  154095. * @param optimizer defines the current optimizer
  154096. * @returns true if everything that can be done was applied
  154097. */
  154098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154099. }
  154100. /**
  154101. * Defines an optimization used to increase or decrease the rendering resolution
  154102. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154103. */
  154104. export class HardwareScalingOptimization extends SceneOptimization {
  154105. /**
  154106. * Defines the priority of this optimization (0 by default which means first in the list)
  154107. */
  154108. priority: number;
  154109. /**
  154110. * Defines the maximum scale to use (2 by default)
  154111. */
  154112. maximumScale: number;
  154113. /**
  154114. * Defines the step to use between two passes (0.5 by default)
  154115. */
  154116. step: number;
  154117. private _currentScale;
  154118. private _directionOffset;
  154119. /**
  154120. * Gets a string describing the action executed by the current optimization
  154121. * @return description string
  154122. */
  154123. getDescription(): string;
  154124. /**
  154125. * Creates the HardwareScalingOptimization object
  154126. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154127. * @param maximumScale defines the maximum scale to use (2 by default)
  154128. * @param step defines the step to use between two passes (0.5 by default)
  154129. */
  154130. constructor(
  154131. /**
  154132. * Defines the priority of this optimization (0 by default which means first in the list)
  154133. */
  154134. priority?: number,
  154135. /**
  154136. * Defines the maximum scale to use (2 by default)
  154137. */
  154138. maximumScale?: number,
  154139. /**
  154140. * Defines the step to use between two passes (0.5 by default)
  154141. */
  154142. step?: number);
  154143. /**
  154144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154145. * @param scene defines the current scene where to apply this optimization
  154146. * @param optimizer defines the current optimizer
  154147. * @returns true if everything that can be done was applied
  154148. */
  154149. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154150. }
  154151. /**
  154152. * Defines an optimization used to remove shadows
  154153. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154154. */
  154155. export class ShadowsOptimization extends SceneOptimization {
  154156. /**
  154157. * Gets a string describing the action executed by the current optimization
  154158. * @return description string
  154159. */
  154160. getDescription(): string;
  154161. /**
  154162. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154163. * @param scene defines the current scene where to apply this optimization
  154164. * @param optimizer defines the current optimizer
  154165. * @returns true if everything that can be done was applied
  154166. */
  154167. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154168. }
  154169. /**
  154170. * Defines an optimization used to turn post-processes off
  154171. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154172. */
  154173. export class PostProcessesOptimization extends SceneOptimization {
  154174. /**
  154175. * Gets a string describing the action executed by the current optimization
  154176. * @return description string
  154177. */
  154178. getDescription(): string;
  154179. /**
  154180. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154181. * @param scene defines the current scene where to apply this optimization
  154182. * @param optimizer defines the current optimizer
  154183. * @returns true if everything that can be done was applied
  154184. */
  154185. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154186. }
  154187. /**
  154188. * Defines an optimization used to turn lens flares off
  154189. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154190. */
  154191. export class LensFlaresOptimization extends SceneOptimization {
  154192. /**
  154193. * Gets a string describing the action executed by the current optimization
  154194. * @return description string
  154195. */
  154196. getDescription(): string;
  154197. /**
  154198. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154199. * @param scene defines the current scene where to apply this optimization
  154200. * @param optimizer defines the current optimizer
  154201. * @returns true if everything that can be done was applied
  154202. */
  154203. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154204. }
  154205. /**
  154206. * Defines an optimization based on user defined callback.
  154207. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154208. */
  154209. export class CustomOptimization extends SceneOptimization {
  154210. /**
  154211. * Callback called to apply the custom optimization.
  154212. */
  154213. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  154214. /**
  154215. * Callback called to get custom description
  154216. */
  154217. onGetDescription: () => string;
  154218. /**
  154219. * Gets a string describing the action executed by the current optimization
  154220. * @returns description string
  154221. */
  154222. getDescription(): string;
  154223. /**
  154224. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154225. * @param scene defines the current scene where to apply this optimization
  154226. * @param optimizer defines the current optimizer
  154227. * @returns true if everything that can be done was applied
  154228. */
  154229. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154230. }
  154231. /**
  154232. * Defines an optimization used to turn particles off
  154233. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154234. */
  154235. export class ParticlesOptimization extends SceneOptimization {
  154236. /**
  154237. * Gets a string describing the action executed by the current optimization
  154238. * @return description string
  154239. */
  154240. getDescription(): string;
  154241. /**
  154242. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154243. * @param scene defines the current scene where to apply this optimization
  154244. * @param optimizer defines the current optimizer
  154245. * @returns true if everything that can be done was applied
  154246. */
  154247. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154248. }
  154249. /**
  154250. * Defines an optimization used to turn render targets off
  154251. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154252. */
  154253. export class RenderTargetsOptimization extends SceneOptimization {
  154254. /**
  154255. * Gets a string describing the action executed by the current optimization
  154256. * @return description string
  154257. */
  154258. getDescription(): string;
  154259. /**
  154260. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154261. * @param scene defines the current scene where to apply this optimization
  154262. * @param optimizer defines the current optimizer
  154263. * @returns true if everything that can be done was applied
  154264. */
  154265. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154266. }
  154267. /**
  154268. * Defines an optimization used to merge meshes with compatible materials
  154269. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154270. */
  154271. export class MergeMeshesOptimization extends SceneOptimization {
  154272. private static _UpdateSelectionTree;
  154273. /**
  154274. * Gets or sets a boolean which defines if optimization octree has to be updated
  154275. */
  154276. static get UpdateSelectionTree(): boolean;
  154277. /**
  154278. * Gets or sets a boolean which defines if optimization octree has to be updated
  154279. */
  154280. static set UpdateSelectionTree(value: boolean);
  154281. /**
  154282. * Gets a string describing the action executed by the current optimization
  154283. * @return description string
  154284. */
  154285. getDescription(): string;
  154286. private _canBeMerged;
  154287. /**
  154288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154289. * @param scene defines the current scene where to apply this optimization
  154290. * @param optimizer defines the current optimizer
  154291. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  154292. * @returns true if everything that can be done was applied
  154293. */
  154294. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  154295. }
  154296. /**
  154297. * Defines a list of options used by SceneOptimizer
  154298. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154299. */
  154300. export class SceneOptimizerOptions {
  154301. /**
  154302. * Defines the target frame rate to reach (60 by default)
  154303. */
  154304. targetFrameRate: number;
  154305. /**
  154306. * Defines the interval between two checkes (2000ms by default)
  154307. */
  154308. trackerDuration: number;
  154309. /**
  154310. * Gets the list of optimizations to apply
  154311. */
  154312. optimizations: SceneOptimization[];
  154313. /**
  154314. * Creates a new list of options used by SceneOptimizer
  154315. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  154316. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  154317. */
  154318. constructor(
  154319. /**
  154320. * Defines the target frame rate to reach (60 by default)
  154321. */
  154322. targetFrameRate?: number,
  154323. /**
  154324. * Defines the interval between two checkes (2000ms by default)
  154325. */
  154326. trackerDuration?: number);
  154327. /**
  154328. * Add a new optimization
  154329. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  154330. * @returns the current SceneOptimizerOptions
  154331. */
  154332. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  154333. /**
  154334. * Add a new custom optimization
  154335. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  154336. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  154337. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154338. * @returns the current SceneOptimizerOptions
  154339. */
  154340. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  154341. /**
  154342. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  154343. * @param targetFrameRate defines the target frame rate (60 by default)
  154344. * @returns a SceneOptimizerOptions object
  154345. */
  154346. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154347. /**
  154348. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  154349. * @param targetFrameRate defines the target frame rate (60 by default)
  154350. * @returns a SceneOptimizerOptions object
  154351. */
  154352. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154353. /**
  154354. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  154355. * @param targetFrameRate defines the target frame rate (60 by default)
  154356. * @returns a SceneOptimizerOptions object
  154357. */
  154358. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154359. }
  154360. /**
  154361. * Class used to run optimizations in order to reach a target frame rate
  154362. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154363. */
  154364. export class SceneOptimizer implements IDisposable {
  154365. private _isRunning;
  154366. private _options;
  154367. private _scene;
  154368. private _currentPriorityLevel;
  154369. private _targetFrameRate;
  154370. private _trackerDuration;
  154371. private _currentFrameRate;
  154372. private _sceneDisposeObserver;
  154373. private _improvementMode;
  154374. /**
  154375. * Defines an observable called when the optimizer reaches the target frame rate
  154376. */
  154377. onSuccessObservable: Observable<SceneOptimizer>;
  154378. /**
  154379. * Defines an observable called when the optimizer enables an optimization
  154380. */
  154381. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  154382. /**
  154383. * Defines an observable called when the optimizer is not able to reach the target frame rate
  154384. */
  154385. onFailureObservable: Observable<SceneOptimizer>;
  154386. /**
  154387. * Gets a boolean indicating if the optimizer is in improvement mode
  154388. */
  154389. get isInImprovementMode(): boolean;
  154390. /**
  154391. * Gets the current priority level (0 at start)
  154392. */
  154393. get currentPriorityLevel(): number;
  154394. /**
  154395. * Gets the current frame rate checked by the SceneOptimizer
  154396. */
  154397. get currentFrameRate(): number;
  154398. /**
  154399. * Gets or sets the current target frame rate (60 by default)
  154400. */
  154401. get targetFrameRate(): number;
  154402. /**
  154403. * Gets or sets the current target frame rate (60 by default)
  154404. */
  154405. set targetFrameRate(value: number);
  154406. /**
  154407. * Gets or sets the current interval between two checks (every 2000ms by default)
  154408. */
  154409. get trackerDuration(): number;
  154410. /**
  154411. * Gets or sets the current interval between two checks (every 2000ms by default)
  154412. */
  154413. set trackerDuration(value: number);
  154414. /**
  154415. * Gets the list of active optimizations
  154416. */
  154417. get optimizations(): SceneOptimization[];
  154418. /**
  154419. * Creates a new SceneOptimizer
  154420. * @param scene defines the scene to work on
  154421. * @param options defines the options to use with the SceneOptimizer
  154422. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  154423. * @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)
  154424. */
  154425. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  154426. /**
  154427. * Stops the current optimizer
  154428. */
  154429. stop(): void;
  154430. /**
  154431. * Reset the optimizer to initial step (current priority level = 0)
  154432. */
  154433. reset(): void;
  154434. /**
  154435. * Start the optimizer. By default it will try to reach a specific framerate
  154436. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  154437. */
  154438. start(): void;
  154439. private _checkCurrentState;
  154440. /**
  154441. * Release all resources
  154442. */
  154443. dispose(): void;
  154444. /**
  154445. * Helper function to create a SceneOptimizer with one single line of code
  154446. * @param scene defines the scene to work on
  154447. * @param options defines the options to use with the SceneOptimizer
  154448. * @param onSuccess defines a callback to call on success
  154449. * @param onFailure defines a callback to call on failure
  154450. * @returns the new SceneOptimizer object
  154451. */
  154452. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  154453. }
  154454. }
  154455. declare module BABYLON {
  154456. /**
  154457. * Class used to serialize a scene into a string
  154458. */
  154459. export class SceneSerializer {
  154460. /**
  154461. * Clear cache used by a previous serialization
  154462. */
  154463. static ClearCache(): void;
  154464. /**
  154465. * Serialize a scene into a JSON compatible object
  154466. * @param scene defines the scene to serialize
  154467. * @returns a JSON compatible object
  154468. */
  154469. static Serialize(scene: Scene): any;
  154470. /**
  154471. * Serialize a mesh into a JSON compatible object
  154472. * @param toSerialize defines the mesh to serialize
  154473. * @param withParents defines if parents must be serialized as well
  154474. * @param withChildren defines if children must be serialized as well
  154475. * @returns a JSON compatible object
  154476. */
  154477. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  154478. }
  154479. }
  154480. declare module BABYLON {
  154481. /**
  154482. * Class used to host texture specific utilities
  154483. */
  154484. export class TextureTools {
  154485. /**
  154486. * Uses the GPU to create a copy texture rescaled at a given size
  154487. * @param texture Texture to copy from
  154488. * @param width defines the desired width
  154489. * @param height defines the desired height
  154490. * @param useBilinearMode defines if bilinear mode has to be used
  154491. * @return the generated texture
  154492. */
  154493. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  154494. }
  154495. }
  154496. declare module BABYLON {
  154497. /**
  154498. * This represents the different options available for the video capture.
  154499. */
  154500. export interface VideoRecorderOptions {
  154501. /** Defines the mime type of the video. */
  154502. mimeType: string;
  154503. /** Defines the FPS the video should be recorded at. */
  154504. fps: number;
  154505. /** Defines the chunk size for the recording data. */
  154506. recordChunckSize: number;
  154507. /** The audio tracks to attach to the recording. */
  154508. audioTracks?: MediaStreamTrack[];
  154509. }
  154510. /**
  154511. * This can help with recording videos from BabylonJS.
  154512. * This is based on the available WebRTC functionalities of the browser.
  154513. *
  154514. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  154515. */
  154516. export class VideoRecorder {
  154517. private static readonly _defaultOptions;
  154518. /**
  154519. * Returns whether or not the VideoRecorder is available in your browser.
  154520. * @param engine Defines the Babylon Engine.
  154521. * @returns true if supported otherwise false.
  154522. */
  154523. static IsSupported(engine: Engine): boolean;
  154524. private readonly _options;
  154525. private _canvas;
  154526. private _mediaRecorder;
  154527. private _recordedChunks;
  154528. private _fileName;
  154529. private _resolve;
  154530. private _reject;
  154531. /**
  154532. * True when a recording is already in progress.
  154533. */
  154534. get isRecording(): boolean;
  154535. /**
  154536. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  154537. * @param engine Defines the BabylonJS Engine you wish to record.
  154538. * @param options Defines options that can be used to customize the capture.
  154539. */
  154540. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  154541. /**
  154542. * Stops the current recording before the default capture timeout passed in the startRecording function.
  154543. */
  154544. stopRecording(): void;
  154545. /**
  154546. * Starts recording the canvas for a max duration specified in parameters.
  154547. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  154548. * If null no automatic download will start and you can rely on the promise to get the data back.
  154549. * @param maxDuration Defines the maximum recording time in seconds.
  154550. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  154551. * @return A promise callback at the end of the recording with the video data in Blob.
  154552. */
  154553. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  154554. /**
  154555. * Releases internal resources used during the recording.
  154556. */
  154557. dispose(): void;
  154558. private _handleDataAvailable;
  154559. private _handleError;
  154560. private _handleStop;
  154561. }
  154562. }
  154563. declare module BABYLON {
  154564. /**
  154565. * Class containing a set of static utilities functions for screenshots
  154566. */
  154567. export class ScreenshotTools {
  154568. /**
  154569. * Captures a screenshot of the current rendering
  154570. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154571. * @param engine defines the rendering engine
  154572. * @param camera defines the source camera
  154573. * @param size This parameter can be set to a single number or to an object with the
  154574. * following (optional) properties: precision, width, height. If a single number is passed,
  154575. * it will be used for both width and height. If an object is passed, the screenshot size
  154576. * will be derived from the parameters. The precision property is a multiplier allowing
  154577. * rendering at a higher or lower resolution
  154578. * @param successCallback defines the callback receives a single parameter which contains the
  154579. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154580. * src parameter of an <img> to display it
  154581. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154582. * Check your browser for supported MIME types
  154583. */
  154584. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  154585. /**
  154586. * Captures a screenshot of the current rendering
  154587. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154588. * @param engine defines the rendering engine
  154589. * @param camera defines the source camera
  154590. * @param size This parameter can be set to a single number or to an object with the
  154591. * following (optional) properties: precision, width, height. If a single number is passed,
  154592. * it will be used for both width and height. If an object is passed, the screenshot size
  154593. * will be derived from the parameters. The precision property is a multiplier allowing
  154594. * rendering at a higher or lower resolution
  154595. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154596. * Check your browser for supported MIME types
  154597. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154598. * to the src parameter of an <img> to display it
  154599. */
  154600. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  154601. /**
  154602. * Generates an image screenshot from the specified camera.
  154603. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154604. * @param engine The engine to use for rendering
  154605. * @param camera The camera to use for rendering
  154606. * @param size This parameter can be set to a single number or to an object with the
  154607. * following (optional) properties: precision, width, height. If a single number is passed,
  154608. * it will be used for both width and height. If an object is passed, the screenshot size
  154609. * will be derived from the parameters. The precision property is a multiplier allowing
  154610. * rendering at a higher or lower resolution
  154611. * @param successCallback The callback receives a single parameter which contains the
  154612. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154613. * src parameter of an <img> to display it
  154614. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154615. * Check your browser for supported MIME types
  154616. * @param samples Texture samples (default: 1)
  154617. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154618. * @param fileName A name for for the downloaded file.
  154619. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154620. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  154621. */
  154622. 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;
  154623. /**
  154624. * Generates an image screenshot from the specified camera.
  154625. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154626. * @param engine The engine to use for rendering
  154627. * @param camera The camera to use for rendering
  154628. * @param size This parameter can be set to a single number or to an object with the
  154629. * following (optional) properties: precision, width, height. If a single number is passed,
  154630. * it will be used for both width and height. If an object is passed, the screenshot size
  154631. * will be derived from the parameters. The precision property is a multiplier allowing
  154632. * rendering at a higher or lower resolution
  154633. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154634. * Check your browser for supported MIME types
  154635. * @param samples Texture samples (default: 1)
  154636. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154637. * @param fileName A name for for the downloaded file.
  154638. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154639. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154640. * to the src parameter of an <img> to display it
  154641. */
  154642. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  154643. /**
  154644. * Gets height and width for screenshot size
  154645. * @private
  154646. */
  154647. private static _getScreenshotSize;
  154648. }
  154649. }
  154650. declare module BABYLON {
  154651. /**
  154652. * Interface for a data buffer
  154653. */
  154654. export interface IDataBuffer {
  154655. /**
  154656. * Reads bytes from the data buffer.
  154657. * @param byteOffset The byte offset to read
  154658. * @param byteLength The byte length to read
  154659. * @returns A promise that resolves when the bytes are read
  154660. */
  154661. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  154662. /**
  154663. * The byte length of the buffer.
  154664. */
  154665. readonly byteLength: number;
  154666. }
  154667. /**
  154668. * Utility class for reading from a data buffer
  154669. */
  154670. export class DataReader {
  154671. /**
  154672. * The data buffer associated with this data reader.
  154673. */
  154674. readonly buffer: IDataBuffer;
  154675. /**
  154676. * The current byte offset from the beginning of the data buffer.
  154677. */
  154678. byteOffset: number;
  154679. private _dataView;
  154680. private _dataByteOffset;
  154681. /**
  154682. * Constructor
  154683. * @param buffer The buffer to read
  154684. */
  154685. constructor(buffer: IDataBuffer);
  154686. /**
  154687. * Loads the given byte length.
  154688. * @param byteLength The byte length to load
  154689. * @returns A promise that resolves when the load is complete
  154690. */
  154691. loadAsync(byteLength: number): Promise<void>;
  154692. /**
  154693. * Read a unsigned 32-bit integer from the currently loaded data range.
  154694. * @returns The 32-bit integer read
  154695. */
  154696. readUint32(): number;
  154697. /**
  154698. * Read a byte array from the currently loaded data range.
  154699. * @param byteLength The byte length to read
  154700. * @returns The byte array read
  154701. */
  154702. readUint8Array(byteLength: number): Uint8Array;
  154703. /**
  154704. * Read a string from the currently loaded data range.
  154705. * @param byteLength The byte length to read
  154706. * @returns The string read
  154707. */
  154708. readString(byteLength: number): string;
  154709. /**
  154710. * Skips the given byte length the currently loaded data range.
  154711. * @param byteLength The byte length to skip
  154712. */
  154713. skipBytes(byteLength: number): void;
  154714. }
  154715. }
  154716. declare module BABYLON {
  154717. /**
  154718. * Class for storing data to local storage if available or in-memory storage otherwise
  154719. */
  154720. export class DataStorage {
  154721. private static _Storage;
  154722. private static _GetStorage;
  154723. /**
  154724. * Reads a string from the data storage
  154725. * @param key The key to read
  154726. * @param defaultValue The value if the key doesn't exist
  154727. * @returns The string value
  154728. */
  154729. static ReadString(key: string, defaultValue: string): string;
  154730. /**
  154731. * Writes a string to the data storage
  154732. * @param key The key to write
  154733. * @param value The value to write
  154734. */
  154735. static WriteString(key: string, value: string): void;
  154736. /**
  154737. * Reads a boolean from the data storage
  154738. * @param key The key to read
  154739. * @param defaultValue The value if the key doesn't exist
  154740. * @returns The boolean value
  154741. */
  154742. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  154743. /**
  154744. * Writes a boolean to the data storage
  154745. * @param key The key to write
  154746. * @param value The value to write
  154747. */
  154748. static WriteBoolean(key: string, value: boolean): void;
  154749. /**
  154750. * Reads a number from the data storage
  154751. * @param key The key to read
  154752. * @param defaultValue The value if the key doesn't exist
  154753. * @returns The number value
  154754. */
  154755. static ReadNumber(key: string, defaultValue: number): number;
  154756. /**
  154757. * Writes a number to the data storage
  154758. * @param key The key to write
  154759. * @param value The value to write
  154760. */
  154761. static WriteNumber(key: string, value: number): void;
  154762. }
  154763. }
  154764. declare module BABYLON {
  154765. /**
  154766. * Class used to record delta files between 2 scene states
  154767. */
  154768. export class SceneRecorder {
  154769. private _trackedScene;
  154770. private _savedJSON;
  154771. /**
  154772. * Track a given scene. This means the current scene state will be considered the original state
  154773. * @param scene defines the scene to track
  154774. */
  154775. track(scene: Scene): void;
  154776. /**
  154777. * Get the delta between current state and original state
  154778. * @returns a string containing the delta
  154779. */
  154780. getDelta(): any;
  154781. private _compareArray;
  154782. private _compareObjects;
  154783. private _compareCollections;
  154784. private static GetShadowGeneratorById;
  154785. /**
  154786. * Apply a given delta to a given scene
  154787. * @param deltaJSON defines the JSON containing the delta
  154788. * @param scene defines the scene to apply the delta to
  154789. */
  154790. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  154791. private static _ApplyPropertiesToEntity;
  154792. private static _ApplyDeltaForEntity;
  154793. }
  154794. }
  154795. declare module BABYLON {
  154796. /**
  154797. * A 3D trajectory consisting of an order list of vectors describing a
  154798. * path of motion through 3D space.
  154799. */
  154800. export class Trajectory {
  154801. private _points;
  154802. private readonly _segmentLength;
  154803. /**
  154804. * Serialize to JSON.
  154805. * @returns serialized JSON string
  154806. */
  154807. serialize(): string;
  154808. /**
  154809. * Deserialize from JSON.
  154810. * @param json serialized JSON string
  154811. * @returns deserialized Trajectory
  154812. */
  154813. static Deserialize(json: string): Trajectory;
  154814. /**
  154815. * Create a new empty Trajectory.
  154816. * @param segmentLength radius of discretization for Trajectory points
  154817. */
  154818. constructor(segmentLength?: number);
  154819. /**
  154820. * Get the length of the Trajectory.
  154821. * @returns length of the Trajectory
  154822. */
  154823. getLength(): number;
  154824. /**
  154825. * Append a new point to the Trajectory.
  154826. * NOTE: This implementation has many allocations.
  154827. * @param point point to append to the Trajectory
  154828. */
  154829. add(point: DeepImmutable<Vector3>): void;
  154830. /**
  154831. * Create a new Trajectory with a segment length chosen to make it
  154832. * probable that the new Trajectory will have a specified number of
  154833. * segments. This operation is imprecise.
  154834. * @param targetResolution number of segments desired
  154835. * @returns new Trajectory with approximately the requested number of segments
  154836. */
  154837. resampleAtTargetResolution(targetResolution: number): Trajectory;
  154838. /**
  154839. * Convert Trajectory segments into tokenized representation. This
  154840. * representation is an array of numbers where each nth number is the
  154841. * index of the token which is most similar to the nth segment of the
  154842. * Trajectory.
  154843. * @param tokens list of vectors which serve as discrete tokens
  154844. * @returns list of indices of most similar token per segment
  154845. */
  154846. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  154847. private static _forwardDir;
  154848. private static _inverseFromVec;
  154849. private static _upDir;
  154850. private static _fromToVec;
  154851. private static _lookMatrix;
  154852. /**
  154853. * Transform the rotation (i.e., direction) of a segment to isolate
  154854. * the relative transformation represented by the segment. This operation
  154855. * may or may not succeed due to singularities in the equations that define
  154856. * motion relativity in this context.
  154857. * @param priorVec the origin of the prior segment
  154858. * @param fromVec the origin of the current segment
  154859. * @param toVec the destination of the current segment
  154860. * @param result reference to output variable
  154861. * @returns whether or not transformation was successful
  154862. */
  154863. private static _transformSegmentDirToRef;
  154864. private static _bestMatch;
  154865. private static _score;
  154866. private static _bestScore;
  154867. /**
  154868. * Determine which token vector is most similar to the
  154869. * segment vector.
  154870. * @param segment segment vector
  154871. * @param tokens token vector list
  154872. * @returns index of the most similar token to the segment
  154873. */
  154874. private static _tokenizeSegment;
  154875. }
  154876. /**
  154877. * Class representing a set of known, named trajectories to which Trajectories can be
  154878. * added and using which Trajectories can be recognized.
  154879. */
  154880. export class TrajectoryClassifier {
  154881. private _maximumAllowableMatchCost;
  154882. private _vector3Alphabet;
  154883. private _levenshteinAlphabet;
  154884. private _nameToDescribedTrajectory;
  154885. /**
  154886. * Serialize to JSON.
  154887. * @returns JSON serialization
  154888. */
  154889. serialize(): string;
  154890. /**
  154891. * Deserialize from JSON.
  154892. * @param json JSON serialization
  154893. * @returns deserialized TrajectorySet
  154894. */
  154895. static Deserialize(json: string): TrajectoryClassifier;
  154896. /**
  154897. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  154898. * VERY naive, need to be generating these things from known
  154899. * sets. Better version later, probably eliminating this one.
  154900. * @returns auto-generated TrajectorySet
  154901. */
  154902. static Generate(): TrajectoryClassifier;
  154903. private constructor();
  154904. /**
  154905. * Add a new Trajectory to the set with a given name.
  154906. * @param trajectory new Trajectory to be added
  154907. * @param classification name to which to add the Trajectory
  154908. */
  154909. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  154910. /**
  154911. * Remove a known named trajectory and all Trajectories associated with it.
  154912. * @param classification name to remove
  154913. * @returns whether anything was removed
  154914. */
  154915. deleteClassification(classification: string): boolean;
  154916. /**
  154917. * Attempt to recognize a Trajectory from among all the classifications
  154918. * already known to the classifier.
  154919. * @param trajectory Trajectory to be recognized
  154920. * @returns classification of Trajectory if recognized, null otherwise
  154921. */
  154922. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  154923. }
  154924. }
  154925. declare module BABYLON {
  154926. /**
  154927. * An interface for all Hit test features
  154928. */
  154929. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  154930. /**
  154931. * Triggered when new babylon (transformed) hit test results are available
  154932. */
  154933. onHitTestResultObservable: Observable<T[]>;
  154934. }
  154935. /**
  154936. * Options used for hit testing
  154937. */
  154938. export interface IWebXRLegacyHitTestOptions {
  154939. /**
  154940. * Only test when user interacted with the scene. Default - hit test every frame
  154941. */
  154942. testOnPointerDownOnly?: boolean;
  154943. /**
  154944. * The node to use to transform the local results to world coordinates
  154945. */
  154946. worldParentNode?: TransformNode;
  154947. }
  154948. /**
  154949. * Interface defining the babylon result of raycasting/hit-test
  154950. */
  154951. export interface IWebXRLegacyHitResult {
  154952. /**
  154953. * Transformation matrix that can be applied to a node that will put it in the hit point location
  154954. */
  154955. transformationMatrix: Matrix;
  154956. /**
  154957. * The native hit test result
  154958. */
  154959. xrHitResult: XRHitResult | XRHitTestResult;
  154960. }
  154961. /**
  154962. * The currently-working hit-test module.
  154963. * Hit test (or Ray-casting) is used to interact with the real world.
  154964. * For further information read here - https://github.com/immersive-web/hit-test
  154965. */
  154966. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  154967. /**
  154968. * options to use when constructing this feature
  154969. */
  154970. readonly options: IWebXRLegacyHitTestOptions;
  154971. private _direction;
  154972. private _mat;
  154973. private _onSelectEnabled;
  154974. private _origin;
  154975. /**
  154976. * The module's name
  154977. */
  154978. static readonly Name: string;
  154979. /**
  154980. * The (Babylon) version of this module.
  154981. * This is an integer representing the implementation version.
  154982. * This number does not correspond to the WebXR specs version
  154983. */
  154984. static readonly Version: number;
  154985. /**
  154986. * Populated with the last native XR Hit Results
  154987. */
  154988. lastNativeXRHitResults: XRHitResult[];
  154989. /**
  154990. * Triggered when new babylon (transformed) hit test results are available
  154991. */
  154992. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  154993. /**
  154994. * Creates a new instance of the (legacy version) hit test feature
  154995. * @param _xrSessionManager an instance of WebXRSessionManager
  154996. * @param options options to use when constructing this feature
  154997. */
  154998. constructor(_xrSessionManager: WebXRSessionManager,
  154999. /**
  155000. * options to use when constructing this feature
  155001. */
  155002. options?: IWebXRLegacyHitTestOptions);
  155003. /**
  155004. * execute a hit test with an XR Ray
  155005. *
  155006. * @param xrSession a native xrSession that will execute this hit test
  155007. * @param xrRay the ray (position and direction) to use for ray-casting
  155008. * @param referenceSpace native XR reference space to use for the hit-test
  155009. * @param filter filter function that will filter the results
  155010. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155011. */
  155012. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155013. /**
  155014. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155015. * @param event the (select) event to use to select with
  155016. * @param referenceSpace the reference space to use for this hit test
  155017. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155018. */
  155019. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155020. /**
  155021. * attach this feature
  155022. * Will usually be called by the features manager
  155023. *
  155024. * @returns true if successful.
  155025. */
  155026. attach(): boolean;
  155027. /**
  155028. * detach this feature.
  155029. * Will usually be called by the features manager
  155030. *
  155031. * @returns true if successful.
  155032. */
  155033. detach(): boolean;
  155034. /**
  155035. * Dispose this feature and all of the resources attached
  155036. */
  155037. dispose(): void;
  155038. protected _onXRFrame(frame: XRFrame): void;
  155039. private _onHitTestResults;
  155040. private _onSelect;
  155041. }
  155042. }
  155043. declare module BABYLON {
  155044. /**
  155045. * Options used for hit testing (version 2)
  155046. */
  155047. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155048. /**
  155049. * Do not create a permanent hit test. Will usually be used when only
  155050. * transient inputs are needed.
  155051. */
  155052. disablePermanentHitTest?: boolean;
  155053. /**
  155054. * Enable transient (for example touch-based) hit test inspections
  155055. */
  155056. enableTransientHitTest?: boolean;
  155057. /**
  155058. * Offset ray for the permanent hit test
  155059. */
  155060. offsetRay?: Vector3;
  155061. /**
  155062. * Offset ray for the transient hit test
  155063. */
  155064. transientOffsetRay?: Vector3;
  155065. /**
  155066. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155067. */
  155068. useReferenceSpace?: boolean;
  155069. /**
  155070. * Override the default entity type(s) of the hit-test result
  155071. */
  155072. entityTypes?: XRHitTestTrackableType[];
  155073. }
  155074. /**
  155075. * Interface defining the babylon result of hit-test
  155076. */
  155077. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155078. /**
  155079. * The input source that generated this hit test (if transient)
  155080. */
  155081. inputSource?: XRInputSource;
  155082. /**
  155083. * Is this a transient hit test
  155084. */
  155085. isTransient?: boolean;
  155086. /**
  155087. * Position of the hit test result
  155088. */
  155089. position: Vector3;
  155090. /**
  155091. * Rotation of the hit test result
  155092. */
  155093. rotationQuaternion: Quaternion;
  155094. /**
  155095. * The native hit test result
  155096. */
  155097. xrHitResult: XRHitTestResult;
  155098. }
  155099. /**
  155100. * The currently-working hit-test module.
  155101. * Hit test (or Ray-casting) is used to interact with the real world.
  155102. * For further information read here - https://github.com/immersive-web/hit-test
  155103. *
  155104. * Tested on chrome (mobile) 80.
  155105. */
  155106. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  155107. /**
  155108. * options to use when constructing this feature
  155109. */
  155110. readonly options: IWebXRHitTestOptions;
  155111. private _tmpMat;
  155112. private _tmpPos;
  155113. private _tmpQuat;
  155114. private _transientXrHitTestSource;
  155115. private _xrHitTestSource;
  155116. private initHitTestSource;
  155117. /**
  155118. * The module's name
  155119. */
  155120. static readonly Name: string;
  155121. /**
  155122. * The (Babylon) version of this module.
  155123. * This is an integer representing the implementation version.
  155124. * This number does not correspond to the WebXR specs version
  155125. */
  155126. static readonly Version: number;
  155127. /**
  155128. * When set to true, each hit test will have its own position/rotation objects
  155129. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  155130. * the developers will clone them or copy them as they see fit.
  155131. */
  155132. autoCloneTransformation: boolean;
  155133. /**
  155134. * Triggered when new babylon (transformed) hit test results are available
  155135. * Note - this will be called when results come back from the device. It can be an empty array!!
  155136. */
  155137. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  155138. /**
  155139. * Use this to temporarily pause hit test checks.
  155140. */
  155141. paused: boolean;
  155142. /**
  155143. * Creates a new instance of the hit test feature
  155144. * @param _xrSessionManager an instance of WebXRSessionManager
  155145. * @param options options to use when constructing this feature
  155146. */
  155147. constructor(_xrSessionManager: WebXRSessionManager,
  155148. /**
  155149. * options to use when constructing this feature
  155150. */
  155151. options?: IWebXRHitTestOptions);
  155152. /**
  155153. * attach this feature
  155154. * Will usually be called by the features manager
  155155. *
  155156. * @returns true if successful.
  155157. */
  155158. attach(): boolean;
  155159. /**
  155160. * detach this feature.
  155161. * Will usually be called by the features manager
  155162. *
  155163. * @returns true if successful.
  155164. */
  155165. detach(): boolean;
  155166. /**
  155167. * Dispose this feature and all of the resources attached
  155168. */
  155169. dispose(): void;
  155170. protected _onXRFrame(frame: XRFrame): void;
  155171. private _processWebXRHitTestResult;
  155172. }
  155173. }
  155174. declare module BABYLON {
  155175. /**
  155176. * Configuration options of the anchor system
  155177. */
  155178. export interface IWebXRAnchorSystemOptions {
  155179. /**
  155180. * a node that will be used to convert local to world coordinates
  155181. */
  155182. worldParentNode?: TransformNode;
  155183. /**
  155184. * If set to true a reference of the created anchors will be kept until the next session starts
  155185. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  155186. */
  155187. doNotRemoveAnchorsOnSessionEnded?: boolean;
  155188. }
  155189. /**
  155190. * A babylon container for an XR Anchor
  155191. */
  155192. export interface IWebXRAnchor {
  155193. /**
  155194. * A babylon-assigned ID for this anchor
  155195. */
  155196. id: number;
  155197. /**
  155198. * Transformation matrix to apply to an object attached to this anchor
  155199. */
  155200. transformationMatrix: Matrix;
  155201. /**
  155202. * The native anchor object
  155203. */
  155204. xrAnchor: XRAnchor;
  155205. /**
  155206. * if defined, this object will be constantly updated by the anchor's position and rotation
  155207. */
  155208. attachedNode?: TransformNode;
  155209. }
  155210. /**
  155211. * An implementation of the anchor system for WebXR.
  155212. * For further information see https://github.com/immersive-web/anchors/
  155213. */
  155214. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  155215. private _options;
  155216. private _lastFrameDetected;
  155217. private _trackedAnchors;
  155218. private _referenceSpaceForFrameAnchors;
  155219. private _futureAnchors;
  155220. /**
  155221. * The module's name
  155222. */
  155223. static readonly Name: string;
  155224. /**
  155225. * The (Babylon) version of this module.
  155226. * This is an integer representing the implementation version.
  155227. * This number does not correspond to the WebXR specs version
  155228. */
  155229. static readonly Version: number;
  155230. /**
  155231. * Observers registered here will be executed when a new anchor was added to the session
  155232. */
  155233. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  155234. /**
  155235. * Observers registered here will be executed when an anchor was removed from the session
  155236. */
  155237. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  155238. /**
  155239. * Observers registered here will be executed when an existing anchor updates
  155240. * This can execute N times every frame
  155241. */
  155242. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  155243. /**
  155244. * Set the reference space to use for anchor creation, when not using a hit test.
  155245. * Will default to the session's reference space if not defined
  155246. */
  155247. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  155248. /**
  155249. * constructs a new anchor system
  155250. * @param _xrSessionManager an instance of WebXRSessionManager
  155251. * @param _options configuration object for this feature
  155252. */
  155253. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  155254. private _tmpVector;
  155255. private _tmpQuaternion;
  155256. private _populateTmpTransformation;
  155257. /**
  155258. * Create a new anchor point using a hit test result at a specific point in the scene
  155259. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155260. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155261. *
  155262. * @param hitTestResult The hit test result to use for this anchor creation
  155263. * @param position an optional position offset for this anchor
  155264. * @param rotationQuaternion an optional rotation offset for this anchor
  155265. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155266. */
  155267. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  155268. /**
  155269. * Add a new anchor at a specific position and rotation
  155270. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  155271. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  155272. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155273. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155274. *
  155275. * @param position the position in which to add an anchor
  155276. * @param rotationQuaternion an optional rotation for the anchor transformation
  155277. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  155278. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155279. */
  155280. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  155281. /**
  155282. * detach this feature.
  155283. * Will usually be called by the features manager
  155284. *
  155285. * @returns true if successful.
  155286. */
  155287. detach(): boolean;
  155288. /**
  155289. * Dispose this feature and all of the resources attached
  155290. */
  155291. dispose(): void;
  155292. protected _onXRFrame(frame: XRFrame): void;
  155293. /**
  155294. * avoiding using Array.find for global support.
  155295. * @param xrAnchor the plane to find in the array
  155296. */
  155297. private _findIndexInAnchorArray;
  155298. private _updateAnchorWithXRFrame;
  155299. private _createAnchorAtTransformation;
  155300. }
  155301. }
  155302. declare module BABYLON {
  155303. /**
  155304. * Options used in the plane detector module
  155305. */
  155306. export interface IWebXRPlaneDetectorOptions {
  155307. /**
  155308. * The node to use to transform the local results to world coordinates
  155309. */
  155310. worldParentNode?: TransformNode;
  155311. /**
  155312. * If set to true a reference of the created planes will be kept until the next session starts
  155313. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  155314. */
  155315. doNotRemovePlanesOnSessionEnded?: boolean;
  155316. }
  155317. /**
  155318. * A babylon interface for a WebXR plane.
  155319. * A Plane is actually a polygon, built from N points in space
  155320. *
  155321. * Supported in chrome 79, not supported in canary 81 ATM
  155322. */
  155323. export interface IWebXRPlane {
  155324. /**
  155325. * a babylon-assigned ID for this polygon
  155326. */
  155327. id: number;
  155328. /**
  155329. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  155330. */
  155331. polygonDefinition: Array<Vector3>;
  155332. /**
  155333. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  155334. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  155335. */
  155336. transformationMatrix: Matrix;
  155337. /**
  155338. * the native xr-plane object
  155339. */
  155340. xrPlane: XRPlane;
  155341. }
  155342. /**
  155343. * The plane detector is used to detect planes in the real world when in AR
  155344. * For more information see https://github.com/immersive-web/real-world-geometry/
  155345. */
  155346. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  155347. private _options;
  155348. private _detectedPlanes;
  155349. private _enabled;
  155350. private _lastFrameDetected;
  155351. /**
  155352. * The module's name
  155353. */
  155354. static readonly Name: string;
  155355. /**
  155356. * The (Babylon) version of this module.
  155357. * This is an integer representing the implementation version.
  155358. * This number does not correspond to the WebXR specs version
  155359. */
  155360. static readonly Version: number;
  155361. /**
  155362. * Observers registered here will be executed when a new plane was added to the session
  155363. */
  155364. onPlaneAddedObservable: Observable<IWebXRPlane>;
  155365. /**
  155366. * Observers registered here will be executed when a plane is no longer detected in the session
  155367. */
  155368. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  155369. /**
  155370. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  155371. * This can execute N times every frame
  155372. */
  155373. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  155374. /**
  155375. * construct a new Plane Detector
  155376. * @param _xrSessionManager an instance of xr Session manager
  155377. * @param _options configuration to use when constructing this feature
  155378. */
  155379. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  155380. /**
  155381. * detach this feature.
  155382. * Will usually be called by the features manager
  155383. *
  155384. * @returns true if successful.
  155385. */
  155386. detach(): boolean;
  155387. /**
  155388. * Dispose this feature and all of the resources attached
  155389. */
  155390. dispose(): void;
  155391. protected _onXRFrame(frame: XRFrame): void;
  155392. private _init;
  155393. private _updatePlaneWithXRPlane;
  155394. /**
  155395. * avoiding using Array.find for global support.
  155396. * @param xrPlane the plane to find in the array
  155397. */
  155398. private findIndexInPlaneArray;
  155399. }
  155400. }
  155401. declare module BABYLON {
  155402. /**
  155403. * Options interface for the background remover plugin
  155404. */
  155405. export interface IWebXRBackgroundRemoverOptions {
  155406. /**
  155407. * Further background meshes to disable when entering AR
  155408. */
  155409. backgroundMeshes?: AbstractMesh[];
  155410. /**
  155411. * flags to configure the removal of the environment helper.
  155412. * If not set, the entire background will be removed. If set, flags should be set as well.
  155413. */
  155414. environmentHelperRemovalFlags?: {
  155415. /**
  155416. * Should the skybox be removed (default false)
  155417. */
  155418. skyBox?: boolean;
  155419. /**
  155420. * Should the ground be removed (default false)
  155421. */
  155422. ground?: boolean;
  155423. };
  155424. /**
  155425. * don't disable the environment helper
  155426. */
  155427. ignoreEnvironmentHelper?: boolean;
  155428. }
  155429. /**
  155430. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  155431. */
  155432. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  155433. /**
  155434. * read-only options to be used in this module
  155435. */
  155436. readonly options: IWebXRBackgroundRemoverOptions;
  155437. /**
  155438. * The module's name
  155439. */
  155440. static readonly Name: string;
  155441. /**
  155442. * The (Babylon) version of this module.
  155443. * This is an integer representing the implementation version.
  155444. * This number does not correspond to the WebXR specs version
  155445. */
  155446. static readonly Version: number;
  155447. /**
  155448. * registered observers will be triggered when the background state changes
  155449. */
  155450. onBackgroundStateChangedObservable: Observable<boolean>;
  155451. /**
  155452. * constructs a new background remover module
  155453. * @param _xrSessionManager the session manager for this module
  155454. * @param options read-only options to be used in this module
  155455. */
  155456. constructor(_xrSessionManager: WebXRSessionManager,
  155457. /**
  155458. * read-only options to be used in this module
  155459. */
  155460. options?: IWebXRBackgroundRemoverOptions);
  155461. /**
  155462. * attach this feature
  155463. * Will usually be called by the features manager
  155464. *
  155465. * @returns true if successful.
  155466. */
  155467. attach(): boolean;
  155468. /**
  155469. * detach this feature.
  155470. * Will usually be called by the features manager
  155471. *
  155472. * @returns true if successful.
  155473. */
  155474. detach(): boolean;
  155475. /**
  155476. * Dispose this feature and all of the resources attached
  155477. */
  155478. dispose(): void;
  155479. protected _onXRFrame(_xrFrame: XRFrame): void;
  155480. private _setBackgroundState;
  155481. }
  155482. }
  155483. declare module BABYLON {
  155484. /**
  155485. * Options for the controller physics feature
  155486. */
  155487. export class IWebXRControllerPhysicsOptions {
  155488. /**
  155489. * Should the headset get its own impostor
  155490. */
  155491. enableHeadsetImpostor?: boolean;
  155492. /**
  155493. * Optional parameters for the headset impostor
  155494. */
  155495. headsetImpostorParams?: {
  155496. /**
  155497. * The type of impostor to create. Default is sphere
  155498. */
  155499. impostorType: number;
  155500. /**
  155501. * the size of the impostor. Defaults to 10cm
  155502. */
  155503. impostorSize?: number | {
  155504. width: number;
  155505. height: number;
  155506. depth: number;
  155507. };
  155508. /**
  155509. * Friction definitions
  155510. */
  155511. friction?: number;
  155512. /**
  155513. * Restitution
  155514. */
  155515. restitution?: number;
  155516. };
  155517. /**
  155518. * The physics properties of the future impostors
  155519. */
  155520. physicsProperties?: {
  155521. /**
  155522. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  155523. * Note that this requires a physics engine that supports mesh impostors!
  155524. */
  155525. useControllerMesh?: boolean;
  155526. /**
  155527. * The type of impostor to create. Default is sphere
  155528. */
  155529. impostorType?: number;
  155530. /**
  155531. * the size of the impostor. Defaults to 10cm
  155532. */
  155533. impostorSize?: number | {
  155534. width: number;
  155535. height: number;
  155536. depth: number;
  155537. };
  155538. /**
  155539. * Friction definitions
  155540. */
  155541. friction?: number;
  155542. /**
  155543. * Restitution
  155544. */
  155545. restitution?: number;
  155546. };
  155547. /**
  155548. * the xr input to use with this pointer selection
  155549. */
  155550. xrInput: WebXRInput;
  155551. }
  155552. /**
  155553. * Add physics impostor to your webxr controllers,
  155554. * including naive calculation of their linear and angular velocity
  155555. */
  155556. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  155557. private readonly _options;
  155558. private _attachController;
  155559. private _controllers;
  155560. private _debugMode;
  155561. private _delta;
  155562. private _headsetImpostor?;
  155563. private _headsetMesh?;
  155564. private _lastTimestamp;
  155565. private _tmpQuaternion;
  155566. private _tmpVector;
  155567. /**
  155568. * The module's name
  155569. */
  155570. static readonly Name: string;
  155571. /**
  155572. * The (Babylon) version of this module.
  155573. * This is an integer representing the implementation version.
  155574. * This number does not correspond to the webxr specs version
  155575. */
  155576. static readonly Version: number;
  155577. /**
  155578. * Construct a new Controller Physics Feature
  155579. * @param _xrSessionManager the corresponding xr session manager
  155580. * @param _options options to create this feature with
  155581. */
  155582. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  155583. /**
  155584. * @hidden
  155585. * enable debugging - will show console outputs and the impostor mesh
  155586. */
  155587. _enablePhysicsDebug(): void;
  155588. /**
  155589. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  155590. * @param xrController the controller to add
  155591. */
  155592. addController(xrController: WebXRInputSource): void;
  155593. /**
  155594. * attach this feature
  155595. * Will usually be called by the features manager
  155596. *
  155597. * @returns true if successful.
  155598. */
  155599. attach(): boolean;
  155600. /**
  155601. * detach this feature.
  155602. * Will usually be called by the features manager
  155603. *
  155604. * @returns true if successful.
  155605. */
  155606. detach(): boolean;
  155607. /**
  155608. * Get the headset impostor, if enabled
  155609. * @returns the impostor
  155610. */
  155611. getHeadsetImpostor(): PhysicsImpostor | undefined;
  155612. /**
  155613. * Get the physics impostor of a specific controller.
  155614. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  155615. * @param controller the controller or the controller id of which to get the impostor
  155616. * @returns the impostor or null
  155617. */
  155618. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  155619. /**
  155620. * Update the physics properties provided in the constructor
  155621. * @param newProperties the new properties object
  155622. */
  155623. setPhysicsProperties(newProperties: {
  155624. impostorType?: number;
  155625. impostorSize?: number | {
  155626. width: number;
  155627. height: number;
  155628. depth: number;
  155629. };
  155630. friction?: number;
  155631. restitution?: number;
  155632. }): void;
  155633. protected _onXRFrame(_xrFrame: any): void;
  155634. private _detachController;
  155635. }
  155636. }
  155637. declare module BABYLON {
  155638. /**
  155639. * A babylon interface for a "WebXR" feature point.
  155640. * Represents the position and confidence value of a given feature point.
  155641. */
  155642. export interface IWebXRFeaturePoint {
  155643. /**
  155644. * Represents the position of the feature point in world space.
  155645. */
  155646. position: Vector3;
  155647. /**
  155648. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  155649. */
  155650. confidenceValue: number;
  155651. }
  155652. /**
  155653. * The feature point system is used to detect feature points from real world geometry.
  155654. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  155655. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  155656. */
  155657. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  155658. private _enabled;
  155659. private _featurePointCloud;
  155660. /**
  155661. * The module's name
  155662. */
  155663. static readonly Name: string;
  155664. /**
  155665. * The (Babylon) version of this module.
  155666. * This is an integer representing the implementation version.
  155667. * This number does not correspond to the WebXR specs version
  155668. */
  155669. static readonly Version: number;
  155670. /**
  155671. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  155672. * Will notify the observers about which feature points have been added.
  155673. */
  155674. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  155675. /**
  155676. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  155677. * Will notify the observers about which feature points have been updated.
  155678. */
  155679. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  155680. /**
  155681. * The current feature point cloud maintained across frames.
  155682. */
  155683. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  155684. /**
  155685. * construct the feature point system
  155686. * @param _xrSessionManager an instance of xr Session manager
  155687. */
  155688. constructor(_xrSessionManager: WebXRSessionManager);
  155689. /**
  155690. * Detach this feature.
  155691. * Will usually be called by the features manager
  155692. *
  155693. * @returns true if successful.
  155694. */
  155695. detach(): boolean;
  155696. /**
  155697. * Dispose this feature and all of the resources attached
  155698. */
  155699. dispose(): void;
  155700. /**
  155701. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  155702. */
  155703. protected _onXRFrame(frame: XRFrame): void;
  155704. /**
  155705. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  155706. */
  155707. private _init;
  155708. }
  155709. }
  155710. declare module BABYLON {
  155711. /**
  155712. * Configuration interface for the hand tracking feature
  155713. */
  155714. export interface IWebXRHandTrackingOptions {
  155715. /**
  155716. * The xrInput that will be used as source for new hands
  155717. */
  155718. xrInput: WebXRInput;
  155719. /**
  155720. * Configuration object for the joint meshes
  155721. */
  155722. jointMeshes?: {
  155723. /**
  155724. * Should the meshes created be invisible (defaults to false)
  155725. */
  155726. invisible?: boolean;
  155727. /**
  155728. * A source mesh to be used to create instances. Defaults to a sphere.
  155729. * This mesh will be the source for all other (25) meshes.
  155730. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  155731. */
  155732. sourceMesh?: Mesh;
  155733. /**
  155734. * Should the source mesh stay visible. Defaults to false
  155735. */
  155736. keepOriginalVisible?: boolean;
  155737. /**
  155738. * Scale factor for all instances (defaults to 2)
  155739. */
  155740. scaleFactor?: number;
  155741. /**
  155742. * Should each instance have its own physics impostor
  155743. */
  155744. enablePhysics?: boolean;
  155745. /**
  155746. * If enabled, override default physics properties
  155747. */
  155748. physicsProps?: {
  155749. friction?: number;
  155750. restitution?: number;
  155751. impostorType?: number;
  155752. };
  155753. /**
  155754. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  155755. */
  155756. handMesh?: AbstractMesh;
  155757. };
  155758. }
  155759. /**
  155760. * Parts of the hands divided to writs and finger names
  155761. */
  155762. export const enum HandPart {
  155763. /**
  155764. * HandPart - Wrist
  155765. */
  155766. WRIST = "wrist",
  155767. /**
  155768. * HandPart - The THumb
  155769. */
  155770. THUMB = "thumb",
  155771. /**
  155772. * HandPart - Index finger
  155773. */
  155774. INDEX = "index",
  155775. /**
  155776. * HandPart - Middle finger
  155777. */
  155778. MIDDLE = "middle",
  155779. /**
  155780. * HandPart - Ring finger
  155781. */
  155782. RING = "ring",
  155783. /**
  155784. * HandPart - Little finger
  155785. */
  155786. LITTLE = "little"
  155787. }
  155788. /**
  155789. * Representing a single hand (with its corresponding native XRHand object)
  155790. */
  155791. export class WebXRHand implements IDisposable {
  155792. /** the controller to which the hand correlates */
  155793. readonly xrController: WebXRInputSource;
  155794. /** the meshes to be used to track the hand joints */
  155795. readonly trackedMeshes: AbstractMesh[];
  155796. /**
  155797. * Hand-parts definition (key is HandPart)
  155798. */
  155799. handPartsDefinition: {
  155800. [key: string]: number[];
  155801. };
  155802. /**
  155803. * Populate the HandPartsDefinition object.
  155804. * This is called as a side effect since certain browsers don't have XRHand defined.
  155805. */
  155806. private generateHandPartsDefinition;
  155807. /**
  155808. * Construct a new hand object
  155809. * @param xrController the controller to which the hand correlates
  155810. * @param trackedMeshes the meshes to be used to track the hand joints
  155811. */
  155812. constructor(
  155813. /** the controller to which the hand correlates */
  155814. xrController: WebXRInputSource,
  155815. /** the meshes to be used to track the hand joints */
  155816. trackedMeshes: AbstractMesh[]);
  155817. /**
  155818. * Update this hand from the latest xr frame
  155819. * @param xrFrame xrFrame to update from
  155820. * @param referenceSpace The current viewer reference space
  155821. * @param scaleFactor optional scale factor for the meshes
  155822. */
  155823. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  155824. /**
  155825. * Get meshes of part of the hand
  155826. * @param part the part of hand to get
  155827. * @returns An array of meshes that correlate to the hand part requested
  155828. */
  155829. getHandPartMeshes(part: HandPart): AbstractMesh[];
  155830. /**
  155831. * Dispose this Hand object
  155832. */
  155833. dispose(): void;
  155834. }
  155835. /**
  155836. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  155837. */
  155838. export class WebXRHandTracking extends WebXRAbstractFeature {
  155839. /**
  155840. * options to use when constructing this feature
  155841. */
  155842. readonly options: IWebXRHandTrackingOptions;
  155843. private static _idCounter;
  155844. /**
  155845. * The module's name
  155846. */
  155847. static readonly Name: string;
  155848. /**
  155849. * The (Babylon) version of this module.
  155850. * This is an integer representing the implementation version.
  155851. * This number does not correspond to the WebXR specs version
  155852. */
  155853. static readonly Version: number;
  155854. /**
  155855. * This observable will notify registered observers when a new hand object was added and initialized
  155856. */
  155857. onHandAddedObservable: Observable<WebXRHand>;
  155858. /**
  155859. * This observable will notify its observers right before the hand object is disposed
  155860. */
  155861. onHandRemovedObservable: Observable<WebXRHand>;
  155862. private _hands;
  155863. /**
  155864. * Creates a new instance of the hit test feature
  155865. * @param _xrSessionManager an instance of WebXRSessionManager
  155866. * @param options options to use when constructing this feature
  155867. */
  155868. constructor(_xrSessionManager: WebXRSessionManager,
  155869. /**
  155870. * options to use when constructing this feature
  155871. */
  155872. options: IWebXRHandTrackingOptions);
  155873. /**
  155874. * Check if the needed objects are defined.
  155875. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  155876. */
  155877. isCompatible(): boolean;
  155878. /**
  155879. * attach this feature
  155880. * Will usually be called by the features manager
  155881. *
  155882. * @returns true if successful.
  155883. */
  155884. attach(): boolean;
  155885. /**
  155886. * detach this feature.
  155887. * Will usually be called by the features manager
  155888. *
  155889. * @returns true if successful.
  155890. */
  155891. detach(): boolean;
  155892. /**
  155893. * Dispose this feature and all of the resources attached
  155894. */
  155895. dispose(): void;
  155896. /**
  155897. * Get the hand object according to the controller id
  155898. * @param controllerId the controller id to which we want to get the hand
  155899. * @returns null if not found or the WebXRHand object if found
  155900. */
  155901. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  155902. /**
  155903. * Get a hand object according to the requested handedness
  155904. * @param handedness the handedness to request
  155905. * @returns null if not found or the WebXRHand object if found
  155906. */
  155907. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  155908. protected _onXRFrame(_xrFrame: XRFrame): void;
  155909. private _attachHand;
  155910. private _detachHand;
  155911. }
  155912. }
  155913. declare module BABYLON {
  155914. /**
  155915. * The motion controller class for all microsoft mixed reality controllers
  155916. */
  155917. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  155918. protected readonly _mapping: {
  155919. defaultButton: {
  155920. valueNodeName: string;
  155921. unpressedNodeName: string;
  155922. pressedNodeName: string;
  155923. };
  155924. defaultAxis: {
  155925. valueNodeName: string;
  155926. minNodeName: string;
  155927. maxNodeName: string;
  155928. };
  155929. buttons: {
  155930. "xr-standard-trigger": {
  155931. rootNodeName: string;
  155932. componentProperty: string;
  155933. states: string[];
  155934. };
  155935. "xr-standard-squeeze": {
  155936. rootNodeName: string;
  155937. componentProperty: string;
  155938. states: string[];
  155939. };
  155940. "xr-standard-touchpad": {
  155941. rootNodeName: string;
  155942. labelAnchorNodeName: string;
  155943. touchPointNodeName: string;
  155944. };
  155945. "xr-standard-thumbstick": {
  155946. rootNodeName: string;
  155947. componentProperty: string;
  155948. states: string[];
  155949. };
  155950. };
  155951. axes: {
  155952. "xr-standard-touchpad": {
  155953. "x-axis": {
  155954. rootNodeName: string;
  155955. };
  155956. "y-axis": {
  155957. rootNodeName: string;
  155958. };
  155959. };
  155960. "xr-standard-thumbstick": {
  155961. "x-axis": {
  155962. rootNodeName: string;
  155963. };
  155964. "y-axis": {
  155965. rootNodeName: string;
  155966. };
  155967. };
  155968. };
  155969. };
  155970. /**
  155971. * The base url used to load the left and right controller models
  155972. */
  155973. static MODEL_BASE_URL: string;
  155974. /**
  155975. * The name of the left controller model file
  155976. */
  155977. static MODEL_LEFT_FILENAME: string;
  155978. /**
  155979. * The name of the right controller model file
  155980. */
  155981. static MODEL_RIGHT_FILENAME: string;
  155982. profileId: string;
  155983. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  155984. protected _getFilenameAndPath(): {
  155985. filename: string;
  155986. path: string;
  155987. };
  155988. protected _getModelLoadingConstraints(): boolean;
  155989. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155990. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155991. protected _updateModel(): void;
  155992. }
  155993. }
  155994. declare module BABYLON {
  155995. /**
  155996. * The motion controller class for oculus touch (quest, rift).
  155997. * This class supports legacy mapping as well the standard xr mapping
  155998. */
  155999. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156000. private _forceLegacyControllers;
  156001. private _modelRootNode;
  156002. /**
  156003. * The base url used to load the left and right controller models
  156004. */
  156005. static MODEL_BASE_URL: string;
  156006. /**
  156007. * The name of the left controller model file
  156008. */
  156009. static MODEL_LEFT_FILENAME: string;
  156010. /**
  156011. * The name of the right controller model file
  156012. */
  156013. static MODEL_RIGHT_FILENAME: string;
  156014. /**
  156015. * Base Url for the Quest controller model.
  156016. */
  156017. static QUEST_MODEL_BASE_URL: string;
  156018. profileId: string;
  156019. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156020. protected _getFilenameAndPath(): {
  156021. filename: string;
  156022. path: string;
  156023. };
  156024. protected _getModelLoadingConstraints(): boolean;
  156025. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156026. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156027. protected _updateModel(): void;
  156028. /**
  156029. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156030. * between the touch and touch 2.
  156031. */
  156032. private _isQuest;
  156033. }
  156034. }
  156035. declare module BABYLON {
  156036. /**
  156037. * The motion controller class for the standard HTC-Vive controllers
  156038. */
  156039. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156040. private _modelRootNode;
  156041. /**
  156042. * The base url used to load the left and right controller models
  156043. */
  156044. static MODEL_BASE_URL: string;
  156045. /**
  156046. * File name for the controller model.
  156047. */
  156048. static MODEL_FILENAME: string;
  156049. profileId: string;
  156050. /**
  156051. * Create a new Vive motion controller object
  156052. * @param scene the scene to use to create this controller
  156053. * @param gamepadObject the corresponding gamepad object
  156054. * @param handedness the handedness of the controller
  156055. */
  156056. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156057. protected _getFilenameAndPath(): {
  156058. filename: string;
  156059. path: string;
  156060. };
  156061. protected _getModelLoadingConstraints(): boolean;
  156062. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156063. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156064. protected _updateModel(): void;
  156065. }
  156066. }
  156067. declare module BABYLON {
  156068. /**
  156069. * A cursor which tracks a point on a path
  156070. */
  156071. export class PathCursor {
  156072. private path;
  156073. /**
  156074. * Stores path cursor callbacks for when an onchange event is triggered
  156075. */
  156076. private _onchange;
  156077. /**
  156078. * The value of the path cursor
  156079. */
  156080. value: number;
  156081. /**
  156082. * The animation array of the path cursor
  156083. */
  156084. animations: Animation[];
  156085. /**
  156086. * Initializes the path cursor
  156087. * @param path The path to track
  156088. */
  156089. constructor(path: Path2);
  156090. /**
  156091. * Gets the cursor point on the path
  156092. * @returns A point on the path cursor at the cursor location
  156093. */
  156094. getPoint(): Vector3;
  156095. /**
  156096. * Moves the cursor ahead by the step amount
  156097. * @param step The amount to move the cursor forward
  156098. * @returns This path cursor
  156099. */
  156100. moveAhead(step?: number): PathCursor;
  156101. /**
  156102. * Moves the cursor behind by the step amount
  156103. * @param step The amount to move the cursor back
  156104. * @returns This path cursor
  156105. */
  156106. moveBack(step?: number): PathCursor;
  156107. /**
  156108. * Moves the cursor by the step amount
  156109. * If the step amount is greater than one, an exception is thrown
  156110. * @param step The amount to move the cursor
  156111. * @returns This path cursor
  156112. */
  156113. move(step: number): PathCursor;
  156114. /**
  156115. * Ensures that the value is limited between zero and one
  156116. * @returns This path cursor
  156117. */
  156118. private ensureLimits;
  156119. /**
  156120. * Runs onchange callbacks on change (used by the animation engine)
  156121. * @returns This path cursor
  156122. */
  156123. private raiseOnChange;
  156124. /**
  156125. * Executes a function on change
  156126. * @param f A path cursor onchange callback
  156127. * @returns This path cursor
  156128. */
  156129. onchange(f: (cursor: PathCursor) => void): PathCursor;
  156130. }
  156131. }
  156132. declare module BABYLON {
  156133. /** @hidden */
  156134. export var blurPixelShader: {
  156135. name: string;
  156136. shader: string;
  156137. };
  156138. }
  156139. declare module BABYLON {
  156140. /** @hidden */
  156141. export var pointCloudVertexDeclaration: {
  156142. name: string;
  156143. shader: string;
  156144. };
  156145. }
  156146. // Mixins
  156147. interface Window {
  156148. mozIndexedDB: IDBFactory;
  156149. webkitIndexedDB: IDBFactory;
  156150. msIndexedDB: IDBFactory;
  156151. webkitURL: typeof URL;
  156152. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  156153. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  156154. WebGLRenderingContext: WebGLRenderingContext;
  156155. MSGesture: MSGesture;
  156156. CANNON: any;
  156157. AudioContext: AudioContext;
  156158. webkitAudioContext: AudioContext;
  156159. PointerEvent: any;
  156160. Math: Math;
  156161. Uint8Array: Uint8ArrayConstructor;
  156162. Float32Array: Float32ArrayConstructor;
  156163. mozURL: typeof URL;
  156164. msURL: typeof URL;
  156165. VRFrameData: any; // WebVR, from specs 1.1
  156166. DracoDecoderModule: any;
  156167. setImmediate(handler: (...args: any[]) => void): number;
  156168. }
  156169. interface HTMLCanvasElement {
  156170. requestPointerLock(): void;
  156171. msRequestPointerLock?(): void;
  156172. mozRequestPointerLock?(): void;
  156173. webkitRequestPointerLock?(): void;
  156174. /** Track wether a record is in progress */
  156175. isRecording: boolean;
  156176. /** Capture Stream method defined by some browsers */
  156177. captureStream(fps?: number): MediaStream;
  156178. }
  156179. interface CanvasRenderingContext2D {
  156180. msImageSmoothingEnabled: boolean;
  156181. }
  156182. interface MouseEvent {
  156183. mozMovementX: number;
  156184. mozMovementY: number;
  156185. webkitMovementX: number;
  156186. webkitMovementY: number;
  156187. msMovementX: number;
  156188. msMovementY: number;
  156189. }
  156190. interface Navigator {
  156191. mozGetVRDevices: (any: any) => any;
  156192. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156193. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156194. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156195. webkitGetGamepads(): Gamepad[];
  156196. msGetGamepads(): Gamepad[];
  156197. webkitGamepads(): Gamepad[];
  156198. }
  156199. interface HTMLVideoElement {
  156200. mozSrcObject: any;
  156201. }
  156202. interface Math {
  156203. fround(x: number): number;
  156204. imul(a: number, b: number): number;
  156205. }
  156206. interface WebGLRenderingContext {
  156207. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  156208. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  156209. vertexAttribDivisor(index: number, divisor: number): void;
  156210. createVertexArray(): any;
  156211. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  156212. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  156213. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  156214. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  156215. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  156216. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  156217. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  156218. // Queries
  156219. createQuery(): WebGLQuery;
  156220. deleteQuery(query: WebGLQuery): void;
  156221. beginQuery(target: number, query: WebGLQuery): void;
  156222. endQuery(target: number): void;
  156223. getQueryParameter(query: WebGLQuery, pname: number): any;
  156224. getQuery(target: number, pname: number): any;
  156225. MAX_SAMPLES: number;
  156226. RGBA8: number;
  156227. READ_FRAMEBUFFER: number;
  156228. DRAW_FRAMEBUFFER: number;
  156229. UNIFORM_BUFFER: number;
  156230. HALF_FLOAT_OES: number;
  156231. RGBA16F: number;
  156232. RGBA32F: number;
  156233. R32F: number;
  156234. RG32F: number;
  156235. RGB32F: number;
  156236. R16F: number;
  156237. RG16F: number;
  156238. RGB16F: number;
  156239. RED: number;
  156240. RG: number;
  156241. R8: number;
  156242. RG8: number;
  156243. UNSIGNED_INT_24_8: number;
  156244. DEPTH24_STENCIL8: number;
  156245. MIN: number;
  156246. MAX: number;
  156247. /* Multiple Render Targets */
  156248. drawBuffers(buffers: number[]): void;
  156249. readBuffer(src: number): void;
  156250. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  156251. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  156252. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  156253. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  156254. // Occlusion Query
  156255. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  156256. ANY_SAMPLES_PASSED: number;
  156257. QUERY_RESULT_AVAILABLE: number;
  156258. QUERY_RESULT: number;
  156259. }
  156260. interface WebGLProgram {
  156261. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  156262. }
  156263. interface EXT_disjoint_timer_query {
  156264. QUERY_COUNTER_BITS_EXT: number;
  156265. TIME_ELAPSED_EXT: number;
  156266. TIMESTAMP_EXT: number;
  156267. GPU_DISJOINT_EXT: number;
  156268. QUERY_RESULT_EXT: number;
  156269. QUERY_RESULT_AVAILABLE_EXT: number;
  156270. queryCounterEXT(query: WebGLQuery, target: number): void;
  156271. createQueryEXT(): WebGLQuery;
  156272. beginQueryEXT(target: number, query: WebGLQuery): void;
  156273. endQueryEXT(target: number): void;
  156274. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  156275. deleteQueryEXT(query: WebGLQuery): void;
  156276. }
  156277. interface WebGLUniformLocation {
  156278. _currentState: any;
  156279. }
  156280. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  156281. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  156282. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  156283. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156284. interface WebGLRenderingContext {
  156285. readonly RASTERIZER_DISCARD: number;
  156286. readonly DEPTH_COMPONENT24: number;
  156287. readonly TEXTURE_3D: number;
  156288. readonly TEXTURE_2D_ARRAY: number;
  156289. readonly TEXTURE_COMPARE_FUNC: number;
  156290. readonly TEXTURE_COMPARE_MODE: number;
  156291. readonly COMPARE_REF_TO_TEXTURE: number;
  156292. readonly TEXTURE_WRAP_R: number;
  156293. readonly HALF_FLOAT: number;
  156294. readonly RGB8: number;
  156295. readonly RED_INTEGER: number;
  156296. readonly RG_INTEGER: number;
  156297. readonly RGB_INTEGER: number;
  156298. readonly RGBA_INTEGER: number;
  156299. readonly R8_SNORM: number;
  156300. readonly RG8_SNORM: number;
  156301. readonly RGB8_SNORM: number;
  156302. readonly RGBA8_SNORM: number;
  156303. readonly R8I: number;
  156304. readonly RG8I: number;
  156305. readonly RGB8I: number;
  156306. readonly RGBA8I: number;
  156307. readonly R8UI: number;
  156308. readonly RG8UI: number;
  156309. readonly RGB8UI: number;
  156310. readonly RGBA8UI: number;
  156311. readonly R16I: number;
  156312. readonly RG16I: number;
  156313. readonly RGB16I: number;
  156314. readonly RGBA16I: number;
  156315. readonly R16UI: number;
  156316. readonly RG16UI: number;
  156317. readonly RGB16UI: number;
  156318. readonly RGBA16UI: number;
  156319. readonly R32I: number;
  156320. readonly RG32I: number;
  156321. readonly RGB32I: number;
  156322. readonly RGBA32I: number;
  156323. readonly R32UI: number;
  156324. readonly RG32UI: number;
  156325. readonly RGB32UI: number;
  156326. readonly RGBA32UI: number;
  156327. readonly RGB10_A2UI: number;
  156328. readonly R11F_G11F_B10F: number;
  156329. readonly RGB9_E5: number;
  156330. readonly RGB10_A2: number;
  156331. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  156332. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  156333. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  156334. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  156335. readonly DEPTH_COMPONENT32F: number;
  156336. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  156337. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  156338. 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;
  156339. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  156340. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  156341. readonly TRANSFORM_FEEDBACK: number;
  156342. readonly INTERLEAVED_ATTRIBS: number;
  156343. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  156344. createTransformFeedback(): WebGLTransformFeedback;
  156345. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  156346. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  156347. beginTransformFeedback(primitiveMode: number): void;
  156348. endTransformFeedback(): void;
  156349. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  156350. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156351. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156352. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156353. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  156354. }
  156355. interface ImageBitmap {
  156356. readonly width: number;
  156357. readonly height: number;
  156358. close(): void;
  156359. }
  156360. interface WebGLQuery extends WebGLObject {
  156361. }
  156362. declare var WebGLQuery: {
  156363. prototype: WebGLQuery;
  156364. new(): WebGLQuery;
  156365. };
  156366. interface WebGLSampler extends WebGLObject {
  156367. }
  156368. declare var WebGLSampler: {
  156369. prototype: WebGLSampler;
  156370. new(): WebGLSampler;
  156371. };
  156372. interface WebGLSync extends WebGLObject {
  156373. }
  156374. declare var WebGLSync: {
  156375. prototype: WebGLSync;
  156376. new(): WebGLSync;
  156377. };
  156378. interface WebGLTransformFeedback extends WebGLObject {
  156379. }
  156380. declare var WebGLTransformFeedback: {
  156381. prototype: WebGLTransformFeedback;
  156382. new(): WebGLTransformFeedback;
  156383. };
  156384. interface WebGLVertexArrayObject extends WebGLObject {
  156385. }
  156386. declare var WebGLVertexArrayObject: {
  156387. prototype: WebGLVertexArrayObject;
  156388. new(): WebGLVertexArrayObject;
  156389. };
  156390. // Type definitions for WebVR API
  156391. // Project: https://w3c.github.io/webvr/
  156392. // Definitions by: six a <https://github.com/lostfictions>
  156393. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156394. interface VRDisplay extends EventTarget {
  156395. /**
  156396. * Dictionary of capabilities describing the VRDisplay.
  156397. */
  156398. readonly capabilities: VRDisplayCapabilities;
  156399. /**
  156400. * z-depth defining the far plane of the eye view frustum
  156401. * enables mapping of values in the render target depth
  156402. * attachment to scene coordinates. Initially set to 10000.0.
  156403. */
  156404. depthFar: number;
  156405. /**
  156406. * z-depth defining the near plane of the eye view frustum
  156407. * enables mapping of values in the render target depth
  156408. * attachment to scene coordinates. Initially set to 0.01.
  156409. */
  156410. depthNear: number;
  156411. /**
  156412. * An identifier for this distinct VRDisplay. Used as an
  156413. * association point in the Gamepad API.
  156414. */
  156415. readonly displayId: number;
  156416. /**
  156417. * A display name, a user-readable name identifying it.
  156418. */
  156419. readonly displayName: string;
  156420. readonly isConnected: boolean;
  156421. readonly isPresenting: boolean;
  156422. /**
  156423. * If this VRDisplay supports room-scale experiences, the optional
  156424. * stage attribute contains details on the room-scale parameters.
  156425. */
  156426. readonly stageParameters: VRStageParameters | null;
  156427. /**
  156428. * Passing the value returned by `requestAnimationFrame` to
  156429. * `cancelAnimationFrame` will unregister the callback.
  156430. * @param handle Define the hanle of the request to cancel
  156431. */
  156432. cancelAnimationFrame(handle: number): void;
  156433. /**
  156434. * Stops presenting to the VRDisplay.
  156435. * @returns a promise to know when it stopped
  156436. */
  156437. exitPresent(): Promise<void>;
  156438. /**
  156439. * Return the current VREyeParameters for the given eye.
  156440. * @param whichEye Define the eye we want the parameter for
  156441. * @returns the eye parameters
  156442. */
  156443. getEyeParameters(whichEye: string): VREyeParameters;
  156444. /**
  156445. * Populates the passed VRFrameData with the information required to render
  156446. * the current frame.
  156447. * @param frameData Define the data structure to populate
  156448. * @returns true if ok otherwise false
  156449. */
  156450. getFrameData(frameData: VRFrameData): boolean;
  156451. /**
  156452. * Get the layers currently being presented.
  156453. * @returns the list of VR layers
  156454. */
  156455. getLayers(): VRLayer[];
  156456. /**
  156457. * Return a VRPose containing the future predicted pose of the VRDisplay
  156458. * when the current frame will be presented. The value returned will not
  156459. * change until JavaScript has returned control to the browser.
  156460. *
  156461. * The VRPose will contain the position, orientation, velocity,
  156462. * and acceleration of each of these properties.
  156463. * @returns the pose object
  156464. */
  156465. getPose(): VRPose;
  156466. /**
  156467. * Return the current instantaneous pose of the VRDisplay, with no
  156468. * prediction applied.
  156469. * @returns the current instantaneous pose
  156470. */
  156471. getImmediatePose(): VRPose;
  156472. /**
  156473. * The callback passed to `requestAnimationFrame` will be called
  156474. * any time a new frame should be rendered. When the VRDisplay is
  156475. * presenting the callback will be called at the native refresh
  156476. * rate of the HMD. When not presenting this function acts
  156477. * identically to how window.requestAnimationFrame acts. Content should
  156478. * make no assumptions of frame rate or vsync behavior as the HMD runs
  156479. * asynchronously from other displays and at differing refresh rates.
  156480. * @param callback Define the eaction to run next frame
  156481. * @returns the request handle it
  156482. */
  156483. requestAnimationFrame(callback: FrameRequestCallback): number;
  156484. /**
  156485. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  156486. * Repeat calls while already presenting will update the VRLayers being displayed.
  156487. * @param layers Define the list of layer to present
  156488. * @returns a promise to know when the request has been fulfilled
  156489. */
  156490. requestPresent(layers: VRLayer[]): Promise<void>;
  156491. /**
  156492. * Reset the pose for this display, treating its current position and
  156493. * orientation as the "origin/zero" values. VRPose.position,
  156494. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  156495. * updated when calling resetPose(). This should be called in only
  156496. * sitting-space experiences.
  156497. */
  156498. resetPose(): void;
  156499. /**
  156500. * The VRLayer provided to the VRDisplay will be captured and presented
  156501. * in the HMD. Calling this function has the same effect on the source
  156502. * canvas as any other operation that uses its source image, and canvases
  156503. * created without preserveDrawingBuffer set to true will be cleared.
  156504. * @param pose Define the pose to submit
  156505. */
  156506. submitFrame(pose?: VRPose): void;
  156507. }
  156508. declare var VRDisplay: {
  156509. prototype: VRDisplay;
  156510. new(): VRDisplay;
  156511. };
  156512. interface VRLayer {
  156513. leftBounds?: number[] | Float32Array | null;
  156514. rightBounds?: number[] | Float32Array | null;
  156515. source?: HTMLCanvasElement | null;
  156516. }
  156517. interface VRDisplayCapabilities {
  156518. readonly canPresent: boolean;
  156519. readonly hasExternalDisplay: boolean;
  156520. readonly hasOrientation: boolean;
  156521. readonly hasPosition: boolean;
  156522. readonly maxLayers: number;
  156523. }
  156524. interface VREyeParameters {
  156525. /** @deprecated */
  156526. readonly fieldOfView: VRFieldOfView;
  156527. readonly offset: Float32Array;
  156528. readonly renderHeight: number;
  156529. readonly renderWidth: number;
  156530. }
  156531. interface VRFieldOfView {
  156532. readonly downDegrees: number;
  156533. readonly leftDegrees: number;
  156534. readonly rightDegrees: number;
  156535. readonly upDegrees: number;
  156536. }
  156537. interface VRFrameData {
  156538. readonly leftProjectionMatrix: Float32Array;
  156539. readonly leftViewMatrix: Float32Array;
  156540. readonly pose: VRPose;
  156541. readonly rightProjectionMatrix: Float32Array;
  156542. readonly rightViewMatrix: Float32Array;
  156543. readonly timestamp: number;
  156544. }
  156545. interface VRPose {
  156546. readonly angularAcceleration: Float32Array | null;
  156547. readonly angularVelocity: Float32Array | null;
  156548. readonly linearAcceleration: Float32Array | null;
  156549. readonly linearVelocity: Float32Array | null;
  156550. readonly orientation: Float32Array | null;
  156551. readonly position: Float32Array | null;
  156552. readonly timestamp: number;
  156553. }
  156554. interface VRStageParameters {
  156555. sittingToStandingTransform?: Float32Array;
  156556. sizeX?: number;
  156557. sizeY?: number;
  156558. }
  156559. interface Navigator {
  156560. getVRDisplays(): Promise<VRDisplay[]>;
  156561. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  156562. }
  156563. interface Window {
  156564. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  156565. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  156566. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  156567. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156568. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156569. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  156570. }
  156571. interface Gamepad {
  156572. readonly displayId: number;
  156573. }
  156574. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  156575. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  156576. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  156577. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  156578. type XRHandedness = "none" | "left" | "right";
  156579. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  156580. type XREye = "none" | "left" | "right";
  156581. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  156582. interface XRSpace extends EventTarget {}
  156583. interface XRRenderState {
  156584. depthNear?: number;
  156585. depthFar?: number;
  156586. inlineVerticalFieldOfView?: number;
  156587. baseLayer?: XRWebGLLayer;
  156588. }
  156589. interface XRInputSource {
  156590. handedness: XRHandedness;
  156591. targetRayMode: XRTargetRayMode;
  156592. targetRaySpace: XRSpace;
  156593. gripSpace: XRSpace | undefined;
  156594. gamepad: Gamepad | undefined;
  156595. profiles: Array<string>;
  156596. hand: XRHand | undefined;
  156597. }
  156598. interface XRSessionInit {
  156599. optionalFeatures?: string[];
  156600. requiredFeatures?: string[];
  156601. }
  156602. interface XRSession {
  156603. addEventListener: Function;
  156604. removeEventListener: Function;
  156605. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  156606. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  156607. requestAnimationFrame: Function;
  156608. end(): Promise<void>;
  156609. renderState: XRRenderState;
  156610. inputSources: Array<XRInputSource>;
  156611. // hit test
  156612. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  156613. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  156614. // legacy AR hit test
  156615. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156616. // legacy plane detection
  156617. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  156618. }
  156619. interface XRReferenceSpace extends XRSpace {
  156620. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  156621. onreset: any;
  156622. }
  156623. type XRPlaneSet = Set<XRPlane>;
  156624. type XRAnchorSet = Set<XRAnchor>;
  156625. interface XRFrame {
  156626. session: XRSession;
  156627. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  156628. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  156629. // AR
  156630. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  156631. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  156632. // Anchors
  156633. trackedAnchors?: XRAnchorSet;
  156634. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  156635. // Planes
  156636. worldInformation: {
  156637. detectedPlanes?: XRPlaneSet;
  156638. };
  156639. // Hand tracking
  156640. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  156641. }
  156642. interface XRViewerPose extends XRPose {
  156643. views: Array<XRView>;
  156644. }
  156645. interface XRPose {
  156646. transform: XRRigidTransform;
  156647. emulatedPosition: boolean;
  156648. }
  156649. interface XRWebGLLayerOptions {
  156650. antialias?: boolean;
  156651. depth?: boolean;
  156652. stencil?: boolean;
  156653. alpha?: boolean;
  156654. multiview?: boolean;
  156655. framebufferScaleFactor?: number;
  156656. }
  156657. declare var XRWebGLLayer: {
  156658. prototype: XRWebGLLayer;
  156659. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  156660. };
  156661. interface XRWebGLLayer {
  156662. framebuffer: WebGLFramebuffer;
  156663. framebufferWidth: number;
  156664. framebufferHeight: number;
  156665. getViewport: Function;
  156666. }
  156667. declare class XRRigidTransform {
  156668. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  156669. position: DOMPointReadOnly;
  156670. orientation: DOMPointReadOnly;
  156671. matrix: Float32Array;
  156672. inverse: XRRigidTransform;
  156673. }
  156674. interface XRView {
  156675. eye: XREye;
  156676. projectionMatrix: Float32Array;
  156677. transform: XRRigidTransform;
  156678. }
  156679. interface XRInputSourceChangeEvent {
  156680. session: XRSession;
  156681. removed: Array<XRInputSource>;
  156682. added: Array<XRInputSource>;
  156683. }
  156684. interface XRInputSourceEvent extends Event {
  156685. readonly frame: XRFrame;
  156686. readonly inputSource: XRInputSource;
  156687. }
  156688. // Experimental(er) features
  156689. declare class XRRay {
  156690. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  156691. origin: DOMPointReadOnly;
  156692. direction: DOMPointReadOnly;
  156693. matrix: Float32Array;
  156694. }
  156695. declare enum XRHitTestTrackableType {
  156696. "point",
  156697. "plane",
  156698. "mesh",
  156699. }
  156700. interface XRHitResult {
  156701. hitMatrix: Float32Array;
  156702. }
  156703. interface XRTransientInputHitTestResult {
  156704. readonly inputSource: XRInputSource;
  156705. readonly results: Array<XRHitTestResult>;
  156706. }
  156707. interface XRHitTestResult {
  156708. getPose(baseSpace: XRSpace): XRPose | undefined;
  156709. // When anchor system is enabled
  156710. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  156711. }
  156712. interface XRHitTestSource {
  156713. cancel(): void;
  156714. }
  156715. interface XRTransientInputHitTestSource {
  156716. cancel(): void;
  156717. }
  156718. interface XRHitTestOptionsInit {
  156719. space: XRSpace;
  156720. entityTypes?: Array<XRHitTestTrackableType>;
  156721. offsetRay?: XRRay;
  156722. }
  156723. interface XRTransientInputHitTestOptionsInit {
  156724. profile: string;
  156725. entityTypes?: Array<XRHitTestTrackableType>;
  156726. offsetRay?: XRRay;
  156727. }
  156728. interface XRAnchor {
  156729. anchorSpace: XRSpace;
  156730. delete(): void;
  156731. }
  156732. interface XRPlane {
  156733. orientation: "Horizontal" | "Vertical";
  156734. planeSpace: XRSpace;
  156735. polygon: Array<DOMPointReadOnly>;
  156736. lastChangedTime: number;
  156737. }
  156738. interface XRJointSpace extends XRSpace {}
  156739. interface XRJointPose extends XRPose {
  156740. radius: number | undefined;
  156741. }
  156742. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  156743. readonly length: number;
  156744. [index: number]: XRJointSpace;
  156745. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  156746. readonly WRIST: number;
  156747. readonly THUMB_METACARPAL: number;
  156748. readonly THUMB_PHALANX_PROXIMAL: number;
  156749. readonly THUMB_PHALANX_DISTAL: number;
  156750. readonly THUMB_PHALANX_TIP: number;
  156751. readonly INDEX_METACARPAL: number;
  156752. readonly INDEX_PHALANX_PROXIMAL: number;
  156753. readonly INDEX_PHALANX_INTERMEDIATE: number;
  156754. readonly INDEX_PHALANX_DISTAL: number;
  156755. readonly INDEX_PHALANX_TIP: number;
  156756. readonly MIDDLE_METACARPAL: number;
  156757. readonly MIDDLE_PHALANX_PROXIMAL: number;
  156758. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  156759. readonly MIDDLE_PHALANX_DISTAL: number;
  156760. readonly MIDDLE_PHALANX_TIP: number;
  156761. readonly RING_METACARPAL: number;
  156762. readonly RING_PHALANX_PROXIMAL: number;
  156763. readonly RING_PHALANX_INTERMEDIATE: number;
  156764. readonly RING_PHALANX_DISTAL: number;
  156765. readonly RING_PHALANX_TIP: number;
  156766. readonly LITTLE_METACARPAL: number;
  156767. readonly LITTLE_PHALANX_PROXIMAL: number;
  156768. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  156769. readonly LITTLE_PHALANX_DISTAL: number;
  156770. readonly LITTLE_PHALANX_TIP: number;
  156771. }
  156772. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  156773. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  156774. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  156775. interface XRSession {
  156776. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  156777. }
  156778. interface XRFrame {
  156779. featurePointCloud? : Array<number>;
  156780. }